< prev index next >

src/hotspot/share/prims/jvmtiRawMonitor.cpp

Print this page




 130     node._t_state = QNode::TS_ENTER;
 131 
 132     RawMonitor_lock->lock_without_safepoint_check();
 133     node._next = _entry_list;
 134     _entry_list = &node;
 135     OrderAccess::fence();
 136     if (_owner == NULL && Atomic::replace_if_null(self, &_owner)) {
 137       _entry_list = node._next;
 138       RawMonitor_lock->unlock();
 139       return;
 140     }
 141     RawMonitor_lock->unlock();
 142     while (node._t_state == QNode::TS_ENTER) {
 143       self->_ParkEvent->park();
 144     }
 145   }
 146 }
 147 
 148 void JvmtiRawMonitor::simple_exit(Thread* self) {
 149   guarantee(_owner == self, "invariant");
 150   OrderAccess::release_store(&_owner, (Thread*)NULL);
 151   OrderAccess::fence();
 152   if (_entry_list == NULL) {
 153     return;
 154   }
 155 
 156   RawMonitor_lock->lock_without_safepoint_check();
 157   QNode* w = _entry_list;
 158   if (w != NULL) {
 159     _entry_list = w->_next;
 160   }
 161   RawMonitor_lock->unlock();
 162   if (w != NULL) {
 163     guarantee(w ->_t_state == QNode::TS_ENTER, "invariant");
 164     // Once we set _t_state to TS_RUN the waiting thread can complete
 165     // simple_enter and 'w' is pointing into random stack space. So we have
 166     // to ensure we extract the ParkEvent (which is in type-stable memory)
 167     // before we set the state, and then don't access 'w'.
 168     ParkEvent* ev = w->_event;
 169     OrderAccess::loadstore();
 170     w->_t_state = QNode::TS_RUN;




 130     node._t_state = QNode::TS_ENTER;
 131 
 132     RawMonitor_lock->lock_without_safepoint_check();
 133     node._next = _entry_list;
 134     _entry_list = &node;
 135     OrderAccess::fence();
 136     if (_owner == NULL && Atomic::replace_if_null(self, &_owner)) {
 137       _entry_list = node._next;
 138       RawMonitor_lock->unlock();
 139       return;
 140     }
 141     RawMonitor_lock->unlock();
 142     while (node._t_state == QNode::TS_ENTER) {
 143       self->_ParkEvent->park();
 144     }
 145   }
 146 }
 147 
 148 void JvmtiRawMonitor::simple_exit(Thread* self) {
 149   guarantee(_owner == self, "invariant");
 150   Atomic::release_store(&_owner, (Thread*)NULL);
 151   OrderAccess::fence();
 152   if (_entry_list == NULL) {
 153     return;
 154   }
 155 
 156   RawMonitor_lock->lock_without_safepoint_check();
 157   QNode* w = _entry_list;
 158   if (w != NULL) {
 159     _entry_list = w->_next;
 160   }
 161   RawMonitor_lock->unlock();
 162   if (w != NULL) {
 163     guarantee(w ->_t_state == QNode::TS_ENTER, "invariant");
 164     // Once we set _t_state to TS_RUN the waiting thread can complete
 165     // simple_enter and 'w' is pointing into random stack space. So we have
 166     // to ensure we extract the ParkEvent (which is in type-stable memory)
 167     // before we set the state, and then don't access 'w'.
 168     ParkEvent* ev = w->_event;
 169     OrderAccess::loadstore();
 170     w->_t_state = QNode::TS_RUN;


< prev index next >