206 static PerfCounter * _sync_ContendedLockAttempts;
207 static PerfCounter * _sync_FutileWakeups;
208 static PerfCounter * _sync_Parks;
209 static PerfCounter * _sync_Notifications;
210 static PerfCounter * _sync_Inflations;
211 static PerfCounter * _sync_Deflations;
212 static PerfLongVariable * _sync_MonExtant;
213
214 static int Knob_SpinLimit;
215
216 void* operator new (size_t size) throw();
217 void* operator new[] (size_t size) throw();
218 void operator delete(void* p);
219 void operator delete[] (void* p);
220
221 // TODO-FIXME: the "offset" routines should return a type of off_t instead of int ...
222 // ByteSize would also be an appropriate type.
223 static int header_offset_in_bytes() { return offset_of(ObjectMonitor, _header); }
224 static int object_offset_in_bytes() { return offset_of(ObjectMonitor, _object); }
225 static int owner_offset_in_bytes() { return offset_of(ObjectMonitor, _owner); }
226 static int ref_count_offset_in_bytes() { return offset_of(ObjectMonitor, _ref_count); }
227 static int recursions_offset_in_bytes() { return offset_of(ObjectMonitor, _recursions); }
228 static int cxq_offset_in_bytes() { return offset_of(ObjectMonitor, _cxq); }
229 static int succ_offset_in_bytes() { return offset_of(ObjectMonitor, _succ); }
230 static int EntryList_offset_in_bytes() { return offset_of(ObjectMonitor, _EntryList); }
231
232 // ObjectMonitor references can be ORed with markWord::monitor_value
233 // as part of the ObjectMonitor tagging mechanism. When we combine an
234 // ObjectMonitor reference with an offset, we need to remove the tag
235 // value in order to generate the proper address.
236 //
237 // We can either adjust the ObjectMonitor reference and then add the
238 // offset or we can adjust the offset that is added to the ObjectMonitor
239 // reference. The latter avoids an AGI (Address Generation Interlock)
240 // stall so the helper macro adjusts the offset value that is returned
241 // to the ObjectMonitor reference manipulation code:
242 //
243 #define OM_OFFSET_NO_MONITOR_VALUE_TAG(f) \
244 ((ObjectMonitor::f ## _offset_in_bytes()) - markWord::monitor_value)
245
246 markWord header() const;
379 int TrySpin(Thread* self);
380 void ExitEpilog(Thread* self, ObjectWaiter* Wakee);
381 bool ExitSuspendEquivalent(JavaThread* self);
382 void install_displaced_markword_in_object(const oop obj);
383 };
384
385 // A helper object for managing an ObjectMonitor*'s ref_count. There
386 // are special safety considerations when async deflation is used.
387 class ObjectMonitorHandle : public StackObj {
388 private:
389 ObjectMonitor* _om_ptr;
390 public:
391 ObjectMonitorHandle() { _om_ptr = NULL; }
392 ~ObjectMonitorHandle();
393
394 ObjectMonitor* om_ptr() const { return _om_ptr; }
395 // Save the ObjectMonitor* associated with the specified markWord and
396 // increment the ref_count.
397 bool save_om_ptr(oop object, markWord mark);
398 // Save the specified ObjectMonitor* if safe and increment the ref_count.
399 bool set_om_ptr_if_safe(ObjectMonitor* om_ptr);
400 // Unset the _om_ptr field and decrement the ref_count.
401 void unset_om_ptr();
402
403 // For internal use by ObjectSynchronizer::inflate().
404 void set_om_ptr(ObjectMonitor* om_ptr);
405 };
406
407 // Macro to use guarantee() for more strict AsyncDeflateIdleMonitors
408 // checks and assert() otherwise.
409 #define ADIM_guarantee(p, ...) \
410 do { \
411 if (AsyncDeflateIdleMonitors) { \
412 guarantee(p, __VA_ARGS__); \
413 } else { \
414 assert(p, __VA_ARGS__); \
415 } \
416 } while (0)
417
418 #endif // SHARE_RUNTIME_OBJECTMONITOR_HPP
|
206 static PerfCounter * _sync_ContendedLockAttempts;
207 static PerfCounter * _sync_FutileWakeups;
208 static PerfCounter * _sync_Parks;
209 static PerfCounter * _sync_Notifications;
210 static PerfCounter * _sync_Inflations;
211 static PerfCounter * _sync_Deflations;
212 static PerfLongVariable * _sync_MonExtant;
213
214 static int Knob_SpinLimit;
215
216 void* operator new (size_t size) throw();
217 void* operator new[] (size_t size) throw();
218 void operator delete(void* p);
219 void operator delete[] (void* p);
220
221 // TODO-FIXME: the "offset" routines should return a type of off_t instead of int ...
222 // ByteSize would also be an appropriate type.
223 static int header_offset_in_bytes() { return offset_of(ObjectMonitor, _header); }
224 static int object_offset_in_bytes() { return offset_of(ObjectMonitor, _object); }
225 static int owner_offset_in_bytes() { return offset_of(ObjectMonitor, _owner); }
226 static int recursions_offset_in_bytes() { return offset_of(ObjectMonitor, _recursions); }
227 static int cxq_offset_in_bytes() { return offset_of(ObjectMonitor, _cxq); }
228 static int succ_offset_in_bytes() { return offset_of(ObjectMonitor, _succ); }
229 static int EntryList_offset_in_bytes() { return offset_of(ObjectMonitor, _EntryList); }
230
231 // ObjectMonitor references can be ORed with markWord::monitor_value
232 // as part of the ObjectMonitor tagging mechanism. When we combine an
233 // ObjectMonitor reference with an offset, we need to remove the tag
234 // value in order to generate the proper address.
235 //
236 // We can either adjust the ObjectMonitor reference and then add the
237 // offset or we can adjust the offset that is added to the ObjectMonitor
238 // reference. The latter avoids an AGI (Address Generation Interlock)
239 // stall so the helper macro adjusts the offset value that is returned
240 // to the ObjectMonitor reference manipulation code:
241 //
242 #define OM_OFFSET_NO_MONITOR_VALUE_TAG(f) \
243 ((ObjectMonitor::f ## _offset_in_bytes()) - markWord::monitor_value)
244
245 markWord header() const;
378 int TrySpin(Thread* self);
379 void ExitEpilog(Thread* self, ObjectWaiter* Wakee);
380 bool ExitSuspendEquivalent(JavaThread* self);
381 void install_displaced_markword_in_object(const oop obj);
382 };
383
384 // A helper object for managing an ObjectMonitor*'s ref_count. There
385 // are special safety considerations when async deflation is used.
386 class ObjectMonitorHandle : public StackObj {
387 private:
388 ObjectMonitor* _om_ptr;
389 public:
390 ObjectMonitorHandle() { _om_ptr = NULL; }
391 ~ObjectMonitorHandle();
392
393 ObjectMonitor* om_ptr() const { return _om_ptr; }
394 // Save the ObjectMonitor* associated with the specified markWord and
395 // increment the ref_count.
396 bool save_om_ptr(oop object, markWord mark);
397 // Save the specified ObjectMonitor* if safe and increment the ref_count.
398 bool save_om_ptr_if_safe(ObjectMonitor* om_ptr);
399 // Unset the _om_ptr field and decrement the ref_count.
400 void unset_om_ptr();
401
402 // For internal use by ObjectSynchronizer::inflate().
403 void set_om_ptr(ObjectMonitor* om_ptr);
404 };
405
406 // Macro to use guarantee() for more strict AsyncDeflateIdleMonitors
407 // checks and assert() otherwise.
408 #define ADIM_guarantee(p, ...) \
409 do { \
410 if (AsyncDeflateIdleMonitors) { \
411 guarantee(p, __VA_ARGS__); \
412 } else { \
413 assert(p, __VA_ARGS__); \
414 } \
415 } while (0)
416
417 #endif // SHARE_RUNTIME_OBJECTMONITOR_HPP
|