// // class JvmtiRawMonitor // // Used by JVMTI methods: All RawMonitor methods (CreateRawMonitor, EnterRawMonitor, etc.) // // A simplified version of the ObjectMonitor code. //
// Important note: // Raw monitors can be used in callbacks which happen during safepoint by the VM // thread (e.g., heapRootCallback). This means we may not transition/safepoint // poll in many cases, else the agent JavaThread can deadlock with the VM thread, // as this old comment says: // "We can't safepoint block in here because we could deadlock the vmthread. Blech." // The rules are: // - We must never safepoint poll if raw monitor is owned. // - We may safepoint poll before it is owned and after it has been released. // If this were the only thing we needed to think about we could just stay in // native for all operations. However we need to honor a suspend request, not // entering a monitor if suspended, and check for interrupts. Honoring a suspend // request and reading the interrupt flag must be done from VM state // (a safepoint unsafe state).
class JvmtiRawMonitor : public CHeapObj<mtSynchronizer> {
// Helper class to allow Threads to be linked into queues. // This is a stripped down version of ObjectWaiter. class QNode : public StackObj { friendclass JvmtiRawMonitor; enum TStates { TS_READY, TS_RUN, TS_WAIT, TS_ENTER };
QNode* volatile _next;
QNode* volatile _prev;
ParkEvent* _event; volatileint _notified; volatile TStates _t_state;
QNode(Thread* thread);
};
Thread* volatile _owner; // pointer to owning thread volatileint _recursions; // recursion count, 0 for first entry
QNode* volatile _entry_list; // Threads blocked on entry or reentry. // The list is actually composed of nodes, // acting as proxies for Threads.
QNode* volatile _wait_set; // Threads wait()ing on the monitor int _magic; char* _name; // JVMTI_RM_MAGIC is set in constructor and unset in destructor. enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') };
Thread* owner() const { return _owner; } void set_owner(Thread* owner) { _owner = owner; } int recursions() const { return _recursions; } void raw_enter(Thread* self); int raw_exit(Thread* self); int raw_wait(jlong millis, Thread* self); int raw_notify(Thread* self); int raw_notifyAll(Thread* self); int magic() const { return _magic; } constchar* get_name() const { return _name; } bool is_valid();
};
// Onload pending raw monitors // Class is used to cache onload or onstart monitor enter // which will transition into real monitor when // VM is fully initialized. class JvmtiPendingMonitors : public AllStatic {
private: static GrowableArray<JvmtiRawMonitor*>* _monitors; // Cache raw monitor enter
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.