< prev index next >

src/hotspot/share/interpreter/interpreterRuntime.cpp

Print this page

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

 718     }
 719   }
 720 
 721   ResolvedFieldEntry* entry = pool->resolved_field_entry_at(field_index);
 722   entry->set_flags(info.access_flags().is_final(), info.access_flags().is_volatile());
 723   entry->fill_in(info.field_holder(), info.offset(),
 724                  checked_cast<u2>(info.index()), checked_cast<u1>(state),
 725                  static_cast<u1>(get_code), static_cast<u1>(put_code));
 726 }
 727 
 728 
 729 //------------------------------------------------------------------------------------------------------------------------
 730 // Synchronization
 731 //
 732 // The interpreter's synchronization code is factored out so that it can
 733 // be shared by method invocation and synchronized blocks.
 734 //%note synchronization_3
 735 
 736 //%note monitor_1
 737 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, BasicObjectLock* elem))

 738 #ifdef ASSERT
 739   current->last_frame().interpreter_frame_verify_monitor(elem);
 740 #endif
 741   Handle h_obj(current, elem->obj());
 742   assert(Universe::heap()->is_in_or_null(h_obj()),
 743          "must be null or an object");
 744   ObjectSynchronizer::enter(h_obj, elem->lock(), current);
 745   assert(Universe::heap()->is_in_or_null(elem->obj()),
 746          "must be null or an object");
 747 #ifdef ASSERT
 748   current->last_frame().interpreter_frame_verify_monitor(elem);
 749 #endif
 750 JRT_END
 751 

















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