48 QNode* volatile _prev;
49 ParkEvent* _event;
50 volatile int _notified;
51 volatile TStates _t_state;
52
53 QNode(Thread* thread);
54 };
55
56 Thread* volatile _owner; // pointer to owning thread
57 volatile int _recursions; // recursion count, 0 for first entry
58 QNode* volatile _entry_list; // Threads blocked on entry or reentry.
59 // The list is actually composed of nodes,
60 // acting as proxies for Threads.
61 QNode* volatile _wait_set; // Threads wait()ing on the monitor
62 volatile jint _waiters; // number of waiting threads
63 int _magic;
64 char* _name;
65 // JVMTI_RM_MAGIC is set in contructor and unset in destructor.
66 enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') };
67
68 void simple_enter(Thread* self);
69 void simple_exit(Thread* self);
70 int simple_wait(Thread* self, jlong millis);
71 void simple_notify(Thread* self, bool all);
72
73 public:
74
75 // return codes
76 enum {
77 M_OK, // no error
78 M_ILLEGAL_MONITOR_STATE, // IllegalMonitorStateException
79 M_INTERRUPTED // Thread.interrupt()
80 };
81
82 // Non-aborting operator new
83 void* operator new(size_t size) throw() {
84 return CHeapObj::operator new(size, std::nothrow);
85 }
86
87 JvmtiRawMonitor(const char* name);
88 ~JvmtiRawMonitor();
89
90 Thread* owner() const { return _owner; }
91 void set_owner(Thread* owner) { _owner = owner; }
92 int recursions() const { return _recursions; }
93 void raw_enter(Thread* self);
94 int raw_exit(Thread* self);
95 int raw_wait(jlong millis, bool interruptible, Thread* self);
96 int raw_notify(Thread* self);
97 int raw_notifyAll(Thread* self);
98 int magic() const { return _magic; }
99 const char* get_name() const { return _name; }
100 bool is_valid();
101 };
102
103 // Onload pending raw monitors
104 // Class is used to cache onload or onstart monitor enter
105 // which will transition into real monitor when
106 // VM is fully initialized.
107 class JvmtiPendingMonitors : public AllStatic {
108
109 private:
110 static GrowableArray<JvmtiRawMonitor*>* _monitors; // Cache raw monitor enter
111
112 inline static GrowableArray<JvmtiRawMonitor*>* monitors() { return _monitors; }
113
114 static void dispose() {
115 delete monitors();
|
48 QNode* volatile _prev;
49 ParkEvent* _event;
50 volatile int _notified;
51 volatile TStates _t_state;
52
53 QNode(Thread* thread);
54 };
55
56 Thread* volatile _owner; // pointer to owning thread
57 volatile int _recursions; // recursion count, 0 for first entry
58 QNode* volatile _entry_list; // Threads blocked on entry or reentry.
59 // The list is actually composed of nodes,
60 // acting as proxies for Threads.
61 QNode* volatile _wait_set; // Threads wait()ing on the monitor
62 volatile jint _waiters; // number of waiting threads
63 int _magic;
64 char* _name;
65 // JVMTI_RM_MAGIC is set in contructor and unset in destructor.
66 enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') };
67
68 // Helpers for queue management isolation
69 void enqueue_waiter(QNode& node);
70 void dequeue_waiter(QNode& node);
71
72 // Mostly low-level implementation routines
73 void simple_enter(Thread* self);
74 void simple_exit(Thread* self);
75 int simple_wait(Thread* self, jlong millis);
76 void simple_notify(Thread* self, bool all);
77
78 public:
79
80 // return codes
81 enum {
82 M_OK, // no error
83 M_ILLEGAL_MONITOR_STATE, // IllegalMonitorStateException
84 M_INTERRUPTED // Thread.interrupt()
85 };
86
87 // Non-aborting operator new
88 void* operator new(size_t size) throw() {
89 return CHeapObj::operator new(size, std::nothrow);
90 }
91
92 JvmtiRawMonitor(const char* name);
93 ~JvmtiRawMonitor();
94
95 Thread* owner() const { return _owner; }
96 void set_owner(Thread* owner) { _owner = owner; }
97 int recursions() const { return _recursions; }
98 void raw_enter(Thread* self);
99 int raw_exit(Thread* self);
100 int raw_wait(jlong millis, Thread* self);
101 int raw_notify(Thread* self);
102 int raw_notifyAll(Thread* self);
103 int magic() const { return _magic; }
104 const char* get_name() const { return _name; }
105 bool is_valid();
106 };
107
108 // Onload pending raw monitors
109 // Class is used to cache onload or onstart monitor enter
110 // which will transition into real monitor when
111 // VM is fully initialized.
112 class JvmtiPendingMonitors : public AllStatic {
113
114 private:
115 static GrowableArray<JvmtiRawMonitor*>* _monitors; // Cache raw monitor enter
116
117 inline static GrowableArray<JvmtiRawMonitor*>* monitors() { return _monitors; }
118
119 static void dispose() {
120 delete monitors();
|