author | naoto |
Tue, 09 Jul 2019 08:05:38 -0700 | |
changeset 55627 | 9c1885fb2a42 |
parent 52676 | 2d795829f39f |
permissions | -rw-r--r-- |
42664 | 1 |
/* |
50094
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49950
diff
changeset
|
2 |
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
42664 | 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" |
|
50380
bec342339138
8204195: Clean up macroAssembler.inline.hpp and other inline.hpp files included in .hpp files
coleenp
parents:
50094
diff
changeset
|
27 |
#include "asm/macroAssembler.inline.hpp" |
42664 | 28 |
#include "interpreter/bytecodeHistogram.hpp" |
29 |
#include "interpreter/interp_masm.hpp" |
|
30 |
#include "interpreter/interpreter.hpp" |
|
31 |
#include "interpreter/interpreterRuntime.hpp" |
|
32 |
#include "interpreter/templateInterpreterGenerator.hpp" |
|
33 |
#include "interpreter/templateTable.hpp" |
|
34 |
#include "oops/arrayOop.hpp" |
|
35 |
#include "oops/methodData.hpp" |
|
36 |
#include "oops/method.hpp" |
|
37 |
#include "oops/oop.inline.hpp" |
|
38 |
#include "prims/jvmtiExport.hpp" |
|
39 |
#include "prims/jvmtiThreadState.hpp" |
|
40 |
#include "prims/methodHandles.hpp" |
|
41 |
#include "runtime/arguments.hpp" |
|
42 |
#include "runtime/deoptimization.hpp" |
|
43 |
#include "runtime/frame.inline.hpp" |
|
44 |
#include "runtime/sharedRuntime.hpp" |
|
45 |
#include "runtime/stubRoutines.hpp" |
|
46 |
#include "runtime/synchronizer.hpp" |
|
47 |
#include "runtime/timer.hpp" |
|
48 |
#include "runtime/vframeArray.hpp" |
|
46625 | 49 |
#include "utilities/align.hpp" |
42664 | 50 |
#include "utilities/debug.hpp" |
51 |
#include "utilities/macros.hpp" |
|
52 |
||
53 |
// Size of interpreter code. Increase if too small. Interpreter will |
|
54 |
// fail with a guarantee ("not enough space for interpreter generation"); |
|
55 |
// if too small. |
|
56 |
// Run with +PrintInterpreter to get the VM to print out the size. |
|
57 |
// Max size with JVMTI |
|
58 |
int TemplateInterpreter::InterpreterCodeSize = 180 * 1024; |
|
59 |
||
60 |
#define __ _masm-> |
|
61 |
||
62 |
//------------------------------------------------------------------------------------------------------------------------ |
|
63 |
||
64 |
address TemplateInterpreterGenerator::generate_slow_signature_handler() { |
|
65 |
address entry = __ pc(); |
|
66 |
||
67 |
// callee-save register for saving LR, shared with generate_native_entry |
|
52351 | 68 |
const Register Rsaved_ret_addr = Rtmp_save0; |
42664 | 69 |
|
70 |
__ mov(Rsaved_ret_addr, LR); |
|
71 |
||
72 |
__ mov(R1, Rmethod); |
|
73 |
__ mov(R2, Rlocals); |
|
74 |
__ mov(R3, SP); |
|
75 |
||
76 |
||
77 |
// Safer to save R9 (when scratched) since callers may have been |
|
78 |
// written assuming R9 survives. This is suboptimal but |
|
79 |
// probably not important for this slow case call site. |
|
80 |
// Note for R9 saving: slow_signature_handler may copy register |
|
81 |
// arguments above the current SP (passed as R3). It is safe for |
|
82 |
// call_VM to use push and pop to protect additional values on the |
|
83 |
// stack if needed. |
|
84 |
__ call_VM(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), true /* save R9 if needed*/); |
|
85 |
__ add(SP, SP, wordSize); // Skip R0 |
|
86 |
__ pop(RegisterSet(R1, R3)); // Load arguments passed in registers |
|
87 |
#ifdef __ABI_HARD__ |
|
88 |
// Few alternatives to an always-load-FP-registers approach: |
|
89 |
// - parse method signature to detect FP arguments |
|
90 |
// - keep a counter/flag on a stack indicationg number of FP arguments in the method. |
|
91 |
// The later has been originally implemented and tested but a conditional path could |
|
92 |
// eliminate any gain imposed by avoiding 8 double word loads. |
|
93 |
__ fldmiad(SP, FloatRegisterSet(D0, 8), writeback); |
|
94 |
#endif // __ABI_HARD__ |
|
95 |
||
96 |
__ ret(Rsaved_ret_addr); |
|
97 |
||
98 |
return entry; |
|
99 |
} |
|
100 |
||
101 |
||
102 |
// |
|
103 |
// Various method entries (that c++ and asm interpreter agree upon) |
|
104 |
//------------------------------------------------------------------------------------------------------------------------ |
|
105 |
// |
|
106 |
// |
|
107 |
||
108 |
// Abstract method entry |
|
109 |
// Attempt to execute abstract method. Throw exception |
|
110 |
address TemplateInterpreterGenerator::generate_abstract_entry(void) { |
|
111 |
address entry_point = __ pc(); |
|
112 |
||
113 |
||
114 |
__ empty_expression_stack(); |
|
115 |
||
116 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError)); |
|
117 |
||
118 |
DEBUG_ONLY(STOP("generate_abstract_entry");) // Should not reach here |
|
119 |
return entry_point; |
|
120 |
} |
|
121 |
||
122 |
address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) { |
|
123 |
if (!InlineIntrinsics) return NULL; // Generate a vanilla entry |
|
124 |
||
125 |
// TODO: ARM |
|
126 |
return NULL; |
|
127 |
||
128 |
address entry_point = __ pc(); |
|
129 |
STOP("generate_math_entry"); |
|
130 |
return entry_point; |
|
131 |
} |
|
132 |
||
133 |
address TemplateInterpreterGenerator::generate_StackOverflowError_handler() { |
|
134 |
address entry = __ pc(); |
|
135 |
||
136 |
// Note: There should be a minimal interpreter frame set up when stack |
|
137 |
// overflow occurs since we check explicitly for it now. |
|
138 |
// |
|
139 |
#ifdef ASSERT |
|
140 |
{ Label L; |
|
141 |
__ sub(Rtemp, FP, - frame::interpreter_frame_monitor_block_top_offset * wordSize); |
|
142 |
__ cmp(SP, Rtemp); // Rtemp = maximal SP for current FP, |
|
143 |
// (stack grows negative) |
|
144 |
__ b(L, ls); // check if frame is complete |
|
145 |
__ stop ("interpreter frame not set up"); |
|
146 |
__ bind(L); |
|
147 |
} |
|
148 |
#endif // ASSERT |
|
149 |
||
150 |
// Restore bcp under the assumption that the current frame is still |
|
151 |
// interpreted |
|
152 |
__ restore_bcp(); |
|
153 |
||
154 |
// expression stack must be empty before entering the VM if an exception |
|
155 |
// happened |
|
156 |
__ empty_expression_stack(); |
|
157 |
||
158 |
// throw exception |
|
159 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_StackOverflowError)); |
|
160 |
||
161 |
__ should_not_reach_here(); |
|
162 |
||
163 |
return entry; |
|
164 |
} |
|
165 |
||
50094
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49950
diff
changeset
|
166 |
address TemplateInterpreterGenerator::generate_ArrayIndexOutOfBounds_handler() { |
42664 | 167 |
address entry = __ pc(); |
168 |
||
169 |
// index is in R4_ArrayIndexOutOfBounds_index |
|
170 |
||
171 |
// expression stack must be empty before entering the VM if an exception happened |
|
172 |
__ empty_expression_stack(); |
|
173 |
||
174 |
// setup parameters |
|
50094
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49950
diff
changeset
|
175 |
// Array expected in R1. |
42664 | 176 |
__ mov(R2, R4_ArrayIndexOutOfBounds_index); |
177 |
||
178 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException), R1, R2); |
|
179 |
||
180 |
__ nop(); // to avoid filling CPU pipeline with invalid instructions |
|
181 |
__ nop(); |
|
182 |
__ should_not_reach_here(); |
|
183 |
||
184 |
return entry; |
|
185 |
} |
|
186 |
||
187 |
address TemplateInterpreterGenerator::generate_ClassCastException_handler() { |
|
188 |
address entry = __ pc(); |
|
189 |
||
190 |
// object is in R2_ClassCastException_obj |
|
191 |
||
192 |
// expression stack must be empty before entering the VM if an exception |
|
193 |
// happened |
|
194 |
__ empty_expression_stack(); |
|
195 |
||
196 |
__ mov(R1, R2_ClassCastException_obj); |
|
197 |
__ call_VM(noreg, |
|
198 |
CAST_FROM_FN_PTR(address, |
|
199 |
InterpreterRuntime::throw_ClassCastException), |
|
200 |
R1); |
|
201 |
||
202 |
__ should_not_reach_here(); |
|
203 |
||
204 |
return entry; |
|
205 |
} |
|
206 |
||
207 |
address TemplateInterpreterGenerator::generate_exception_handler_common(const char* name, const char* message, bool pass_oop) { |
|
208 |
assert(!pass_oop || message == NULL, "either oop or message but not both"); |
|
209 |
address entry = __ pc(); |
|
210 |
||
211 |
InlinedString Lname(name); |
|
212 |
InlinedString Lmessage(message); |
|
213 |
||
214 |
if (pass_oop) { |
|
215 |
// object is at TOS |
|
216 |
__ pop_ptr(R2); |
|
217 |
} |
|
218 |
||
219 |
// expression stack must be empty before entering the VM if an exception happened |
|
220 |
__ empty_expression_stack(); |
|
221 |
||
222 |
// setup parameters |
|
223 |
__ ldr_literal(R1, Lname); |
|
224 |
||
225 |
if (pass_oop) { |
|
226 |
__ call_VM(Rexception_obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_klass_exception), R1, R2); |
|
227 |
} else { |
|
228 |
if (message != NULL) { |
|
229 |
__ ldr_literal(R2, Lmessage); |
|
230 |
} else { |
|
231 |
__ mov(R2, 0); |
|
232 |
} |
|
233 |
__ call_VM(Rexception_obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_exception), R1, R2); |
|
234 |
} |
|
235 |
||
236 |
// throw exception |
|
237 |
__ b(Interpreter::throw_exception_entry()); |
|
238 |
||
239 |
__ nop(); // to avoid filling CPU pipeline with invalid instructions |
|
240 |
__ nop(); |
|
241 |
__ bind_literal(Lname); |
|
242 |
if (!pass_oop && (message != NULL)) { |
|
243 |
__ bind_literal(Lmessage); |
|
244 |
} |
|
245 |
||
246 |
return entry; |
|
247 |
} |
|
248 |
||
249 |
address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step, size_t index_size) { |
|
250 |
address entry = __ pc(); |
|
251 |
||
252 |
__ interp_verify_oop(R0_tos, state, __FILE__, __LINE__); |
|
253 |
||
254 |
// Restore stack bottom in case i2c adjusted stack |
|
255 |
__ ldr(SP, Address(FP, frame::interpreter_frame_last_sp_offset * wordSize)); |
|
256 |
// and NULL it as marker that SP is now tos until next java call |
|
257 |
__ mov(Rtemp, (int)NULL_WORD); |
|
258 |
__ str(Rtemp, Address(FP, frame::interpreter_frame_last_sp_offset * wordSize)); |
|
259 |
||
260 |
__ restore_method(); |
|
261 |
__ restore_bcp(); |
|
262 |
__ restore_dispatch(); |
|
263 |
__ restore_locals(); |
|
264 |
||
265 |
const Register Rcache = R2_tmp; |
|
266 |
const Register Rindex = R3_tmp; |
|
267 |
__ get_cache_and_index_at_bcp(Rcache, Rindex, 1, index_size); |
|
268 |
||
269 |
__ add(Rtemp, Rcache, AsmOperand(Rindex, lsl, LogBytesPerWord)); |
|
270 |
__ ldrb(Rtemp, Address(Rtemp, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset())); |
|
271 |
__ check_stack_top(); |
|
272 |
__ add(Rstack_top, Rstack_top, AsmOperand(Rtemp, lsl, Interpreter::logStackElementSize)); |
|
273 |
||
274 |
__ convert_retval_to_tos(state); |
|
275 |
||
46294
345a46524a19
8172020: Internal Error (cpu/arm/vm/frame_arm.cpp:571): assert(obj == __null || Universe::heap()->is_in(obj)) failed: sanity check #
cjplummer
parents:
46263
diff
changeset
|
276 |
__ check_and_handle_popframe(); |
345a46524a19
8172020: Internal Error (cpu/arm/vm/frame_arm.cpp:571): assert(obj == __null || Universe::heap()->is_in(obj)) failed: sanity check #
cjplummer
parents:
46263
diff
changeset
|
277 |
__ check_and_handle_earlyret(); |
345a46524a19
8172020: Internal Error (cpu/arm/vm/frame_arm.cpp:571): assert(obj == __null || Universe::heap()->is_in(obj)) failed: sanity check #
cjplummer
parents:
46263
diff
changeset
|
278 |
|
42664 | 279 |
__ dispatch_next(state, step); |
280 |
||
281 |
return entry; |
|
282 |
} |
|
283 |
||
284 |
||
47916
bdbef8638948
8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents:
47216
diff
changeset
|
285 |
address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, int step, address continuation) { |
42664 | 286 |
address entry = __ pc(); |
287 |
||
288 |
__ interp_verify_oop(R0_tos, state, __FILE__, __LINE__); |
|
289 |
||
290 |
// The stack is not extended by deopt but we must NULL last_sp as this |
|
291 |
// entry is like a "return". |
|
292 |
__ mov(Rtemp, 0); |
|
293 |
__ str(Rtemp, Address(FP, frame::interpreter_frame_last_sp_offset * wordSize)); |
|
294 |
||
295 |
__ restore_method(); |
|
296 |
__ restore_bcp(); |
|
297 |
__ restore_dispatch(); |
|
298 |
__ restore_locals(); |
|
299 |
||
300 |
// handle exceptions |
|
301 |
{ Label L; |
|
302 |
__ ldr(Rtemp, Address(Rthread, Thread::pending_exception_offset())); |
|
303 |
__ cbz(Rtemp, L); |
|
304 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_pending_exception)); |
|
305 |
__ should_not_reach_here(); |
|
306 |
__ bind(L); |
|
307 |
} |
|
308 |
||
47916
bdbef8638948
8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents:
47216
diff
changeset
|
309 |
if (continuation == NULL) { |
bdbef8638948
8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents:
47216
diff
changeset
|
310 |
__ dispatch_next(state, step); |
bdbef8638948
8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents:
47216
diff
changeset
|
311 |
} else { |
bdbef8638948
8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents:
47216
diff
changeset
|
312 |
__ jump_to_entry(continuation); |
bdbef8638948
8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents:
47216
diff
changeset
|
313 |
} |
42664 | 314 |
|
315 |
return entry; |
|
316 |
} |
|
317 |
||
318 |
address TemplateInterpreterGenerator::generate_result_handler_for(BasicType type) { |
|
52676
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
319 |
address entry = __ pc(); |
42664 | 320 |
|
52676
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
321 |
switch (type) { |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
322 |
case T_CHAR : /* Nothing to do */ break; |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
323 |
case T_BYTE : /* Nothing to do */ break; |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
324 |
case T_SHORT : /* Nothing to do */ break; |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
325 |
case T_INT : /* Nothing to do */ break; |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
326 |
case T_LONG : /* Nothing to do */ break; |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
327 |
case T_VOID : /* Nothing to do */ break; |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
328 |
case T_DOUBLE : /* Nothing to do */ break; |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
329 |
case T_FLOAT : /* Nothing to do */ break; |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
330 |
case T_BOOLEAN : __ c2bool(R0); break; |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
331 |
case T_OBJECT : |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
332 |
__ ldr(R0, Address(FP, frame::interpreter_frame_oop_temp_offset * wordSize)); |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
333 |
__ verify_oop(R0); |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
334 |
break; |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
335 |
default : __ should_not_reach_here(); break; |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
336 |
} |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
337 |
|
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
338 |
__ ret(); |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
339 |
return entry; |
42664 | 340 |
} |
341 |
||
342 |
address TemplateInterpreterGenerator::generate_safept_entry_for(TosState state, address runtime_entry) { |
|
343 |
address entry = __ pc(); |
|
344 |
__ push(state); |
|
345 |
__ call_VM(noreg, runtime_entry); |
|
346 |
||
347 |
// load current bytecode |
|
348 |
__ ldrb(R3_bytecode, Address(Rbcp)); |
|
349 |
__ dispatch_only_normal(vtos); |
|
350 |
return entry; |
|
351 |
} |
|
352 |
||
353 |
||
354 |
// Helpers for commoning out cases in the various type of method entries. |
|
355 |
// |
|
356 |
||
357 |
// increment invocation count & check for overflow |
|
358 |
// |
|
359 |
// Note: checking for negative value instead of overflow |
|
360 |
// so we have a 'sticky' overflow test |
|
361 |
// |
|
362 |
// In: Rmethod. |
|
363 |
// |
|
364 |
// Uses R0, R1, Rtemp. |
|
365 |
// |
|
366 |
void TemplateInterpreterGenerator::generate_counter_incr(Label* overflow, |
|
367 |
Label* profile_method, |
|
368 |
Label* profile_method_continue) { |
|
369 |
Label done; |
|
370 |
const Register Rcounters = Rtemp; |
|
371 |
const Address invocation_counter(Rcounters, |
|
372 |
MethodCounters::invocation_counter_offset() + |
|
373 |
InvocationCounter::counter_offset()); |
|
374 |
||
375 |
// Note: In tiered we increment either counters in MethodCounters* or |
|
376 |
// in MDO depending if we're profiling or not. |
|
377 |
if (TieredCompilation) { |
|
378 |
int increment = InvocationCounter::count_increment; |
|
379 |
Label no_mdo; |
|
380 |
if (ProfileInterpreter) { |
|
381 |
// Are we profiling? |
|
382 |
__ ldr(R1_tmp, Address(Rmethod, Method::method_data_offset())); |
|
383 |
__ cbz(R1_tmp, no_mdo); |
|
384 |
// Increment counter in the MDO |
|
385 |
const Address mdo_invocation_counter(R1_tmp, |
|
386 |
in_bytes(MethodData::invocation_counter_offset()) + |
|
387 |
in_bytes(InvocationCounter::counter_offset())); |
|
388 |
const Address mask(R1_tmp, in_bytes(MethodData::invoke_mask_offset())); |
|
389 |
__ increment_mask_and_jump(mdo_invocation_counter, increment, mask, R0_tmp, Rtemp, eq, overflow); |
|
390 |
__ b(done); |
|
391 |
} |
|
392 |
__ bind(no_mdo); |
|
393 |
__ get_method_counters(Rmethod, Rcounters, done); |
|
394 |
const Address mask(Rcounters, in_bytes(MethodCounters::invoke_mask_offset())); |
|
395 |
__ increment_mask_and_jump(invocation_counter, increment, mask, R0_tmp, R1_tmp, eq, overflow); |
|
396 |
__ bind(done); |
|
397 |
} else { // not TieredCompilation |
|
398 |
const Address backedge_counter(Rcounters, |
|
399 |
MethodCounters::backedge_counter_offset() + |
|
400 |
InvocationCounter::counter_offset()); |
|
401 |
||
402 |
const Register Ricnt = R0_tmp; // invocation counter |
|
403 |
const Register Rbcnt = R1_tmp; // backedge counter |
|
404 |
||
405 |
__ get_method_counters(Rmethod, Rcounters, done); |
|
406 |
||
407 |
if (ProfileInterpreter) { |
|
408 |
const Register Riic = R1_tmp; |
|
409 |
__ ldr_s32(Riic, Address(Rcounters, MethodCounters::interpreter_invocation_counter_offset())); |
|
410 |
__ add(Riic, Riic, 1); |
|
411 |
__ str_32(Riic, Address(Rcounters, MethodCounters::interpreter_invocation_counter_offset())); |
|
412 |
} |
|
413 |
||
414 |
// Update standard invocation counters |
|
415 |
||
416 |
__ ldr_u32(Ricnt, invocation_counter); |
|
417 |
__ ldr_u32(Rbcnt, backedge_counter); |
|
418 |
||
419 |
__ add(Ricnt, Ricnt, InvocationCounter::count_increment); |
|
420 |
||
421 |
__ bic(Rbcnt, Rbcnt, ~InvocationCounter::count_mask_value); // mask out the status bits |
|
422 |
||
423 |
__ str_32(Ricnt, invocation_counter); // save invocation count |
|
424 |
__ add(Ricnt, Ricnt, Rbcnt); // add both counters |
|
425 |
||
426 |
// profile_method is non-null only for interpreted method so |
|
427 |
// profile_method != NULL == !native_call |
|
428 |
// BytecodeInterpreter only calls for native so code is elided. |
|
429 |
||
430 |
if (ProfileInterpreter && profile_method != NULL) { |
|
431 |
assert(profile_method_continue != NULL, "should be non-null"); |
|
432 |
||
433 |
// Test to see if we should create a method data oop |
|
434 |
// Reuse R1_tmp as we don't need backedge counters anymore. |
|
435 |
Address profile_limit(Rcounters, in_bytes(MethodCounters::interpreter_profile_limit_offset())); |
|
436 |
__ ldr_s32(R1_tmp, profile_limit); |
|
437 |
__ cmp_32(Ricnt, R1_tmp); |
|
438 |
__ b(*profile_method_continue, lt); |
|
439 |
||
440 |
// if no method data exists, go to profile_method |
|
441 |
__ test_method_data_pointer(R1_tmp, *profile_method); |
|
442 |
} |
|
443 |
||
444 |
Address invoke_limit(Rcounters, in_bytes(MethodCounters::interpreter_invocation_limit_offset())); |
|
445 |
__ ldr_s32(R1_tmp, invoke_limit); |
|
446 |
__ cmp_32(Ricnt, R1_tmp); |
|
447 |
__ b(*overflow, hs); |
|
448 |
__ bind(done); |
|
449 |
} |
|
450 |
} |
|
451 |
||
452 |
void TemplateInterpreterGenerator::generate_counter_overflow(Label& do_continue) { |
|
453 |
// InterpreterRuntime::frequency_counter_overflow takes one argument |
|
454 |
// indicating if the counter overflow occurs at a backwards branch (non-NULL bcp). |
|
455 |
// The call returns the address of the verified entry point for the method or NULL |
|
456 |
// if the compilation did not complete (either went background or bailed out). |
|
457 |
__ mov(R1, (int)false); |
|
458 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), R1); |
|
459 |
||
460 |
// jump to the interpreted entry. |
|
461 |
__ b(do_continue); |
|
462 |
} |
|
463 |
||
464 |
void TemplateInterpreterGenerator::generate_stack_overflow_check(void) { |
|
465 |
// Check if we've got enough room on the stack for |
|
466 |
// - overhead; |
|
467 |
// - locals; |
|
468 |
// - expression stack. |
|
469 |
// |
|
470 |
// Registers on entry: |
|
471 |
// |
|
472 |
// R3 = number of additional locals |
|
473 |
// Rthread |
|
474 |
// Rmethod |
|
475 |
// Registers used: R0, R1, R2, Rtemp. |
|
476 |
||
477 |
const Register Radditional_locals = R3; |
|
52351 | 478 |
const Register RmaxStack = R2; |
42664 | 479 |
|
480 |
// monitor entry size |
|
481 |
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; |
|
482 |
||
483 |
// total overhead size: entry_size + (saved registers, thru expr stack bottom). |
|
484 |
// be sure to change this if you add/subtract anything to/from the overhead area |
|
485 |
const int overhead_size = (frame::sender_sp_offset - frame::interpreter_frame_initial_sp_offset)*wordSize + entry_size; |
|
486 |
||
487 |
// Pages reserved for VM runtime calls and subsequent Java calls. |
|
488 |
const int reserved_pages = JavaThread::stack_shadow_zone_size(); |
|
489 |
||
490 |
// Thread::stack_size() includes guard pages, and they should not be touched. |
|
491 |
const int guard_pages = JavaThread::stack_guard_zone_size(); |
|
492 |
||
493 |
__ ldr(R0, Address(Rthread, Thread::stack_base_offset())); |
|
494 |
__ ldr(R1, Address(Rthread, Thread::stack_size_offset())); |
|
495 |
__ ldr(Rtemp, Address(Rmethod, Method::const_offset())); |
|
496 |
__ ldrh(RmaxStack, Address(Rtemp, ConstMethod::max_stack_offset())); |
|
497 |
__ sub_slow(Rtemp, SP, overhead_size + reserved_pages + guard_pages + Method::extra_stack_words()); |
|
498 |
||
499 |
// reserve space for additional locals |
|
500 |
__ sub(Rtemp, Rtemp, AsmOperand(Radditional_locals, lsl, Interpreter::logStackElementSize)); |
|
501 |
||
502 |
// stack size |
|
503 |
__ sub(R0, R0, R1); |
|
504 |
||
505 |
// reserve space for expression stack |
|
506 |
__ sub(Rtemp, Rtemp, AsmOperand(RmaxStack, lsl, Interpreter::logStackElementSize)); |
|
507 |
||
508 |
__ cmp(Rtemp, R0); |
|
509 |
||
510 |
__ mov(SP, Rsender_sp, ls); // restore SP |
|
511 |
__ b(StubRoutines::throw_StackOverflowError_entry(), ls); |
|
512 |
} |
|
513 |
||
514 |
||
515 |
// Allocate monitor and lock method (asm interpreter) |
|
516 |
// |
|
517 |
void TemplateInterpreterGenerator::lock_method() { |
|
518 |
// synchronize method |
|
519 |
||
520 |
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; |
|
521 |
assert ((entry_size % StackAlignmentInBytes) == 0, "should keep stack alignment"); |
|
522 |
||
523 |
#ifdef ASSERT |
|
524 |
{ Label L; |
|
525 |
__ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); |
|
526 |
__ tbnz(Rtemp, JVM_ACC_SYNCHRONIZED_BIT, L); |
|
527 |
__ stop("method doesn't need synchronization"); |
|
528 |
__ bind(L); |
|
529 |
} |
|
530 |
#endif // ASSERT |
|
531 |
||
532 |
// get synchronization object |
|
533 |
{ Label done; |
|
534 |
__ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); |
|
535 |
__ tst(Rtemp, JVM_ACC_STATIC); |
|
536 |
__ ldr(R0, Address(Rlocals, Interpreter::local_offset_in_bytes(0)), eq); // get receiver (assume this is frequent case) |
|
537 |
__ b(done, eq); |
|
538 |
__ load_mirror(R0, Rmethod, Rtemp); |
|
539 |
__ bind(done); |
|
51847
34e2180a6d51
8209695: ARM: Explicit barriers for interpreter
avoitylov
parents:
50380
diff
changeset
|
540 |
__ resolve(IS_NOT_NULL, R0); |
42664 | 541 |
} |
542 |
||
543 |
// add space for monitor & lock |
|
544 |
||
545 |
||
546 |
__ sub(Rstack_top, Rstack_top, entry_size); |
|
547 |
__ check_stack_top_on_expansion(); |
|
548 |
// add space for a monitor entry |
|
549 |
__ str(Rstack_top, Address(FP, frame::interpreter_frame_monitor_block_top_offset * wordSize)); |
|
550 |
// set new monitor block top |
|
551 |
__ str(R0, Address(Rstack_top, BasicObjectLock::obj_offset_in_bytes())); |
|
552 |
// store object |
|
553 |
__ mov(R1, Rstack_top); // monitor entry address |
|
554 |
__ lock_object(R1); |
|
555 |
} |
|
556 |
||
557 |
||
558 |
// |
|
559 |
// Generate a fixed interpreter frame. This is identical setup for interpreted methods |
|
560 |
// and for native methods hence the shared code. |
|
561 |
||
562 |
void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { |
|
563 |
// Generates the following stack layout: |
|
564 |
// |
|
565 |
// [ expr. stack bottom ] |
|
566 |
// [ saved Rbcp ] |
|
567 |
// [ current Rlocals ] |
|
568 |
// [ cache ] |
|
569 |
// [ mdx ] |
|
570 |
// [ Method* ] |
|
571 |
// [ last_sp ] |
|
572 |
// [ sender_sp ] |
|
573 |
// [ saved FP ] <--- FP |
|
574 |
// [ saved LR ] |
|
575 |
||
576 |
// initialize fixed part of activation frame |
|
577 |
__ push(LR); // save return address |
|
578 |
__ push(FP); // save FP |
|
579 |
__ mov(FP, SP); // establish new FP |
|
580 |
||
581 |
__ push(Rsender_sp); |
|
582 |
||
583 |
__ mov(R0, 0); |
|
584 |
__ push(R0); // leave last_sp as null |
|
585 |
||
586 |
// setup Rbcp |
|
587 |
if (native_call) { |
|
588 |
__ mov(Rbcp, 0); // bcp = 0 for native calls |
|
589 |
} else { |
|
590 |
__ ldr(Rtemp, Address(Rmethod, Method::const_offset())); // get ConstMethod* |
|
591 |
__ add(Rbcp, Rtemp, ConstMethod::codes_offset()); // get codebase |
|
592 |
} |
|
593 |
||
594 |
__ push(Rmethod); // save Method* |
|
595 |
// Get mirror and store it in the frame as GC root for this Method* |
|
596 |
__ load_mirror(Rtemp, Rmethod, Rtemp); |
|
597 |
__ push(Rtemp); |
|
598 |
||
599 |
if (ProfileInterpreter) { |
|
600 |
__ ldr(Rtemp, Address(Rmethod, Method::method_data_offset())); |
|
601 |
__ tst(Rtemp, Rtemp); |
|
602 |
__ add(Rtemp, Rtemp, in_bytes(MethodData::data_offset()), ne); |
|
603 |
__ push(Rtemp); // set the mdp (method data pointer) |
|
604 |
} else { |
|
605 |
__ push(R0); |
|
606 |
} |
|
607 |
||
608 |
__ ldr(Rtemp, Address(Rmethod, Method::const_offset())); |
|
609 |
__ ldr(Rtemp, Address(Rtemp, ConstMethod::constants_offset())); |
|
610 |
__ ldr(Rtemp, Address(Rtemp, ConstantPool::cache_offset_in_bytes())); |
|
611 |
__ push(Rtemp); // set constant pool cache |
|
612 |
__ push(Rlocals); // set locals pointer |
|
613 |
__ push(Rbcp); // set bcp |
|
614 |
__ push(R0); // reserve word for pointer to expression stack bottom |
|
615 |
__ str(SP, Address(SP, 0)); // set expression stack bottom |
|
616 |
} |
|
617 |
||
618 |
||
619 |
// End of helpers |
|
620 |
||
621 |
//------------------------------------------------------------------------------------------------------------------------ |
|
622 |
// Entry points |
|
623 |
// |
|
624 |
// Here we generate the various kind of entries into the interpreter. |
|
625 |
// The two main entry type are generic bytecode methods and native call method. |
|
626 |
// These both come in synchronized and non-synchronized versions but the |
|
627 |
// frame layout they create is very similar. The other method entry |
|
628 |
// types are really just special purpose entries that are really entry |
|
629 |
// and interpretation all in one. These are for trivial methods like |
|
630 |
// accessor, empty, or special math methods. |
|
631 |
// |
|
632 |
// When control flow reaches any of the entry types for the interpreter |
|
633 |
// the following holds -> |
|
634 |
// |
|
635 |
// Arguments: |
|
636 |
// |
|
637 |
// Rmethod: Method* |
|
638 |
// Rthread: thread |
|
639 |
// Rsender_sp: sender sp |
|
640 |
// Rparams (SP on 32-bit ARM): pointer to method parameters |
|
641 |
// |
|
642 |
// LR: return address |
|
643 |
// |
|
644 |
// Stack layout immediately at entry |
|
645 |
// |
|
646 |
// [ parameter n ] <--- Rparams (SP on 32-bit ARM) |
|
647 |
// ... |
|
648 |
// [ parameter 1 ] |
|
649 |
// [ expression stack ] (caller's java expression stack) |
|
650 |
||
651 |
// Assuming that we don't go to one of the trivial specialized |
|
652 |
// entries the stack will look like below when we are ready to execute |
|
653 |
// the first bytecode (or call the native routine). The register usage |
|
654 |
// will be as the template based interpreter expects. |
|
655 |
// |
|
656 |
// local variables follow incoming parameters immediately; i.e. |
|
657 |
// the return address is saved at the end of the locals. |
|
658 |
// |
|
659 |
// [ expr. stack ] <--- Rstack_top (SP on 32-bit ARM) |
|
660 |
// [ monitor entry ] |
|
661 |
// ... |
|
662 |
// [ monitor entry ] |
|
663 |
// [ expr. stack bottom ] |
|
664 |
// [ saved Rbcp ] |
|
665 |
// [ current Rlocals ] |
|
666 |
// [ cache ] |
|
667 |
// [ mdx ] |
|
668 |
// [ mirror ] |
|
669 |
// [ Method* ] |
|
670 |
// |
|
671 |
// 32-bit ARM: |
|
672 |
// [ last_sp ] |
|
673 |
// |
|
674 |
// [ sender_sp ] |
|
675 |
// [ saved FP ] <--- FP |
|
676 |
// [ saved LR ] |
|
677 |
// [ optional padding(*)] |
|
678 |
// [ local variable m ] |
|
679 |
// ... |
|
680 |
// [ local variable 1 ] |
|
681 |
// [ parameter n ] |
|
682 |
// ... |
|
683 |
// [ parameter 1 ] <--- Rlocals |
|
684 |
// |
|
685 |
||
686 |
address TemplateInterpreterGenerator::generate_Reference_get_entry(void) { |
|
49950
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
687 |
// Code: _aload_0, _getfield, _areturn |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
688 |
// parameter size = 1 |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
689 |
// |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
690 |
// The code that gets generated by this routine is split into 2 parts: |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
691 |
// 1. The "intrinsified" code performing an ON_WEAK_OOP_REF load, |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
692 |
// 2. The slow path - which is an expansion of the regular method entry. |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
693 |
// |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
694 |
// Notes:- |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
695 |
// * An intrinsic is always executed, where an ON_WEAK_OOP_REF load is performed. |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
696 |
// * We may jump to the slow path iff the receiver is null. If the |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
697 |
// Reference object is null then we no longer perform an ON_WEAK_OOP_REF load |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
698 |
// Thus we can use the regular method entry code to generate the NPE. |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
699 |
// |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
700 |
// Rmethod: Method* |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
701 |
// Rthread: thread |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
702 |
// Rsender_sp: sender sp, must be preserved for slow path, set SP to it on fast path |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
703 |
// Rparams: parameters |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
704 |
|
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
705 |
address entry = __ pc(); |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
706 |
Label slow_path; |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
707 |
const Register Rthis = R0; |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
708 |
const Register Rret_addr = Rtmp_save1; |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
709 |
assert_different_registers(Rthis, Rret_addr, Rsender_sp); |
42664 | 710 |
|
49950
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
711 |
const int referent_offset = java_lang_ref_Reference::referent_offset; |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
712 |
guarantee(referent_offset > 0, "referent offset not initialized"); |
42664 | 713 |
|
49950
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
714 |
// Check if local 0 != NULL |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
715 |
// If the receiver is null then it is OK to jump to the slow path. |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
716 |
__ ldr(Rthis, Address(Rparams)); |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
717 |
__ cbz(Rthis, slow_path); |
42664 | 718 |
|
49950
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
719 |
// Preserve LR |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
720 |
__ mov(Rret_addr, LR); |
42664 | 721 |
|
49950
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
722 |
// Load the value of the referent field. |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
723 |
const Address field_address(Rthis, referent_offset); |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
724 |
__ load_heap_oop(R0, field_address, Rtemp, R1_tmp, R2_tmp, ON_WEAK_OOP_REF); |
42664 | 725 |
|
49950
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
726 |
// _areturn |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
727 |
__ mov(SP, Rsender_sp); |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
728 |
__ ret(Rret_addr); |
42664 | 729 |
|
49950
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
730 |
// generate a vanilla interpreter entry as the slow path |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
731 |
__ bind(slow_path); |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
732 |
__ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals)); |
7b916885654d
8201786: Modularize interpreter GC barriers: leftovers for ARM32
shade
parents:
47916
diff
changeset
|
733 |
return entry; |
42664 | 734 |
} |
735 |
||
736 |
// Not supported |
|
737 |
address TemplateInterpreterGenerator::generate_CRC32_update_entry() { return NULL; } |
|
738 |
address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) { return NULL; } |
|
739 |
address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) { return NULL; } |
|
740 |
||
741 |
// |
|
742 |
// Interpreter stub for calling a native method. (asm interpreter) |
|
743 |
// This sets up a somewhat different looking stack for calling the native method |
|
744 |
// than the typical interpreter frame setup. |
|
745 |
// |
|
746 |
||
747 |
address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { |
|
748 |
// determine code generation flags |
|
749 |
bool inc_counter = UseCompiler || CountCompiledCalls || LogTouchedMethods; |
|
750 |
||
751 |
// Incoming registers: |
|
752 |
// |
|
753 |
// Rmethod: Method* |
|
754 |
// Rthread: thread |
|
755 |
// Rsender_sp: sender sp |
|
756 |
// Rparams: parameters |
|
757 |
||
758 |
address entry_point = __ pc(); |
|
759 |
||
760 |
// Register allocation |
|
52351 | 761 |
const Register Rsize_of_params = R6; |
762 |
const Register Rsig_handler = Rtmp_save0; // R4 |
|
763 |
const Register Rnative_code = Rtmp_save1; // R5 |
|
764 |
const Register Rresult_handler = R6; |
|
42664 | 765 |
|
766 |
const Register Rsaved_result_lo = Rtmp_save0; // R4 |
|
767 |
const Register Rsaved_result_hi = Rtmp_save1; // R5 |
|
768 |
FloatRegister saved_result_fp; |
|
769 |
||
770 |
||
771 |
__ ldr(Rsize_of_params, Address(Rmethod, Method::const_offset())); |
|
772 |
__ ldrh(Rsize_of_params, Address(Rsize_of_params, ConstMethod::size_of_parameters_offset())); |
|
773 |
||
774 |
// native calls don't need the stack size check since they have no expression stack |
|
775 |
// and the arguments are already on the stack and we only add a handful of words |
|
776 |
// to the stack |
|
777 |
||
778 |
// compute beginning of parameters (Rlocals) |
|
779 |
__ sub(Rlocals, Rparams, wordSize); |
|
780 |
__ add(Rlocals, Rlocals, AsmOperand(Rsize_of_params, lsl, Interpreter::logStackElementSize)); |
|
781 |
||
782 |
// reserve stack space for oop_temp |
|
783 |
__ mov(R0, 0); |
|
784 |
__ push(R0); |
|
785 |
||
786 |
generate_fixed_frame(true); // Note: R9 is now saved in the frame |
|
787 |
||
788 |
// make sure method is native & not abstract |
|
789 |
#ifdef ASSERT |
|
790 |
__ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); |
|
791 |
{ |
|
792 |
Label L; |
|
793 |
__ tbnz(Rtemp, JVM_ACC_NATIVE_BIT, L); |
|
794 |
__ stop("tried to execute non-native method as native"); |
|
795 |
__ bind(L); |
|
796 |
} |
|
797 |
{ Label L; |
|
798 |
__ tbz(Rtemp, JVM_ACC_ABSTRACT_BIT, L); |
|
799 |
__ stop("tried to execute abstract method in interpreter"); |
|
800 |
__ bind(L); |
|
801 |
} |
|
802 |
#endif |
|
803 |
||
804 |
// increment invocation count & check for overflow |
|
805 |
Label invocation_counter_overflow; |
|
806 |
if (inc_counter) { |
|
807 |
if (synchronized) { |
|
808 |
// Avoid unlocking method's monitor in case of exception, as it has not |
|
809 |
// been locked yet. |
|
810 |
__ set_do_not_unlock_if_synchronized(true, Rtemp); |
|
811 |
} |
|
812 |
generate_counter_incr(&invocation_counter_overflow, NULL, NULL); |
|
813 |
} |
|
814 |
||
815 |
Label continue_after_compile; |
|
816 |
__ bind(continue_after_compile); |
|
817 |
||
818 |
if (inc_counter && synchronized) { |
|
819 |
__ set_do_not_unlock_if_synchronized(false, Rtemp); |
|
820 |
} |
|
821 |
||
822 |
// check for synchronized methods |
|
823 |
// Must happen AFTER invocation_counter check and stack overflow check, |
|
824 |
// so method is not locked if overflows. |
|
825 |
// |
|
826 |
if (synchronized) { |
|
827 |
lock_method(); |
|
828 |
} else { |
|
829 |
// no synchronization necessary |
|
830 |
#ifdef ASSERT |
|
831 |
{ Label L; |
|
832 |
__ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); |
|
833 |
__ tbz(Rtemp, JVM_ACC_SYNCHRONIZED_BIT, L); |
|
834 |
__ stop("method needs synchronization"); |
|
835 |
__ bind(L); |
|
836 |
} |
|
837 |
#endif |
|
838 |
} |
|
839 |
||
840 |
// start execution |
|
841 |
#ifdef ASSERT |
|
842 |
{ Label L; |
|
843 |
__ ldr(Rtemp, Address(FP, frame::interpreter_frame_monitor_block_top_offset * wordSize)); |
|
844 |
__ cmp(Rtemp, Rstack_top); |
|
845 |
__ b(L, eq); |
|
846 |
__ stop("broken stack frame setup in interpreter"); |
|
847 |
__ bind(L); |
|
848 |
} |
|
849 |
#endif |
|
850 |
__ check_extended_sp(Rtemp); |
|
851 |
||
852 |
// jvmti/dtrace support |
|
853 |
__ notify_method_entry(); |
|
854 |
#if R9_IS_SCRATCHED |
|
855 |
__ restore_method(); |
|
856 |
#endif |
|
857 |
||
858 |
{ |
|
859 |
Label L; |
|
860 |
__ ldr(Rsig_handler, Address(Rmethod, Method::signature_handler_offset())); |
|
861 |
__ cbnz(Rsig_handler, L); |
|
862 |
__ mov(R1, Rmethod); |
|
863 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), R1, true); |
|
864 |
__ ldr(Rsig_handler, Address(Rmethod, Method::signature_handler_offset())); |
|
865 |
__ bind(L); |
|
866 |
} |
|
867 |
||
868 |
{ |
|
869 |
Label L; |
|
870 |
__ ldr(Rnative_code, Address(Rmethod, Method::native_function_offset())); |
|
871 |
__ cbnz(Rnative_code, L); |
|
872 |
__ mov(R1, Rmethod); |
|
873 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), R1); |
|
874 |
__ ldr(Rnative_code, Address(Rmethod, Method::native_function_offset())); |
|
875 |
__ bind(L); |
|
876 |
} |
|
877 |
||
878 |
// Allocate stack space for arguments |
|
879 |
||
880 |
||
881 |
// C functions need aligned stack |
|
882 |
__ bic(SP, SP, StackAlignmentInBytes - 1); |
|
883 |
// Multiply by BytesPerLong instead of BytesPerWord, because calling convention |
|
884 |
// may require empty slots due to long alignment, e.g. func(int, jlong, int, jlong) |
|
885 |
__ sub(SP, SP, AsmOperand(Rsize_of_params, lsl, LogBytesPerLong)); |
|
886 |
||
887 |
#ifdef __ABI_HARD__ |
|
888 |
// Allocate more stack space to accomodate all GP as well as FP registers: |
|
889 |
// 4 * wordSize |
|
890 |
// 8 * BytesPerLong |
|
46620
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46369
diff
changeset
|
891 |
int reg_arguments = align_up((4*wordSize) + (8*BytesPerLong), StackAlignmentInBytes); |
42664 | 892 |
#else |
893 |
// Reserve at least 4 words on the stack for loading |
|
894 |
// of parameters passed on registers (R0-R3). |
|
895 |
// See generate_slow_signature_handler(). |
|
896 |
// It is also used for JNIEnv & class additional parameters. |
|
897 |
int reg_arguments = 4 * wordSize; |
|
898 |
#endif // __ABI_HARD__ |
|
899 |
||
900 |
__ sub(SP, SP, reg_arguments); |
|
901 |
||
902 |
||
52351 | 903 |
// Note: signature handler blows R4 besides all scratch registers. |
42664 | 904 |
// See AbstractInterpreterGenerator::generate_slow_signature_handler(). |
905 |
__ call(Rsig_handler); |
|
906 |
#if R9_IS_SCRATCHED |
|
907 |
__ restore_method(); |
|
908 |
#endif |
|
909 |
__ mov(Rresult_handler, R0); |
|
910 |
||
911 |
// Pass JNIEnv and mirror for static methods |
|
912 |
{ |
|
913 |
Label L; |
|
914 |
__ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); |
|
915 |
__ add(R0, Rthread, in_bytes(JavaThread::jni_environment_offset())); |
|
916 |
__ tbz(Rtemp, JVM_ACC_STATIC_BIT, L); |
|
917 |
__ load_mirror(Rtemp, Rmethod, Rtemp); |
|
918 |
__ add(R1, FP, frame::interpreter_frame_oop_temp_offset * wordSize); |
|
919 |
__ str(Rtemp, Address(R1, 0)); |
|
920 |
__ bind(L); |
|
921 |
} |
|
922 |
||
923 |
__ set_last_Java_frame(SP, FP, true, Rtemp); |
|
924 |
||
925 |
// Changing state to _thread_in_native must be the last thing to do |
|
926 |
// before the jump to native code. At this moment stack must be |
|
927 |
// safepoint-safe and completely prepared for stack walking. |
|
928 |
#ifdef ASSERT |
|
929 |
{ |
|
930 |
Label L; |
|
931 |
__ ldr_u32(Rtemp, Address(Rthread, JavaThread::thread_state_offset())); |
|
932 |
__ cmp_32(Rtemp, _thread_in_Java); |
|
933 |
__ b(L, eq); |
|
934 |
__ stop("invalid thread state"); |
|
935 |
__ bind(L); |
|
936 |
} |
|
937 |
#endif |
|
938 |
||
939 |
// Force all preceding writes to be observed prior to thread state change |
|
940 |
__ membar(MacroAssembler::StoreStore, Rtemp); |
|
941 |
||
942 |
__ mov(Rtemp, _thread_in_native); |
|
943 |
__ str(Rtemp, Address(Rthread, JavaThread::thread_state_offset())); |
|
944 |
||
945 |
__ call(Rnative_code); |
|
946 |
#if R9_IS_SCRATCHED |
|
947 |
__ restore_method(); |
|
948 |
#endif |
|
949 |
||
950 |
// Set FPSCR/FPCR to a known state |
|
951 |
if (AlwaysRestoreFPU) { |
|
952 |
__ restore_default_fp_mode(); |
|
953 |
} |
|
954 |
||
955 |
// Do safepoint check |
|
956 |
__ mov(Rtemp, _thread_in_native_trans); |
|
957 |
__ str_32(Rtemp, Address(Rthread, JavaThread::thread_state_offset())); |
|
958 |
||
959 |
// Force this write out before the read below |
|
960 |
__ membar(MacroAssembler::StoreLoad, Rtemp); |
|
961 |
||
962 |
__ ldr_global_s32(Rtemp, SafepointSynchronize::address_of_state()); |
|
963 |
||
964 |
// Protect the return value in the interleaved code: save it to callee-save registers. |
|
965 |
__ mov(Rsaved_result_lo, R0); |
|
966 |
__ mov(Rsaved_result_hi, R1); |
|
967 |
#ifdef __ABI_HARD__ |
|
968 |
// preserve native FP result in a callee-saved register |
|
969 |
saved_result_fp = D8; |
|
970 |
__ fcpyd(saved_result_fp, D0); |
|
971 |
#else |
|
972 |
saved_result_fp = fnoreg; |
|
973 |
#endif // __ABI_HARD__ |
|
974 |
||
975 |
{ |
|
976 |
__ ldr_u32(R3, Address(Rthread, JavaThread::suspend_flags_offset())); |
|
977 |
__ cmp(Rtemp, SafepointSynchronize::_not_synchronized); |
|
978 |
__ cond_cmp(R3, 0, eq); |
|
979 |
||
980 |
__ mov(R0, Rthread, ne); |
|
981 |
__ call(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans), relocInfo::none, ne); |
|
982 |
#if R9_IS_SCRATCHED |
|
983 |
__ restore_method(); |
|
984 |
#endif |
|
985 |
} |
|
986 |
||
987 |
// Perform Native->Java thread transition |
|
988 |
__ mov(Rtemp, _thread_in_Java); |
|
989 |
__ str_32(Rtemp, Address(Rthread, JavaThread::thread_state_offset())); |
|
990 |
||
991 |
// Zero handles and last_java_sp |
|
992 |
__ reset_last_Java_frame(Rtemp); |
|
993 |
__ ldr(R3, Address(Rthread, JavaThread::active_handles_offset())); |
|
994 |
__ str_32(__ zero_register(Rtemp), Address(R3, JNIHandleBlock::top_offset_in_bytes())); |
|
995 |
if (CheckJNICalls) { |
|
996 |
__ str(__ zero_register(Rtemp), Address(Rthread, JavaThread::pending_jni_exception_check_fn_offset())); |
|
997 |
} |
|
998 |
||
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
999 |
// Unbox oop result, e.g. JNIHandles::resolve result if it's an oop. |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1000 |
{ |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1001 |
Label Lnot_oop; |
52676
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
1002 |
__ mov_slow(Rtemp, AbstractInterpreter::result_handler(T_OBJECT)); |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
1003 |
__ cmp(Rtemp, Rresult_handler); |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
1004 |
__ b(Lnot_oop, ne); |
52351 | 1005 |
Register value = Rsaved_result_lo; |
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1006 |
__ resolve_jobject(value, // value |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1007 |
Rtemp, // tmp1 |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1008 |
R1_tmp); // tmp2 |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1009 |
// Store resolved result in frame for GC visibility. |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1010 |
__ str(value, Address(FP, frame::interpreter_frame_oop_temp_offset * wordSize)); |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1011 |
__ bind(Lnot_oop); |
42664 | 1012 |
} |
1013 |
||
1014 |
||
1015 |
// reguard stack if StackOverflow exception happened while in native. |
|
1016 |
{ |
|
1017 |
__ ldr_u32(Rtemp, Address(Rthread, JavaThread::stack_guard_state_offset())); |
|
1018 |
__ cmp_32(Rtemp, JavaThread::stack_guard_yellow_reserved_disabled); |
|
1019 |
__ call(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages), relocInfo::none, eq); |
|
1020 |
#if R9_IS_SCRATCHED |
|
1021 |
__ restore_method(); |
|
1022 |
#endif |
|
1023 |
} |
|
1024 |
||
1025 |
// check pending exceptions |
|
1026 |
{ |
|
1027 |
__ ldr(Rtemp, Address(Rthread, Thread::pending_exception_offset())); |
|
1028 |
__ cmp(Rtemp, 0); |
|
1029 |
__ mov(Rexception_pc, PC, ne); |
|
1030 |
__ b(StubRoutines::forward_exception_entry(), ne); |
|
1031 |
} |
|
1032 |
||
1033 |
if (synchronized) { |
|
1034 |
// address of first monitor |
|
1035 |
__ sub(R1, FP, - (frame::interpreter_frame_monitor_block_bottom_offset - frame::interpreter_frame_monitor_size()) * wordSize); |
|
1036 |
__ unlock_object(R1); |
|
1037 |
} |
|
1038 |
||
1039 |
// jvmti/dtrace support |
|
1040 |
// Note: This must happen _after_ handling/throwing any exceptions since |
|
1041 |
// the exception handler code notifies the runtime of method exits |
|
1042 |
// too. If this happens before, method entry/exit notifications are |
|
1043 |
// not properly paired (was bug - gri 11/22/99). |
|
1044 |
__ notify_method_exit(vtos, InterpreterMacroAssembler::NotifyJVMTI, true, Rsaved_result_lo, Rsaved_result_hi, saved_result_fp); |
|
1045 |
||
52676
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
1046 |
// Restore the result. Oop result is restored from the stack by the |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
1047 |
// result handler. |
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
1048 |
__ mov(R0, Rsaved_result_lo); |
42664 | 1049 |
__ mov(R1, Rsaved_result_hi); |
1050 |
||
1051 |
#ifdef __ABI_HARD__ |
|
1052 |
// reload native FP result |
|
1053 |
__ fcpyd(D0, D8); |
|
1054 |
#endif // __ABI_HARD__ |
|
1055 |
||
52676
2d795829f39f
8213845: ARM32: Interpreter doesn't call result handler after native calls
bulasevich
parents:
52351
diff
changeset
|
1056 |
__ blx(Rresult_handler); |
42664 | 1057 |
|
1058 |
// Restore FP/LR, sender_sp and return |
|
1059 |
__ mov(Rtemp, FP); |
|
1060 |
__ ldmia(FP, RegisterSet(FP) | RegisterSet(LR)); |
|
1061 |
__ ldr(SP, Address(Rtemp, frame::interpreter_frame_sender_sp_offset * wordSize)); |
|
1062 |
||
1063 |
__ ret(); |
|
1064 |
||
1065 |
if (inc_counter) { |
|
1066 |
// Handle overflow of counter and compile method |
|
1067 |
__ bind(invocation_counter_overflow); |
|
1068 |
generate_counter_overflow(continue_after_compile); |
|
1069 |
} |
|
1070 |
||
1071 |
return entry_point; |
|
1072 |
} |
|
1073 |
||
1074 |
// |
|
1075 |
// Generic interpreted method entry to (asm) interpreter |
|
1076 |
// |
|
1077 |
address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { |
|
1078 |
// determine code generation flags |
|
1079 |
bool inc_counter = UseCompiler || CountCompiledCalls || LogTouchedMethods; |
|
1080 |
||
1081 |
// Rmethod: Method* |
|
1082 |
// Rthread: thread |
|
1083 |
// Rsender_sp: sender sp (could differ from SP if we were called via c2i) |
|
1084 |
// Rparams: pointer to the last parameter in the stack |
|
1085 |
||
1086 |
address entry_point = __ pc(); |
|
1087 |
||
52351 | 1088 |
const Register RconstMethod = R3; |
42664 | 1089 |
|
1090 |
||
1091 |
__ ldr(RconstMethod, Address(Rmethod, Method::const_offset())); |
|
1092 |
||
1093 |
__ ldrh(R2, Address(RconstMethod, ConstMethod::size_of_parameters_offset())); |
|
1094 |
__ ldrh(R3, Address(RconstMethod, ConstMethod::size_of_locals_offset())); |
|
1095 |
||
1096 |
// setup Rlocals |
|
1097 |
__ sub(Rlocals, Rparams, wordSize); |
|
1098 |
__ add(Rlocals, Rlocals, AsmOperand(R2, lsl, Interpreter::logStackElementSize)); |
|
1099 |
||
1100 |
__ sub(R3, R3, R2); // number of additional locals |
|
1101 |
||
1102 |
||
1103 |
// see if we've got enough room on the stack for locals plus overhead. |
|
1104 |
generate_stack_overflow_check(); |
|
1105 |
||
1106 |
// allocate space for locals |
|
1107 |
// explicitly initialize locals |
|
1108 |
||
1109 |
// Loop is unrolled 4 times |
|
1110 |
Label loop; |
|
1111 |
__ mov(R0, 0); |
|
1112 |
__ bind(loop); |
|
1113 |
||
1114 |
// #1 |
|
1115 |
__ subs(R3, R3, 1); |
|
1116 |
__ push(R0, ge); |
|
1117 |
||
1118 |
// #2 |
|
1119 |
__ subs(R3, R3, 1, ge); |
|
1120 |
__ push(R0, ge); |
|
1121 |
||
1122 |
// #3 |
|
1123 |
__ subs(R3, R3, 1, ge); |
|
1124 |
__ push(R0, ge); |
|
1125 |
||
1126 |
// #4 |
|
1127 |
__ subs(R3, R3, 1, ge); |
|
1128 |
__ push(R0, ge); |
|
1129 |
||
1130 |
__ b(loop, gt); |
|
1131 |
||
1132 |
// initialize fixed part of activation frame |
|
1133 |
generate_fixed_frame(false); |
|
1134 |
||
1135 |
__ restore_dispatch(); |
|
1136 |
||
1137 |
// make sure method is not native & not abstract |
|
1138 |
#ifdef ASSERT |
|
1139 |
__ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); |
|
1140 |
{ |
|
1141 |
Label L; |
|
1142 |
__ tbz(Rtemp, JVM_ACC_NATIVE_BIT, L); |
|
1143 |
__ stop("tried to execute native method as non-native"); |
|
1144 |
__ bind(L); |
|
1145 |
} |
|
1146 |
{ Label L; |
|
1147 |
__ tbz(Rtemp, JVM_ACC_ABSTRACT_BIT, L); |
|
1148 |
__ stop("tried to execute abstract method in interpreter"); |
|
1149 |
__ bind(L); |
|
1150 |
} |
|
1151 |
#endif |
|
1152 |
||
1153 |
// increment invocation count & check for overflow |
|
1154 |
Label invocation_counter_overflow; |
|
1155 |
Label profile_method; |
|
1156 |
Label profile_method_continue; |
|
1157 |
if (inc_counter) { |
|
1158 |
if (synchronized) { |
|
1159 |
// Avoid unlocking method's monitor in case of exception, as it has not |
|
1160 |
// been locked yet. |
|
1161 |
__ set_do_not_unlock_if_synchronized(true, Rtemp); |
|
1162 |
} |
|
1163 |
generate_counter_incr(&invocation_counter_overflow, &profile_method, &profile_method_continue); |
|
1164 |
if (ProfileInterpreter) { |
|
1165 |
__ bind(profile_method_continue); |
|
1166 |
} |
|
1167 |
} |
|
1168 |
Label continue_after_compile; |
|
1169 |
__ bind(continue_after_compile); |
|
1170 |
||
1171 |
if (inc_counter && synchronized) { |
|
1172 |
__ set_do_not_unlock_if_synchronized(false, Rtemp); |
|
1173 |
} |
|
1174 |
#if R9_IS_SCRATCHED |
|
1175 |
__ restore_method(); |
|
1176 |
#endif |
|
1177 |
||
1178 |
// check for synchronized methods |
|
1179 |
// Must happen AFTER invocation_counter check and stack overflow check, |
|
1180 |
// so method is not locked if overflows. |
|
1181 |
// |
|
1182 |
if (synchronized) { |
|
1183 |
// Allocate monitor and lock method |
|
1184 |
lock_method(); |
|
1185 |
} else { |
|
1186 |
// no synchronization necessary |
|
1187 |
#ifdef ASSERT |
|
1188 |
{ Label L; |
|
1189 |
__ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); |
|
1190 |
__ tbz(Rtemp, JVM_ACC_SYNCHRONIZED_BIT, L); |
|
1191 |
__ stop("method needs synchronization"); |
|
1192 |
__ bind(L); |
|
1193 |
} |
|
1194 |
#endif |
|
1195 |
} |
|
1196 |
||
1197 |
// start execution |
|
1198 |
#ifdef ASSERT |
|
1199 |
{ Label L; |
|
1200 |
__ ldr(Rtemp, Address(FP, frame::interpreter_frame_monitor_block_top_offset * wordSize)); |
|
1201 |
__ cmp(Rtemp, Rstack_top); |
|
1202 |
__ b(L, eq); |
|
1203 |
__ stop("broken stack frame setup in interpreter"); |
|
1204 |
__ bind(L); |
|
1205 |
} |
|
1206 |
#endif |
|
1207 |
__ check_extended_sp(Rtemp); |
|
1208 |
||
1209 |
// jvmti support |
|
1210 |
__ notify_method_entry(); |
|
1211 |
#if R9_IS_SCRATCHED |
|
1212 |
__ restore_method(); |
|
1213 |
#endif |
|
1214 |
||
1215 |
__ dispatch_next(vtos); |
|
1216 |
||
1217 |
// invocation counter overflow |
|
1218 |
if (inc_counter) { |
|
1219 |
if (ProfileInterpreter) { |
|
1220 |
// We have decided to profile this method in the interpreter |
|
1221 |
__ bind(profile_method); |
|
1222 |
||
1223 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method)); |
|
1224 |
__ set_method_data_pointer_for_bcp(); |
|
1225 |
||
1226 |
__ b(profile_method_continue); |
|
1227 |
} |
|
1228 |
||
1229 |
// Handle overflow of counter and compile method |
|
1230 |
__ bind(invocation_counter_overflow); |
|
1231 |
generate_counter_overflow(continue_after_compile); |
|
1232 |
} |
|
1233 |
||
1234 |
return entry_point; |
|
1235 |
} |
|
1236 |
||
1237 |
//------------------------------------------------------------------------------------------------------------------------ |
|
1238 |
// Exceptions |
|
1239 |
||
1240 |
void TemplateInterpreterGenerator::generate_throw_exception() { |
|
1241 |
// Entry point in previous activation (i.e., if the caller was interpreted) |
|
1242 |
Interpreter::_rethrow_exception_entry = __ pc(); |
|
1243 |
// Rexception_obj: exception |
|
1244 |
||
1245 |
// Clear interpreter_frame_last_sp. |
|
1246 |
__ mov(Rtemp, 0); |
|
1247 |
__ str(Rtemp, Address(FP, frame::interpreter_frame_last_sp_offset * wordSize)); |
|
1248 |
||
1249 |
#if R9_IS_SCRATCHED |
|
1250 |
__ restore_method(); |
|
1251 |
#endif |
|
1252 |
__ restore_bcp(); |
|
1253 |
__ restore_dispatch(); |
|
1254 |
__ restore_locals(); |
|
1255 |
||
1256 |
||
1257 |
// Entry point for exceptions thrown within interpreter code |
|
1258 |
Interpreter::_throw_exception_entry = __ pc(); |
|
1259 |
||
1260 |
// expression stack is undefined here |
|
1261 |
// Rexception_obj: exception |
|
1262 |
// Rbcp: exception bcp |
|
1263 |
__ verify_oop(Rexception_obj); |
|
1264 |
||
1265 |
// expression stack must be empty before entering the VM in case of an exception |
|
1266 |
__ empty_expression_stack(); |
|
1267 |
// find exception handler address and preserve exception oop |
|
1268 |
__ mov(R1, Rexception_obj); |
|
1269 |
__ call_VM(Rexception_obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::exception_handler_for_exception), R1); |
|
1270 |
// R0: exception handler entry point |
|
1271 |
// Rexception_obj: preserved exception oop |
|
1272 |
// Rbcp: bcp for exception handler |
|
1273 |
__ push_ptr(Rexception_obj); // push exception which is now the only value on the stack |
|
1274 |
__ jump(R0); // jump to exception handler (may be _remove_activation_entry!) |
|
1275 |
||
1276 |
// If the exception is not handled in the current frame the frame is removed and |
|
1277 |
// the exception is rethrown (i.e. exception continuation is _rethrow_exception). |
|
1278 |
// |
|
1279 |
// Note: At this point the bci is still the bxi for the instruction which caused |
|
1280 |
// the exception and the expression stack is empty. Thus, for any VM calls |
|
1281 |
// at this point, GC will find a legal oop map (with empty expression stack). |
|
1282 |
||
1283 |
// In current activation |
|
1284 |
// tos: exception |
|
1285 |
// Rbcp: exception bcp |
|
1286 |
||
1287 |
// |
|
1288 |
// JVMTI PopFrame support |
|
1289 |
// |
|
1290 |
Interpreter::_remove_activation_preserving_args_entry = __ pc(); |
|
1291 |
||
1292 |
||
1293 |
__ empty_expression_stack(); |
|
1294 |
||
1295 |
// Set the popframe_processing bit in _popframe_condition indicating that we are |
|
1296 |
// currently handling popframe, so that call_VMs that may happen later do not trigger new |
|
1297 |
// popframe handling cycles. |
|
1298 |
||
1299 |
__ ldr_s32(Rtemp, Address(Rthread, JavaThread::popframe_condition_offset())); |
|
1300 |
__ orr(Rtemp, Rtemp, (unsigned)JavaThread::popframe_processing_bit); |
|
1301 |
__ str_32(Rtemp, Address(Rthread, JavaThread::popframe_condition_offset())); |
|
1302 |
||
1303 |
{ |
|
1304 |
// Check to see whether we are returning to a deoptimized frame. |
|
1305 |
// (The PopFrame call ensures that the caller of the popped frame is |
|
1306 |
// either interpreted or compiled and deoptimizes it if compiled.) |
|
1307 |
// In this case, we can't call dispatch_next() after the frame is |
|
1308 |
// popped, but instead must save the incoming arguments and restore |
|
1309 |
// them after deoptimization has occurred. |
|
1310 |
// |
|
1311 |
// Note that we don't compare the return PC against the |
|
1312 |
// deoptimization blob's unpack entry because of the presence of |
|
1313 |
// adapter frames in C2. |
|
1314 |
Label caller_not_deoptimized; |
|
1315 |
__ ldr(R0, Address(FP, frame::return_addr_offset * wordSize)); |
|
1316 |
__ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::interpreter_contains), R0); |
|
1317 |
__ cbnz_32(R0, caller_not_deoptimized); |
|
1318 |
||
1319 |
// Compute size of arguments for saving when returning to deoptimized caller |
|
1320 |
__ restore_method(); |
|
1321 |
__ ldr(R0, Address(Rmethod, Method::const_offset())); |
|
1322 |
__ ldrh(R0, Address(R0, ConstMethod::size_of_parameters_offset())); |
|
1323 |
||
1324 |
__ logical_shift_left(R1, R0, Interpreter::logStackElementSize); |
|
1325 |
// Save these arguments |
|
1326 |
__ restore_locals(); |
|
1327 |
__ sub(R2, Rlocals, R1); |
|
1328 |
__ add(R2, R2, wordSize); |
|
1329 |
__ mov(R0, Rthread); |
|
1330 |
__ call_VM_leaf(CAST_FROM_FN_PTR(address, Deoptimization::popframe_preserve_args), R0, R1, R2); |
|
1331 |
||
1332 |
__ remove_activation(vtos, LR, |
|
1333 |
/* throw_monitor_exception */ false, |
|
1334 |
/* install_monitor_exception */ false, |
|
1335 |
/* notify_jvmdi */ false); |
|
1336 |
||
1337 |
// Inform deoptimization that it is responsible for restoring these arguments |
|
1338 |
__ mov(Rtemp, JavaThread::popframe_force_deopt_reexecution_bit); |
|
1339 |
__ str_32(Rtemp, Address(Rthread, JavaThread::popframe_condition_offset())); |
|
1340 |
||
1341 |
// Continue in deoptimization handler |
|
1342 |
__ ret(); |
|
1343 |
||
1344 |
__ bind(caller_not_deoptimized); |
|
1345 |
} |
|
1346 |
||
1347 |
__ remove_activation(vtos, R4, |
|
1348 |
/* throw_monitor_exception */ false, |
|
1349 |
/* install_monitor_exception */ false, |
|
1350 |
/* notify_jvmdi */ false); |
|
1351 |
||
1352 |
// Finish with popframe handling |
|
1353 |
// A previous I2C followed by a deoptimization might have moved the |
|
1354 |
// outgoing arguments further up the stack. PopFrame expects the |
|
1355 |
// mutations to those outgoing arguments to be preserved and other |
|
1356 |
// constraints basically require this frame to look exactly as |
|
1357 |
// though it had previously invoked an interpreted activation with |
|
1358 |
// no space between the top of the expression stack (current |
|
1359 |
// last_sp) and the top of stack. Rather than force deopt to |
|
1360 |
// maintain this kind of invariant all the time we call a small |
|
1361 |
// fixup routine to move the mutated arguments onto the top of our |
|
1362 |
// expression stack if necessary. |
|
1363 |
__ mov(R1, SP); |
|
1364 |
__ ldr(R2, Address(FP, frame::interpreter_frame_last_sp_offset * wordSize)); |
|
1365 |
// PC must point into interpreter here |
|
1366 |
__ set_last_Java_frame(SP, FP, true, Rtemp); |
|
1367 |
__ mov(R0, Rthread); |
|
1368 |
__ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), R0, R1, R2); |
|
1369 |
__ reset_last_Java_frame(Rtemp); |
|
1370 |
||
1371 |
// Restore the last_sp and null it out |
|
1372 |
__ ldr(SP, Address(FP, frame::interpreter_frame_last_sp_offset * wordSize)); |
|
1373 |
__ mov(Rtemp, (int)NULL_WORD); |
|
1374 |
__ str(Rtemp, Address(FP, frame::interpreter_frame_last_sp_offset * wordSize)); |
|
1375 |
||
1376 |
__ restore_bcp(); |
|
1377 |
__ restore_dispatch(); |
|
1378 |
__ restore_locals(); |
|
1379 |
__ restore_method(); |
|
1380 |
||
1381 |
// The method data pointer was incremented already during |
|
1382 |
// call profiling. We have to restore the mdp for the current bcp. |
|
1383 |
if (ProfileInterpreter) { |
|
1384 |
__ set_method_data_pointer_for_bcp(); |
|
1385 |
} |
|
1386 |
||
1387 |
// Clear the popframe condition flag |
|
1388 |
assert(JavaThread::popframe_inactive == 0, "adjust this code"); |
|
1389 |
__ str_32(__ zero_register(Rtemp), Address(Rthread, JavaThread::popframe_condition_offset())); |
|
1390 |
||
1391 |
#if INCLUDE_JVMTI |
|
1392 |
{ |
|
1393 |
Label L_done; |
|
1394 |
||
1395 |
__ ldrb(Rtemp, Address(Rbcp, 0)); |
|
1396 |
__ cmp(Rtemp, Bytecodes::_invokestatic); |
|
1397 |
__ b(L_done, ne); |
|
1398 |
||
1399 |
// The member name argument must be restored if _invokestatic is re-executed after a PopFrame call. |
|
1400 |
// Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL. |
|
1401 |
||
1402 |
// get local0 |
|
1403 |
__ ldr(R1, Address(Rlocals, 0)); |
|
1404 |
__ mov(R2, Rmethod); |
|
1405 |
__ mov(R3, Rbcp); |
|
1406 |
__ call_VM(R0, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null), R1, R2, R3); |
|
1407 |
||
1408 |
__ cbz(R0, L_done); |
|
1409 |
||
1410 |
__ str(R0, Address(Rstack_top)); |
|
1411 |
__ bind(L_done); |
|
1412 |
} |
|
1413 |
#endif // INCLUDE_JVMTI |
|
1414 |
||
1415 |
__ dispatch_next(vtos); |
|
1416 |
// end of PopFrame support |
|
1417 |
||
1418 |
Interpreter::_remove_activation_entry = __ pc(); |
|
1419 |
||
1420 |
// preserve exception over this code sequence |
|
1421 |
__ pop_ptr(R0_tos); |
|
1422 |
__ str(R0_tos, Address(Rthread, JavaThread::vm_result_offset())); |
|
1423 |
// remove the activation (without doing throws on illegalMonitorExceptions) |
|
1424 |
__ remove_activation(vtos, Rexception_pc, false, true, false); |
|
1425 |
// restore exception |
|
1426 |
__ get_vm_result(Rexception_obj, Rtemp); |
|
1427 |
||
1428 |
// Inbetween activations - previous activation type unknown yet |
|
1429 |
// compute continuation point - the continuation point expects |
|
1430 |
// the following registers set up: |
|
1431 |
// |
|
1432 |
// Rexception_obj: exception |
|
1433 |
// Rexception_pc: return address/pc that threw exception |
|
1434 |
// SP: expression stack of caller |
|
1435 |
// FP: frame pointer of caller |
|
1436 |
__ mov(c_rarg0, Rthread); |
|
1437 |
__ mov(c_rarg1, Rexception_pc); |
|
1438 |
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), c_rarg0, c_rarg1); |
|
1439 |
// Note that an "issuing PC" is actually the next PC after the call |
|
1440 |
||
1441 |
__ jump(R0); // jump to exception handler of caller |
|
1442 |
} |
|
1443 |
||
1444 |
||
1445 |
// |
|
1446 |
// JVMTI ForceEarlyReturn support |
|
1447 |
// |
|
1448 |
address TemplateInterpreterGenerator::generate_earlyret_entry_for(TosState state) { |
|
1449 |
address entry = __ pc(); |
|
1450 |
||
1451 |
||
1452 |
__ restore_bcp(); |
|
1453 |
__ restore_dispatch(); |
|
1454 |
__ restore_locals(); |
|
1455 |
||
1456 |
__ empty_expression_stack(); |
|
1457 |
||
1458 |
__ load_earlyret_value(state); |
|
1459 |
||
1460 |
// Clear the earlyret state |
|
1461 |
__ ldr(Rtemp, Address(Rthread, JavaThread::jvmti_thread_state_offset())); |
|
1462 |
||
1463 |
assert(JvmtiThreadState::earlyret_inactive == 0, "adjust this code"); |
|
1464 |
__ str_32(__ zero_register(R2), Address(Rtemp, JvmtiThreadState::earlyret_state_offset())); |
|
1465 |
||
1466 |
__ remove_activation(state, LR, |
|
1467 |
false, /* throw_monitor_exception */ |
|
1468 |
false, /* install_monitor_exception */ |
|
1469 |
true); /* notify_jvmdi */ |
|
1470 |
||
1471 |
// According to interpreter calling conventions, result is returned in R0/R1, |
|
1472 |
// so ftos (S0) and dtos (D0) are moved to R0/R1. |
|
1473 |
// This conversion should be done after remove_activation, as it uses |
|
1474 |
// push(state) & pop(state) to preserve return value. |
|
1475 |
__ convert_tos_to_retval(state); |
|
1476 |
__ ret(); |
|
1477 |
||
1478 |
return entry; |
|
1479 |
} // end of ForceEarlyReturn support |
|
1480 |
||
1481 |
||
1482 |
//------------------------------------------------------------------------------------------------------------------------ |
|
1483 |
// Helper for vtos entry point generation |
|
1484 |
||
1485 |
void TemplateInterpreterGenerator::set_vtos_entry_points (Template* t, address& bep, address& cep, address& sep, address& aep, address& iep, address& lep, address& fep, address& dep, address& vep) { |
|
1486 |
assert(t->is_valid() && t->tos_in() == vtos, "illegal template"); |
|
1487 |
Label L; |
|
1488 |
||
1489 |
#ifdef __SOFTFP__ |
|
1490 |
dep = __ pc(); // fall through |
|
1491 |
#else |
|
1492 |
fep = __ pc(); __ push(ftos); __ b(L); |
|
1493 |
dep = __ pc(); __ push(dtos); __ b(L); |
|
1494 |
#endif // __SOFTFP__ |
|
1495 |
||
1496 |
lep = __ pc(); __ push(ltos); __ b(L); |
|
1497 |
||
52351 | 1498 |
if (VerifyOops) { // can't share atos entry if VerifyOops |
42664 | 1499 |
aep = __ pc(); __ push(atos); __ b(L); |
1500 |
} else { |
|
1501 |
aep = __ pc(); // fall through |
|
1502 |
} |
|
1503 |
||
1504 |
#ifdef __SOFTFP__ |
|
1505 |
fep = __ pc(); // fall through |
|
1506 |
#endif // __SOFTFP__ |
|
1507 |
||
1508 |
bep = cep = sep = // fall through |
|
1509 |
iep = __ pc(); __ push(itos); // fall through |
|
1510 |
vep = __ pc(); __ bind(L); // fall through |
|
1511 |
generate_and_dispatch(t); |
|
1512 |
} |
|
1513 |
||
1514 |
//------------------------------------------------------------------------------------------------------------------------ |
|
1515 |
||
1516 |
// Non-product code |
|
1517 |
#ifndef PRODUCT |
|
1518 |
address TemplateInterpreterGenerator::generate_trace_code(TosState state) { |
|
1519 |
address entry = __ pc(); |
|
1520 |
||
1521 |
// prepare expression stack |
|
1522 |
__ push(state); // save tosca |
|
1523 |
||
1524 |
// pass tosca registers as arguments |
|
1525 |
__ mov(R2, R0_tos); |
|
1526 |
__ mov(R3, R1_tos_hi); |
|
1527 |
__ mov(R1, LR); // save return address |
|
1528 |
||
1529 |
// call tracer |
|
1530 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), R1, R2, R3); |
|
1531 |
||
1532 |
__ mov(LR, R0); // restore return address |
|
1533 |
__ pop(state); // restore tosca |
|
1534 |
||
1535 |
// return |
|
1536 |
__ ret(); |
|
1537 |
||
1538 |
return entry; |
|
1539 |
} |
|
1540 |
||
1541 |
||
1542 |
void TemplateInterpreterGenerator::count_bytecode() { |
|
1543 |
__ inc_global_counter((address) &BytecodeCounter::_counter_value, 0, Rtemp, R2_tmp, true); |
|
1544 |
} |
|
1545 |
||
1546 |
||
1547 |
void TemplateInterpreterGenerator::histogram_bytecode(Template* t) { |
|
1548 |
__ inc_global_counter((address)&BytecodeHistogram::_counters[0], sizeof(BytecodeHistogram::_counters[0]) * t->bytecode(), Rtemp, R2_tmp, true); |
|
1549 |
} |
|
1550 |
||
1551 |
||
1552 |
void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) { |
|
1553 |
const Register Rindex_addr = R2_tmp; |
|
1554 |
Label Lcontinue; |
|
1555 |
InlinedAddress Lcounters((address)BytecodePairHistogram::_counters); |
|
1556 |
InlinedAddress Lindex((address)&BytecodePairHistogram::_index); |
|
1557 |
const Register Rcounters_addr = R2_tmp; |
|
1558 |
const Register Rindex = R4_tmp; |
|
1559 |
||
1560 |
// calculate new index for counter: |
|
1561 |
// index = (_index >> log2_number_of_codes) | (bytecode << log2_number_of_codes). |
|
1562 |
// (_index >> log2_number_of_codes) is previous bytecode |
|
1563 |
||
1564 |
__ ldr_literal(Rindex_addr, Lindex); |
|
1565 |
__ ldr_s32(Rindex, Address(Rindex_addr)); |
|
1566 |
__ mov_slow(Rtemp, ((int)t->bytecode()) << BytecodePairHistogram::log2_number_of_codes); |
|
1567 |
__ orr(Rindex, Rtemp, AsmOperand(Rindex, lsr, BytecodePairHistogram::log2_number_of_codes)); |
|
1568 |
__ str_32(Rindex, Address(Rindex_addr)); |
|
1569 |
||
1570 |
// Rindex (R4) contains index of counter |
|
1571 |
||
1572 |
__ ldr_literal(Rcounters_addr, Lcounters); |
|
1573 |
__ ldr_s32(Rtemp, Address::indexed_32(Rcounters_addr, Rindex)); |
|
1574 |
__ adds_32(Rtemp, Rtemp, 1); |
|
1575 |
__ b(Lcontinue, mi); // avoid overflow |
|
1576 |
__ str_32(Rtemp, Address::indexed_32(Rcounters_addr, Rindex)); |
|
1577 |
||
1578 |
__ b(Lcontinue); |
|
1579 |
||
1580 |
__ bind_literal(Lindex); |
|
1581 |
__ bind_literal(Lcounters); |
|
1582 |
||
1583 |
__ bind(Lcontinue); |
|
1584 |
} |
|
1585 |
||
1586 |
||
1587 |
void TemplateInterpreterGenerator::trace_bytecode(Template* t) { |
|
1588 |
// Call a little run-time stub to avoid blow-up for each bytecode. |
|
1589 |
// The run-time runtime saves the right registers, depending on |
|
1590 |
// the tosca in-state for the given template. |
|
1591 |
assert(Interpreter::trace_code(t->tos_in()) != NULL, |
|
1592 |
"entry must have been generated"); |
|
1593 |
address trace_entry = Interpreter::trace_code(t->tos_in()); |
|
1594 |
__ call(trace_entry, relocInfo::none); |
|
1595 |
} |
|
1596 |
||
1597 |
||
1598 |
void TemplateInterpreterGenerator::stop_interpreter_at() { |
|
1599 |
Label Lcontinue; |
|
1600 |
const Register stop_at = R2_tmp; |
|
1601 |
||
1602 |
__ ldr_global_s32(Rtemp, (address) &BytecodeCounter::_counter_value); |
|
1603 |
__ mov_slow(stop_at, StopInterpreterAt); |
|
1604 |
||
1605 |
// test bytecode counter |
|
1606 |
__ cmp(Rtemp, stop_at); |
|
1607 |
__ b(Lcontinue, ne); |
|
1608 |
||
1609 |
__ trace_state("stop_interpreter_at"); |
|
1610 |
__ breakpoint(); |
|
1611 |
||
1612 |
__ bind(Lcontinue); |
|
1613 |
} |
|
1614 |
#endif // !PRODUCT |