Mercurial > hg > truffle
annotate src/share/vm/code/location.hpp @ 3763:e66f38dd58a9
Merge
author | ysr |
---|---|
date | Wed, 08 Jun 2011 08:39:53 -0700 |
parents | f95d63e2154a |
children |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
331
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
331
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
331
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_CODE_LOCATION_HPP |
26 #define SHARE_VM_CODE_LOCATION_HPP | |
27 | |
28 #include "asm/assembler.hpp" | |
29 #include "code/vmreg.hpp" | |
30 #include "memory/allocation.hpp" | |
31 | |
0 | 32 // A Location describes a concrete machine variable location |
33 // (such as integer or floating point register or a stack-held | |
34 // variable). Used when generating debug-information for nmethods. | |
35 // | |
36 // Encoding: | |
37 // | |
331 | 38 // bits (use low bits for best compression): |
39 // Type: [3..0] | |
40 // Where: [4] | |
41 // Offset: [31..5] | |
0 | 42 |
43 class Location VALUE_OBJ_CLASS_SPEC { | |
44 friend class VMStructs; | |
45 public: | |
46 enum Where { | |
47 on_stack, | |
48 in_register | |
49 }; | |
50 | |
51 enum Type { | |
331 | 52 invalid, // Invalid location |
0 | 53 normal, // Ints, floats, double halves |
54 oop, // Oop (please GC me!) | |
55 int_in_long, // Integer held in long register | |
56 lng, // Long held in one register | |
57 float_in_dbl, // Float held in double register | |
58 dbl, // Double held in one register | |
59 addr, // JSR return address | |
331 | 60 narrowoop // Narrow Oop (please GC me!) |
0 | 61 }; |
62 | |
63 | |
64 private: | |
65 enum { | |
331 | 66 TYPE_MASK = (juint) 0x0F, |
67 TYPE_SHIFT = 0, | |
68 WHERE_MASK = (juint) 0x10, | |
69 WHERE_SHIFT = 4, | |
70 OFFSET_MASK = (juint) 0xFFFFFFE0, | |
71 OFFSET_SHIFT = 5 | |
0 | 72 }; |
73 | |
331 | 74 juint _value; |
0 | 75 |
76 // Create a bit-packed Location | |
77 Location(Where where_, Type type_, unsigned offset_) { | |
78 set(where_, type_, offset_); | |
79 assert( where () == where_ , "" ); | |
80 assert( type () == type_ , "" ); | |
81 assert( offset() == offset_, "" ); | |
82 } | |
83 | |
84 inline void set(Where where_, Type type_, unsigned offset_) { | |
331 | 85 _value = (juint) ((where_ << WHERE_SHIFT) | |
86 (type_ << TYPE_SHIFT) | | |
87 ((offset_ << OFFSET_SHIFT) & OFFSET_MASK)); | |
0 | 88 } |
89 | |
90 public: | |
91 | |
92 // Stack location Factory. Offset is 4-byte aligned; remove low bits | |
93 static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); } | |
94 // Register location Factory | |
95 static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); } | |
96 // Default constructor | |
331 | 97 Location() { set(on_stack,invalid,0); } |
0 | 98 |
99 // Bit field accessors | |
100 Where where() const { return (Where) ((_value & WHERE_MASK) >> WHERE_SHIFT);} | |
101 Type type() const { return (Type) ((_value & TYPE_MASK) >> TYPE_SHIFT); } | |
102 unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); } | |
103 | |
104 // Accessors | |
105 bool is_register() const { return where() == in_register; } | |
106 bool is_stack() const { return where() == on_stack; } | |
107 | |
108 int stack_offset() const { assert(where() == on_stack, "wrong Where"); return offset()<<LogBytesPerInt; } | |
109 int register_number() const { assert(where() == in_register, "wrong Where"); return offset() ; } | |
110 | |
111 VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset()) ; } | |
112 | |
113 // Printing | |
114 void print_on(outputStream* st) const; | |
115 | |
116 // Serialization of debugging information | |
117 Location(DebugInfoReadStream* stream); | |
118 void write_on(DebugInfoWriteStream* stream); | |
119 | |
120 // check | |
121 static bool legal_offset_in_bytes(int offset_in_bytes); | |
122 }; | |
1972 | 123 |
124 #endif // SHARE_VM_CODE_LOCATION_HPP |