Sat, 07 Nov 2020 10:30:02 +0800
Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #ifndef SHARE_VM_PRIMS_JVMTITHREADSTATE_HPP |
aoqi@0 | 26 | #define SHARE_VM_PRIMS_JVMTITHREADSTATE_HPP |
aoqi@0 | 27 | |
aoqi@0 | 28 | #include "jvmtifiles/jvmti.h" |
aoqi@0 | 29 | #include "memory/allocation.hpp" |
aoqi@0 | 30 | #include "memory/allocation.inline.hpp" |
aoqi@0 | 31 | #include "prims/jvmtiEventController.hpp" |
aoqi@0 | 32 | #include "runtime/thread.hpp" |
aoqi@0 | 33 | #include "utilities/growableArray.hpp" |
aoqi@0 | 34 | |
aoqi@0 | 35 | // |
aoqi@0 | 36 | // Forward Declarations |
aoqi@0 | 37 | // |
aoqi@0 | 38 | |
aoqi@0 | 39 | class JvmtiEnvBase; |
aoqi@0 | 40 | class JvmtiEnvThreadState; |
aoqi@0 | 41 | class JvmtiDynamicCodeEventCollector; |
aoqi@0 | 42 | |
aoqi@0 | 43 | enum JvmtiClassLoadKind { |
aoqi@0 | 44 | jvmti_class_load_kind_load = 100, |
aoqi@0 | 45 | jvmti_class_load_kind_retransform, |
aoqi@0 | 46 | jvmti_class_load_kind_redefine |
aoqi@0 | 47 | }; |
aoqi@0 | 48 | |
aoqi@0 | 49 | /////////////////////////////////////////////////////////////// |
aoqi@0 | 50 | // |
aoqi@0 | 51 | // class JvmtiEnvThreadStateIterator |
aoqi@0 | 52 | // |
aoqi@0 | 53 | // The only safe means of iterating through the JvmtiEnvThreadStates |
aoqi@0 | 54 | // in a JvmtiThreadState. |
aoqi@0 | 55 | // Note that this iteratation includes invalid environments pending |
aoqi@0 | 56 | // deallocation -- in fact, some uses depend on this behavior. |
aoqi@0 | 57 | // |
aoqi@0 | 58 | class JvmtiEnvThreadStateIterator : public StackObj { |
aoqi@0 | 59 | private: |
aoqi@0 | 60 | JvmtiThreadState* state; |
aoqi@0 | 61 | public: |
aoqi@0 | 62 | JvmtiEnvThreadStateIterator(JvmtiThreadState* thread_state); |
aoqi@0 | 63 | ~JvmtiEnvThreadStateIterator(); |
aoqi@0 | 64 | JvmtiEnvThreadState* first(); |
aoqi@0 | 65 | JvmtiEnvThreadState* next(JvmtiEnvThreadState* ets); |
aoqi@0 | 66 | }; |
aoqi@0 | 67 | |
aoqi@0 | 68 | |
aoqi@0 | 69 | /////////////////////////////////////////////////////////////// |
aoqi@0 | 70 | // |
aoqi@0 | 71 | // class JvmtiThreadState |
aoqi@0 | 72 | // |
aoqi@0 | 73 | // The Jvmti state for each thread (across all JvmtiEnv): |
aoqi@0 | 74 | // 1. Local table of enabled events. |
aoqi@0 | 75 | class JvmtiThreadState : public CHeapObj<mtInternal> { |
aoqi@0 | 76 | private: |
aoqi@0 | 77 | friend class JvmtiEnv; |
aoqi@0 | 78 | JavaThread *_thread; |
aoqi@0 | 79 | bool _exception_detected; |
aoqi@0 | 80 | bool _exception_caught; |
aoqi@0 | 81 | bool _hide_single_stepping; |
aoqi@0 | 82 | bool _pending_step_for_popframe; |
aoqi@0 | 83 | bool _pending_step_for_earlyret; |
aoqi@0 | 84 | int _hide_level; |
aoqi@0 | 85 | |
aoqi@0 | 86 | // Used to send class being redefined/retransformed and kind of transform |
aoqi@0 | 87 | // info to the class file load hook event handler. |
aoqi@0 | 88 | KlassHandle *_class_being_redefined; |
aoqi@0 | 89 | JvmtiClassLoadKind _class_load_kind; |
aoqi@0 | 90 | |
aoqi@0 | 91 | // This is only valid when is_interp_only_mode() returns true |
aoqi@0 | 92 | int _cur_stack_depth; |
aoqi@0 | 93 | |
aoqi@0 | 94 | JvmtiThreadEventEnable _thread_event_enable; |
aoqi@0 | 95 | |
aoqi@0 | 96 | // for support of JvmtiEnvThreadState |
aoqi@0 | 97 | JvmtiEnvThreadState* _head_env_thread_state; |
aoqi@0 | 98 | |
aoqi@0 | 99 | // doubly-linked linear list of active thread state |
aoqi@0 | 100 | // needed in order to iterate the list without holding Threads_lock |
aoqi@0 | 101 | static JvmtiThreadState *_head; |
aoqi@0 | 102 | JvmtiThreadState *_next; |
aoqi@0 | 103 | JvmtiThreadState *_prev; |
aoqi@0 | 104 | |
aoqi@0 | 105 | // holds the current dynamic code event collector, NULL if no event collector in use |
aoqi@0 | 106 | JvmtiDynamicCodeEventCollector* _dynamic_code_event_collector; |
aoqi@0 | 107 | // holds the current vm object alloc event collector, NULL if no event collector in use |
aoqi@0 | 108 | JvmtiVMObjectAllocEventCollector* _vm_object_alloc_event_collector; |
aoqi@0 | 109 | |
aoqi@0 | 110 | // Should only be created by factory methods |
aoqi@0 | 111 | JvmtiThreadState(JavaThread *thread); |
aoqi@0 | 112 | |
aoqi@0 | 113 | friend class JvmtiEnvThreadStateIterator; |
aoqi@0 | 114 | inline JvmtiEnvThreadState* head_env_thread_state(); |
aoqi@0 | 115 | inline void set_head_env_thread_state(JvmtiEnvThreadState* ets); |
aoqi@0 | 116 | |
aoqi@0 | 117 | public: |
aoqi@0 | 118 | ~JvmtiThreadState(); |
aoqi@0 | 119 | |
aoqi@0 | 120 | // is event_type enabled and usable for this thread in any enviroments? |
aoqi@0 | 121 | bool is_enabled(jvmtiEvent event_type) { |
aoqi@0 | 122 | return _thread_event_enable.is_enabled(event_type); |
aoqi@0 | 123 | } |
aoqi@0 | 124 | |
aoqi@0 | 125 | JvmtiThreadEventEnable *thread_event_enable() { |
aoqi@0 | 126 | return &_thread_event_enable; |
aoqi@0 | 127 | } |
aoqi@0 | 128 | |
aoqi@0 | 129 | // Must only be called in situations where the state is for the current thread and |
aoqi@0 | 130 | // the environment can not go away. To be safe, the returned JvmtiEnvThreadState |
aoqi@0 | 131 | // must be used in such a way as there can be no intervening safepoints. |
aoqi@0 | 132 | inline JvmtiEnvThreadState* env_thread_state(JvmtiEnvBase *env); |
aoqi@0 | 133 | |
aoqi@0 | 134 | static void periodic_clean_up(); |
aoqi@0 | 135 | |
aoqi@0 | 136 | void add_env(JvmtiEnvBase *env); |
aoqi@0 | 137 | |
aoqi@0 | 138 | // Used by the interpreter for fullspeed debugging support |
aoqi@0 | 139 | bool is_interp_only_mode() { return _thread->is_interp_only_mode(); } |
aoqi@0 | 140 | void enter_interp_only_mode(); |
aoqi@0 | 141 | void leave_interp_only_mode(); |
aoqi@0 | 142 | |
aoqi@0 | 143 | // access to the linked list of all JVMTI thread states |
aoqi@0 | 144 | static JvmtiThreadState *first() { |
aoqi@0 | 145 | assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check"); |
aoqi@0 | 146 | return _head; |
aoqi@0 | 147 | } |
aoqi@0 | 148 | |
aoqi@0 | 149 | JvmtiThreadState *next() { |
aoqi@0 | 150 | return _next; |
aoqi@0 | 151 | } |
aoqi@0 | 152 | |
aoqi@0 | 153 | // Current stack depth is only valid when is_interp_only_mode() returns true. |
aoqi@0 | 154 | // These functions should only be called at a safepoint - usually called from same thread. |
aoqi@0 | 155 | // Returns the number of Java activations on the stack. |
aoqi@0 | 156 | int cur_stack_depth(); |
aoqi@0 | 157 | void invalidate_cur_stack_depth(); |
aoqi@0 | 158 | void incr_cur_stack_depth(); |
aoqi@0 | 159 | void decr_cur_stack_depth(); |
aoqi@0 | 160 | |
aoqi@0 | 161 | int count_frames(); |
aoqi@0 | 162 | |
aoqi@0 | 163 | inline JavaThread *get_thread() { return _thread; } |
aoqi@0 | 164 | inline bool is_exception_detected() { return _exception_detected; } |
aoqi@0 | 165 | inline bool is_exception_caught() { return _exception_caught; } |
aoqi@0 | 166 | inline void set_exception_detected() { _exception_detected = true; |
aoqi@0 | 167 | _exception_caught = false; } |
aoqi@0 | 168 | inline void clear_exception_detected() { |
aoqi@0 | 169 | _exception_detected = false; |
aoqi@0 | 170 | assert(_exception_caught == false, "_exception_caught is out of phase"); |
aoqi@0 | 171 | } |
aoqi@0 | 172 | inline void set_exception_caught() { _exception_caught = true; |
aoqi@0 | 173 | _exception_detected = false; } |
aoqi@0 | 174 | |
aoqi@0 | 175 | inline void clear_hide_single_stepping() { |
aoqi@0 | 176 | if (_hide_level > 0) { |
aoqi@0 | 177 | _hide_level--; |
aoqi@0 | 178 | } else { |
aoqi@0 | 179 | assert(_hide_single_stepping, "hide_single_stepping is out of phase"); |
aoqi@0 | 180 | _hide_single_stepping = false; |
aoqi@0 | 181 | } |
aoqi@0 | 182 | } |
aoqi@0 | 183 | inline bool hide_single_stepping() { return _hide_single_stepping; } |
aoqi@0 | 184 | inline void set_hide_single_stepping() { |
aoqi@0 | 185 | if (_hide_single_stepping) { |
aoqi@0 | 186 | _hide_level++; |
aoqi@0 | 187 | } else { |
aoqi@0 | 188 | assert(_hide_level == 0, "hide_level is out of phase"); |
aoqi@0 | 189 | _hide_single_stepping = true; |
aoqi@0 | 190 | } |
aoqi@0 | 191 | } |
aoqi@0 | 192 | |
aoqi@0 | 193 | // Step pending flag is set when PopFrame is called and it is cleared |
aoqi@0 | 194 | // when step for the Pop Frame is completed. |
aoqi@0 | 195 | // This logic is used to distinguish b/w step for pop frame and repeat step. |
aoqi@0 | 196 | void set_pending_step_for_popframe() { _pending_step_for_popframe = true; } |
aoqi@0 | 197 | void clr_pending_step_for_popframe() { _pending_step_for_popframe = false; } |
aoqi@0 | 198 | bool is_pending_step_for_popframe() { return _pending_step_for_popframe; } |
aoqi@0 | 199 | void process_pending_step_for_popframe(); |
aoqi@0 | 200 | |
aoqi@0 | 201 | // Step pending flag is set when ForceEarlyReturn is called and it is cleared |
aoqi@0 | 202 | // when step for the ForceEarlyReturn is completed. |
aoqi@0 | 203 | // This logic is used to distinguish b/w step for early return and repeat step. |
aoqi@0 | 204 | void set_pending_step_for_earlyret() { _pending_step_for_earlyret = true; } |
aoqi@0 | 205 | void clr_pending_step_for_earlyret() { _pending_step_for_earlyret = false; } |
aoqi@0 | 206 | bool is_pending_step_for_earlyret() { return _pending_step_for_earlyret; } |
aoqi@0 | 207 | void process_pending_step_for_earlyret(); |
aoqi@0 | 208 | |
aoqi@0 | 209 | // Setter and getter method is used to send redefined class info |
aoqi@0 | 210 | // when class file load hook event is posted. |
aoqi@0 | 211 | // It is set while loading redefined class and cleared before the |
aoqi@0 | 212 | // class file load hook event is posted. |
aoqi@0 | 213 | inline void set_class_being_redefined(KlassHandle *h_class, JvmtiClassLoadKind kind) { |
aoqi@0 | 214 | _class_being_redefined = h_class; |
aoqi@0 | 215 | _class_load_kind = kind; |
aoqi@0 | 216 | } |
aoqi@0 | 217 | |
aoqi@0 | 218 | inline void clear_class_being_redefined() { |
aoqi@0 | 219 | _class_being_redefined = NULL; |
aoqi@0 | 220 | _class_load_kind = jvmti_class_load_kind_load; |
aoqi@0 | 221 | } |
aoqi@0 | 222 | |
aoqi@0 | 223 | inline KlassHandle *get_class_being_redefined() { |
aoqi@0 | 224 | return _class_being_redefined; |
aoqi@0 | 225 | } |
aoqi@0 | 226 | |
aoqi@0 | 227 | inline JvmtiClassLoadKind get_class_load_kind() { |
aoqi@0 | 228 | return _class_load_kind; |
aoqi@0 | 229 | } |
aoqi@0 | 230 | |
aoqi@0 | 231 | // RedefineClasses support |
aoqi@0 | 232 | // The bug 6214132 caused the verification to fail. |
aoqi@0 | 233 | // |
aoqi@0 | 234 | // Below is the detailed description of the fix approach taken: |
aoqi@0 | 235 | // 1. What's done in RedefineClasses() before verification: |
aoqi@0 | 236 | // a) A reference to the class being redefined (_the_class) and a |
aoqi@0 | 237 | // reference to new version of the class (_scratch_class) are |
aoqi@0 | 238 | // saved here for use during the bytecode verification phase of |
aoqi@0 | 239 | // RedefineClasses. See RedefineVerifyMark for how these fields |
aoqi@0 | 240 | // are managed. |
aoqi@0 | 241 | // b) The _java_mirror field from _the_class is copied to the |
aoqi@0 | 242 | // _java_mirror field in _scratch_class. This means that a jclass |
aoqi@0 | 243 | // returned for _the_class or _scratch_class will refer to the |
aoqi@0 | 244 | // same Java mirror. The verifier will see the "one true mirror" |
aoqi@0 | 245 | // for the class being verified. |
aoqi@0 | 246 | // 2. What is done at verification: |
aoqi@0 | 247 | // When the verifier makes calls into the VM to ask questions about |
aoqi@0 | 248 | // the class being verified, it will pass the jclass to JVM_* functions. |
aoqi@0 | 249 | // The jclass is always pointing to the mirror of _the_class. |
aoqi@0 | 250 | // ~28 JVM_* functions called by the verifier for the information |
aoqi@0 | 251 | // about CP entries and klass structure should check the jvmtiThreadState |
aoqi@0 | 252 | // info about equivalent klass versions and use it to replace a Klass* |
aoqi@0 | 253 | // of _the_class with a Klass* of _scratch_class. The function |
aoqi@0 | 254 | // class_to_verify_considering_redefinition() must be called for it. |
aoqi@0 | 255 | // |
aoqi@0 | 256 | // Note again, that this redirection happens only for the verifier thread. |
aoqi@0 | 257 | // Other threads have very small overhead by checking the existence |
aoqi@0 | 258 | // of the jvmtiThreadSate and the information about klasses equivalence. |
aoqi@0 | 259 | // No JNI functions need to be changed, they don't reference the klass guts. |
aoqi@0 | 260 | // The JavaThread pointer is already available in all JVM_* functions |
aoqi@0 | 261 | // used by the verifier, so there is no extra performance issue with it. |
aoqi@0 | 262 | |
aoqi@0 | 263 | private: |
aoqi@0 | 264 | KlassHandle *_the_class_for_redefinition_verification; |
aoqi@0 | 265 | KlassHandle *_scratch_class_for_redefinition_verification; |
aoqi@0 | 266 | |
aoqi@0 | 267 | public: |
aoqi@0 | 268 | inline void set_class_versions_map(KlassHandle *the_class, |
aoqi@0 | 269 | KlassHandle *scratch_class) { |
aoqi@0 | 270 | _the_class_for_redefinition_verification = the_class; |
aoqi@0 | 271 | _scratch_class_for_redefinition_verification = scratch_class; |
aoqi@0 | 272 | } |
aoqi@0 | 273 | |
aoqi@0 | 274 | inline void clear_class_versions_map() { set_class_versions_map(NULL, NULL); } |
aoqi@0 | 275 | |
aoqi@0 | 276 | static inline |
aoqi@0 | 277 | Klass* class_to_verify_considering_redefinition(Klass* klass, |
aoqi@0 | 278 | JavaThread *thread) { |
aoqi@0 | 279 | JvmtiThreadState *state = thread->jvmti_thread_state(); |
aoqi@0 | 280 | if (state != NULL && state->_the_class_for_redefinition_verification != NULL) { |
aoqi@0 | 281 | if ((*(state->_the_class_for_redefinition_verification))() == klass) { |
aoqi@0 | 282 | klass = (*(state->_scratch_class_for_redefinition_verification))(); |
aoqi@0 | 283 | } |
aoqi@0 | 284 | } |
aoqi@0 | 285 | return klass; |
aoqi@0 | 286 | } |
aoqi@0 | 287 | |
aoqi@0 | 288 | // Todo: get rid of this! |
aoqi@0 | 289 | private: |
aoqi@0 | 290 | bool _debuggable; |
aoqi@0 | 291 | public: |
aoqi@0 | 292 | // Should the thread be enumerated by jvmtiInternal::GetAllThreads? |
aoqi@0 | 293 | bool is_debuggable() { return _debuggable; } |
aoqi@0 | 294 | // If a thread cannot be suspended (has no valid last_java_frame) then it gets marked !debuggable |
aoqi@0 | 295 | void set_debuggable(bool debuggable) { _debuggable = debuggable; } |
aoqi@0 | 296 | |
aoqi@0 | 297 | public: |
aoqi@0 | 298 | |
aoqi@0 | 299 | bool may_be_walked(); |
aoqi@0 | 300 | |
aoqi@0 | 301 | // Thread local event collector setter and getter methods. |
aoqi@0 | 302 | JvmtiDynamicCodeEventCollector* get_dynamic_code_event_collector() { |
aoqi@0 | 303 | return _dynamic_code_event_collector; |
aoqi@0 | 304 | } |
aoqi@0 | 305 | JvmtiVMObjectAllocEventCollector* get_vm_object_alloc_event_collector() { |
aoqi@0 | 306 | return _vm_object_alloc_event_collector; |
aoqi@0 | 307 | } |
aoqi@0 | 308 | void set_dynamic_code_event_collector(JvmtiDynamicCodeEventCollector* collector) { |
aoqi@0 | 309 | _dynamic_code_event_collector = collector; |
aoqi@0 | 310 | } |
aoqi@0 | 311 | void set_vm_object_alloc_event_collector(JvmtiVMObjectAllocEventCollector* collector) { |
aoqi@0 | 312 | _vm_object_alloc_event_collector = collector; |
aoqi@0 | 313 | } |
aoqi@0 | 314 | |
aoqi@0 | 315 | |
aoqi@0 | 316 | // |
aoqi@0 | 317 | // Frame routines |
aoqi@0 | 318 | // |
aoqi@0 | 319 | |
aoqi@0 | 320 | public: |
aoqi@0 | 321 | |
aoqi@0 | 322 | // true when the thread was suspended with a pointer to the last Java frame. |
aoqi@0 | 323 | bool has_last_frame() { return _thread->has_last_Java_frame(); } |
aoqi@0 | 324 | |
aoqi@0 | 325 | void update_for_pop_top_frame(); |
aoqi@0 | 326 | |
aoqi@0 | 327 | // already holding JvmtiThreadState_lock - retrieve or create JvmtiThreadState |
aoqi@0 | 328 | // Can return NULL if JavaThread is exiting. |
aoqi@0 | 329 | inline static JvmtiThreadState *state_for_while_locked(JavaThread *thread) { |
aoqi@0 | 330 | assert(JvmtiThreadState_lock->is_locked(), "sanity check"); |
aoqi@0 | 331 | |
aoqi@0 | 332 | JvmtiThreadState *state = thread->jvmti_thread_state(); |
aoqi@0 | 333 | if (state == NULL) { |
aoqi@0 | 334 | if (thread->is_exiting()) { |
aoqi@0 | 335 | // don't add a JvmtiThreadState to a thread that is exiting |
aoqi@0 | 336 | return NULL; |
aoqi@0 | 337 | } |
aoqi@0 | 338 | |
aoqi@0 | 339 | state = new JvmtiThreadState(thread); |
aoqi@0 | 340 | } |
aoqi@0 | 341 | return state; |
aoqi@0 | 342 | } |
aoqi@0 | 343 | |
aoqi@0 | 344 | // retrieve or create JvmtiThreadState |
aoqi@0 | 345 | // Can return NULL if JavaThread is exiting. |
aoqi@0 | 346 | inline static JvmtiThreadState *state_for(JavaThread *thread) { |
aoqi@0 | 347 | JvmtiThreadState *state = thread->jvmti_thread_state(); |
aoqi@0 | 348 | if (state == NULL) { |
aoqi@0 | 349 | MutexLocker mu(JvmtiThreadState_lock); |
aoqi@0 | 350 | // check again with the lock held |
aoqi@0 | 351 | state = state_for_while_locked(thread); |
aoqi@0 | 352 | } else { |
aoqi@0 | 353 | CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); |
aoqi@0 | 354 | } |
aoqi@0 | 355 | return state; |
aoqi@0 | 356 | } |
aoqi@0 | 357 | |
aoqi@0 | 358 | // JVMTI ForceEarlyReturn support |
aoqi@0 | 359 | |
aoqi@0 | 360 | // This is set to earlyret_pending to signal that top Java frame |
aoqi@0 | 361 | // should be returned immediately |
aoqi@0 | 362 | public: |
aoqi@0 | 363 | int _earlyret_state; |
aoqi@0 | 364 | TosState _earlyret_tos; |
aoqi@0 | 365 | jvalue _earlyret_value; |
aoqi@0 | 366 | oop _earlyret_oop; // Used to return an oop result into Java code from |
aoqi@0 | 367 | // ForceEarlyReturnObject, GC-preserved |
aoqi@0 | 368 | |
aoqi@0 | 369 | // Setting and clearing earlyret_state |
aoqi@0 | 370 | // earlyret_pending indicates that a ForceEarlyReturn() has been |
aoqi@0 | 371 | // requested and not yet been completed. |
aoqi@0 | 372 | public: |
aoqi@0 | 373 | enum EarlyretState { |
aoqi@0 | 374 | earlyret_inactive = 0, |
aoqi@0 | 375 | earlyret_pending = 1 |
aoqi@0 | 376 | }; |
aoqi@0 | 377 | |
aoqi@0 | 378 | void set_earlyret_pending(void) { _earlyret_state = earlyret_pending; } |
aoqi@0 | 379 | void clr_earlyret_pending(void) { _earlyret_state = earlyret_inactive; } |
aoqi@0 | 380 | bool is_earlyret_pending(void) { return (_earlyret_state == earlyret_pending); } |
aoqi@0 | 381 | |
aoqi@0 | 382 | TosState earlyret_tos() { return _earlyret_tos; } |
aoqi@0 | 383 | oop earlyret_oop() const { return _earlyret_oop; } |
aoqi@0 | 384 | void set_earlyret_oop (oop x) { _earlyret_oop = x; } |
aoqi@0 | 385 | jvalue earlyret_value() { return _earlyret_value; } |
aoqi@0 | 386 | void set_earlyret_value(jvalue val, TosState tos) { _earlyret_tos = tos; _earlyret_value = val; } |
aoqi@0 | 387 | void clr_earlyret_value() { _earlyret_tos = ilgl; _earlyret_value.j = 0L; } |
aoqi@0 | 388 | |
aoqi@0 | 389 | static ByteSize earlyret_state_offset() { return byte_offset_of(JvmtiThreadState, _earlyret_state); } |
aoqi@0 | 390 | static ByteSize earlyret_tos_offset() { return byte_offset_of(JvmtiThreadState, _earlyret_tos); } |
aoqi@0 | 391 | static ByteSize earlyret_oop_offset() { return byte_offset_of(JvmtiThreadState, _earlyret_oop); } |
aoqi@0 | 392 | static ByteSize earlyret_value_offset() { return byte_offset_of(JvmtiThreadState, _earlyret_value); } |
aoqi@0 | 393 | |
aoqi@0 | 394 | void oops_do(OopClosure* f) NOT_JVMTI_RETURN; // GC support |
aoqi@0 | 395 | |
aoqi@0 | 396 | public: |
aoqi@0 | 397 | void set_should_post_on_exceptions(bool val) { _thread->set_should_post_on_exceptions_flag(val ? JNI_TRUE : JNI_FALSE); } |
aoqi@0 | 398 | }; |
aoqi@0 | 399 | |
aoqi@0 | 400 | class RedefineVerifyMark : public StackObj { |
aoqi@0 | 401 | private: |
aoqi@0 | 402 | JvmtiThreadState *_state; |
aoqi@0 | 403 | KlassHandle _scratch_class; |
aoqi@0 | 404 | Handle _scratch_mirror; |
aoqi@0 | 405 | |
aoqi@0 | 406 | public: |
aoqi@0 | 407 | RedefineVerifyMark(KlassHandle *the_class, KlassHandle *scratch_class, |
aoqi@0 | 408 | JvmtiThreadState *state) : _state(state), _scratch_class(*scratch_class) |
aoqi@0 | 409 | { |
aoqi@0 | 410 | _state->set_class_versions_map(the_class, scratch_class); |
aoqi@0 | 411 | _scratch_mirror = Handle(_scratch_class->java_mirror()); |
aoqi@0 | 412 | (*scratch_class)->set_java_mirror((*the_class)->java_mirror()); |
aoqi@0 | 413 | } |
aoqi@0 | 414 | |
aoqi@0 | 415 | ~RedefineVerifyMark() { |
aoqi@0 | 416 | // Restore the scratch class's mirror, so when scratch_class is removed |
aoqi@0 | 417 | // the correct mirror pointing to it can be cleared. |
aoqi@0 | 418 | _scratch_class->set_java_mirror(_scratch_mirror()); |
aoqi@0 | 419 | _state->clear_class_versions_map(); |
aoqi@0 | 420 | } |
aoqi@0 | 421 | }; |
aoqi@0 | 422 | |
aoqi@0 | 423 | #endif // SHARE_VM_PRIMS_JVMTITHREADSTATE_HPP |