< prev index next >

src/share/vm/prims/jvmtiThreadState.cpp

Print this page




  33 
  34 // marker for when the stack depth has been reset and is now unknown.
  35 // any negative number would work but small ones might obscure an
  36 // underrun error.
  37 static const int UNKNOWN_STACK_DEPTH = -99;
  38 
  39 ///////////////////////////////////////////////////////////////
  40 //
  41 // class JvmtiThreadState
  42 //
  43 // Instances of JvmtiThreadState hang off of each thread.
  44 // Thread local storage for JVMTI.
  45 //
  46 
  47 JvmtiThreadState *JvmtiThreadState::_head = NULL;
  48 
  49 JvmtiThreadState::JvmtiThreadState(JavaThread* thread)
  50   : _thread_event_enable() {
  51   assert(JvmtiThreadState_lock->is_locked(), "sanity check");
  52   _thread               = thread;
  53   _exception_detected   = false;
  54   _exception_caught     = false;
  55   _debuggable           = true;
  56   _hide_single_stepping = false;
  57   _hide_level           = 0;
  58   _pending_step_for_popframe = false;
  59   _class_being_redefined = NULL;
  60   _class_load_kind = jvmti_class_load_kind_load;
  61   _head_env_thread_state = NULL;
  62   _dynamic_code_event_collector = NULL;
  63   _vm_object_alloc_event_collector = NULL;
  64   _the_class_for_redefinition_verification = NULL;
  65   _scratch_class_for_redefinition_verification = NULL;
  66   _cur_stack_depth = UNKNOWN_STACK_DEPTH;
  67 
  68   // JVMTI ForceEarlyReturn support
  69   _pending_step_for_earlyret = false;
  70   _earlyret_state = earlyret_inactive;
  71   _earlyret_tos = ilgl;
  72   _earlyret_value.j = 0L;
  73   _earlyret_oop = NULL;
  74 


 293     // If the popframe_condition field is not popframe_inactive, then
 294     // we missed all of the popframe_field cleanup points:
 295     //
 296     // - unpack_frames() was not called (nothing to deopt)
 297     // - remove_activation_preserving_args_entry() was not called
 298     //   (did not get suspended in a call_vm() family call and did
 299     //   not complete a call_vm() family call on the way here)
 300     thr->clear_popframe_condition();
 301   }
 302 
 303   // clearing the flag indicates we are done with the PopFrame() dance
 304   clr_pending_step_for_popframe();
 305 
 306   // If exception was thrown in this frame, need to reset jvmti thread state.
 307   // Single stepping may not get enabled correctly by the agent since
 308   // exception state is passed in MethodExit event which may be sent at some
 309   // time in the future. JDWP agent ignores MethodExit events if caused by
 310   // an exception.
 311   //
 312   if (is_exception_detected()) {
 313     clear_exception_detected();
 314   }
 315   // If step is pending for popframe then it may not be
 316   // a repeat step. The new_bci and method_id is same as current_bci
 317   // and current method_id after pop and step for recursive calls.
 318   // Force the step by clearing the last location.
 319   JvmtiEnvThreadStateIterator it(this);
 320   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
 321     ets->clear_current_location();
 322   }
 323 }
 324 
 325 
 326 // Class:     JvmtiThreadState
 327 // Function:  update_for_pop_top_frame
 328 // Description:
 329 //   This function removes any frame pop notification request for
 330 //   the top frame and invalidates both the current stack depth and
 331 //   all cached frameIDs.
 332 //
 333 // Called by: PopFrame


 368     // One legitimate way for us to miss all the cleanup points is
 369     // if we got here right after handling a compiled return. If that
 370     // is the case, then we consider our return from compiled code to
 371     // complete the ForceEarlyReturn request and we clear the condition.
 372     clr_earlyret_pending();
 373     set_earlyret_oop(NULL);
 374     clr_earlyret_value();
 375   }
 376 
 377   // clearing the flag indicates we are done with
 378   // the ForceEarlyReturn() dance
 379   clr_pending_step_for_earlyret();
 380 
 381   // If exception was thrown in this frame, need to reset jvmti thread state.
 382   // Single stepping may not get enabled correctly by the agent since
 383   // exception state is passed in MethodExit event which may be sent at some
 384   // time in the future. JDWP agent ignores MethodExit events if caused by
 385   // an exception.
 386   //
 387   if (is_exception_detected()) {
 388     clear_exception_detected();
 389   }
 390   // If step is pending for earlyret then it may not be a repeat step.
 391   // The new_bci and method_id is same as current_bci and current
 392   // method_id after earlyret and step for recursive calls.
 393   // Force the step by clearing the last location.
 394   JvmtiEnvThreadStateIterator it(this);
 395   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
 396     ets->clear_current_location();
 397   }
 398 }
 399 
 400 void JvmtiThreadState::oops_do(OopClosure* f) {
 401   f->do_oop((oop*) &_earlyret_oop);
 402 }


  33 
  34 // marker for when the stack depth has been reset and is now unknown.
  35 // any negative number would work but small ones might obscure an
  36 // underrun error.
  37 static const int UNKNOWN_STACK_DEPTH = -99;
  38 
  39 ///////////////////////////////////////////////////////////////
  40 //
  41 // class JvmtiThreadState
  42 //
  43 // Instances of JvmtiThreadState hang off of each thread.
  44 // Thread local storage for JVMTI.
  45 //
  46 
  47 JvmtiThreadState *JvmtiThreadState::_head = NULL;
  48 
  49 JvmtiThreadState::JvmtiThreadState(JavaThread* thread)
  50   : _thread_event_enable() {
  51   assert(JvmtiThreadState_lock->is_locked(), "sanity check");
  52   _thread               = thread;
  53   _exception_state      = ES_CLEARED;

  54   _debuggable           = true;
  55   _hide_single_stepping = false;
  56   _hide_level           = 0;
  57   _pending_step_for_popframe = false;
  58   _class_being_redefined = NULL;
  59   _class_load_kind = jvmti_class_load_kind_load;
  60   _head_env_thread_state = NULL;
  61   _dynamic_code_event_collector = NULL;
  62   _vm_object_alloc_event_collector = NULL;
  63   _the_class_for_redefinition_verification = NULL;
  64   _scratch_class_for_redefinition_verification = NULL;
  65   _cur_stack_depth = UNKNOWN_STACK_DEPTH;
  66 
  67   // JVMTI ForceEarlyReturn support
  68   _pending_step_for_earlyret = false;
  69   _earlyret_state = earlyret_inactive;
  70   _earlyret_tos = ilgl;
  71   _earlyret_value.j = 0L;
  72   _earlyret_oop = NULL;
  73 


 292     // If the popframe_condition field is not popframe_inactive, then
 293     // we missed all of the popframe_field cleanup points:
 294     //
 295     // - unpack_frames() was not called (nothing to deopt)
 296     // - remove_activation_preserving_args_entry() was not called
 297     //   (did not get suspended in a call_vm() family call and did
 298     //   not complete a call_vm() family call on the way here)
 299     thr->clear_popframe_condition();
 300   }
 301 
 302   // clearing the flag indicates we are done with the PopFrame() dance
 303   clr_pending_step_for_popframe();
 304 
 305   // If exception was thrown in this frame, need to reset jvmti thread state.
 306   // Single stepping may not get enabled correctly by the agent since
 307   // exception state is passed in MethodExit event which may be sent at some
 308   // time in the future. JDWP agent ignores MethodExit events if caused by
 309   // an exception.
 310   //
 311   if (is_exception_detected()) {
 312     clear_exception_state();
 313   }
 314   // If step is pending for popframe then it may not be
 315   // a repeat step. The new_bci and method_id is same as current_bci
 316   // and current method_id after pop and step for recursive calls.
 317   // Force the step by clearing the last location.
 318   JvmtiEnvThreadStateIterator it(this);
 319   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
 320     ets->clear_current_location();
 321   }
 322 }
 323 
 324 
 325 // Class:     JvmtiThreadState
 326 // Function:  update_for_pop_top_frame
 327 // Description:
 328 //   This function removes any frame pop notification request for
 329 //   the top frame and invalidates both the current stack depth and
 330 //   all cached frameIDs.
 331 //
 332 // Called by: PopFrame


 367     // One legitimate way for us to miss all the cleanup points is
 368     // if we got here right after handling a compiled return. If that
 369     // is the case, then we consider our return from compiled code to
 370     // complete the ForceEarlyReturn request and we clear the condition.
 371     clr_earlyret_pending();
 372     set_earlyret_oop(NULL);
 373     clr_earlyret_value();
 374   }
 375 
 376   // clearing the flag indicates we are done with
 377   // the ForceEarlyReturn() dance
 378   clr_pending_step_for_earlyret();
 379 
 380   // If exception was thrown in this frame, need to reset jvmti thread state.
 381   // Single stepping may not get enabled correctly by the agent since
 382   // exception state is passed in MethodExit event which may be sent at some
 383   // time in the future. JDWP agent ignores MethodExit events if caused by
 384   // an exception.
 385   //
 386   if (is_exception_detected()) {
 387     clear_exception_state();
 388   }
 389   // If step is pending for earlyret then it may not be a repeat step.
 390   // The new_bci and method_id is same as current_bci and current
 391   // method_id after earlyret and step for recursive calls.
 392   // Force the step by clearing the last location.
 393   JvmtiEnvThreadStateIterator it(this);
 394   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
 395     ets->clear_current_location();
 396   }
 397 }
 398 
 399 void JvmtiThreadState::oops_do(OopClosure* f) {
 400   f->do_oop((oop*) &_earlyret_oop);
 401 }
< prev index next >