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;
|
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 static void deflate_idle_monitors_conc();
149 static bool should_deflate_idle_monitors_conc() { return _should_deflate_idle_monitors_conc; }
150 static void set_should_deflate_idle_monitors_conc() { _should_deflate_idle_monitors_conc = true; }
151 static void do_safepoint_work();
152
153 private:
154 static void append_to_freelist_for_after_safepoint(int nScavenged, ObjectMonitor* head, ObjectMonitor* tail);
155
156 enum { _BLOCKSIZE = 128 };
157 // global list of blocks of monitors
158 // gBlockList is really PaddedEnd<ObjectMonitor> *, but we don't
159 // want to expose the PaddedEnd template more than necessary.
160 static ObjectMonitor * volatile gBlockList;
161 // global monitor free list
162 static ObjectMonitor * volatile gFreeList;
163 static ObjectMonitor * gFreeListNextSafepoint;
164 static ObjectMonitor * gFreeListNextSafepointTail;
165 // global monitor in-use list, for moribund threads,
166 // monitors they inflated need to be scanned for deflation
167 static ObjectMonitor * volatile gOmInUseList;
168 // count of entries in gOmInUseList
169 static int gOmInUseCount;
170 static bool _should_deflate_idle_monitors_conc;
171
172 // Process oops in all monitors
173 static void global_oops_do(OopClosure* f);
174 // Process oops in all global used monitors (i.e. moribund thread's monitors)
175 static void global_used_oops_do(OopClosure* f);
176 // Process oops in monitors on the given list
177 static void list_oops_do(ObjectMonitor* list, OopClosure* f);
178
179 };
180
181 // ObjectLocker enforced balanced locking and can never thrown an
182 // IllegalMonitorStateException. However, a pending exception may
183 // have to pass through, and we must also be able to deal with
184 // asynchronous exceptions. The caller is responsible for checking
185 // the threads pending exception if needed.
186 // doLock was added to support classloading with UnsyncloadClass which
187 // requires flag based choice of locking the classloader lock.
188 class ObjectLocker : public StackObj {
189 private:
190 Thread* _thread;
|