Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/cpu/arm/abstractInterpreter_arm.cpp
40930 views
1
/*
2
* Copyright (c) 2008, 2017, 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
#include "precompiled.hpp"
26
#include "asm/assembler.hpp"
27
#include "interpreter/bytecode.hpp"
28
#include "interpreter/interpreter.hpp"
29
#include "oops/constMethod.hpp"
30
#include "oops/klass.inline.hpp"
31
#include "oops/method.hpp"
32
#include "prims/methodHandles.hpp"
33
#include "runtime/handles.inline.hpp"
34
#include "runtime/frame.inline.hpp"
35
#include "runtime/synchronizer.hpp"
36
#include "utilities/align.hpp"
37
#include "utilities/macros.hpp"
38
39
int AbstractInterpreter::BasicType_as_index(BasicType type) {
40
int i = 0;
41
switch (type) {
42
case T_VOID : i = 0; break;
43
case T_BOOLEAN: i = 1; break;
44
case T_CHAR : i = 2; break;
45
case T_BYTE : i = 3; break;
46
case T_SHORT : i = 4; break;
47
case T_INT : i = 5; break;
48
case T_OBJECT : // fall through
49
case T_ARRAY : i = 6; break;
50
case T_LONG : i = 7; break;
51
case T_FLOAT : i = 8; break;
52
case T_DOUBLE : i = 9; break;
53
default : ShouldNotReachHere();
54
}
55
assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds");
56
return i;
57
}
58
59
// How much stack a method activation needs in words.
60
int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
61
const int stub_code = 12; // see generate_call_stub
62
// Save space for one monitor to get into the interpreted method in case
63
// the method is synchronized
64
int monitor_size = method->is_synchronized() ?
65
1*frame::interpreter_frame_monitor_size() : 0;
66
67
// total overhead size: monitor_size + (sender SP, thru expr stack bottom).
68
// be sure to change this if you add/subtract anything to/from the overhead area
69
const int overhead_size = monitor_size +
70
(frame::sender_sp_offset - frame::interpreter_frame_initial_sp_offset);
71
const int method_stack = (method->max_locals() + method->max_stack()) *
72
Interpreter::stackElementWords;
73
return overhead_size + method_stack + stub_code;
74
}
75
76
// asm based interpreter deoptimization helpers
77
int AbstractInterpreter::size_activation(int max_stack,
78
int tempcount,
79
int extra_args,
80
int moncount,
81
int callee_param_count,
82
int callee_locals,
83
bool is_top_frame) {
84
// Note: This calculation must exactly parallel the frame setup
85
// in TemplateInterpreterGenerator::generate_fixed_frame.
86
// fixed size of an interpreter frame:
87
int overhead = frame::sender_sp_offset - frame::interpreter_frame_initial_sp_offset;
88
89
// Our locals were accounted for by the caller (or last_frame_adjust on the transistion)
90
// Since the callee parameters already account for the callee's params we only need to account for
91
// the extra locals.
92
93
int size = overhead +
94
((callee_locals - callee_param_count)*Interpreter::stackElementWords) +
95
(moncount*frame::interpreter_frame_monitor_size()) +
96
tempcount*Interpreter::stackElementWords + extra_args;
97
98
99
return size;
100
}
101
102
void AbstractInterpreter::layout_activation(Method* method,
103
int tempcount,
104
int popframe_extra_args,
105
int moncount,
106
int caller_actual_parameters,
107
int callee_param_count,
108
int callee_locals,
109
frame* caller,
110
frame* interpreter_frame,
111
bool is_top_frame,
112
bool is_bottom_frame) {
113
114
// Set up the method, locals, and monitors.
115
// The frame interpreter_frame is guaranteed to be the right size,
116
// as determined by a previous call to the size_activation() method.
117
// It is also guaranteed to be walkable even though it is in a skeletal state
118
// NOTE: return size is in words not bytes
119
120
// fixed size of an interpreter frame:
121
int max_locals = method->max_locals() * Interpreter::stackElementWords;
122
int extra_locals = (method->max_locals() - method->size_of_parameters()) * Interpreter::stackElementWords;
123
124
#ifdef ASSERT
125
assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable");
126
#endif
127
128
interpreter_frame->interpreter_frame_set_method(method);
129
// NOTE the difference in using sender_sp and interpreter_frame_sender_sp
130
// interpreter_frame_sender_sp is the original sp of the caller (the unextended_sp)
131
// and sender_sp is (fp + sender_sp_offset*wordSize)
132
133
intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
134
135
interpreter_frame->interpreter_frame_set_locals(locals);
136
BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
137
BasicObjectLock* monbot = montop - moncount;
138
interpreter_frame->interpreter_frame_set_monitor_end(monbot);
139
140
// Set last_sp
141
intptr_t* stack_top = (intptr_t*) monbot -
142
tempcount*Interpreter::stackElementWords -
143
popframe_extra_args;
144
interpreter_frame->interpreter_frame_set_last_sp(stack_top);
145
146
// All frames but the initial (oldest) interpreter frame we fill in have a
147
// value for sender_sp that allows walking the stack but isn't
148
// truly correct. Correct the value here.
149
150
if (extra_locals != 0 &&
151
interpreter_frame->sender_sp() == interpreter_frame->interpreter_frame_sender_sp() ) {
152
interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() + extra_locals);
153
}
154
155
*interpreter_frame->interpreter_frame_cache_addr() =
156
method->constants()->cache();
157
*interpreter_frame->interpreter_frame_mirror_addr() =
158
method->method_holder()->java_mirror();
159
}
160
161