Path: blob/master/src/hotspot/share/runtime/basicLock.hpp
40951 views
/*1* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_RUNTIME_BASICLOCK_HPP25#define SHARE_RUNTIME_BASICLOCK_HPP2627#include "oops/markWord.hpp"28#include "runtime/atomic.hpp"29#include "runtime/handles.hpp"3031class BasicLock {32friend class VMStructs;33friend class JVMCIVMStructs;34private:35volatile markWord _displaced_header;36public:37markWord displaced_header() const {38return Atomic::load(&_displaced_header);39}4041void set_displaced_header(markWord header) {42Atomic::store(&_displaced_header, header);43}4445void print_on(outputStream* st, oop owner) const;4647// move a basic lock (used during deoptimization48void move_to(oop obj, BasicLock* dest);4950static int displaced_header_offset_in_bytes() { return offset_of(BasicLock, _displaced_header); }51};5253// A BasicObjectLock associates a specific Java object with a BasicLock.54// It is currently embedded in an interpreter frame.5556// Because some machines have alignment restrictions on the control stack,57// the actual space allocated by the interpreter may include padding words58// after the end of the BasicObjectLock. Also, in order to guarantee59// alignment of the embedded BasicLock objects on such machines, we60// put the embedded BasicLock at the beginning of the struct.6162class BasicObjectLock {63friend class VMStructs;64private:65BasicLock _lock; // the lock, must be double word aligned66oop _obj; // object holds the lock;6768public:69// Manipulation70oop obj() const { return _obj; }71void set_obj(oop obj) { _obj = obj; }72BasicLock* lock() { return &_lock; }7374// Note: Use frame::interpreter_frame_monitor_size() for the size of BasicObjectLocks75// in interpreter activation frames since it includes machine-specific padding.76static int size() { return sizeof(BasicObjectLock)/wordSize; }7778// GC support79void oops_do(OopClosure* f) { f->do_oop(&_obj); }8081static int obj_offset_in_bytes() { return offset_of(BasicObjectLock, _obj); }82static int lock_offset_in_bytes() { return offset_of(BasicObjectLock, _lock); }83};848586#endif // SHARE_RUNTIME_BASICLOCK_HPP878889