119 static LockOwnership query_lock_ownership(JavaThread * self, Handle h_obj);
120
121 static JavaThread* get_lock_owner(Handle h_obj, bool doLock);
122
123 // JNI detach support
124 static void release_monitors_owned_by_thread(TRAPS);
125 static void monitors_iterate(MonitorClosure* m);
126
127 // GC: we current use aggressive monitor deflation policy
128 // Basically we deflate all monitors that are not busy.
129 // An adaptive profile-based deflation policy could be used if needed
130 static void deflate_idle_monitors();
131 // For a given monitor list: global or per-thread, deflate idle monitors
132 static int deflate_monitor_list(ObjectMonitor** listheadp,
133 ObjectMonitor** freeHeadp,
134 ObjectMonitor** freeTailp);
135 static bool deflate_monitor(ObjectMonitor* mid, oop obj,
136 ObjectMonitor** freeHeadp,
137 ObjectMonitor** freeTailp);
138 static void oops_do(OopClosure* f);
139
140 // debugging
141 static void sanity_checks(const bool verbose,
142 const unsigned int cache_line_size,
143 int *error_cnt_ptr, int *warning_cnt_ptr);
144 static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
145
146 private:
147 enum { _BLOCKSIZE = 128 };
148 // global list of blocks of monitors
149 // gBlockList is really PaddedEnd<ObjectMonitor> *, but we don't
150 // want to expose the PaddedEnd template more than necessary.
151 static ObjectMonitor * volatile gBlockList;
152 // global monitor free list
153 static ObjectMonitor * volatile gFreeList;
154 // global monitor in-use list, for moribund threads,
155 // monitors they inflated need to be scanned for deflation
156 static ObjectMonitor * volatile gOmInUseList;
157 // count of entries in gOmInUseList
158 static int gOmInUseCount;
159 };
160
161 // ObjectLocker enforced balanced locking and can never thrown an
162 // IllegalMonitorStateException. However, a pending exception may
163 // have to pass through, and we must also be able to deal with
164 // asynchronous exceptions. The caller is responsible for checking
165 // the threads pending exception if needed.
166 // doLock was added to support classloading with UnsyncloadClass which
167 // requires flag based choice of locking the classloader lock.
168 class ObjectLocker : public StackObj {
169 private:
170 Thread* _thread;
171 Handle _obj;
172 BasicLock _lock;
173 bool _dolock; // default true
174 public:
175 ObjectLocker(Handle obj, Thread* thread, bool doLock = true);
176 ~ObjectLocker();
177
178 // Monitor behavior
|
119 static LockOwnership query_lock_ownership(JavaThread * self, Handle h_obj);
120
121 static JavaThread* get_lock_owner(Handle h_obj, bool doLock);
122
123 // JNI detach support
124 static void release_monitors_owned_by_thread(TRAPS);
125 static void monitors_iterate(MonitorClosure* m);
126
127 // GC: we current use aggressive monitor deflation policy
128 // Basically we deflate all monitors that are not busy.
129 // An adaptive profile-based deflation policy could be used if needed
130 static void deflate_idle_monitors();
131 // For a given monitor list: global or per-thread, deflate idle monitors
132 static int deflate_monitor_list(ObjectMonitor** listheadp,
133 ObjectMonitor** freeHeadp,
134 ObjectMonitor** freeTailp);
135 static bool deflate_monitor(ObjectMonitor* mid, oop obj,
136 ObjectMonitor** freeHeadp,
137 ObjectMonitor** freeTailp);
138 static void oops_do(OopClosure* f);
139 // Process oops in thread local used monitors
140 static void thread_local_used_oops_do(Thread* thread, OopClosure* f);
141
142 // debugging
143 static void sanity_checks(const bool verbose,
144 const unsigned int cache_line_size,
145 int *error_cnt_ptr, int *warning_cnt_ptr);
146 static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
147
148 private:
149 enum { _BLOCKSIZE = 128 };
150 // global list of blocks of monitors
151 // gBlockList is really PaddedEnd<ObjectMonitor> *, but we don't
152 // want to expose the PaddedEnd template more than necessary.
153 static ObjectMonitor * volatile gBlockList;
154 // global monitor free list
155 static ObjectMonitor * volatile gFreeList;
156 // global monitor in-use list, for moribund threads,
157 // monitors they inflated need to be scanned for deflation
158 static ObjectMonitor * volatile gOmInUseList;
159 // count of entries in gOmInUseList
160 static int gOmInUseCount;
161
162 // Process oops in all monitors
163 static void global_oops_do(OopClosure* f);
164 // Process oops in all global used monitors (i.e. moribund thread's monitors)
165 static void global_used_oops_do(OopClosure* f);
166 // Process oops in monitors on the given list
167 static void list_oops_do(ObjectMonitor* list, OopClosure* f);
168
169 };
170
171 // ObjectLocker enforced balanced locking and can never thrown an
172 // IllegalMonitorStateException. However, a pending exception may
173 // have to pass through, and we must also be able to deal with
174 // asynchronous exceptions. The caller is responsible for checking
175 // the threads pending exception if needed.
176 // doLock was added to support classloading with UnsyncloadClass which
177 // requires flag based choice of locking the classloader lock.
178 class ObjectLocker : public StackObj {
179 private:
180 Thread* _thread;
181 Handle _obj;
182 BasicLock _lock;
183 bool _dolock; // default true
184 public:
185 ObjectLocker(Handle obj, Thread* thread, bool doLock = true);
186 ~ObjectLocker();
187
188 // Monitor behavior
|