259
260 ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD, obj());
261
262 monitor->reenter(recursion, THREAD);
263 }
264 // -----------------------------------------------------------------------------
265 // JNI locks on java objects
266 // NOTE: must use heavy weight monitor to handle jni monitor enter
267 void ObjectSynchronizer::jni_enter(Handle obj, TRAPS) {
268 // the current locking is from JNI instead of Java code
269 TEVENT(jni_enter);
270 if (UseBiasedLocking) {
271 BiasedLocking::revoke_and_rebias(obj, false, THREAD);
272 assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
273 }
274 THREAD->set_current_pending_monitor_is_from_java(false);
275 ObjectSynchronizer::inflate(THREAD, obj())->enter(THREAD);
276 THREAD->set_current_pending_monitor_is_from_java(true);
277 }
278
279 // NOTE: must use heavy weight monitor to handle jni monitor enter
280 bool ObjectSynchronizer::jni_try_enter(Handle obj, Thread* THREAD) {
281 if (UseBiasedLocking) {
282 BiasedLocking::revoke_and_rebias(obj, false, THREAD);
283 assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
284 }
285
286 ObjectMonitor* monitor = ObjectSynchronizer::inflate_helper(obj());
287 return monitor->try_enter(THREAD);
288 }
289
290
291 // NOTE: must use heavy weight monitor to handle jni monitor exit
292 void ObjectSynchronizer::jni_exit(oop obj, Thread* THREAD) {
293 TEVENT(jni_exit);
294 if (UseBiasedLocking) {
295 Handle h_obj(THREAD, obj);
296 BiasedLocking::revoke_and_rebias(h_obj, false, THREAD);
297 obj = h_obj();
298 }
299 assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
300
301 ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD, obj);
302 // If this thread has locked the object, exit the monitor. Note: can't use
303 // monitor->check(CHECK); must exit even if an exception is pending.
304 if (monitor->check(THREAD)) {
305 monitor->exit(true, THREAD);
306 }
307 }
308
309 // -----------------------------------------------------------------------------
310 // Internal VM locks on java objects
|
259
260 ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD, obj());
261
262 monitor->reenter(recursion, THREAD);
263 }
264 // -----------------------------------------------------------------------------
265 // JNI locks on java objects
266 // NOTE: must use heavy weight monitor to handle jni monitor enter
267 void ObjectSynchronizer::jni_enter(Handle obj, TRAPS) {
268 // the current locking is from JNI instead of Java code
269 TEVENT(jni_enter);
270 if (UseBiasedLocking) {
271 BiasedLocking::revoke_and_rebias(obj, false, THREAD);
272 assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
273 }
274 THREAD->set_current_pending_monitor_is_from_java(false);
275 ObjectSynchronizer::inflate(THREAD, obj())->enter(THREAD);
276 THREAD->set_current_pending_monitor_is_from_java(true);
277 }
278
279 // NOTE: must use heavy weight monitor to handle jni monitor exit
280 void ObjectSynchronizer::jni_exit(oop obj, Thread* THREAD) {
281 TEVENT(jni_exit);
282 if (UseBiasedLocking) {
283 Handle h_obj(THREAD, obj);
284 BiasedLocking::revoke_and_rebias(h_obj, false, THREAD);
285 obj = h_obj();
286 }
287 assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
288
289 ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD, obj);
290 // If this thread has locked the object, exit the monitor. Note: can't use
291 // monitor->check(CHECK); must exit even if an exception is pending.
292 if (monitor->check(THREAD)) {
293 monitor->exit(true, THREAD);
294 }
295 }
296
297 // -----------------------------------------------------------------------------
298 // Internal VM locks on java objects
|