159 static int _num_mutex; |
159 static int _num_mutex; |
160 |
160 |
161 #ifdef ASSERT |
161 #ifdef ASSERT |
162 void assert_locked_or_safepoint(const Mutex* lock) { |
162 void assert_locked_or_safepoint(const Mutex* lock) { |
163 // check if this thread owns the lock (common case) |
163 // check if this thread owns the lock (common case) |
164 if (IgnoreLockingAssertions) return; |
|
165 assert(lock != NULL, "Need non-NULL lock"); |
164 assert(lock != NULL, "Need non-NULL lock"); |
166 if (lock->owned_by_self()) return; |
165 if (lock->owned_by_self()) return; |
167 if (SafepointSynchronize::is_at_safepoint()) return; |
166 if (SafepointSynchronize::is_at_safepoint()) return; |
168 if (!Universe::is_fully_initialized()) return; |
167 if (!Universe::is_fully_initialized()) return; |
169 // see if invoker of VM operation owns it |
168 // see if invoker of VM operation owns it |
172 fatal("must own lock %s", lock->name()); |
171 fatal("must own lock %s", lock->name()); |
173 } |
172 } |
174 |
173 |
175 // a weaker assertion than the above |
174 // a weaker assertion than the above |
176 void assert_locked_or_safepoint_weak(const Mutex* lock) { |
175 void assert_locked_or_safepoint_weak(const Mutex* lock) { |
177 if (IgnoreLockingAssertions) return; |
|
178 assert(lock != NULL, "Need non-NULL lock"); |
176 assert(lock != NULL, "Need non-NULL lock"); |
179 if (lock->is_locked()) return; |
177 if (lock->is_locked()) return; |
180 if (SafepointSynchronize::is_at_safepoint()) return; |
178 if (SafepointSynchronize::is_at_safepoint()) return; |
181 if (!Universe::is_fully_initialized()) return; |
179 if (!Universe::is_fully_initialized()) return; |
182 fatal("must own lock %s", lock->name()); |
180 fatal("must own lock %s", lock->name()); |
183 } |
181 } |
184 |
182 |
185 // a stronger assertion than the above |
183 // a stronger assertion than the above |
186 void assert_lock_strong(const Mutex* lock) { |
184 void assert_lock_strong(const Mutex* lock) { |
187 if (IgnoreLockingAssertions) return; |
|
188 assert(lock != NULL, "Need non-NULL lock"); |
185 assert(lock != NULL, "Need non-NULL lock"); |
189 if (lock->owned_by_self()) return; |
186 if (lock->owned_by_self()) return; |
190 fatal("must own lock %s", lock->name()); |
187 fatal("must own lock %s", lock->name()); |
191 } |
188 } |
192 #endif |
189 #endif |