acorn@2233: /* stefank@2314: * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. acorn@2233: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. acorn@2233: * acorn@2233: * This code is free software; you can redistribute it and/or modify it acorn@2233: * under the terms of the GNU General Public License version 2 only, as acorn@2233: * published by the Free Software Foundation. acorn@2233: * acorn@2233: * This code is distributed in the hope that it will be useful, but WITHOUT acorn@2233: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or acorn@2233: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License acorn@2233: * version 2 for more details (a copy is included in the LICENSE file that acorn@2233: * accompanied this code). acorn@2233: * acorn@2233: * You should have received a copy of the GNU General Public License version acorn@2233: * 2 along with this work; if not, write to the Free Software Foundation, acorn@2233: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. acorn@2233: * acorn@2233: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA acorn@2233: * or visit www.oracle.com if you need additional information or have any acorn@2233: * questions. acorn@2233: * acorn@2233: */ acorn@2233: stefank@2314: #ifndef SHARE_VM_RUNTIME_BASICLOCK_HPP stefank@2314: #define SHARE_VM_RUNTIME_BASICLOCK_HPP stefank@2314: stefank@2314: #include "oops/markOop.hpp" stefank@2314: #include "runtime/handles.hpp" stefank@2314: #include "utilities/top.hpp" stefank@2314: acorn@2233: class BasicLock VALUE_OBJ_CLASS_SPEC { acorn@2233: friend class VMStructs; acorn@2233: private: acorn@2233: volatile markOop _displaced_header; acorn@2233: public: acorn@2233: markOop displaced_header() const { return _displaced_header; } acorn@2233: void set_displaced_header(markOop header) { _displaced_header = header; } acorn@2233: acorn@2233: void print_on(outputStream* st) const; acorn@2233: acorn@2233: // move a basic lock (used during deoptimization acorn@2233: void move_to(oop obj, BasicLock* dest); acorn@2233: acorn@2233: static int displaced_header_offset_in_bytes() { return offset_of(BasicLock, _displaced_header); } acorn@2233: }; acorn@2233: acorn@2233: // A BasicObjectLock associates a specific Java object with a BasicLock. acorn@2233: // It is currently embedded in an interpreter frame. acorn@2233: acorn@2233: // Because some machines have alignment restrictions on the control stack, acorn@2233: // the actual space allocated by the interpreter may include padding words acorn@2233: // after the end of the BasicObjectLock. Also, in order to guarantee acorn@2233: // alignment of the embedded BasicLock objects on such machines, we acorn@2233: // put the embedded BasicLock at the beginning of the struct. acorn@2233: acorn@2233: class BasicObjectLock VALUE_OBJ_CLASS_SPEC { acorn@2233: friend class VMStructs; acorn@2233: private: acorn@2233: BasicLock _lock; // the lock, must be double word aligned acorn@2233: oop _obj; // object holds the lock; acorn@2233: acorn@2233: public: acorn@2233: // Manipulation acorn@2233: oop obj() const { return _obj; } acorn@2233: void set_obj(oop obj) { _obj = obj; } acorn@2233: BasicLock* lock() { return &_lock; } acorn@2233: acorn@2233: // Note: Use frame::interpreter_frame_monitor_size() for the size of BasicObjectLocks acorn@2233: // in interpreter activation frames since it includes machine-specific padding. acorn@2233: static int size() { return sizeof(BasicObjectLock)/wordSize; } acorn@2233: acorn@2233: // GC support acorn@2233: void oops_do(OopClosure* f) { f->do_oop(&_obj); } acorn@2233: acorn@2233: static int obj_offset_in_bytes() { return offset_of(BasicObjectLock, _obj); } acorn@2233: static int lock_offset_in_bytes() { return offset_of(BasicObjectLock, _lock); } acorn@2233: }; acorn@2233: stefank@2314: stefank@2314: #endif // SHARE_VM_RUNTIME_BASICLOCK_HPP