1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/code/location.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,114 @@ 1.4 +/* 1.5 + * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// A Location describes a concrete machine variable location 1.29 +// (such as integer or floating point register or a stack-held 1.30 +// variable). Used when generating debug-information for nmethods. 1.31 +// 1.32 +// Encoding: 1.33 +// 1.34 +// bits: 1.35 +// Where: [15] 1.36 +// Type: [14..12] 1.37 +// Offset: [11..0] 1.38 + 1.39 +class Location VALUE_OBJ_CLASS_SPEC { 1.40 + friend class VMStructs; 1.41 + public: 1.42 + enum Where { 1.43 + on_stack, 1.44 + in_register 1.45 + }; 1.46 + 1.47 + enum Type { 1.48 + normal, // Ints, floats, double halves 1.49 + oop, // Oop (please GC me!) 1.50 + int_in_long, // Integer held in long register 1.51 + lng, // Long held in one register 1.52 + float_in_dbl, // Float held in double register 1.53 + dbl, // Double held in one register 1.54 + addr, // JSR return address 1.55 + invalid // Invalid location 1.56 + }; 1.57 + 1.58 + 1.59 + private: 1.60 + enum { 1.61 + OFFSET_MASK = (jchar) 0x0FFF, 1.62 + OFFSET_SHIFT = 0, 1.63 + TYPE_MASK = (jchar) 0x7000, 1.64 + TYPE_SHIFT = 12, 1.65 + WHERE_MASK = (jchar) 0x8000, 1.66 + WHERE_SHIFT = 15 1.67 + }; 1.68 + 1.69 + uint16_t _value; 1.70 + 1.71 + // Create a bit-packed Location 1.72 + Location(Where where_, Type type_, unsigned offset_) { 1.73 + set(where_, type_, offset_); 1.74 + assert( where () == where_ , "" ); 1.75 + assert( type () == type_ , "" ); 1.76 + assert( offset() == offset_, "" ); 1.77 + } 1.78 + 1.79 + inline void set(Where where_, Type type_, unsigned offset_) { 1.80 + _value = (uint16_t) ((where_ << WHERE_SHIFT) | 1.81 + (type_ << TYPE_SHIFT) | 1.82 + ((offset_ << OFFSET_SHIFT) & OFFSET_MASK)); 1.83 + } 1.84 + 1.85 + public: 1.86 + 1.87 + // Stack location Factory. Offset is 4-byte aligned; remove low bits 1.88 + static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); } 1.89 + // Register location Factory 1.90 + static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); } 1.91 + // Default constructor 1.92 + Location() { set(on_stack,invalid,(unsigned) -1); } 1.93 + 1.94 + // Bit field accessors 1.95 + Where where() const { return (Where) ((_value & WHERE_MASK) >> WHERE_SHIFT);} 1.96 + Type type() const { return (Type) ((_value & TYPE_MASK) >> TYPE_SHIFT); } 1.97 + unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); } 1.98 + 1.99 + // Accessors 1.100 + bool is_register() const { return where() == in_register; } 1.101 + bool is_stack() const { return where() == on_stack; } 1.102 + 1.103 + int stack_offset() const { assert(where() == on_stack, "wrong Where"); return offset()<<LogBytesPerInt; } 1.104 + int register_number() const { assert(where() == in_register, "wrong Where"); return offset() ; } 1.105 + 1.106 + VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset()) ; } 1.107 + 1.108 + // Printing 1.109 + void print_on(outputStream* st) const; 1.110 + 1.111 + // Serialization of debugging information 1.112 + Location(DebugInfoReadStream* stream); 1.113 + void write_on(DebugInfoWriteStream* stream); 1.114 + 1.115 + // check 1.116 + static bool legal_offset_in_bytes(int offset_in_bytes); 1.117 +};