1 /* 2 * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_RUNTIME_SYNCHRONIZER_INLINE_HPP 26 #define SHARE_RUNTIME_SYNCHRONIZER_INLINE_HPP 27 28 #include "runtime/synchronizer.hpp" 29 30 #include "runtime/lightweightSynchronizer.hpp" 31 #include "runtime/safepointVerifiers.hpp" 32 33 inline ObjectMonitor* ObjectSynchronizer::read_monitor(markWord mark) { 34 return mark.monitor(); 35 } 36 37 inline ObjectMonitor* ObjectSynchronizer::read_monitor(Thread* current, oop obj) { 38 return ObjectSynchronizer::read_monitor(current, obj, obj->mark()); 39 } 40 41 inline ObjectMonitor* ObjectSynchronizer::read_monitor(Thread* current, oop obj, markWord mark) { 42 if (!UseObjectMonitorTable) { 43 return read_monitor(mark); 44 } else { 45 return LightweightSynchronizer::get_monitor_from_table(current, obj); 46 } 47 } 48 49 inline void ObjectSynchronizer::enter(Handle obj, BasicLock* lock, JavaThread* current) { 50 assert(current == Thread::current(), "must be"); 51 52 LightweightSynchronizer::enter(obj, lock, current); 53 } 54 55 inline bool ObjectSynchronizer::quick_enter(oop obj, BasicLock* lock, JavaThread* current) { 56 assert(current->thread_state() == _thread_in_Java, "invariant"); 57 NoSafepointVerifier nsv; 58 if (obj == nullptr) return false; // Need to throw NPE 59 60 if (obj->klass()->is_value_based()) { 61 return false; 62 } 63 64 return LightweightSynchronizer::quick_enter(obj, lock, current); 65 } 66 67 inline void ObjectSynchronizer::exit(oop object, BasicLock* lock, JavaThread* current) { 68 current->dec_held_monitor_count(); 69 70 LightweightSynchronizer::exit(object, lock, current); 71 } 72 73 #endif // SHARE_RUNTIME_SYNCHRONIZER_INLINE_HPP