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_LOCATION_HPP aoqi@0: #define SHARE_VM_CODE_LOCATION_HPP aoqi@0: aoqi@0: #include "asm/assembler.hpp" aoqi@0: #include "code/vmreg.hpp" aoqi@0: #include "memory/allocation.hpp" aoqi@0: aoqi@0: // A Location describes a concrete machine variable location aoqi@0: // (such as integer or floating point register or a stack-held aoqi@0: // variable). Used when generating debug-information for nmethods. aoqi@0: // aoqi@0: // Encoding: aoqi@0: // aoqi@0: // bits (use low bits for best compression): aoqi@0: // Type: [3..0] aoqi@0: // Where: [4] aoqi@0: // Offset: [31..5] aoqi@0: aoqi@0: class Location VALUE_OBJ_CLASS_SPEC { aoqi@0: friend class VMStructs; aoqi@0: public: aoqi@0: enum Where { aoqi@0: on_stack, aoqi@0: in_register aoqi@0: }; aoqi@0: aoqi@0: enum Type { aoqi@0: invalid, // Invalid location aoqi@0: normal, // Ints, floats, double halves aoqi@0: oop, // Oop (please GC me!) aoqi@0: int_in_long, // Integer held in long register aoqi@0: lng, // Long held in one register aoqi@0: float_in_dbl, // Float held in double register aoqi@0: dbl, // Double held in one register aoqi@0: addr, // JSR return address aoqi@0: narrowoop // Narrow Oop (please GC me!) aoqi@0: }; aoqi@0: aoqi@0: aoqi@0: private: aoqi@0: enum { aoqi@0: TYPE_MASK = (juint) 0x0F, aoqi@0: TYPE_SHIFT = 0, aoqi@0: WHERE_MASK = (juint) 0x10, aoqi@0: WHERE_SHIFT = 4, aoqi@0: OFFSET_MASK = (juint) 0xFFFFFFE0, aoqi@0: OFFSET_SHIFT = 5 aoqi@0: }; aoqi@0: aoqi@0: juint _value; aoqi@0: aoqi@0: // Create a bit-packed Location aoqi@0: Location(Where where_, Type type_, unsigned offset_) { aoqi@0: set(where_, type_, offset_); aoqi@0: assert( where () == where_ , "" ); aoqi@0: assert( type () == type_ , "" ); aoqi@0: assert( offset() == offset_, "" ); aoqi@0: } aoqi@0: aoqi@0: inline void set(Where where_, Type type_, unsigned offset_) { aoqi@0: _value = (juint) ((where_ << WHERE_SHIFT) | aoqi@0: (type_ << TYPE_SHIFT) | aoqi@0: ((offset_ << OFFSET_SHIFT) & OFFSET_MASK)); aoqi@0: } aoqi@0: aoqi@0: public: aoqi@0: aoqi@0: // Stack location Factory. Offset is 4-byte aligned; remove low bits aoqi@0: static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); } aoqi@0: // Register location Factory aoqi@0: static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); } aoqi@0: // Default constructor aoqi@0: Location() { set(on_stack,invalid,0); } aoqi@0: aoqi@0: // Bit field accessors aoqi@0: Where where() const { return (Where) ((_value & WHERE_MASK) >> WHERE_SHIFT);} aoqi@0: Type type() const { return (Type) ((_value & TYPE_MASK) >> TYPE_SHIFT); } aoqi@0: unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); } aoqi@0: aoqi@0: // Accessors aoqi@0: bool is_register() const { return where() == in_register; } aoqi@0: bool is_stack() const { return where() == on_stack; } aoqi@0: aoqi@0: int stack_offset() const { assert(where() == on_stack, "wrong Where"); return offset()<