Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/code/vmreg.hpp
32285 views
1
/*
2
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
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
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef SHARE_VM_CODE_VMREG_HPP
26
#define SHARE_VM_CODE_VMREG_HPP
27
28
#include "memory/allocation.hpp"
29
#include "utilities/globalDefinitions.hpp"
30
#include "asm/register.hpp"
31
32
#ifdef COMPILER2
33
#include "opto/adlcVMDeps.hpp"
34
#include "utilities/ostream.hpp"
35
#if defined ADGLOBALS_MD_HPP
36
# include ADGLOBALS_MD_HPP
37
#elif defined TARGET_ARCH_MODEL_x86_32
38
# include "adfiles/adGlobals_x86_32.hpp"
39
#elif defined TARGET_ARCH_MODEL_x86_64
40
# include "adfiles/adGlobals_x86_64.hpp"
41
#elif defined TARGET_ARCH_MODEL_aarch32
42
# include "adfiles/adGlobals_aarch32.hpp"
43
#elif defined TARGET_ARCH_MODEL_aarch64
44
# include "adfiles/adGlobals_aarch64.hpp"
45
#elif defined TARGET_ARCH_MODEL_sparc
46
# include "adfiles/adGlobals_sparc.hpp"
47
#elif defined TARGET_ARCH_MODEL_zero
48
# include "adfiles/adGlobals_zero.hpp"
49
#elif defined TARGET_ARCH_MODEL_ppc_64
50
# include "adfiles/adGlobals_ppc_64.hpp"
51
#endif
52
#endif
53
54
//------------------------------VMReg------------------------------------------
55
// The VM uses 'unwarped' stack slots; the compiler uses 'warped' stack slots.
56
// Register numbers below VMRegImpl::stack0 are the same for both. Register
57
// numbers above stack0 are either warped (in the compiler) or unwarped
58
// (in the VM). Unwarped numbers represent stack indices, offsets from
59
// the current stack pointer. Warped numbers are required during compilation
60
// when we do not yet know how big the frame will be.
61
62
class VMRegImpl;
63
typedef VMRegImpl* VMReg;
64
65
class VMRegImpl {
66
// friend class OopMap;
67
friend class VMStructs;
68
friend class OptoReg;
69
// friend class Location;
70
private:
71
enum {
72
BAD_REG = -1
73
};
74
75
76
77
static VMReg stack0;
78
// Names for registers
79
static const char *regName[];
80
static const int register_count;
81
82
83
public:
84
85
static VMReg as_VMReg(int val, bool bad_ok = false) { assert(val > BAD_REG || bad_ok, "invalid"); return (VMReg) (intptr_t) val; }
86
87
const char* name() {
88
if (is_reg()) {
89
return regName[value()];
90
} else if (!is_valid()) {
91
return "BAD";
92
} else {
93
// shouldn't really be called with stack
94
return "STACKED REG";
95
}
96
}
97
static VMReg Bad() { return (VMReg) (intptr_t) BAD_REG; }
98
bool is_valid() const { return ((intptr_t) this) != BAD_REG; }
99
bool is_stack() const { return (intptr_t) this >= (intptr_t) stack0; }
100
bool is_reg() const { return is_valid() && !is_stack(); }
101
102
// A concrete register is a value that returns true for is_reg() and is
103
// also a register you could use in the assembler. On machines with
104
// 64bit registers only one half of the VMReg (and OptoReg) is considered
105
// concrete.
106
bool is_concrete();
107
108
// VMRegs are 4 bytes wide on all platforms
109
static const int stack_slot_size;
110
static const int slots_per_word;
111
112
113
// This really ought to check that the register is "real" in the sense that
114
// we don't try and get the VMReg number of a physical register that doesn't
115
// have an expressible part. That would be pd specific code
116
VMReg next() {
117
assert((is_reg() && value() < stack0->value() - 1) || is_stack(), "must be");
118
return (VMReg)(intptr_t)(value() + 1);
119
}
120
VMReg next(int i) {
121
assert((is_reg() && value() < stack0->value() - i) || is_stack(), "must be");
122
return (VMReg)(intptr_t)(value() + i);
123
}
124
VMReg prev() {
125
assert((is_stack() && value() > stack0->value()) || (is_reg() && value() != 0), "must be");
126
return (VMReg)(intptr_t)(value() - 1);
127
}
128
129
130
intptr_t value() const {return (intptr_t) this; }
131
132
void print_on(outputStream* st) const;
133
void print() const { print_on(tty); }
134
135
// bias a stack slot.
136
// Typically used to adjust a virtual frame slots by amounts that are offset by
137
// amounts that are part of the native abi. The VMReg must be a stack slot
138
// and the result must be also.
139
140
VMReg bias(int offset) {
141
assert(is_stack(), "must be");
142
// VMReg res = VMRegImpl::as_VMReg(value() + offset);
143
VMReg res = stack2reg(reg2stack() + offset);
144
assert(res->is_stack(), "must be");
145
return res;
146
}
147
148
// Convert register numbers to stack slots and vice versa
149
static VMReg stack2reg( int idx ) {
150
return (VMReg) (intptr_t) (stack0->value() + idx);
151
}
152
153
uintptr_t reg2stack() {
154
assert( is_stack(), "Not a stack-based register" );
155
return value() - stack0->value();
156
}
157
158
static void set_regName();
159
160
#ifdef TARGET_ARCH_x86
161
# include "vmreg_x86.hpp"
162
#endif
163
#ifdef TARGET_ARCH_aarch32
164
# include "vmreg_aarch32.hpp"
165
#endif
166
#ifdef TARGET_ARCH_aarch64
167
# include "vmreg_aarch64.hpp"
168
#endif
169
#ifdef TARGET_ARCH_sparc
170
# include "vmreg_sparc.hpp"
171
#endif
172
#ifdef TARGET_ARCH_zero
173
# include "vmreg_zero.hpp"
174
#endif
175
#ifdef TARGET_ARCH_arm
176
# include "vmreg_arm.hpp"
177
#endif
178
#ifdef TARGET_ARCH_ppc
179
# include "vmreg_ppc.hpp"
180
#endif
181
182
183
};
184
185
//---------------------------VMRegPair-------------------------------------------
186
// Pairs of 32-bit registers for arguments.
187
// SharedRuntime::java_calling_convention will overwrite the structs with
188
// the calling convention's registers. VMRegImpl::Bad is returned for any
189
// unused 32-bit register. This happens for the unused high half of Int
190
// arguments, or for 32-bit pointers or for longs in the 32-bit sparc build
191
// (which are passed to natives in low 32-bits of e.g. O0/O1 and the high
192
// 32-bits of O0/O1 are set to VMRegImpl::Bad). Longs in one register & doubles
193
// always return a high and a low register, as do 64-bit pointers.
194
//
195
class VMRegPair {
196
private:
197
VMReg _second;
198
VMReg _first;
199
public:
200
void set_bad ( ) { _second=VMRegImpl::Bad(); _first=VMRegImpl::Bad(); }
201
void set1 ( VMReg v ) { _second=VMRegImpl::Bad(); _first=v; }
202
void set2 ( VMReg v ) { _second=v->next(); _first=v; }
203
void set_pair( VMReg second, VMReg first ) { _second= second; _first= first; }
204
void set_ptr ( VMReg ptr ) {
205
#ifdef _LP64
206
_second = ptr->next();
207
#else
208
_second = VMRegImpl::Bad();
209
#endif
210
_first = ptr;
211
}
212
// Return true if single register, even if the pair is really just adjacent stack slots
213
bool is_single_reg() const {
214
return (_first->is_valid()) && (_first->value() + 1 == _second->value());
215
}
216
217
// Return true if single stack based "register" where the slot alignment matches input alignment
218
bool is_adjacent_on_stack(int alignment) const {
219
return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0));
220
}
221
222
// Return true if single stack based "register" where the slot alignment matches input alignment
223
bool is_adjacent_aligned_on_stack(int alignment) const {
224
return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0));
225
}
226
227
// Return true if single register but adjacent stack slots do not count
228
bool is_single_phys_reg() const {
229
return (_first->is_reg() && (_first->value() + 1 == _second->value()));
230
}
231
232
VMReg second() const { return _second; }
233
VMReg first() const { return _first; }
234
VMRegPair(VMReg s, VMReg f) { _second = s; _first = f; }
235
VMRegPair(VMReg f) { _second = VMRegImpl::Bad(); _first = f; }
236
VMRegPair() { _second = VMRegImpl::Bad(); _first = VMRegImpl::Bad(); }
237
};
238
239
#endif // SHARE_VM_CODE_VMREG_HPP
240
241