< prev index next >

src/hotspot/share/interpreter/interpreterRuntime.cpp

Print this page

  54 #include "oops/oop.inline.hpp"
  55 #include "oops/symbol.hpp"
  56 #include "prims/jvmtiExport.hpp"
  57 #include "prims/methodHandles.hpp"
  58 #include "prims/nativeLookup.hpp"
  59 #include "runtime/atomic.hpp"
  60 #include "runtime/continuation.hpp"
  61 #include "runtime/deoptimization.hpp"
  62 #include "runtime/fieldDescriptor.inline.hpp"
  63 #include "runtime/frame.inline.hpp"
  64 #include "runtime/handles.inline.hpp"
  65 #include "runtime/icache.hpp"
  66 #include "runtime/interfaceSupport.inline.hpp"
  67 #include "runtime/java.hpp"
  68 #include "runtime/javaCalls.hpp"
  69 #include "runtime/jfieldIDWorkaround.hpp"
  70 #include "runtime/osThread.hpp"
  71 #include "runtime/sharedRuntime.hpp"
  72 #include "runtime/stackWatermarkSet.hpp"
  73 #include "runtime/stubRoutines.hpp"
  74 #include "runtime/synchronizer.hpp"
  75 #include "runtime/threadCritical.hpp"
  76 #include "utilities/align.hpp"
  77 #include "utilities/checkedCast.hpp"
  78 #include "utilities/copy.hpp"
  79 #include "utilities/events.hpp"
  80 #ifdef COMPILER2
  81 #include "opto/runtime.hpp"
  82 #endif
  83 
  84 // Helper class to access current interpreter state
  85 class LastFrameAccessor : public StackObj {
  86   frame _last_frame;
  87 public:
  88   LastFrameAccessor(JavaThread* current) {
  89     assert(current == Thread::current(), "sanity");
  90     _last_frame = current->last_frame();
  91   }
  92   bool is_interpreted_frame() const              { return _last_frame.is_interpreted_frame(); }
  93   Method*   method() const                       { return _last_frame.interpreter_frame_method(); }
  94   address   bcp() const                          { return _last_frame.interpreter_frame_bcp(); }

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

  54 #include "oops/oop.inline.hpp"
  55 #include "oops/symbol.hpp"
  56 #include "prims/jvmtiExport.hpp"
  57 #include "prims/methodHandles.hpp"
  58 #include "prims/nativeLookup.hpp"
  59 #include "runtime/atomic.hpp"
  60 #include "runtime/continuation.hpp"
  61 #include "runtime/deoptimization.hpp"
  62 #include "runtime/fieldDescriptor.inline.hpp"
  63 #include "runtime/frame.inline.hpp"
  64 #include "runtime/handles.inline.hpp"
  65 #include "runtime/icache.hpp"
  66 #include "runtime/interfaceSupport.inline.hpp"
  67 #include "runtime/java.hpp"
  68 #include "runtime/javaCalls.hpp"
  69 #include "runtime/jfieldIDWorkaround.hpp"
  70 #include "runtime/osThread.hpp"
  71 #include "runtime/sharedRuntime.hpp"
  72 #include "runtime/stackWatermarkSet.hpp"
  73 #include "runtime/stubRoutines.hpp"
  74 #include "runtime/synchronizer.inline.hpp"
  75 #include "runtime/threadCritical.hpp"
  76 #include "utilities/align.hpp"
  77 #include "utilities/checkedCast.hpp"
  78 #include "utilities/copy.hpp"
  79 #include "utilities/events.hpp"
  80 #ifdef COMPILER2
  81 #include "opto/runtime.hpp"
  82 #endif
  83 
  84 // Helper class to access current interpreter state
  85 class LastFrameAccessor : public StackObj {
  86   frame _last_frame;
  87 public:
  88   LastFrameAccessor(JavaThread* current) {
  89     assert(current == Thread::current(), "sanity");
  90     _last_frame = current->last_frame();
  91   }
  92   bool is_interpreted_frame() const              { return _last_frame.is_interpreted_frame(); }
  93   Method*   method() const                       { return _last_frame.interpreter_frame_method(); }
  94   address   bcp() const                          { return _last_frame.interpreter_frame_bcp(); }

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

 728 #ifdef ASSERT
 729   current->last_frame().interpreter_frame_verify_monitor(elem);
 730 #endif
 731   Handle h_obj(current, elem->obj());
 732   assert(Universe::heap()->is_in_or_null(h_obj()),
 733          "must be null or an object");
 734   ObjectSynchronizer::enter(h_obj, elem->lock(), current);
 735   assert(Universe::heap()->is_in_or_null(elem->obj()),
 736          "must be null or an object");
 737 #ifdef ASSERT
 738   current->last_frame().interpreter_frame_verify_monitor(elem);
 739 #endif
 740 JRT_END
 741 

















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