comparison src/share/vm/runtime/mutex.hpp @ 55:2a8eb116ebbe

6610420: Debug VM crashes during monitor lock rank checking Summary: Make SerializePage lock as raw lock and add name for mutex locks Reviewed-by: never, dice, dholmes
author xlu
date Tue, 05 Feb 2008 23:21:57 -0800
parents a61af66fc99e
children d1605aabd0a1
comparison
equal deleted inserted replaced
54:d4a0f561287a 55:2a8eb116ebbe
79 79
80 // See orderAccess.hpp. We assume throughout the VM that mutex lock and 80 // See orderAccess.hpp. We assume throughout the VM that mutex lock and
81 // try_lock do fence-lock-acquire, and that unlock does a release-unlock, 81 // try_lock do fence-lock-acquire, and that unlock does a release-unlock,
82 // *in that order*. If their implementations change such that these 82 // *in that order*. If their implementations change such that these
83 // assumptions are violated, a whole lot of code will break. 83 // assumptions are violated, a whole lot of code will break.
84
85 // The default length of monitor name is choosen to be 64 to avoid false sharing.
86 static const int MONITOR_NAME_LEN = 64;
84 87
85 class Monitor : public CHeapObj { 88 class Monitor : public CHeapObj {
86 89
87 public: 90 public:
88 // A special lock: Is a lock where you are guaranteed not to block while you are 91 // A special lock: Is a lock where you are guaranteed not to block while you are
124 ParkEvent * volatile _EntryList ; // List of threads waiting for entry 127 ParkEvent * volatile _EntryList ; // List of threads waiting for entry
125 ParkEvent * volatile _OnDeck ; // heir-presumptive 128 ParkEvent * volatile _OnDeck ; // heir-presumptive
126 volatile intptr_t _WaitLock [1] ; // Protects _WaitSet 129 volatile intptr_t _WaitLock [1] ; // Protects _WaitSet
127 ParkEvent * volatile _WaitSet ; // LL of ParkEvents 130 ParkEvent * volatile _WaitSet ; // LL of ParkEvents
128 volatile bool _snuck; // Used for sneaky locking (evil). 131 volatile bool _snuck; // Used for sneaky locking (evil).
129 const char * _name; // Name of mutex
130 int NotifyCount ; // diagnostic assist 132 int NotifyCount ; // diagnostic assist
131 double pad [8] ; // avoid false sharing 133 char _name[MONITOR_NAME_LEN]; // Name of mutex
132 134
133 // Debugging fields for naming, deadlock detection, etc. (some only used in debug mode) 135 // Debugging fields for naming, deadlock detection, etc. (some only used in debug mode)
134 #ifndef PRODUCT 136 #ifndef PRODUCT
135 bool _allow_vm_block; 137 bool _allow_vm_block;
136 debug_only(int _rank;) // rank (to avoid/detect potential deadlocks) 138 debug_only(int _rank;) // rank (to avoid/detect potential deadlocks)
168 void ILock (Thread * Self) ; 170 void ILock (Thread * Self) ;
169 int IWait (Thread * Self, jlong timo); 171 int IWait (Thread * Self, jlong timo);
170 int ILocked () ; 172 int ILocked () ;
171 173
172 protected: 174 protected:
173 static void ClearMonitor (Monitor * m) ; 175 static void ClearMonitor (Monitor * m, const char* name = NULL) ;
174 Monitor() ; 176 Monitor() ;
175 177
176 public: 178 public:
177 Monitor(int rank, const char *name, bool allow_vm_block=false); 179 Monitor(int rank, const char *name, bool allow_vm_block=false);
178 ~Monitor(); 180 ~Monitor();