author | lucy |
Tue, 04 Dec 2018 11:57:18 +0100 | |
changeset 52815 | 10bb941d7fd4 |
parent 49621 | 5ef28d560b6f |
child 53149 | 259c36ef27df |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49373
47b5652f2928
8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1135
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1135
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1135
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 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 |
||
1 | 31 |
// A Location describes a concrete machine variable location |
32 |
// (such as integer or floating point register or a stack-held |
|
33 |
// variable). Used when generating debug-information for nmethods. |
|
34 |
// |
|
35 |
// Encoding: |
|
36 |
// |
|
1135 | 37 |
// bits (use low bits for best compression): |
38 |
// Type: [3..0] |
|
39 |
// Where: [4] |
|
40 |
// Offset: [31..5] |
|
1 | 41 |
|
49373
47b5652f2928
8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents:
47216
diff
changeset
|
42 |
class Location { |
1 | 43 |
friend class VMStructs; |
44 |
public: |
|
45 |
enum Where { |
|
46 |
on_stack, |
|
47 |
in_register |
|
48 |
}; |
|
49 |
||
50 |
enum Type { |
|
1135 | 51 |
invalid, // Invalid location |
1 | 52 |
normal, // Ints, floats, double halves |
53 |
oop, // Oop (please GC me!) |
|
54 |
int_in_long, // Integer held in long register |
|
55 |
lng, // Long held in one register |
|
56 |
float_in_dbl, // Float held in double register |
|
57 |
dbl, // Double held in one register |
|
58 |
addr, // JSR return address |
|
1135 | 59 |
narrowoop // Narrow Oop (please GC me!) |
1 | 60 |
}; |
61 |
||
62 |
||
63 |
private: |
|
64 |
enum { |
|
1135 | 65 |
TYPE_MASK = (juint) 0x0F, |
66 |
TYPE_SHIFT = 0, |
|
67 |
WHERE_MASK = (juint) 0x10, |
|
68 |
WHERE_SHIFT = 4, |
|
69 |
OFFSET_MASK = (juint) 0xFFFFFFE0, |
|
70 |
OFFSET_SHIFT = 5 |
|
1 | 71 |
}; |
72 |
||
1135 | 73 |
juint _value; |
1 | 74 |
|
75 |
// Create a bit-packed Location |
|
76 |
Location(Where where_, Type type_, unsigned offset_) { |
|
77 |
set(where_, type_, offset_); |
|
78 |
assert( where () == where_ , "" ); |
|
79 |
assert( type () == type_ , "" ); |
|
80 |
assert( offset() == offset_, "" ); |
|
81 |
} |
|
82 |
||
83 |
inline void set(Where where_, Type type_, unsigned offset_) { |
|
1135 | 84 |
_value = (juint) ((where_ << WHERE_SHIFT) | |
85 |
(type_ << TYPE_SHIFT) | |
|
86 |
((offset_ << OFFSET_SHIFT) & OFFSET_MASK)); |
|
1 | 87 |
} |
88 |
||
89 |
public: |
|
90 |
||
91 |
// Stack location Factory. Offset is 4-byte aligned; remove low bits |
|
92 |
static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); } |
|
93 |
// Register location Factory |
|
94 |
static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); } |
|
95 |
// Default constructor |
|
1135 | 96 |
Location() { set(on_stack,invalid,0); } |
1 | 97 |
|
98 |
// Bit field accessors |
|
99 |
Where where() const { return (Where) ((_value & WHERE_MASK) >> WHERE_SHIFT);} |
|
100 |
Type type() const { return (Type) ((_value & TYPE_MASK) >> TYPE_SHIFT); } |
|
101 |
unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); } |
|
102 |
||
103 |
// Accessors |
|
104 |
bool is_register() const { return where() == in_register; } |
|
105 |
bool is_stack() const { return where() == on_stack; } |
|
106 |
||
107 |
int stack_offset() const { assert(where() == on_stack, "wrong Where"); return offset()<<LogBytesPerInt; } |
|
108 |
int register_number() const { assert(where() == in_register, "wrong Where"); return offset() ; } |
|
109 |
||
110 |
VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset()) ; } |
|
111 |
||
112 |
// Printing |
|
113 |
void print_on(outputStream* st) const; |
|
114 |
||
115 |
// Serialization of debugging information |
|
116 |
Location(DebugInfoReadStream* stream); |
|
117 |
void write_on(DebugInfoWriteStream* stream); |
|
118 |
||
119 |
// check |
|
120 |
static bool legal_offset_in_bytes(int offset_in_bytes); |
|
121 |
}; |
|
7397 | 122 |
|
123 |
#endif // SHARE_VM_CODE_LOCATION_HPP |