annotate src/share/vm/code/location.hpp @ 0:a61af66fc99e jdk7-b24

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