Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp
64441 views
1
/*
2
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*
24
*/
25
26
#ifndef CPU_AARCH64_FRAME_AARCH64_INLINE_HPP
27
#define CPU_AARCH64_FRAME_AARCH64_INLINE_HPP
28
29
#include "code/codeCache.hpp"
30
#include "code/vmreg.inline.hpp"
31
#include "pauth_aarch64.hpp"
32
33
// Inline functions for AArch64 frames:
34
35
// Constructors:
36
37
inline frame::frame() {
38
_pc = NULL;
39
_sp = NULL;
40
_unextended_sp = NULL;
41
_fp = NULL;
42
_cb = NULL;
43
_deopt_state = unknown;
44
}
45
46
static int spin;
47
48
inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {
49
assert(pauth_ptr_is_raw(pc), "cannot be signed");
50
intptr_t a = intptr_t(sp);
51
intptr_t b = intptr_t(fp);
52
_sp = sp;
53
_unextended_sp = sp;
54
_fp = fp;
55
_pc = pc;
56
assert(pc != NULL, "no pc?");
57
_cb = CodeCache::find_blob(pc);
58
adjust_unextended_sp();
59
60
address original_pc = CompiledMethod::get_deopt_original_pc(this);
61
if (original_pc != NULL) {
62
_pc = original_pc;
63
_deopt_state = is_deoptimized;
64
} else {
65
_deopt_state = not_deoptimized;
66
}
67
}
68
69
inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) {
70
init(sp, fp, pc);
71
}
72
73
inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {
74
assert(pauth_ptr_is_raw(pc), "cannot be signed");
75
intptr_t a = intptr_t(sp);
76
intptr_t b = intptr_t(fp);
77
_sp = sp;
78
_unextended_sp = unextended_sp;
79
_fp = fp;
80
_pc = pc;
81
assert(pc != NULL, "no pc?");
82
_cb = CodeCache::find_blob(pc);
83
adjust_unextended_sp();
84
85
address original_pc = CompiledMethod::get_deopt_original_pc(this);
86
if (original_pc != NULL) {
87
_pc = original_pc;
88
assert(_cb->as_compiled_method()->insts_contains_inclusive(_pc),
89
"original PC must be in the main code section of the the compiled method (or must be immediately following it)");
90
_deopt_state = is_deoptimized;
91
} else {
92
_deopt_state = not_deoptimized;
93
}
94
}
95
96
inline frame::frame(intptr_t* sp, intptr_t* fp) {
97
intptr_t a = intptr_t(sp);
98
intptr_t b = intptr_t(fp);
99
_sp = sp;
100
_unextended_sp = sp;
101
_fp = fp;
102
_pc = (address)(sp[-1]);
103
104
// Here's a sticky one. This constructor can be called via AsyncGetCallTrace
105
// when last_Java_sp is non-null but the pc fetched is junk. If we are truly
106
// unlucky the junk value could be to a zombied method and we'll die on the
107
// find_blob call. This is also why we can have no asserts on the validity
108
// of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler
109
// -> pd_last_frame should use a specialized version of pd_last_frame which could
110
// call a specilaized frame constructor instead of this one.
111
// Then we could use the assert below. However this assert is of somewhat dubious
112
// value.
113
// assert(_pc != NULL, "no pc?");
114
115
_cb = CodeCache::find_blob(_pc);
116
adjust_unextended_sp();
117
118
address original_pc = CompiledMethod::get_deopt_original_pc(this);
119
if (original_pc != NULL) {
120
_pc = original_pc;
121
_deopt_state = is_deoptimized;
122
} else {
123
_deopt_state = not_deoptimized;
124
}
125
}
126
127
// Accessors
128
129
inline bool frame::equal(frame other) const {
130
bool ret = sp() == other.sp()
131
&& unextended_sp() == other.unextended_sp()
132
&& fp() == other.fp()
133
&& pc() == other.pc();
134
assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");
135
return ret;
136
}
137
138
// Return unique id for this frame. The id must have a value where we can distinguish
139
// identity and younger/older relationship. NULL represents an invalid (incomparable)
140
// frame.
141
inline intptr_t* frame::id(void) const { return unextended_sp(); }
142
143
// Return true if the frame is older (less recent activation) than the frame represented by id
144
inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
145
return this->id() > id ; }
146
147
inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
148
149
inline intptr_t* frame::link_or_null() const {
150
intptr_t** ptr = (intptr_t **)addr_at(link_offset);
151
return os::is_readable_pointer(ptr) ? *ptr : NULL;
152
}
153
154
inline intptr_t* frame::unextended_sp() const { return _unextended_sp; }
155
156
// Return address:
157
158
inline address* frame::sender_pc_addr() const { return (address*) addr_at( return_addr_offset); }
159
inline address frame::sender_pc_maybe_signed() const { return *sender_pc_addr(); }
160
inline address frame::sender_pc() const { return pauth_strip_pointer(sender_pc_maybe_signed()); }
161
162
inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); }
163
164
inline intptr_t** frame::interpreter_frame_locals_addr() const {
165
return (intptr_t**)addr_at(interpreter_frame_locals_offset);
166
}
167
168
inline intptr_t* frame::interpreter_frame_last_sp() const {
169
return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);
170
}
171
172
inline intptr_t* frame::interpreter_frame_bcp_addr() const {
173
return (intptr_t*)addr_at(interpreter_frame_bcp_offset);
174
}
175
176
inline intptr_t* frame::interpreter_frame_mdp_addr() const {
177
return (intptr_t*)addr_at(interpreter_frame_mdp_offset);
178
}
179
180
181
// Constant pool cache
182
183
inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {
184
return (ConstantPoolCache**)addr_at(interpreter_frame_cache_offset);
185
}
186
187
// Method
188
189
inline Method** frame::interpreter_frame_method_addr() const {
190
return (Method**)addr_at(interpreter_frame_method_offset);
191
}
192
193
// Mirror
194
195
inline oop* frame::interpreter_frame_mirror_addr() const {
196
return (oop*)addr_at(interpreter_frame_mirror_offset);
197
}
198
199
// top of expression stack
200
inline intptr_t* frame::interpreter_frame_tos_address() const {
201
intptr_t* last_sp = interpreter_frame_last_sp();
202
if (last_sp == NULL) {
203
return sp();
204
} else {
205
// sp() may have been extended or shrunk by an adapter. At least
206
// check that we don't fall behind the legal region.
207
// For top deoptimized frame last_sp == interpreter_frame_monitor_end.
208
assert(last_sp <= (intptr_t*) interpreter_frame_monitor_end(), "bad tos");
209
return last_sp;
210
}
211
}
212
213
inline oop* frame::interpreter_frame_temp_oop_addr() const {
214
return (oop *)(fp() + interpreter_frame_oop_temp_offset);
215
}
216
217
inline int frame::interpreter_frame_monitor_size() {
218
return BasicObjectLock::size();
219
}
220
221
222
// expression stack
223
// (the max_stack arguments are used by the GC; see class FrameClosure)
224
225
inline intptr_t* frame::interpreter_frame_expression_stack() const {
226
intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();
227
return monitor_end-1;
228
}
229
230
231
// Entry frames
232
233
inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {
234
return (JavaCallWrapper**)addr_at(entry_frame_call_wrapper_offset);
235
}
236
237
238
// Compiled frames
239
240
inline oop frame::saved_oop_result(RegisterMap* map) const {
241
oop* result_adr = (oop *)map->location(r0->as_VMReg());
242
guarantee(result_adr != NULL, "bad register save location");
243
244
return (*result_adr);
245
}
246
247
inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
248
oop* result_adr = (oop *)map->location(r0->as_VMReg());
249
guarantee(result_adr != NULL, "bad register save location");
250
251
*result_adr = obj;
252
}
253
254
#endif // CPU_AARCH64_FRAME_AARCH64_INLINE_HPP
255
256