src/share/vm/code/location.hpp

Wed, 02 Jun 2010 22:45:42 -0700

author
jrose
date
Wed, 02 Jun 2010 22:45:42 -0700
changeset 1934
e9ff18c4ace7
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
permissions
-rw-r--r--

Merge

duke@435 1 /*
trims@1907 2 * Copyright (c) 1997, 2008, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * 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 //
kvn@766 31 // bits (use low bits for best compression):
kvn@766 32 // Type: [3..0]
kvn@766 33 // Where: [4]
kvn@766 34 // Offset: [31..5]
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 {
kvn@766 45 invalid, // Invalid location
duke@435 46 normal, // Ints, floats, double halves
duke@435 47 oop, // Oop (please GC me!)
duke@435 48 int_in_long, // Integer held in long register
duke@435 49 lng, // Long held in one register
duke@435 50 float_in_dbl, // Float held in double register
duke@435 51 dbl, // Double held in one register
duke@435 52 addr, // JSR return address
kvn@766 53 narrowoop // Narrow Oop (please GC me!)
duke@435 54 };
duke@435 55
duke@435 56
duke@435 57 private:
duke@435 58 enum {
kvn@766 59 TYPE_MASK = (juint) 0x0F,
kvn@766 60 TYPE_SHIFT = 0,
kvn@766 61 WHERE_MASK = (juint) 0x10,
kvn@766 62 WHERE_SHIFT = 4,
kvn@766 63 OFFSET_MASK = (juint) 0xFFFFFFE0,
kvn@766 64 OFFSET_SHIFT = 5
duke@435 65 };
duke@435 66
kvn@766 67 juint _value;
duke@435 68
duke@435 69 // Create a bit-packed Location
duke@435 70 Location(Where where_, Type type_, unsigned offset_) {
duke@435 71 set(where_, type_, offset_);
duke@435 72 assert( where () == where_ , "" );
duke@435 73 assert( type () == type_ , "" );
duke@435 74 assert( offset() == offset_, "" );
duke@435 75 }
duke@435 76
duke@435 77 inline void set(Where where_, Type type_, unsigned offset_) {
kvn@766 78 _value = (juint) ((where_ << WHERE_SHIFT) |
kvn@766 79 (type_ << TYPE_SHIFT) |
kvn@766 80 ((offset_ << OFFSET_SHIFT) & OFFSET_MASK));
duke@435 81 }
duke@435 82
duke@435 83 public:
duke@435 84
duke@435 85 // Stack location Factory. Offset is 4-byte aligned; remove low bits
duke@435 86 static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); }
duke@435 87 // Register location Factory
duke@435 88 static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); }
duke@435 89 // Default constructor
kvn@766 90 Location() { set(on_stack,invalid,0); }
duke@435 91
duke@435 92 // Bit field accessors
duke@435 93 Where where() const { return (Where) ((_value & WHERE_MASK) >> WHERE_SHIFT);}
duke@435 94 Type type() const { return (Type) ((_value & TYPE_MASK) >> TYPE_SHIFT); }
duke@435 95 unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); }
duke@435 96
duke@435 97 // Accessors
duke@435 98 bool is_register() const { return where() == in_register; }
duke@435 99 bool is_stack() const { return where() == on_stack; }
duke@435 100
duke@435 101 int stack_offset() const { assert(where() == on_stack, "wrong Where"); return offset()<<LogBytesPerInt; }
duke@435 102 int register_number() const { assert(where() == in_register, "wrong Where"); return offset() ; }
duke@435 103
duke@435 104 VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset()) ; }
duke@435 105
duke@435 106 // Printing
duke@435 107 void print_on(outputStream* st) const;
duke@435 108
duke@435 109 // Serialization of debugging information
duke@435 110 Location(DebugInfoReadStream* stream);
duke@435 111 void write_on(DebugInfoWriteStream* stream);
duke@435 112
duke@435 113 // check
duke@435 114 static bool legal_offset_in_bytes(int offset_in_bytes);
duke@435 115 };

mercurial