author | aph |
Thu, 11 Dec 2014 13:11:53 -0800 | |
changeset 29180 | 50369728b00e |
parent 25715 | d5a8dbdc5150 |
child 37466 | 287c4ebd11b0 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
22827
diff
changeset
|
2 |
* Copyright (c) 1998, 2014, 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:
670
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
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:
670
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_CODE_VMREG_HPP |
26 |
#define SHARE_VM_CODE_VMREG_HPP |
|
27 |
||
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
22827
diff
changeset
|
28 |
#include "asm/register.hpp" |
7397 | 29 |
#include "memory/allocation.hpp" |
30 |
#include "utilities/globalDefinitions.hpp" |
|
14631
526804361522
8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
13963
diff
changeset
|
31 |
|
7397 | 32 |
#ifdef COMPILER2 |
33 |
#include "opto/adlcVMDeps.hpp" |
|
34 |
#include "utilities/ostream.hpp" |
|
35 |
#endif |
|
36 |
||
1 | 37 |
//------------------------------VMReg------------------------------------------ |
38 |
// The VM uses 'unwarped' stack slots; the compiler uses 'warped' stack slots. |
|
39 |
// Register numbers below VMRegImpl::stack0 are the same for both. Register |
|
40 |
// numbers above stack0 are either warped (in the compiler) or unwarped |
|
41 |
// (in the VM). Unwarped numbers represent stack indices, offsets from |
|
42 |
// the current stack pointer. Warped numbers are required during compilation |
|
43 |
// when we do not yet know how big the frame will be. |
|
44 |
||
45 |
class VMRegImpl; |
|
46 |
typedef VMRegImpl* VMReg; |
|
47 |
||
48 |
class VMRegImpl { |
|
49 |
// friend class OopMap; |
|
50 |
friend class VMStructs; |
|
51 |
friend class OptoReg; |
|
52 |
// friend class Location; |
|
53 |
private: |
|
54 |
enum { |
|
22827 | 55 |
BAD_REG = -1 |
1 | 56 |
}; |
57 |
||
58 |
||
59 |
||
60 |
static VMReg stack0; |
|
61 |
// Names for registers |
|
62 |
static const char *regName[]; |
|
63 |
static const int register_count; |
|
64 |
||
65 |
||
66 |
public: |
|
67 |
||
22827 | 68 |
static VMReg as_VMReg(int val, bool bad_ok = false) { assert(val > BAD_REG || bad_ok, "invalid"); return (VMReg) (intptr_t) val; } |
1 | 69 |
|
70 |
const char* name() { |
|
71 |
if (is_reg()) { |
|
72 |
return regName[value()]; |
|
73 |
} else if (!is_valid()) { |
|
74 |
return "BAD"; |
|
75 |
} else { |
|
76 |
// shouldn't really be called with stack |
|
77 |
return "STACKED REG"; |
|
78 |
} |
|
79 |
} |
|
22827 | 80 |
static VMReg Bad() { return (VMReg) (intptr_t) BAD_REG; } |
81 |
bool is_valid() const { return ((intptr_t) this) != BAD_REG; } |
|
198
8601165a33c3
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
1
diff
changeset
|
82 |
bool is_stack() const { return (intptr_t) this >= (intptr_t) stack0; } |
8601165a33c3
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
1
diff
changeset
|
83 |
bool is_reg() const { return is_valid() && !is_stack(); } |
1 | 84 |
|
85 |
// A concrete register is a value that returns true for is_reg() and is |
|
86 |
// also a register you could use in the assembler. On machines with |
|
87 |
// 64bit registers only one half of the VMReg (and OptoReg) is considered |
|
88 |
// concrete. |
|
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
22827
diff
changeset
|
89 |
// bool is_concrete(); |
1 | 90 |
|
91 |
// VMRegs are 4 bytes wide on all platforms |
|
92 |
static const int stack_slot_size; |
|
93 |
static const int slots_per_word; |
|
94 |
||
95 |
||
96 |
// This really ought to check that the register is "real" in the sense that |
|
97 |
// we don't try and get the VMReg number of a physical register that doesn't |
|
98 |
// have an expressible part. That would be pd specific code |
|
99 |
VMReg next() { |
|
100 |
assert((is_reg() && value() < stack0->value() - 1) || is_stack(), "must be"); |
|
101 |
return (VMReg)(intptr_t)(value() + 1); |
|
102 |
} |
|
13294 | 103 |
VMReg next(int i) { |
104 |
assert((is_reg() && value() < stack0->value() - i) || is_stack(), "must be"); |
|
105 |
return (VMReg)(intptr_t)(value() + i); |
|
106 |
} |
|
1 | 107 |
VMReg prev() { |
108 |
assert((is_stack() && value() > stack0->value()) || (is_reg() && value() != 0), "must be"); |
|
109 |
return (VMReg)(intptr_t)(value() - 1); |
|
110 |
} |
|
111 |
||
112 |
||
113 |
intptr_t value() const {return (intptr_t) this; } |
|
114 |
||
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
115 |
void print_on(outputStream* st) const; |
198
8601165a33c3
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
1
diff
changeset
|
116 |
void print() const { print_on(tty); } |
1 | 117 |
|
118 |
// bias a stack slot. |
|
119 |
// Typically used to adjust a virtual frame slots by amounts that are offset by |
|
120 |
// amounts that are part of the native abi. The VMReg must be a stack slot |
|
121 |
// and the result must be also. |
|
122 |
||
123 |
VMReg bias(int offset) { |
|
124 |
assert(is_stack(), "must be"); |
|
125 |
// VMReg res = VMRegImpl::as_VMReg(value() + offset); |
|
126 |
VMReg res = stack2reg(reg2stack() + offset); |
|
127 |
assert(res->is_stack(), "must be"); |
|
128 |
return res; |
|
129 |
} |
|
130 |
||
131 |
// Convert register numbers to stack slots and vice versa |
|
132 |
static VMReg stack2reg( int idx ) { |
|
133 |
return (VMReg) (intptr_t) (stack0->value() + idx); |
|
134 |
} |
|
135 |
||
136 |
uintptr_t reg2stack() { |
|
137 |
assert( is_stack(), "Not a stack-based register" ); |
|
138 |
return value() - stack0->value(); |
|
139 |
} |
|
140 |
||
141 |
static void set_regName(); |
|
142 |
||
7397 | 143 |
#ifdef TARGET_ARCH_x86 |
144 |
# include "vmreg_x86.hpp" |
|
145 |
#endif |
|
146 |
#ifdef TARGET_ARCH_sparc |
|
147 |
# include "vmreg_sparc.hpp" |
|
148 |
#endif |
|
149 |
#ifdef TARGET_ARCH_zero |
|
150 |
# include "vmreg_zero.hpp" |
|
151 |
#endif |
|
8107
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
152 |
#ifdef TARGET_ARCH_arm |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
153 |
# include "vmreg_arm.hpp" |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
154 |
#endif |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
155 |
#ifdef TARGET_ARCH_ppc |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
156 |
# include "vmreg_ppc.hpp" |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
157 |
#endif |
29180 | 158 |
#ifdef TARGET_ARCH_aarch64 |
159 |
# include "vmreg_aarch64.hpp" |
|
160 |
#endif |
|
7397 | 161 |
|
1 | 162 |
|
163 |
}; |
|
164 |
||
165 |
//---------------------------VMRegPair------------------------------------------- |
|
166 |
// Pairs of 32-bit registers for arguments. |
|
167 |
// SharedRuntime::java_calling_convention will overwrite the structs with |
|
168 |
// the calling convention's registers. VMRegImpl::Bad is returned for any |
|
169 |
// unused 32-bit register. This happens for the unused high half of Int |
|
170 |
// arguments, or for 32-bit pointers or for longs in the 32-bit sparc build |
|
171 |
// (which are passed to natives in low 32-bits of e.g. O0/O1 and the high |
|
172 |
// 32-bits of O0/O1 are set to VMRegImpl::Bad). Longs in one register & doubles |
|
173 |
// always return a high and a low register, as do 64-bit pointers. |
|
174 |
// |
|
175 |
class VMRegPair { |
|
176 |
private: |
|
177 |
VMReg _second; |
|
178 |
VMReg _first; |
|
179 |
public: |
|
180 |
void set_bad ( ) { _second=VMRegImpl::Bad(); _first=VMRegImpl::Bad(); } |
|
181 |
void set1 ( VMReg v ) { _second=VMRegImpl::Bad(); _first=v; } |
|
182 |
void set2 ( VMReg v ) { _second=v->next(); _first=v; } |
|
183 |
void set_pair( VMReg second, VMReg first ) { _second= second; _first= first; } |
|
184 |
void set_ptr ( VMReg ptr ) { |
|
185 |
#ifdef _LP64 |
|
186 |
_second = ptr->next(); |
|
187 |
#else |
|
188 |
_second = VMRegImpl::Bad(); |
|
189 |
#endif |
|
190 |
_first = ptr; |
|
191 |
} |
|
192 |
// Return true if single register, even if the pair is really just adjacent stack slots |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
193 |
bool is_single_reg() const { |
1 | 194 |
return (_first->is_valid()) && (_first->value() + 1 == _second->value()); |
195 |
} |
|
196 |
||
197 |
// Return true if single stack based "register" where the slot alignment matches input alignment |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
198 |
bool is_adjacent_on_stack(int alignment) const { |
1 | 199 |
return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0)); |
200 |
} |
|
201 |
||
202 |
// Return true if single stack based "register" where the slot alignment matches input alignment |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
203 |
bool is_adjacent_aligned_on_stack(int alignment) const { |
1 | 204 |
return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0)); |
205 |
} |
|
206 |
||
207 |
// Return true if single register but adjacent stack slots do not count |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
208 |
bool is_single_phys_reg() const { |
1 | 209 |
return (_first->is_reg() && (_first->value() + 1 == _second->value())); |
210 |
} |
|
211 |
||
212 |
VMReg second() const { return _second; } |
|
213 |
VMReg first() const { return _first; } |
|
214 |
VMRegPair(VMReg s, VMReg f) { _second = s; _first = f; } |
|
215 |
VMRegPair(VMReg f) { _second = VMRegImpl::Bad(); _first = f; } |
|
216 |
VMRegPair() { _second = VMRegImpl::Bad(); _first = VMRegImpl::Bad(); } |
|
217 |
}; |
|
7397 | 218 |
|
219 |
#endif // SHARE_VM_CODE_VMREG_HPP |