< prev index next >

src/share/vm/prims/jvmtiThreadState.cpp

Print this page




  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 
  75   // add all the JvmtiEnvThreadState to the new JvmtiThreadState
  76   {
  77     JvmtiEnvIterator it;
  78     for (JvmtiEnvBase* env = it.first(); env != NULL; env = it.next(env)) {
  79       if (env->is_valid()) {
  80         add_env(env);
  81       }
  82     }
  83   }
  84 
  85   // link us into the list
  86   {
  87     // The thread state list manipulation code must not have safepoints.
  88     // See periodic_clean_up().
  89     debug_only(No_Safepoint_Verifier nosafepoint;)
  90 
  91     _prev = NULL;
  92     _next = _head;
  93     if (_head != NULL) {
  94       _head->_prev = this;
  95     }
  96     _head = this;
  97   }
  98 
  99   // set this as the state for the thread
 100   thread->set_jvmti_thread_state(this);
 101 }
 102 
 103 
 104 JvmtiThreadState::~JvmtiThreadState()   {
 105   assert(JvmtiThreadState_lock->is_locked(), "sanity check");
 106 
 107   // clear this as the state for the thread
 108   get_thread()->set_jvmti_thread_state(NULL);
 109 
 110   // zap our env thread states
 111   {
 112     JvmtiEnvBase::entering_dying_thread_env_iteration();
 113     JvmtiEnvThreadStateIterator it(this);
 114     for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ) {
 115       JvmtiEnvThreadState* zap = ets;
 116       ets = it.next(ets);
 117       delete zap;
 118     }
 119     JvmtiEnvBase::leaving_dying_thread_env_iteration();
 120   }
 121 
 122   // remove us from the list
 123   {
 124     // The thread state list manipulation code must not have safepoints.
 125     // See periodic_clean_up().
 126     debug_only(No_Safepoint_Verifier nosafepoint;)
 127 
 128     if (_prev == NULL) {
 129       assert(_head == this, "sanity check");
 130       _head = _next;
 131     } else {
 132       assert(_head != this, "sanity check");
 133       _prev->_next = _next;
 134     }
 135     if (_next != NULL) {
 136       _next->_prev = _prev;
 137     }
 138     _next = NULL;
 139     _prev = NULL;
 140   }
 141 }
 142 
 143 
 144 void
 145 JvmtiThreadState::periodic_clean_up() {
 146   assert(SafepointSynchronize::is_at_safepoint(), "at safepoint");
 147 
 148   // This iteration is initialized with "_head" instead of "JvmtiThreadState::first()"
 149   // because the latter requires the JvmtiThreadState_lock.
 150   // This iteration is safe at a safepoint as well, see the No_Safepoint_Verifier
 151   // asserts at all list manipulation sites.
 152   for (JvmtiThreadState *state = _head; state != NULL; state = state->next()) {
 153     // For each environment thread state corresponding to an invalid environment
 154     // unlink it from the list and deallocate it.
 155     JvmtiEnvThreadStateIterator it(state);
 156     JvmtiEnvThreadState* previous_ets = NULL;
 157     JvmtiEnvThreadState* ets = it.first();
 158     while (ets != NULL) {
 159       if (ets->get_env()->is_valid()) {
 160         previous_ets = ets;
 161         ets = it.next(ets);
 162       } else {
 163         // This one isn't valid, remove it from the list and deallocate it
 164         JvmtiEnvThreadState* defunct_ets = ets;
 165         ets = ets->next();
 166         if (previous_ets == NULL) {
 167           assert(state->head_env_thread_state() == defunct_ets, "sanity check");
 168           state->set_head_env_thread_state(ets);
 169         } else {
 170           previous_ets->set_next(ets);
 171         }
 172         delete defunct_ets;
 173       }
 174     }
 175   }
 176 }
 177 
 178 void JvmtiThreadState::add_env(JvmtiEnvBase *env) {
 179   assert(JvmtiThreadState_lock->is_locked(), "sanity check");
 180 
 181   JvmtiEnvThreadState *new_ets = new JvmtiEnvThreadState(_thread, env);
 182   // add this environment thread state to the end of the list (order is important)
 183   {
 184     // list deallocation (which occurs at a safepoint) cannot occur simultaneously
 185     debug_only(No_Safepoint_Verifier nosafepoint;)
 186 
 187     JvmtiEnvThreadStateIterator it(this);
 188     JvmtiEnvThreadState* previous_ets = NULL;
 189     for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
 190       previous_ets = ets;
 191     }
 192     if (previous_ets == NULL) {
 193       set_head_env_thread_state(new_ets);
 194     } else {
 195       previous_ets->set_next(new_ets);
 196     }
 197   }
 198 }
 199 
 200 
 201 
 202 
 203 void JvmtiThreadState::enter_interp_only_mode() {
 204   assert(_thread->get_interp_only_mode() == 0, "entering interp only when mode not zero");
 205   _thread->increment_interp_only_mode();




  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 
  75   // add all the JvmtiEnvThreadState to the new JvmtiThreadState
  76   {
  77     JvmtiEnvIterator it;
  78     for (JvmtiEnvBase* env = it.first(); env != NULL; env = it.next(env)) {
  79       if (env->is_valid()) {
  80         add_env(env);
  81       }
  82     }
  83   }
  84 
  85   // link us into the list
  86   {
  87     // The thread state list manipulation code must not have safepoints.
  88     // See periodic_clean_up().
  89     debug_only(NoSafepointVerifier nosafepoint;)
  90 
  91     _prev = NULL;
  92     _next = _head;
  93     if (_head != NULL) {
  94       _head->_prev = this;
  95     }
  96     _head = this;
  97   }
  98 
  99   // set this as the state for the thread
 100   thread->set_jvmti_thread_state(this);
 101 }
 102 
 103 
 104 JvmtiThreadState::~JvmtiThreadState()   {
 105   assert(JvmtiThreadState_lock->is_locked(), "sanity check");
 106 
 107   // clear this as the state for the thread
 108   get_thread()->set_jvmti_thread_state(NULL);
 109 
 110   // zap our env thread states
 111   {
 112     JvmtiEnvBase::entering_dying_thread_env_iteration();
 113     JvmtiEnvThreadStateIterator it(this);
 114     for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ) {
 115       JvmtiEnvThreadState* zap = ets;
 116       ets = it.next(ets);
 117       delete zap;
 118     }
 119     JvmtiEnvBase::leaving_dying_thread_env_iteration();
 120   }
 121 
 122   // remove us from the list
 123   {
 124     // The thread state list manipulation code must not have safepoints.
 125     // See periodic_clean_up().
 126     debug_only(NoSafepointVerifier nosafepoint;)
 127 
 128     if (_prev == NULL) {
 129       assert(_head == this, "sanity check");
 130       _head = _next;
 131     } else {
 132       assert(_head != this, "sanity check");
 133       _prev->_next = _next;
 134     }
 135     if (_next != NULL) {
 136       _next->_prev = _prev;
 137     }
 138     _next = NULL;
 139     _prev = NULL;
 140   }
 141 }
 142 
 143 
 144 void
 145 JvmtiThreadState::periodic_clean_up() {
 146   assert(SafepointSynchronize::is_at_safepoint(), "at safepoint");
 147 
 148   // This iteration is initialized with "_head" instead of "JvmtiThreadState::first()"
 149   // because the latter requires the JvmtiThreadState_lock.
 150   // This iteration is safe at a safepoint as well, see the NoSafepointVerifier
 151   // asserts at all list manipulation sites.
 152   for (JvmtiThreadState *state = _head; state != NULL; state = state->next()) {
 153     // For each environment thread state corresponding to an invalid environment
 154     // unlink it from the list and deallocate it.
 155     JvmtiEnvThreadStateIterator it(state);
 156     JvmtiEnvThreadState* previous_ets = NULL;
 157     JvmtiEnvThreadState* ets = it.first();
 158     while (ets != NULL) {
 159       if (ets->get_env()->is_valid()) {
 160         previous_ets = ets;
 161         ets = it.next(ets);
 162       } else {
 163         // This one isn't valid, remove it from the list and deallocate it
 164         JvmtiEnvThreadState* defunct_ets = ets;
 165         ets = ets->next();
 166         if (previous_ets == NULL) {
 167           assert(state->head_env_thread_state() == defunct_ets, "sanity check");
 168           state->set_head_env_thread_state(ets);
 169         } else {
 170           previous_ets->set_next(ets);
 171         }
 172         delete defunct_ets;
 173       }
 174     }
 175   }
 176 }
 177 
 178 void JvmtiThreadState::add_env(JvmtiEnvBase *env) {
 179   assert(JvmtiThreadState_lock->is_locked(), "sanity check");
 180 
 181   JvmtiEnvThreadState *new_ets = new JvmtiEnvThreadState(_thread, env);
 182   // add this environment thread state to the end of the list (order is important)
 183   {
 184     // list deallocation (which occurs at a safepoint) cannot occur simultaneously
 185     debug_only(NoSafepointVerifier nosafepoint;)
 186 
 187     JvmtiEnvThreadStateIterator it(this);
 188     JvmtiEnvThreadState* previous_ets = NULL;
 189     for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
 190       previous_ets = ets;
 191     }
 192     if (previous_ets == NULL) {
 193       set_head_env_thread_state(new_ets);
 194     } else {
 195       previous_ets->set_next(new_ets);
 196     }
 197   }
 198 }
 199 
 200 
 201 
 202 
 203 void JvmtiThreadState::enter_interp_only_mode() {
 204   assert(_thread->get_interp_only_mode() == 0, "entering interp only when mode not zero");
 205   _thread->increment_interp_only_mode();


< prev index next >