src/share/vm/code/location.hpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 766
cecd8eb4e0ca
permissions
-rw-r--r--

Initial load

duke@435 1 /*
duke@435 2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // A Location describes a concrete machine variable location
duke@435 26 // (such as integer or floating point register or a stack-held
duke@435 27 // variable). Used when generating debug-information for nmethods.
duke@435 28 //
duke@435 29 // Encoding:
duke@435 30 //
duke@435 31 // bits:
duke@435 32 // Where: [15]
duke@435 33 // Type: [14..12]
duke@435 34 // Offset: [11..0]
duke@435 35
duke@435 36 class Location VALUE_OBJ_CLASS_SPEC {
duke@435 37 friend class VMStructs;
duke@435 38 public:
duke@435 39 enum Where {
duke@435 40 on_stack,
duke@435 41 in_register
duke@435 42 };
duke@435 43
duke@435 44 enum Type {
duke@435 45 normal, // Ints, floats, double halves
duke@435 46 oop, // Oop (please GC me!)
duke@435 47 int_in_long, // Integer held in long register
duke@435 48 lng, // Long held in one register
duke@435 49 float_in_dbl, // Float held in double register
duke@435 50 dbl, // Double held in one register
duke@435 51 addr, // JSR return address
duke@435 52 invalid // Invalid location
duke@435 53 };
duke@435 54
duke@435 55
duke@435 56 private:
duke@435 57 enum {
duke@435 58 OFFSET_MASK = (jchar) 0x0FFF,
duke@435 59 OFFSET_SHIFT = 0,
duke@435 60 TYPE_MASK = (jchar) 0x7000,
duke@435 61 TYPE_SHIFT = 12,
duke@435 62 WHERE_MASK = (jchar) 0x8000,
duke@435 63 WHERE_SHIFT = 15
duke@435 64 };
duke@435 65
duke@435 66 uint16_t _value;
duke@435 67
duke@435 68 // Create a bit-packed Location
duke@435 69 Location(Where where_, Type type_, unsigned offset_) {
duke@435 70 set(where_, type_, offset_);
duke@435 71 assert( where () == where_ , "" );
duke@435 72 assert( type () == type_ , "" );
duke@435 73 assert( offset() == offset_, "" );
duke@435 74 }
duke@435 75
duke@435 76 inline void set(Where where_, Type type_, unsigned offset_) {
duke@435 77 _value = (uint16_t) ((where_ << WHERE_SHIFT) |
duke@435 78 (type_ << TYPE_SHIFT) |
duke@435 79 ((offset_ << OFFSET_SHIFT) & OFFSET_MASK));
duke@435 80 }
duke@435 81
duke@435 82 public:
duke@435 83
duke@435 84 // Stack location Factory. Offset is 4-byte aligned; remove low bits
duke@435 85 static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); }
duke@435 86 // Register location Factory
duke@435 87 static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); }
duke@435 88 // Default constructor
duke@435 89 Location() { set(on_stack,invalid,(unsigned) -1); }
duke@435 90
duke@435 91 // Bit field accessors
duke@435 92 Where where() const { return (Where) ((_value & WHERE_MASK) >> WHERE_SHIFT);}
duke@435 93 Type type() const { return (Type) ((_value & TYPE_MASK) >> TYPE_SHIFT); }
duke@435 94 unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); }
duke@435 95
duke@435 96 // Accessors
duke@435 97 bool is_register() const { return where() == in_register; }
duke@435 98 bool is_stack() const { return where() == on_stack; }
duke@435 99
duke@435 100 int stack_offset() const { assert(where() == on_stack, "wrong Where"); return offset()<<LogBytesPerInt; }
duke@435 101 int register_number() const { assert(where() == in_register, "wrong Where"); return offset() ; }
duke@435 102
duke@435 103 VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset()) ; }
duke@435 104
duke@435 105 // Printing
duke@435 106 void print_on(outputStream* st) const;
duke@435 107
duke@435 108 // Serialization of debugging information
duke@435 109 Location(DebugInfoReadStream* stream);
duke@435 110 void write_on(DebugInfoWriteStream* stream);
duke@435 111
duke@435 112 // check
duke@435 113 static bool legal_offset_in_bytes(int offset_in_bytes);
duke@435 114 };

mercurial