658 }
659 return NULL;
660 #endif
661 }
662
663 inline Thread* Thread::current_or_null_safe() {
664 if (ThreadLocalStorage::is_initialized()) {
665 return ThreadLocalStorage::thread();
666 }
667 return NULL;
668 }
669
670 class CompilerThread;
671
672 typedef void (*ThreadFunction)(JavaThread*, TRAPS);
673
674 class JavaThread: public Thread {
675 friend class VMStructs;
676 friend class JVMCIVMStructs;
677 friend class WhiteBox;
678 friend class ThreadsSMRSupport; // to access _threadObj for exiting_threads_oops_do
679 friend class HandshakeState;
680 private:
681 bool _on_thread_list; // Is set when this JavaThread is added to the Threads list
682 OopHandle _threadObj; // The Java level thread object
683
684 #ifdef ASSERT
685 private:
686 int _java_call_counter;
687
688 public:
689 int java_call_counter() { return _java_call_counter; }
690 void inc_java_call_counter() { _java_call_counter++; }
691 void dec_java_call_counter() {
692 assert(_java_call_counter > 0, "Invalid nesting of JavaCallWrapper");
693 _java_call_counter--;
694 }
695 private: // restore original namespace restriction
696 #endif // ifdef ASSERT
697
708 vframeArray* _vframe_array_head; // Holds the heap of the active vframeArrays
709 vframeArray* _vframe_array_last; // Holds last vFrameArray we popped
710 // Holds updates by JVMTI agents for compiled frames that cannot be performed immediately. They
711 // will be carried out as soon as possible which, in most cases, is just before deoptimization of
712 // the frame, when control returns to it.
713 JvmtiDeferredUpdates* _jvmti_deferred_updates;
714
715 // Handshake value for fixing 6243940. We need a place for the i2c
716 // adapter to store the callee Method*. This value is NEVER live
717 // across a gc point so it does NOT have to be gc'd
718 // The handshake is open ended since we can't be certain that it will
719 // be NULLed. This is because we rarely ever see the race and end up
720 // in handle_wrong_method which is the backend of the handshake. See
721 // code in i2c adapters and handle_wrong_method.
722
723 Method* _callee_target;
724
725 // Used to pass back results to the interpreter or generated code running Java code.
726 oop _vm_result; // oop result is GC-preserved
727 Metadata* _vm_result_2; // non-oop result
728
729 // See ReduceInitialCardMarks: this holds the precise space interval of
730 // the most recent slow path allocation for which compiled code has
731 // elided card-marks for performance along the fast-path.
732 MemRegion _deferred_card_mark;
733
734 ObjectMonitor* volatile _current_pending_monitor; // ObjectMonitor this thread is waiting to lock
735 bool _current_pending_monitor_is_from_java; // locking is from Java code
736 ObjectMonitor* volatile _current_waiting_monitor; // ObjectMonitor on which this thread called Object.wait()
737
738 // Active_handles points to a block of handles
739 JNIHandleBlock* _active_handles;
740
741 // One-element thread local free list
742 JNIHandleBlock* _free_handle_block;
743
744 public:
745 volatile intptr_t _Stalled;
746
747 // For tracking the heavyweight monitor the thread is pending on.
1197 vframeArray* vframe_array_last() const { return _vframe_array_last; }
1198
1199 // The special resourceMark used during deoptimization
1200
1201 void set_deopt_mark(DeoptResourceMark* value) { _deopt_mark = value; }
1202 DeoptResourceMark* deopt_mark(void) { return _deopt_mark; }
1203
1204 void set_deopt_compiled_method(CompiledMethod* nm) { _deopt_nmethod = nm; }
1205 CompiledMethod* deopt_compiled_method() { return _deopt_nmethod; }
1206
1207 Method* callee_target() const { return _callee_target; }
1208 void set_callee_target (Method* x) { _callee_target = x; }
1209
1210 // Oop results of vm runtime calls
1211 oop vm_result() const { return _vm_result; }
1212 void set_vm_result (oop x) { _vm_result = x; }
1213
1214 Metadata* vm_result_2() const { return _vm_result_2; }
1215 void set_vm_result_2 (Metadata* x) { _vm_result_2 = x; }
1216
1217 MemRegion deferred_card_mark() const { return _deferred_card_mark; }
1218 void set_deferred_card_mark(MemRegion mr) { _deferred_card_mark = mr; }
1219
1220 #if INCLUDE_JVMCI
1221 int pending_deoptimization() const { return _pending_deoptimization; }
1222 jlong pending_failed_speculation() const { return _pending_failed_speculation; }
1223 bool has_pending_monitorenter() const { return _pending_monitorenter; }
1224 void set_pending_monitorenter(bool b) { _pending_monitorenter = b; }
1225 void set_pending_deoptimization(int reason) { _pending_deoptimization = reason; }
1226 void set_pending_failed_speculation(jlong failed_speculation) { _pending_failed_speculation = failed_speculation; }
1227 void set_pending_transfer_to_interpreter(bool b) { _pending_transfer_to_interpreter = b; }
1228 void set_jvmci_alternate_call_target(address a) { assert(_jvmci._alternate_call_target == NULL, "must be"); _jvmci._alternate_call_target = a; }
1229 void set_jvmci_implicit_exception_pc(address a) { assert(_jvmci._implicit_exception_pc == NULL, "must be"); _jvmci._implicit_exception_pc = a; }
1230
1231 virtual bool in_retryable_allocation() const { return _in_retryable_allocation; }
1232 void set_in_retryable_allocation(bool b) { _in_retryable_allocation = b; }
1233 #endif // INCLUDE_JVMCI
1234
1235 // Exception handling for compiled methods
1236 oop exception_oop() const;
1261 bool do_not_unlock(void) { return _do_not_unlock_if_synchronized; }
1262
1263 // For assembly stub generation
1264 static ByteSize threadObj_offset() { return byte_offset_of(JavaThread, _threadObj); }
1265 static ByteSize jni_environment_offset() { return byte_offset_of(JavaThread, _jni_environment); }
1266 static ByteSize pending_jni_exception_check_fn_offset() {
1267 return byte_offset_of(JavaThread, _pending_jni_exception_check_fn);
1268 }
1269 static ByteSize last_Java_sp_offset() {
1270 return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_sp_offset();
1271 }
1272 static ByteSize last_Java_pc_offset() {
1273 return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_pc_offset();
1274 }
1275 static ByteSize frame_anchor_offset() {
1276 return byte_offset_of(JavaThread, _anchor);
1277 }
1278 static ByteSize callee_target_offset() { return byte_offset_of(JavaThread, _callee_target); }
1279 static ByteSize vm_result_offset() { return byte_offset_of(JavaThread, _vm_result); }
1280 static ByteSize vm_result_2_offset() { return byte_offset_of(JavaThread, _vm_result_2); }
1281 static ByteSize thread_state_offset() { return byte_offset_of(JavaThread, _thread_state); }
1282 static ByteSize polling_word_offset() { return byte_offset_of(JavaThread, _poll_data) + byte_offset_of(SafepointMechanism::ThreadData, _polling_word);}
1283 static ByteSize polling_page_offset() { return byte_offset_of(JavaThread, _poll_data) + byte_offset_of(SafepointMechanism::ThreadData, _polling_page);}
1284 static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc); }
1285 static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread); }
1286 #if INCLUDE_JVMCI
1287 static ByteSize pending_deoptimization_offset() { return byte_offset_of(JavaThread, _pending_deoptimization); }
1288 static ByteSize pending_monitorenter_offset() { return byte_offset_of(JavaThread, _pending_monitorenter); }
1289 static ByteSize pending_failed_speculation_offset() { return byte_offset_of(JavaThread, _pending_failed_speculation); }
1290 static ByteSize jvmci_alternate_call_target_offset() { return byte_offset_of(JavaThread, _jvmci._alternate_call_target); }
1291 static ByteSize jvmci_implicit_exception_pc_offset() { return byte_offset_of(JavaThread, _jvmci._implicit_exception_pc); }
1292 static ByteSize jvmci_counters_offset() { return byte_offset_of(JavaThread, _jvmci_counters); }
1293 #endif // INCLUDE_JVMCI
1294 static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop); }
1295 static ByteSize exception_pc_offset() { return byte_offset_of(JavaThread, _exception_pc); }
1296 static ByteSize exception_handler_pc_offset() { return byte_offset_of(JavaThread, _exception_handler_pc); }
1297 static ByteSize is_method_handle_return_offset() { return byte_offset_of(JavaThread, _is_method_handle_return); }
1298
1299 static ByteSize active_handles_offset() { return byte_offset_of(JavaThread, _active_handles); }
1300
|
658 }
659 return NULL;
660 #endif
661 }
662
663 inline Thread* Thread::current_or_null_safe() {
664 if (ThreadLocalStorage::is_initialized()) {
665 return ThreadLocalStorage::thread();
666 }
667 return NULL;
668 }
669
670 class CompilerThread;
671
672 typedef void (*ThreadFunction)(JavaThread*, TRAPS);
673
674 class JavaThread: public Thread {
675 friend class VMStructs;
676 friend class JVMCIVMStructs;
677 friend class WhiteBox;
678 friend class VTBuffer;
679 friend class ThreadsSMRSupport; // to access _threadObj for exiting_threads_oops_do
680 friend class HandshakeState;
681 private:
682 bool _on_thread_list; // Is set when this JavaThread is added to the Threads list
683 OopHandle _threadObj; // The Java level thread object
684
685 #ifdef ASSERT
686 private:
687 int _java_call_counter;
688
689 public:
690 int java_call_counter() { return _java_call_counter; }
691 void inc_java_call_counter() { _java_call_counter++; }
692 void dec_java_call_counter() {
693 assert(_java_call_counter > 0, "Invalid nesting of JavaCallWrapper");
694 _java_call_counter--;
695 }
696 private: // restore original namespace restriction
697 #endif // ifdef ASSERT
698
709 vframeArray* _vframe_array_head; // Holds the heap of the active vframeArrays
710 vframeArray* _vframe_array_last; // Holds last vFrameArray we popped
711 // Holds updates by JVMTI agents for compiled frames that cannot be performed immediately. They
712 // will be carried out as soon as possible which, in most cases, is just before deoptimization of
713 // the frame, when control returns to it.
714 JvmtiDeferredUpdates* _jvmti_deferred_updates;
715
716 // Handshake value for fixing 6243940. We need a place for the i2c
717 // adapter to store the callee Method*. This value is NEVER live
718 // across a gc point so it does NOT have to be gc'd
719 // The handshake is open ended since we can't be certain that it will
720 // be NULLed. This is because we rarely ever see the race and end up
721 // in handle_wrong_method which is the backend of the handshake. See
722 // code in i2c adapters and handle_wrong_method.
723
724 Method* _callee_target;
725
726 // Used to pass back results to the interpreter or generated code running Java code.
727 oop _vm_result; // oop result is GC-preserved
728 Metadata* _vm_result_2; // non-oop result
729 oop _return_buffered_value; // buffered value being returned
730
731 // See ReduceInitialCardMarks: this holds the precise space interval of
732 // the most recent slow path allocation for which compiled code has
733 // elided card-marks for performance along the fast-path.
734 MemRegion _deferred_card_mark;
735
736 ObjectMonitor* volatile _current_pending_monitor; // ObjectMonitor this thread is waiting to lock
737 bool _current_pending_monitor_is_from_java; // locking is from Java code
738 ObjectMonitor* volatile _current_waiting_monitor; // ObjectMonitor on which this thread called Object.wait()
739
740 // Active_handles points to a block of handles
741 JNIHandleBlock* _active_handles;
742
743 // One-element thread local free list
744 JNIHandleBlock* _free_handle_block;
745
746 public:
747 volatile intptr_t _Stalled;
748
749 // For tracking the heavyweight monitor the thread is pending on.
1199 vframeArray* vframe_array_last() const { return _vframe_array_last; }
1200
1201 // The special resourceMark used during deoptimization
1202
1203 void set_deopt_mark(DeoptResourceMark* value) { _deopt_mark = value; }
1204 DeoptResourceMark* deopt_mark(void) { return _deopt_mark; }
1205
1206 void set_deopt_compiled_method(CompiledMethod* nm) { _deopt_nmethod = nm; }
1207 CompiledMethod* deopt_compiled_method() { return _deopt_nmethod; }
1208
1209 Method* callee_target() const { return _callee_target; }
1210 void set_callee_target (Method* x) { _callee_target = x; }
1211
1212 // Oop results of vm runtime calls
1213 oop vm_result() const { return _vm_result; }
1214 void set_vm_result (oop x) { _vm_result = x; }
1215
1216 Metadata* vm_result_2() const { return _vm_result_2; }
1217 void set_vm_result_2 (Metadata* x) { _vm_result_2 = x; }
1218
1219 oop return_buffered_value() const { return _return_buffered_value; }
1220 void set_return_buffered_value(oop val) { _return_buffered_value = val; }
1221
1222 MemRegion deferred_card_mark() const { return _deferred_card_mark; }
1223 void set_deferred_card_mark(MemRegion mr) { _deferred_card_mark = mr; }
1224
1225 #if INCLUDE_JVMCI
1226 int pending_deoptimization() const { return _pending_deoptimization; }
1227 jlong pending_failed_speculation() const { return _pending_failed_speculation; }
1228 bool has_pending_monitorenter() const { return _pending_monitorenter; }
1229 void set_pending_monitorenter(bool b) { _pending_monitorenter = b; }
1230 void set_pending_deoptimization(int reason) { _pending_deoptimization = reason; }
1231 void set_pending_failed_speculation(jlong failed_speculation) { _pending_failed_speculation = failed_speculation; }
1232 void set_pending_transfer_to_interpreter(bool b) { _pending_transfer_to_interpreter = b; }
1233 void set_jvmci_alternate_call_target(address a) { assert(_jvmci._alternate_call_target == NULL, "must be"); _jvmci._alternate_call_target = a; }
1234 void set_jvmci_implicit_exception_pc(address a) { assert(_jvmci._implicit_exception_pc == NULL, "must be"); _jvmci._implicit_exception_pc = a; }
1235
1236 virtual bool in_retryable_allocation() const { return _in_retryable_allocation; }
1237 void set_in_retryable_allocation(bool b) { _in_retryable_allocation = b; }
1238 #endif // INCLUDE_JVMCI
1239
1240 // Exception handling for compiled methods
1241 oop exception_oop() const;
1266 bool do_not_unlock(void) { return _do_not_unlock_if_synchronized; }
1267
1268 // For assembly stub generation
1269 static ByteSize threadObj_offset() { return byte_offset_of(JavaThread, _threadObj); }
1270 static ByteSize jni_environment_offset() { return byte_offset_of(JavaThread, _jni_environment); }
1271 static ByteSize pending_jni_exception_check_fn_offset() {
1272 return byte_offset_of(JavaThread, _pending_jni_exception_check_fn);
1273 }
1274 static ByteSize last_Java_sp_offset() {
1275 return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_sp_offset();
1276 }
1277 static ByteSize last_Java_pc_offset() {
1278 return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_pc_offset();
1279 }
1280 static ByteSize frame_anchor_offset() {
1281 return byte_offset_of(JavaThread, _anchor);
1282 }
1283 static ByteSize callee_target_offset() { return byte_offset_of(JavaThread, _callee_target); }
1284 static ByteSize vm_result_offset() { return byte_offset_of(JavaThread, _vm_result); }
1285 static ByteSize vm_result_2_offset() { return byte_offset_of(JavaThread, _vm_result_2); }
1286 static ByteSize return_buffered_value_offset() { return byte_offset_of(JavaThread, _return_buffered_value); }
1287 static ByteSize thread_state_offset() { return byte_offset_of(JavaThread, _thread_state); }
1288 static ByteSize polling_word_offset() { return byte_offset_of(JavaThread, _poll_data) + byte_offset_of(SafepointMechanism::ThreadData, _polling_word);}
1289 static ByteSize polling_page_offset() { return byte_offset_of(JavaThread, _poll_data) + byte_offset_of(SafepointMechanism::ThreadData, _polling_page);}
1290 static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc); }
1291 static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread); }
1292 #if INCLUDE_JVMCI
1293 static ByteSize pending_deoptimization_offset() { return byte_offset_of(JavaThread, _pending_deoptimization); }
1294 static ByteSize pending_monitorenter_offset() { return byte_offset_of(JavaThread, _pending_monitorenter); }
1295 static ByteSize pending_failed_speculation_offset() { return byte_offset_of(JavaThread, _pending_failed_speculation); }
1296 static ByteSize jvmci_alternate_call_target_offset() { return byte_offset_of(JavaThread, _jvmci._alternate_call_target); }
1297 static ByteSize jvmci_implicit_exception_pc_offset() { return byte_offset_of(JavaThread, _jvmci._implicit_exception_pc); }
1298 static ByteSize jvmci_counters_offset() { return byte_offset_of(JavaThread, _jvmci_counters); }
1299 #endif // INCLUDE_JVMCI
1300 static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop); }
1301 static ByteSize exception_pc_offset() { return byte_offset_of(JavaThread, _exception_pc); }
1302 static ByteSize exception_handler_pc_offset() { return byte_offset_of(JavaThread, _exception_handler_pc); }
1303 static ByteSize is_method_handle_return_offset() { return byte_offset_of(JavaThread, _is_method_handle_return); }
1304
1305 static ByteSize active_handles_offset() { return byte_offset_of(JavaThread, _active_handles); }
1306
|