aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_CODE_PCDESC_HPP aoqi@0: #define SHARE_VM_CODE_PCDESC_HPP aoqi@0: aoqi@0: #include "memory/allocation.hpp" aoqi@0: aoqi@0: // PcDescs map a physical PC (given as offset from start of nmethod) to aoqi@0: // the corresponding source scope and byte code index. aoqi@0: aoqi@0: class nmethod; aoqi@0: aoqi@0: class PcDesc VALUE_OBJ_CLASS_SPEC { aoqi@0: friend class VMStructs; aoqi@0: private: aoqi@0: int _pc_offset; // offset from start of nmethod aoqi@0: int _scope_decode_offset; // offset for scope in nmethod aoqi@0: int _obj_decode_offset; aoqi@0: aoqi@0: enum { aoqi@0: PCDESC_reexecute = 1 << 0, aoqi@0: PCDESC_is_method_handle_invoke = 1 << 1, aoqi@0: PCDESC_return_oop = 1 << 2 aoqi@0: }; aoqi@0: aoqi@0: int _flags; aoqi@0: aoqi@0: void set_flag(int mask, bool z) { aoqi@0: _flags = z ? (_flags | mask) : (_flags & ~mask); aoqi@0: } aoqi@0: aoqi@0: public: aoqi@0: int pc_offset() const { return _pc_offset; } aoqi@0: int scope_decode_offset() const { return _scope_decode_offset; } aoqi@0: int obj_decode_offset() const { return _obj_decode_offset; } aoqi@0: aoqi@0: void set_pc_offset(int x) { _pc_offset = x; } aoqi@0: void set_scope_decode_offset(int x) { _scope_decode_offset = x; } aoqi@0: void set_obj_decode_offset(int x) { _obj_decode_offset = x; } aoqi@0: aoqi@0: // Constructor (only used for static in nmethod.cpp) aoqi@0: // Also used by ScopeDesc::sender()] aoqi@0: PcDesc(int pc_offset, int scope_decode_offset, int obj_decode_offset); aoqi@0: aoqi@0: enum { aoqi@0: // upper and lower exclusive limits real offsets: aoqi@0: lower_offset_limit = -1, aoqi@0: upper_offset_limit = (unsigned int)-1 >> 1 aoqi@0: }; aoqi@0: aoqi@0: // Flags aoqi@0: bool should_reexecute() const { return (_flags & PCDESC_reexecute) != 0; } aoqi@0: void set_should_reexecute(bool z) { set_flag(PCDESC_reexecute, z); } aoqi@0: aoqi@0: // Does pd refer to the same information as pd? aoqi@0: bool is_same_info(const PcDesc* pd) { aoqi@0: return _scope_decode_offset == pd->_scope_decode_offset && aoqi@0: _obj_decode_offset == pd->_obj_decode_offset && aoqi@0: _flags == pd->_flags; aoqi@0: } aoqi@0: aoqi@0: bool is_method_handle_invoke() const { return (_flags & PCDESC_is_method_handle_invoke) != 0; } aoqi@0: void set_is_method_handle_invoke(bool z) { set_flag(PCDESC_is_method_handle_invoke, z); } aoqi@0: aoqi@0: bool return_oop() const { return (_flags & PCDESC_return_oop) != 0; } aoqi@0: void set_return_oop(bool z) { set_flag(PCDESC_return_oop, z); } aoqi@0: aoqi@0: // Returns the real pc aoqi@0: address real_pc(const nmethod* code) const; aoqi@0: aoqi@0: void print(nmethod* code); aoqi@0: bool verify(nmethod* code); aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_CODE_PCDESC_HPP