< prev index next >

src/hotspot/share/runtime/thread.hpp

Print this page

        

@@ -30,10 +30,11 @@
 #include "gc/shared/gcThreadLocalData.hpp"
 #include "gc/shared/threadLocalAllocBuffer.hpp"
 #include "memory/allocation.hpp"
 #include "oops/oop.hpp"
 #include "prims/jvmtiExport.hpp"
+#include "runtime/continuation.hpp"
 #include "runtime/frame.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/handshake.hpp"
 #include "runtime/javaFrameAnchor.hpp"
 #include "runtime/jniHandles.hpp"

@@ -984,10 +985,11 @@
 
 class JavaThread: public Thread {
   friend class VMStructs;
   friend class JVMCIVMStructs;
   friend class WhiteBox;
+  friend class Continuation;
  private:
   bool           _on_thread_list;                // Is set when this JavaThread is added to the Threads list
   oop            _threadObj;                     // The Java level thread object
 
 #ifdef ASSERT

@@ -1029,10 +1031,11 @@
   // Because deoptimization is lazy we must save jvmti requests to set locals
   // in compiled frames until we deoptimize and we have an interpreter frame.
   // This holds the pointer to array (yeah like there might be more than one) of
   // description of compiled vframes that have locals that need to be updated.
   GrowableArray<jvmtiDeferredLocalVariableSet*>* _deferred_locals_updates;
+  GrowableArray<WeakHandle<vm_nmethod_keepalive_data> >* _keepalive_cleanup;
 
   // Handshake value for fixing 6243940. We need a place for the i2c
   // adapter to store the callee Method*. This value is NEVER live
   // across a gc point so it does NOT have to be gc'd
   // The handshake is open ended since we can't be certain that it will

@@ -1106,10 +1109,12 @@
   // A native thread that is attaching via JNI starts with a value
   // of _attaching_via_jni and transitions to _attached_via_jni.
   volatile JNIAttachStates _jni_attach_state;
 
  public:
+  DEBUG_ONLY(oopDesc* _continuation;)
+
   // State of the stack guard pages for this thread.
   enum StackGuardState {
     stack_guard_unused,         // not needed
     stack_guard_reserved_disabled,
     stack_guard_yellow_reserved_disabled,// disabled (temporarily) after stack overflow

@@ -1197,10 +1202,15 @@
   // and during exception propagation, pop the top
   // _frames_to_pop_failed_realloc frames, the ones that reference
   // failed reallocations.
   int _frames_to_pop_failed_realloc;
 
+  bool _cont_yield; // a continuation yield is in progress
+  bool _cont_preempt;
+  FrameInfo _cont_frame;
+  int _cont_fastpath;
+
 #ifndef PRODUCT
   int _jmp_ring_index;
   struct {
     // We use intptr_t instead of address so debugger doesn't try and display strings
     intptr_t _target;

@@ -1327,10 +1337,19 @@
 
   inline void set_polling_page_release(void* poll_value);
   inline void set_polling_page(void* poll_value);
   inline volatile void* get_polling_page();
 
+  // Continuation support
+  bool cont_yield() { return _cont_yield; }
+  void set_cont_yield(bool x) { _cont_yield = x; }
+  bool cont_fastpath() { return _cont_fastpath != 0; }
+  void set_cont_fastpath(bool x) { _cont_fastpath = (int)x; }
+  bool cont_preempt() { return _cont_preempt; }
+  void set_cont_preempt(bool x) { _cont_preempt = x; }
+  FrameInfo* cont_frame() { return &_cont_frame; }
+
  private:
   // Support for thread handshake operations
   HandshakeState _handshake;
  public:
   void set_handshake_operation(HandshakeOperation* op) {

@@ -1468,10 +1487,11 @@
     AsyncRequests x = _special_runtime_exit_condition;
     _special_runtime_exit_condition = _no_async_condition;
     return x;
   }
 
+  bool is_cont_force_yield() { return cont_preempt(); }
   // Are any async conditions present?
   bool has_async_condition() { return (_special_runtime_exit_condition != _no_async_condition); }
 
   void check_and_handle_async_exceptions(bool check_unsafe_error = true);
 

@@ -1489,11 +1509,11 @@
     // we will see the new flag value the next time through. It's also
     // possible that the external suspend request is dropped after
     // we have checked is_external_suspend(), we will recheck its value
     // under SR_lock in java_suspend_self().
     return (_special_runtime_exit_condition != _no_async_condition) ||
-            is_external_suspend() || is_trace_suspend();
+            is_external_suspend() || is_trace_suspend() || is_cont_force_yield();
   }
 
   void set_pending_unsafe_access_error()          { _special_runtime_exit_condition = _async_unsafe_access_error; }
 
   inline void set_pending_async_exception(oop e);

@@ -1509,10 +1529,13 @@
 
   // Side structure for deferring update of java frame locals until deopt occurs
   GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred_locals() const { return _deferred_locals_updates; }
   void set_deferred_locals(GrowableArray<jvmtiDeferredLocalVariableSet *>* vf) { _deferred_locals_updates = vf; }
 
+  void set_keepalive_cleanup(GrowableArray<WeakHandle<vm_nmethod_keepalive_data> >* lst) { _keepalive_cleanup = lst; }
+  GrowableArray<WeakHandle<vm_nmethod_keepalive_data> >* keepalive_cleanup() const { return _keepalive_cleanup; }
+
   // These only really exist to make debugging deopt problems simpler
 
   void set_vframe_array_last(vframeArray* value) { _vframe_array_last = value; }
   vframeArray* vframe_array_last() const         { return _vframe_array_last;  }
 

@@ -1802,10 +1825,15 @@
   static ByteSize should_post_on_exceptions_flag_offset() {
     return byte_offset_of(JavaThread, _should_post_on_exceptions_flag);
   }
   static ByteSize doing_unsafe_access_offset() { return byte_offset_of(JavaThread, _doing_unsafe_access); }
 
+  DEBUG_ONLY(static ByteSize continuation_offset() { return byte_offset_of(JavaThread, _continuation); })
+  static ByteSize cont_fastpath_offset()      { return byte_offset_of(JavaThread, _cont_fastpath); }
+  static ByteSize cont_frame_offset()         { return byte_offset_of(JavaThread, _cont_frame); }
+  static ByteSize cont_preempt_offset()       { return byte_offset_of(JavaThread, _cont_preempt); }
+
   // Returns the jni environment for this thread
   JNIEnv* jni_environment()                      { return &_jni_environment; }
 
   static JavaThread* thread_from_jni_environment(JNIEnv* env) {
     JavaThread *thread_from_jni_env = (JavaThread*)((intptr_t)env - in_bytes(jni_environment_offset()));

@@ -1885,10 +1913,11 @@
   void print_on(outputStream* st) const { print_on(st, false); }
   void print() const;
   void print_value();
   void print_thread_state_on(outputStream*) const      PRODUCT_RETURN;
   void print_thread_state() const                      PRODUCT_RETURN;
+  DEBUG_ONLY(const char* thread_state_name() const;)
   void print_on_error(outputStream* st, char* buf, int buflen) const;
   void print_name_on_error(outputStream* st, char* buf, int buflen) const;
   void verify();
   const char* get_thread_name() const;
  protected:

@@ -1903,10 +1932,12 @@
     _anchor.make_walkable(this);
     return pd_last_frame();
   }
   javaVFrame* last_java_vframe(RegisterMap* reg_map);
 
+  oop last_continuation();
+  
   // Returns method at 'depth' java or native frames down the stack
   // Used for security checks
   Klass* security_get_caller_class(int depth);
 
   // Print stack trace in external format
< prev index next >