comparison src/share/vm/runtime/synchronizer.hpp @ 1878:fa83ab460c54

6988353: refactor contended sync subsystem Summary: reduce complexity by factoring synchronizer.cpp Reviewed-by: dholmes, never, coleenp
author acorn
date Fri, 22 Oct 2010 15:59:34 -0400
parents bfc89697cccb
children f95d63e2154a
comparison
equal deleted inserted replaced
1874:75ab0162aa84 1878:fa83ab460c54
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 * 22 *
23 */ 23 */
24 24
25 class BasicLock VALUE_OBJ_CLASS_SPEC {
26 friend class VMStructs;
27 private:
28 volatile markOop _displaced_header;
29 public:
30 markOop displaced_header() const { return _displaced_header; }
31 void set_displaced_header(markOop header) { _displaced_header = header; }
32
33 void print_on(outputStream* st) const;
34
35 // move a basic lock (used during deoptimization
36 void move_to(oop obj, BasicLock* dest);
37
38 static int displaced_header_offset_in_bytes() { return offset_of(BasicLock, _displaced_header); }
39 };
40
41 // A BasicObjectLock associates a specific Java object with a BasicLock.
42 // It is currently embedded in an interpreter frame.
43
44 // Because some machines have alignment restrictions on the control stack,
45 // the actual space allocated by the interpreter may include padding words
46 // after the end of the BasicObjectLock. Also, in order to guarantee
47 // alignment of the embedded BasicLock objects on such machines, we
48 // put the embedded BasicLock at the beginning of the struct.
49
50 class BasicObjectLock VALUE_OBJ_CLASS_SPEC {
51 friend class VMStructs;
52 private:
53 BasicLock _lock; // the lock, must be double word aligned
54 oop _obj; // object holds the lock;
55
56 public:
57 // Manipulation
58 oop obj() const { return _obj; }
59 void set_obj(oop obj) { _obj = obj; }
60 BasicLock* lock() { return &_lock; }
61
62 // Note: Use frame::interpreter_frame_monitor_size() for the size of BasicObjectLocks
63 // in interpreter activation frames since it includes machine-specific padding.
64 static int size() { return sizeof(BasicObjectLock)/wordSize; }
65
66 // GC support
67 void oops_do(OopClosure* f) { f->do_oop(&_obj); }
68
69 static int obj_offset_in_bytes() { return offset_of(BasicObjectLock, _obj); }
70 static int lock_offset_in_bytes() { return offset_of(BasicObjectLock, _lock); }
71 };
72 25
73 class ObjectMonitor; 26 class ObjectMonitor;
74 27
75 class ObjectSynchronizer : AllStatic { 28 class ObjectSynchronizer : AllStatic {
76 friend class VMStructs; 29 friend class VMStructs;
161 // debugging 114 // debugging
162 static void trace_locking(Handle obj, bool is_compiled, bool is_method, bool is_locking) PRODUCT_RETURN; 115 static void trace_locking(Handle obj, bool is_compiled, bool is_method, bool is_locking) PRODUCT_RETURN;
163 static void verify() PRODUCT_RETURN; 116 static void verify() PRODUCT_RETURN;
164 static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0; 117 static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
165 118
119 static void RegisterSpinCallback (int (*)(intptr_t, int), intptr_t) ;
120
166 private: 121 private:
167 enum { _BLOCKSIZE = 128 }; 122 enum { _BLOCKSIZE = 128 };
168 static ObjectMonitor* gBlockList; 123 static ObjectMonitor* gBlockList;
169 static ObjectMonitor * volatile gFreeList; 124 static ObjectMonitor * volatile gFreeList;
170 static ObjectMonitor * volatile gOmInUseList; // for moribund thread, so monitors they inflated still get scanned 125 static ObjectMonitor * volatile gOmInUseList; // for moribund thread, so monitors they inflated still get scanned
171 static int gOmInUseCount; 126 static int gOmInUseCount;
172
173 public:
174 static void Initialize () ;
175 static PerfCounter * _sync_ContendedLockAttempts ;
176 static PerfCounter * _sync_FutileWakeups ;
177 static PerfCounter * _sync_Parks ;
178 static PerfCounter * _sync_EmptyNotifications ;
179 static PerfCounter * _sync_Notifications ;
180 static PerfCounter * _sync_SlowEnter ;
181 static PerfCounter * _sync_SlowExit ;
182 static PerfCounter * _sync_SlowNotify ;
183 static PerfCounter * _sync_SlowNotifyAll ;
184 static PerfCounter * _sync_FailedSpins ;
185 static PerfCounter * _sync_SuccessfulSpins ;
186 static PerfCounter * _sync_PrivateA ;
187 static PerfCounter * _sync_PrivateB ;
188 static PerfCounter * _sync_MonInCirculation ;
189 static PerfCounter * _sync_MonScavenged ;
190 static PerfCounter * _sync_Inflations ;
191 static PerfCounter * _sync_Deflations ;
192 static PerfLongVariable * _sync_MonExtant ;
193
194 public:
195 static void RegisterSpinCallback (int (*)(intptr_t, int), intptr_t) ;
196 127
197 }; 128 };
198 129
199 // ObjectLocker enforced balanced locking and can never thrown an 130 // ObjectLocker enforced balanced locking and can never thrown an
200 // IllegalMonitorStateException. However, a pending exception may 131 // IllegalMonitorStateException. However, a pending exception may