< prev index next >

src/hotspot/share/interpreter/interpreterRuntime.cpp

Print this page

 707     put_code,
 708     info.field_holder(),
 709     info.index(),
 710     info.offset(),
 711     state,
 712     info.access_flags().is_final(),
 713     info.access_flags().is_volatile()
 714   );
 715 }
 716 
 717 
 718 //------------------------------------------------------------------------------------------------------------------------
 719 // Synchronization
 720 //
 721 // The interpreter's synchronization code is factored out so that it can
 722 // be shared by method invocation and synchronized blocks.
 723 //%note synchronization_3
 724 
 725 //%note monitor_1
 726 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, BasicObjectLock* elem))

 727 #ifdef ASSERT
 728   current->last_frame().interpreter_frame_verify_monitor(elem);
 729 #endif
 730   if (PrintBiasedLockingStatistics) {
 731     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
 732   }
 733   Handle h_obj(current, elem->obj());
 734   assert(Universe::heap()->is_in_or_null(h_obj()),
 735          "must be NULL or an object");
 736   ObjectSynchronizer::enter(h_obj, elem->lock(), current);
 737   assert(Universe::heap()->is_in_or_null(elem->obj()),
 738          "must be NULL or an object");
 739 #ifdef ASSERT
 740   current->last_frame().interpreter_frame_verify_monitor(elem);
 741 #endif
 742 JRT_END
 743 
















 744 
 745 JRT_LEAF(void, InterpreterRuntime::monitorexit(BasicObjectLock* elem))
 746   oop obj = elem->obj();
 747   assert(Universe::heap()->is_in(obj), "must be an object");
 748   // The object could become unlocked through a JNI call, which we have no other checks for.
 749   // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
 750   if (obj->is_unlocked()) {
 751     if (CheckJNICalls) {
 752       fatal("Object has been unlocked by JNI");
 753     }
 754     return;
 755   }
 756   ObjectSynchronizer::exit(obj, elem->lock(), JavaThread::current());
 757   // Free entry. If it is not cleared, the exception handling code will try to unlock the monitor
 758   // again at method exit or in the case of an exception.
 759   elem->set_obj(NULL);
 760 JRT_END
 761 
 762 
 763 JRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* current))

 707     put_code,
 708     info.field_holder(),
 709     info.index(),
 710     info.offset(),
 711     state,
 712     info.access_flags().is_final(),
 713     info.access_flags().is_volatile()
 714   );
 715 }
 716 
 717 
 718 //------------------------------------------------------------------------------------------------------------------------
 719 // Synchronization
 720 //
 721 // The interpreter's synchronization code is factored out so that it can
 722 // be shared by method invocation and synchronized blocks.
 723 //%note synchronization_3
 724 
 725 //%note monitor_1
 726 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, BasicObjectLock* elem))
 727   assert(LockingMode != LM_LIGHTWEIGHT, "Should call monitorenter_obj() when using the new lightweight locking");
 728 #ifdef ASSERT
 729   current->last_frame().interpreter_frame_verify_monitor(elem);
 730 #endif
 731   if (PrintBiasedLockingStatistics) {
 732     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
 733   }
 734   Handle h_obj(current, elem->obj());
 735   assert(Universe::heap()->is_in_or_null(h_obj()),
 736          "must be NULL or an object");
 737   ObjectSynchronizer::enter(h_obj, elem->lock(), current);
 738   assert(Universe::heap()->is_in_or_null(elem->obj()),
 739          "must be NULL or an object");
 740 #ifdef ASSERT
 741   current->last_frame().interpreter_frame_verify_monitor(elem);
 742 #endif
 743 JRT_END
 744 
 745 // NOTE: We provide a separate implementation for the new lightweight locking to workaround a limitation
 746 // of registers in x86_32. This entry point accepts an oop instead of a BasicObjectLock*.
 747 // The problem is that we would need to preserve the register that holds the BasicObjectLock,
 748 // but we are using that register to hold the thread. We don't have enough registers to
 749 // also keep the BasicObjectLock, but we don't really need it anyway, we only need
 750 // the object. See also InterpreterMacroAssembler::lock_object().
 751 // As soon as legacy stack-locking goes away we could remove the other monitorenter() entry
 752 // point, and only use oop-accepting entries (same for monitorexit() below).
 753 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter_obj(JavaThread* current, oopDesc* obj))
 754   assert(LockingMode == LM_LIGHTWEIGHT, "Should call monitorenter() when not using the new lightweight locking");
 755   Handle h_obj(current, cast_to_oop(obj));
 756   assert(Universe::heap()->is_in_or_null(h_obj()),
 757          "must be null or an object");
 758   ObjectSynchronizer::enter(h_obj, NULL, current);
 759   return;
 760 JRT_END
 761 
 762 JRT_LEAF(void, InterpreterRuntime::monitorexit(BasicObjectLock* elem))
 763   oop obj = elem->obj();
 764   assert(Universe::heap()->is_in(obj), "must be an object");
 765   // The object could become unlocked through a JNI call, which we have no other checks for.
 766   // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
 767   if (obj->is_unlocked()) {
 768     if (CheckJNICalls) {
 769       fatal("Object has been unlocked by JNI");
 770     }
 771     return;
 772   }
 773   ObjectSynchronizer::exit(obj, elem->lock(), JavaThread::current());
 774   // Free entry. If it is not cleared, the exception handling code will try to unlock the monitor
 775   // again at method exit or in the case of an exception.
 776   elem->set_obj(NULL);
 777 JRT_END
 778 
 779 
 780 JRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* current))
< prev index next >