824 volatile bool _is_attaching;
825
826 public:
827 // State of the stack guard pages for this thread.
828 enum StackGuardState {
829 stack_guard_unused, // not needed
830 stack_guard_yellow_disabled,// disabled (temporarily) after stack overflow
831 stack_guard_enabled // enabled
832 };
833
834 private:
835
836 StackGuardState _stack_guard_state;
837
838 // Compiler exception handling (NOTE: The _exception_oop is *NOT* the same as _pending_exception. It is
839 // used to temp. parsing values into and out of the runtime system during exception handling for compiled
840 // code)
841 volatile oop _exception_oop; // Exception thrown in compiled code
842 volatile address _exception_pc; // PC where exception happened
843 volatile address _exception_handler_pc; // PC for handler of exception
844 volatile int _exception_stack_size; // Size of frame where exception happened
845 volatile int _is_method_handle_return; // true (== 1) if the current exception PC is a MethodHandle call site.
846
847 // support for compilation
848 bool _is_compiling; // is true if a compilation is active inthis thread (one compilation per thread possible)
849
850 // support for JNI critical regions
851 jint _jni_active_critical; // count of entries into JNI critical region
852
853 // For deadlock detection.
854 int _depth_first_number;
855
856 // JVMTI PopFrame support
857 // This is set to popframe_pending to signal that top Java frame should be popped immediately
858 int _popframe_condition;
859
860 #ifndef PRODUCT
861 int _jmp_ring_index;
862 struct {
863 // We use intptr_t instead of address so debugger doesn't try and display strings
864 intptr_t _target;
1165 void clear_must_deopt_id() { _must_deopt_id = NULL; }
1166
1167 void set_deopt_nmethod(nmethod* nm) { _deopt_nmethod = nm; }
1168 nmethod* deopt_nmethod() { return _deopt_nmethod; }
1169
1170 methodOop callee_target() const { return _callee_target; }
1171 void set_callee_target (methodOop x) { _callee_target = x; }
1172
1173 // Oop results of vm runtime calls
1174 oop vm_result() const { return _vm_result; }
1175 void set_vm_result (oop x) { _vm_result = x; }
1176
1177 oop vm_result_2() const { return _vm_result_2; }
1178 void set_vm_result_2 (oop x) { _vm_result_2 = x; }
1179
1180 MemRegion deferred_card_mark() const { return _deferred_card_mark; }
1181 void set_deferred_card_mark(MemRegion mr) { _deferred_card_mark = mr; }
1182
1183 // Exception handling for compiled methods
1184 oop exception_oop() const { return _exception_oop; }
1185 int exception_stack_size() const { return _exception_stack_size; }
1186 address exception_pc() const { return _exception_pc; }
1187 address exception_handler_pc() const { return _exception_handler_pc; }
1188 bool is_method_handle_return() const { return _is_method_handle_return == 1; }
1189
1190 void set_exception_oop(oop o) { _exception_oop = o; }
1191 void set_exception_pc(address a) { _exception_pc = a; }
1192 void set_exception_handler_pc(address a) { _exception_handler_pc = a; }
1193 void set_exception_stack_size(int size) { _exception_stack_size = size; }
1194 void set_is_method_handle_return(bool value) { _is_method_handle_return = value ? 1 : 0; }
1195
1196 // Stack overflow support
1197 inline size_t stack_available(address cur_sp);
1198 address stack_yellow_zone_base()
1199 { return (address)(stack_base() - (stack_size() - (stack_red_zone_size() + stack_yellow_zone_size()))); }
1200 size_t stack_yellow_zone_size()
1201 { return StackYellowPages * os::vm_page_size(); }
1202 address stack_red_zone_base()
1203 { return (address)(stack_base() - (stack_size() - stack_red_zone_size())); }
1204 size_t stack_red_zone_size()
1205 { return StackRedPages * os::vm_page_size(); }
1206 bool in_stack_yellow_zone(address a)
1207 { return (a <= stack_yellow_zone_base()) && (a >= stack_red_zone_base()); }
1208 bool in_stack_red_zone(address a)
1209 { return (a <= stack_red_zone_base()) && (a >= (address)((intptr_t)stack_base() - stack_size())); }
1210
1211 void create_stack_guard_pages();
1212 void remove_stack_guard_pages();
1213
1247 #endif /* PRODUCT */
1248 static ByteSize jni_environment_offset() { return byte_offset_of(JavaThread, _jni_environment ); }
1249 static ByteSize last_Java_sp_offset() {
1250 return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_sp_offset();
1251 }
1252 static ByteSize last_Java_pc_offset() {
1253 return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_pc_offset();
1254 }
1255 static ByteSize frame_anchor_offset() {
1256 return byte_offset_of(JavaThread, _anchor);
1257 }
1258 static ByteSize callee_target_offset() { return byte_offset_of(JavaThread, _callee_target ); }
1259 static ByteSize vm_result_offset() { return byte_offset_of(JavaThread, _vm_result ); }
1260 static ByteSize vm_result_2_offset() { return byte_offset_of(JavaThread, _vm_result_2 ); }
1261 static ByteSize thread_state_offset() { return byte_offset_of(JavaThread, _thread_state ); }
1262 static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc ); }
1263 static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread ); }
1264 static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop ); }
1265 static ByteSize exception_pc_offset() { return byte_offset_of(JavaThread, _exception_pc ); }
1266 static ByteSize exception_handler_pc_offset() { return byte_offset_of(JavaThread, _exception_handler_pc); }
1267 static ByteSize exception_stack_size_offset() { return byte_offset_of(JavaThread, _exception_stack_size); }
1268 static ByteSize is_method_handle_return_offset() { return byte_offset_of(JavaThread, _is_method_handle_return); }
1269 static ByteSize stack_guard_state_offset() { return byte_offset_of(JavaThread, _stack_guard_state ); }
1270 static ByteSize suspend_flags_offset() { return byte_offset_of(JavaThread, _suspend_flags ); }
1271
1272 static ByteSize do_not_unlock_if_synchronized_offset() { return byte_offset_of(JavaThread, _do_not_unlock_if_synchronized); }
1273 static ByteSize should_post_on_exceptions_flag_offset() {
1274 return byte_offset_of(JavaThread, _should_post_on_exceptions_flag);
1275 }
1276
1277 #ifndef SERIALGC
1278 static ByteSize satb_mark_queue_offset() { return byte_offset_of(JavaThread, _satb_mark_queue); }
1279 static ByteSize dirty_card_queue_offset() { return byte_offset_of(JavaThread, _dirty_card_queue); }
1280 #endif // !SERIALGC
1281
1282 // Returns the jni environment for this thread
1283 JNIEnv* jni_environment() { return &_jni_environment; }
1284
1285 static JavaThread* thread_from_jni_environment(JNIEnv* env) {
1286 JavaThread *thread_from_jni_env = (JavaThread*)((intptr_t)env - in_bytes(jni_environment_offset()));
1287 // Only return NULL if thread is off the thread list; starting to
|
824 volatile bool _is_attaching;
825
826 public:
827 // State of the stack guard pages for this thread.
828 enum StackGuardState {
829 stack_guard_unused, // not needed
830 stack_guard_yellow_disabled,// disabled (temporarily) after stack overflow
831 stack_guard_enabled // enabled
832 };
833
834 private:
835
836 StackGuardState _stack_guard_state;
837
838 // Compiler exception handling (NOTE: The _exception_oop is *NOT* the same as _pending_exception. It is
839 // used to temp. parsing values into and out of the runtime system during exception handling for compiled
840 // code)
841 volatile oop _exception_oop; // Exception thrown in compiled code
842 volatile address _exception_pc; // PC where exception happened
843 volatile address _exception_handler_pc; // PC for handler of exception
844 volatile int _is_method_handle_return; // true (== 1) if the current exception PC is a MethodHandle call site.
845
846 // support for compilation
847 bool _is_compiling; // is true if a compilation is active inthis thread (one compilation per thread possible)
848
849 // support for JNI critical regions
850 jint _jni_active_critical; // count of entries into JNI critical region
851
852 // For deadlock detection.
853 int _depth_first_number;
854
855 // JVMTI PopFrame support
856 // This is set to popframe_pending to signal that top Java frame should be popped immediately
857 int _popframe_condition;
858
859 #ifndef PRODUCT
860 int _jmp_ring_index;
861 struct {
862 // We use intptr_t instead of address so debugger doesn't try and display strings
863 intptr_t _target;
1164 void clear_must_deopt_id() { _must_deopt_id = NULL; }
1165
1166 void set_deopt_nmethod(nmethod* nm) { _deopt_nmethod = nm; }
1167 nmethod* deopt_nmethod() { return _deopt_nmethod; }
1168
1169 methodOop callee_target() const { return _callee_target; }
1170 void set_callee_target (methodOop x) { _callee_target = x; }
1171
1172 // Oop results of vm runtime calls
1173 oop vm_result() const { return _vm_result; }
1174 void set_vm_result (oop x) { _vm_result = x; }
1175
1176 oop vm_result_2() const { return _vm_result_2; }
1177 void set_vm_result_2 (oop x) { _vm_result_2 = x; }
1178
1179 MemRegion deferred_card_mark() const { return _deferred_card_mark; }
1180 void set_deferred_card_mark(MemRegion mr) { _deferred_card_mark = mr; }
1181
1182 // Exception handling for compiled methods
1183 oop exception_oop() const { return _exception_oop; }
1184 address exception_pc() const { return _exception_pc; }
1185 address exception_handler_pc() const { return _exception_handler_pc; }
1186 bool is_method_handle_return() const { return _is_method_handle_return == 1; }
1187
1188 void set_exception_oop(oop o) { _exception_oop = o; }
1189 void set_exception_pc(address a) { _exception_pc = a; }
1190 void set_exception_handler_pc(address a) { _exception_handler_pc = a; }
1191 void set_is_method_handle_return(bool value) { _is_method_handle_return = value ? 1 : 0; }
1192
1193 // Stack overflow support
1194 inline size_t stack_available(address cur_sp);
1195 address stack_yellow_zone_base()
1196 { return (address)(stack_base() - (stack_size() - (stack_red_zone_size() + stack_yellow_zone_size()))); }
1197 size_t stack_yellow_zone_size()
1198 { return StackYellowPages * os::vm_page_size(); }
1199 address stack_red_zone_base()
1200 { return (address)(stack_base() - (stack_size() - stack_red_zone_size())); }
1201 size_t stack_red_zone_size()
1202 { return StackRedPages * os::vm_page_size(); }
1203 bool in_stack_yellow_zone(address a)
1204 { return (a <= stack_yellow_zone_base()) && (a >= stack_red_zone_base()); }
1205 bool in_stack_red_zone(address a)
1206 { return (a <= stack_red_zone_base()) && (a >= (address)((intptr_t)stack_base() - stack_size())); }
1207
1208 void create_stack_guard_pages();
1209 void remove_stack_guard_pages();
1210
1244 #endif /* PRODUCT */
1245 static ByteSize jni_environment_offset() { return byte_offset_of(JavaThread, _jni_environment ); }
1246 static ByteSize last_Java_sp_offset() {
1247 return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_sp_offset();
1248 }
1249 static ByteSize last_Java_pc_offset() {
1250 return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_pc_offset();
1251 }
1252 static ByteSize frame_anchor_offset() {
1253 return byte_offset_of(JavaThread, _anchor);
1254 }
1255 static ByteSize callee_target_offset() { return byte_offset_of(JavaThread, _callee_target ); }
1256 static ByteSize vm_result_offset() { return byte_offset_of(JavaThread, _vm_result ); }
1257 static ByteSize vm_result_2_offset() { return byte_offset_of(JavaThread, _vm_result_2 ); }
1258 static ByteSize thread_state_offset() { return byte_offset_of(JavaThread, _thread_state ); }
1259 static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc ); }
1260 static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread ); }
1261 static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop ); }
1262 static ByteSize exception_pc_offset() { return byte_offset_of(JavaThread, _exception_pc ); }
1263 static ByteSize exception_handler_pc_offset() { return byte_offset_of(JavaThread, _exception_handler_pc); }
1264 static ByteSize is_method_handle_return_offset() { return byte_offset_of(JavaThread, _is_method_handle_return); }
1265 static ByteSize stack_guard_state_offset() { return byte_offset_of(JavaThread, _stack_guard_state ); }
1266 static ByteSize suspend_flags_offset() { return byte_offset_of(JavaThread, _suspend_flags ); }
1267
1268 static ByteSize do_not_unlock_if_synchronized_offset() { return byte_offset_of(JavaThread, _do_not_unlock_if_synchronized); }
1269 static ByteSize should_post_on_exceptions_flag_offset() {
1270 return byte_offset_of(JavaThread, _should_post_on_exceptions_flag);
1271 }
1272
1273 #ifndef SERIALGC
1274 static ByteSize satb_mark_queue_offset() { return byte_offset_of(JavaThread, _satb_mark_queue); }
1275 static ByteSize dirty_card_queue_offset() { return byte_offset_of(JavaThread, _dirty_card_queue); }
1276 #endif // !SERIALGC
1277
1278 // Returns the jni environment for this thread
1279 JNIEnv* jni_environment() { return &_jni_environment; }
1280
1281 static JavaThread* thread_from_jni_environment(JNIEnv* env) {
1282 JavaThread *thread_from_jni_env = (JavaThread*)((intptr_t)env - in_bytes(jni_environment_offset()));
1283 // Only return NULL if thread is off the thread list; starting to
|