Mercurial > hg > graal-compiler
annotate src/cpu/ppc/vm/interp_masm_ppc_64.cpp @ 20418:b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
Reviewed-by: kvn, goetz
Contributed-by: asmundak@google.com
author | kvn |
---|---|
date | Thu, 17 Jul 2014 15:40:04 -0700 |
parents | fd1b9f02cc91 |
children | f6bde7889409 |
rev | line source |
---|---|
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1 /* |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
17804 | 3 * Copyright 2012, 2014 SAP AG. All rights reserved. |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5 * |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
6 * This code is free software; you can redistribute it and/or modify it |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
7 * under the terms of the GNU General Public License version 2 only, as |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
8 * published by the Free Software Foundation. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
9 * |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
10 * This code is distributed in the hope that it will be useful, but WITHOUT |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
13 * version 2 for more details (a copy is included in the LICENSE file that |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
14 * accompanied this code). |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
15 * |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License version |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
17 * 2 along with this work; if not, write to the Free Software Foundation, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
19 * |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
21 * or visit www.oracle.com if you need additional information or have any |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
22 * questions. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
23 * |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
24 */ |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
25 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
26 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
27 #include "precompiled.hpp" |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
28 #include "asm/assembler.hpp" |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
29 #include "asm/macroAssembler.inline.hpp" |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
30 #include "interp_masm_ppc_64.hpp" |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
31 #include "interpreter/interpreterRuntime.hpp" |
17804 | 32 #include "prims/jvmtiThreadState.hpp" |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
33 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
34 #ifdef PRODUCT |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
35 #define BLOCK_COMMENT(str) // nothing |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
36 #else |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
37 #define BLOCK_COMMENT(str) block_comment(str) |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
38 #endif |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
39 |
14445 | 40 void InterpreterMacroAssembler::null_check_throw(Register a, int offset, Register temp_reg) { |
41 #ifdef CC_INTERP | |
42 address exception_entry = StubRoutines::throw_NullPointerException_at_call_entry(); | |
43 #else | |
44 address exception_entry = Interpreter::throw_NullPointerException_entry(); | |
45 #endif | |
46 MacroAssembler::null_check_throw(a, offset, temp_reg, exception_entry); | |
47 } | |
48 | |
17804 | 49 void InterpreterMacroAssembler::branch_to_entry(address entry, Register Rscratch) { |
50 assert(entry, "Entry must have been generated by now"); | |
51 if (is_within_range_of_b(entry, pc())) { | |
52 b(entry); | |
53 } else { | |
54 load_const_optimized(Rscratch, entry, R0); | |
55 mtctr(Rscratch); | |
56 bctr(); | |
57 } | |
58 } | |
59 | |
60 #ifndef CC_INTERP | |
61 | |
62 void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr) { | |
63 Register bytecode = R12_scratch2; | |
64 if (bcp_incr != 0) { | |
65 lbzu(bytecode, bcp_incr, R14_bcp); | |
66 } else { | |
67 lbz(bytecode, 0, R14_bcp); | |
68 } | |
69 | |
70 dispatch_Lbyte_code(state, bytecode, Interpreter::dispatch_table(state)); | |
71 } | |
72 | |
73 void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) { | |
74 // Load current bytecode. | |
75 Register bytecode = R12_scratch2; | |
76 lbz(bytecode, 0, R14_bcp); | |
77 dispatch_Lbyte_code(state, bytecode, table); | |
78 } | |
79 | |
80 // Dispatch code executed in the prolog of a bytecode which does not do it's | |
81 // own dispatch. The dispatch address is computed and placed in R24_dispatch_addr. | |
82 void InterpreterMacroAssembler::dispatch_prolog(TosState state, int bcp_incr) { | |
83 Register bytecode = R12_scratch2; | |
84 lbz(bytecode, bcp_incr, R14_bcp); | |
85 | |
86 load_dispatch_table(R24_dispatch_addr, Interpreter::dispatch_table(state)); | |
87 | |
88 sldi(bytecode, bytecode, LogBytesPerWord); | |
89 ldx(R24_dispatch_addr, R24_dispatch_addr, bytecode); | |
90 } | |
91 | |
92 // Dispatch code executed in the epilog of a bytecode which does not do it's | |
93 // own dispatch. The dispatch address in R24_dispatch_addr is used for the | |
94 // dispatch. | |
95 void InterpreterMacroAssembler::dispatch_epilog(TosState state, int bcp_incr) { | |
96 mtctr(R24_dispatch_addr); | |
97 addi(R14_bcp, R14_bcp, bcp_incr); | |
98 bctr(); | |
99 } | |
100 | |
101 void InterpreterMacroAssembler::check_and_handle_popframe(Register scratch_reg) { | |
102 assert(scratch_reg != R0, "can't use R0 as scratch_reg here"); | |
103 if (JvmtiExport::can_pop_frame()) { | |
104 Label L; | |
105 | |
106 // Check the "pending popframe condition" flag in the current thread. | |
107 lwz(scratch_reg, in_bytes(JavaThread::popframe_condition_offset()), R16_thread); | |
108 | |
109 // Initiate popframe handling only if it is not already being | |
110 // processed. If the flag has the popframe_processing bit set, it | |
111 // means that this code is called *during* popframe handling - we | |
112 // don't want to reenter. | |
113 andi_(R0, scratch_reg, JavaThread::popframe_pending_bit); | |
114 beq(CCR0, L); | |
115 | |
116 andi_(R0, scratch_reg, JavaThread::popframe_processing_bit); | |
117 bne(CCR0, L); | |
118 | |
119 // Call the Interpreter::remove_activation_preserving_args_entry() | |
120 // func to get the address of the same-named entrypoint in the | |
121 // generated interpreter code. | |
20418
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
122 #if defined(ABI_ELFv2) |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
123 call_c(CAST_FROM_FN_PTR(address, |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
124 Interpreter::remove_activation_preserving_args_entry), |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
125 relocInfo::none); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
126 #else |
17804 | 127 call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, |
128 Interpreter::remove_activation_preserving_args_entry), | |
129 relocInfo::none); | |
20418
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
130 #endif |
17804 | 131 |
132 // Jump to Interpreter::_remove_activation_preserving_args_entry. | |
133 mtctr(R3_RET); | |
134 bctr(); | |
135 | |
136 align(32, 12); | |
137 bind(L); | |
138 } | |
139 } | |
140 | |
141 void InterpreterMacroAssembler::check_and_handle_earlyret(Register scratch_reg) { | |
142 const Register Rthr_state_addr = scratch_reg; | |
143 if (JvmtiExport::can_force_early_return()) { | |
144 Label Lno_early_ret; | |
145 ld(Rthr_state_addr, in_bytes(JavaThread::jvmti_thread_state_offset()), R16_thread); | |
146 cmpdi(CCR0, Rthr_state_addr, 0); | |
147 beq(CCR0, Lno_early_ret); | |
148 | |
149 lwz(R0, in_bytes(JvmtiThreadState::earlyret_state_offset()), Rthr_state_addr); | |
150 cmpwi(CCR0, R0, JvmtiThreadState::earlyret_pending); | |
151 bne(CCR0, Lno_early_ret); | |
152 | |
153 // Jump to Interpreter::_earlyret_entry. | |
154 lwz(R3_ARG1, in_bytes(JvmtiThreadState::earlyret_tos_offset()), Rthr_state_addr); | |
155 call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry)); | |
156 mtlr(R3_RET); | |
157 blr(); | |
158 | |
159 align(32, 12); | |
160 bind(Lno_early_ret); | |
161 } | |
162 } | |
163 | |
164 void InterpreterMacroAssembler::load_earlyret_value(TosState state, Register Rscratch1) { | |
165 const Register RjvmtiState = Rscratch1; | |
166 const Register Rscratch2 = R0; | |
167 | |
168 ld(RjvmtiState, in_bytes(JavaThread::jvmti_thread_state_offset()), R16_thread); | |
169 li(Rscratch2, 0); | |
170 | |
171 switch (state) { | |
172 case atos: ld(R17_tos, in_bytes(JvmtiThreadState::earlyret_oop_offset()), RjvmtiState); | |
173 std(Rscratch2, in_bytes(JvmtiThreadState::earlyret_oop_offset()), RjvmtiState); | |
174 break; | |
175 case ltos: ld(R17_tos, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState); | |
176 break; | |
177 case btos: // fall through | |
178 case ctos: // fall through | |
179 case stos: // fall through | |
180 case itos: lwz(R17_tos, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState); | |
181 break; | |
182 case ftos: lfs(F15_ftos, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState); | |
183 break; | |
184 case dtos: lfd(F15_ftos, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState); | |
185 break; | |
186 case vtos: break; | |
187 default : ShouldNotReachHere(); | |
188 } | |
189 | |
190 // Clean up tos value in the jvmti thread state. | |
191 std(Rscratch2, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState); | |
192 // Set tos state field to illegal value. | |
193 li(Rscratch2, ilgl); | |
194 stw(Rscratch2, in_bytes(JvmtiThreadState::earlyret_tos_offset()), RjvmtiState); | |
195 } | |
196 | |
197 // Common code to dispatch and dispatch_only. | |
198 // Dispatch value in Lbyte_code and increment Lbcp. | |
199 | |
200 void InterpreterMacroAssembler::load_dispatch_table(Register dst, address* table) { | |
201 address table_base = (address)Interpreter::dispatch_table((TosState)0); | |
202 intptr_t table_offs = (intptr_t)table - (intptr_t)table_base; | |
203 if (is_simm16(table_offs)) { | |
204 addi(dst, R25_templateTableBase, (int)table_offs); | |
205 } else { | |
206 load_const_optimized(dst, table, R0); | |
207 } | |
208 } | |
209 | |
210 void InterpreterMacroAssembler::dispatch_Lbyte_code(TosState state, Register bytecode, address* table, bool verify) { | |
211 if (verify) { | |
212 unimplemented("dispatch_Lbyte_code: verify"); // See Sparc Implementation to implement this | |
213 } | |
214 | |
215 #ifdef FAST_DISPATCH | |
216 unimplemented("dispatch_Lbyte_code FAST_DISPATCH"); | |
217 #else | |
218 assert_different_registers(bytecode, R11_scratch1); | |
219 | |
220 // Calc dispatch table address. | |
221 load_dispatch_table(R11_scratch1, table); | |
222 | |
223 sldi(R12_scratch2, bytecode, LogBytesPerWord); | |
224 ldx(R11_scratch1, R11_scratch1, R12_scratch2); | |
225 | |
226 // Jump off! | |
227 mtctr(R11_scratch1); | |
228 bctr(); | |
229 #endif | |
230 } | |
231 | |
232 void InterpreterMacroAssembler::load_receiver(Register Rparam_count, Register Rrecv_dst) { | |
233 sldi(Rrecv_dst, Rparam_count, Interpreter::logStackElementSize); | |
234 ldx(Rrecv_dst, Rrecv_dst, R15_esp); | |
235 } | |
236 | |
237 // helpers for expression stack | |
238 | |
239 void InterpreterMacroAssembler::pop_i(Register r) { | |
240 lwzu(r, Interpreter::stackElementSize, R15_esp); | |
241 } | |
242 | |
243 void InterpreterMacroAssembler::pop_ptr(Register r) { | |
244 ldu(r, Interpreter::stackElementSize, R15_esp); | |
245 } | |
246 | |
247 void InterpreterMacroAssembler::pop_l(Register r) { | |
248 ld(r, Interpreter::stackElementSize, R15_esp); | |
249 addi(R15_esp, R15_esp, 2 * Interpreter::stackElementSize); | |
250 } | |
251 | |
252 void InterpreterMacroAssembler::pop_f(FloatRegister f) { | |
253 lfsu(f, Interpreter::stackElementSize, R15_esp); | |
254 } | |
255 | |
256 void InterpreterMacroAssembler::pop_d(FloatRegister f) { | |
257 lfd(f, Interpreter::stackElementSize, R15_esp); | |
258 addi(R15_esp, R15_esp, 2 * Interpreter::stackElementSize); | |
259 } | |
260 | |
261 void InterpreterMacroAssembler::push_i(Register r) { | |
262 stw(r, 0, R15_esp); | |
263 addi(R15_esp, R15_esp, - Interpreter::stackElementSize ); | |
264 } | |
265 | |
266 void InterpreterMacroAssembler::push_ptr(Register r) { | |
267 std(r, 0, R15_esp); | |
268 addi(R15_esp, R15_esp, - Interpreter::stackElementSize ); | |
269 } | |
270 | |
271 void InterpreterMacroAssembler::push_l(Register r) { | |
272 std(r, - Interpreter::stackElementSize, R15_esp); | |
273 addi(R15_esp, R15_esp, - 2 * Interpreter::stackElementSize ); | |
274 } | |
275 | |
276 void InterpreterMacroAssembler::push_f(FloatRegister f) { | |
277 stfs(f, 0, R15_esp); | |
278 addi(R15_esp, R15_esp, - Interpreter::stackElementSize ); | |
279 } | |
280 | |
281 void InterpreterMacroAssembler::push_d(FloatRegister f) { | |
282 stfd(f, - Interpreter::stackElementSize, R15_esp); | |
283 addi(R15_esp, R15_esp, - 2 * Interpreter::stackElementSize ); | |
284 } | |
285 | |
286 void InterpreterMacroAssembler::push_2ptrs(Register first, Register second) { | |
287 std(first, 0, R15_esp); | |
288 std(second, -Interpreter::stackElementSize, R15_esp); | |
289 addi(R15_esp, R15_esp, - 2 * Interpreter::stackElementSize ); | |
290 } | |
291 | |
292 void InterpreterMacroAssembler::push_l_pop_d(Register l, FloatRegister d) { | |
293 std(l, 0, R15_esp); | |
294 lfd(d, 0, R15_esp); | |
295 } | |
296 | |
297 void InterpreterMacroAssembler::push_d_pop_l(FloatRegister d, Register l) { | |
298 stfd(d, 0, R15_esp); | |
299 ld(l, 0, R15_esp); | |
300 } | |
301 | |
302 void InterpreterMacroAssembler::push(TosState state) { | |
303 switch (state) { | |
304 case atos: push_ptr(); break; | |
305 case btos: | |
306 case ctos: | |
307 case stos: | |
308 case itos: push_i(); break; | |
309 case ltos: push_l(); break; | |
310 case ftos: push_f(); break; | |
311 case dtos: push_d(); break; | |
312 case vtos: /* nothing to do */ break; | |
313 default : ShouldNotReachHere(); | |
314 } | |
315 } | |
316 | |
317 void InterpreterMacroAssembler::pop(TosState state) { | |
318 switch (state) { | |
319 case atos: pop_ptr(); break; | |
320 case btos: | |
321 case ctos: | |
322 case stos: | |
323 case itos: pop_i(); break; | |
324 case ltos: pop_l(); break; | |
325 case ftos: pop_f(); break; | |
326 case dtos: pop_d(); break; | |
327 case vtos: /* nothing to do */ break; | |
328 default : ShouldNotReachHere(); | |
329 } | |
330 verify_oop(R17_tos, state); | |
331 } | |
332 | |
333 void InterpreterMacroAssembler::empty_expression_stack() { | |
334 addi(R15_esp, R26_monitor, - Interpreter::stackElementSize); | |
335 } | |
336 | |
337 void InterpreterMacroAssembler::get_2_byte_integer_at_bcp(int bcp_offset, | |
338 Register Rdst, | |
339 signedOrNot is_signed) { | |
20418
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
340 #if defined(VM_LITTLE_ENDIAN) |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
341 if (bcp_offset) { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
342 load_const_optimized(Rdst, bcp_offset); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
343 lhbrx(Rdst, R14_bcp, Rdst); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
344 } else { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
345 lhbrx(Rdst, R14_bcp); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
346 } |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
347 if (is_signed == Signed) { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
348 extsh(Rdst, Rdst); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
349 } |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
350 #else |
17804 | 351 // Read Java big endian format. |
352 if (is_signed == Signed) { | |
353 lha(Rdst, bcp_offset, R14_bcp); | |
354 } else { | |
355 lhz(Rdst, bcp_offset, R14_bcp); | |
356 } | |
357 #endif | |
358 } | |
359 | |
360 void InterpreterMacroAssembler::get_4_byte_integer_at_bcp(int bcp_offset, | |
361 Register Rdst, | |
362 signedOrNot is_signed) { | |
20418
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
363 #if defined(VM_LITTLE_ENDIAN) |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
364 if (bcp_offset) { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
365 load_const_optimized(Rdst, bcp_offset); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
366 lwbrx(Rdst, R14_bcp, Rdst); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
367 } else { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
368 lwbrx(Rdst, R14_bcp); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
369 } |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
370 if (is_signed == Signed) { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
371 extsw(Rdst, Rdst); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
372 } |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
373 #else |
17804 | 374 // Read Java big endian format. |
375 if (bcp_offset & 3) { // Offset unaligned? | |
376 load_const_optimized(Rdst, bcp_offset); | |
377 if (is_signed == Signed) { | |
378 lwax(Rdst, R14_bcp, Rdst); | |
379 } else { | |
380 lwzx(Rdst, R14_bcp, Rdst); | |
381 } | |
382 } else { | |
383 if (is_signed == Signed) { | |
384 lwa(Rdst, bcp_offset, R14_bcp); | |
385 } else { | |
386 lwz(Rdst, bcp_offset, R14_bcp); | |
387 } | |
388 } | |
20418
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
389 #endif |
17804 | 390 } |
391 | |
20418
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
392 |
17804 | 393 // Load the constant pool cache index from the bytecode stream. |
394 // | |
395 // Kills / writes: | |
396 // - Rdst, Rscratch | |
397 void InterpreterMacroAssembler::get_cache_index_at_bcp(Register Rdst, int bcp_offset, size_t index_size) { | |
398 assert(bcp_offset > 0, "bcp is still pointing to start of bytecode"); | |
20418
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
399 // Cache index is always in the native format, courtesy of Rewriter. |
17804 | 400 if (index_size == sizeof(u2)) { |
20418
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
401 lhz(Rdst, bcp_offset, R14_bcp); |
17804 | 402 } else if (index_size == sizeof(u4)) { |
403 assert(EnableInvokeDynamic, "giant index used only for JSR 292"); | |
20418
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
404 if (bcp_offset & 3) { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
405 load_const_optimized(Rdst, bcp_offset); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
406 lwax(Rdst, R14_bcp, Rdst); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
407 } else { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
408 lwa(Rdst, bcp_offset, R14_bcp); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
409 } |
17804 | 410 assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line"); |
411 nand(Rdst, Rdst, Rdst); // convert to plain index | |
412 } else if (index_size == sizeof(u1)) { | |
413 lbz(Rdst, bcp_offset, R14_bcp); | |
414 } else { | |
415 ShouldNotReachHere(); | |
416 } | |
417 // Rdst now contains cp cache index. | |
418 } | |
419 | |
420 void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, int bcp_offset, size_t index_size) { | |
421 get_cache_index_at_bcp(cache, bcp_offset, index_size); | |
422 sldi(cache, cache, exact_log2(in_words(ConstantPoolCacheEntry::size()) * BytesPerWord)); | |
423 add(cache, R27_constPoolCache, cache); | |
424 } | |
425 | |
20418
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
426 // Load 4-byte signed or unsigned integer in Java format (that is, big-endian format) |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
427 // from (Rsrc)+offset. |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
428 void InterpreterMacroAssembler::get_u4(Register Rdst, Register Rsrc, int offset, |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
429 signedOrNot is_signed) { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
430 #if defined(VM_LITTLE_ENDIAN) |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
431 if (offset) { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
432 load_const_optimized(Rdst, offset); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
433 lwbrx(Rdst, Rdst, Rsrc); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
434 } else { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
435 lwbrx(Rdst, Rsrc); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
436 } |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
437 if (is_signed == Signed) { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
438 extsw(Rdst, Rdst); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
439 } |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
440 #else |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
441 if (is_signed == Signed) { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
442 lwa(Rdst, offset, Rsrc); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
443 } else { |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
444 lwz(Rdst, offset, Rsrc); |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
445 } |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
446 #endif |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
447 } |
b384ba33c9a0
8050942: PPC64: implement template interpreter for ppc64le
kvn
parents:
17804
diff
changeset
|
448 |
17804 | 449 // Load object from cpool->resolved_references(index). |
450 void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index) { | |
451 assert_different_registers(result, index); | |
452 get_constant_pool(result); | |
453 | |
454 // Convert from field index to resolved_references() index and from | |
455 // word index to byte offset. Since this is a java object, it can be compressed. | |
456 Register tmp = index; // reuse | |
457 sldi(tmp, index, LogBytesPerHeapOop); | |
458 // Load pointer for resolved_references[] objArray. | |
459 ld(result, ConstantPool::resolved_references_offset_in_bytes(), result); | |
460 // JNIHandles::resolve(result) | |
461 ld(result, 0, result); | |
462 #ifdef ASSERT | |
463 Label index_ok; | |
464 lwa(R0, arrayOopDesc::length_offset_in_bytes(), result); | |
465 sldi(R0, R0, LogBytesPerHeapOop); | |
466 cmpd(CCR0, tmp, R0); | |
467 blt(CCR0, index_ok); | |
468 stop("resolved reference index out of bounds", 0x09256); | |
469 bind(index_ok); | |
470 #endif | |
471 // Add in the index. | |
472 add(result, tmp, result); | |
473 load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result); | |
474 } | |
475 | |
476 // Generate a subtype check: branch to ok_is_subtype if sub_klass is | |
477 // a subtype of super_klass. Blows registers Rsub_klass, tmp1, tmp2. | |
478 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass, Register Rsuper_klass, Register Rtmp1, | |
479 Register Rtmp2, Register Rtmp3, Label &ok_is_subtype) { | |
480 // Profile the not-null value's klass. | |
481 profile_typecheck(Rsub_klass, Rtmp1, Rtmp2); | |
482 check_klass_subtype(Rsub_klass, Rsuper_klass, Rtmp1, Rtmp2, ok_is_subtype); | |
483 profile_typecheck_failed(Rtmp1, Rtmp2); | |
484 } | |
485 | |
486 void InterpreterMacroAssembler::generate_stack_overflow_check_with_compare_and_throw(Register Rmem_frame_size, Register Rscratch1) { | |
487 Label done; | |
488 sub(Rmem_frame_size, R1_SP, Rmem_frame_size); | |
489 ld(Rscratch1, thread_(stack_overflow_limit)); | |
490 cmpld(CCR0/*is_stack_overflow*/, Rmem_frame_size, Rscratch1); | |
491 bgt(CCR0/*is_stack_overflow*/, done); | |
492 | |
493 // Load target address of the runtime stub. | |
494 assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "generated in wrong order"); | |
495 load_const_optimized(Rscratch1, (StubRoutines::throw_StackOverflowError_entry()), R0); | |
496 mtctr(Rscratch1); | |
497 // Restore caller_sp. | |
498 #ifdef ASSERT | |
499 ld(Rscratch1, 0, R1_SP); | |
500 ld(R0, 0, R21_sender_SP); | |
501 cmpd(CCR0, R0, Rscratch1); | |
502 asm_assert_eq("backlink", 0x547); | |
503 #endif // ASSERT | |
504 mr(R1_SP, R21_sender_SP); | |
505 bctr(); | |
506 | |
507 align(32, 12); | |
508 bind(done); | |
509 } | |
510 | |
511 // Separate these two to allow for delay slot in middle. | |
512 // These are used to do a test and full jump to exception-throwing code. | |
513 | |
514 // Check that index is in range for array, then shift index by index_shift, | |
515 // and put arrayOop + shifted_index into res. | |
516 // Note: res is still shy of address by array offset into object. | |
517 | |
518 void InterpreterMacroAssembler::index_check_without_pop(Register Rarray, Register Rindex, int index_shift, Register Rtmp, Register Rres) { | |
519 // Check that index is in range for array, then shift index by index_shift, | |
520 // and put arrayOop + shifted_index into res. | |
521 // Note: res is still shy of address by array offset into object. | |
522 // Kills: | |
523 // - Rindex | |
524 // Writes: | |
525 // - Rres: Address that corresponds to the array index if check was successful. | |
526 verify_oop(Rarray); | |
527 const Register Rlength = R0; | |
528 const Register RsxtIndex = Rtmp; | |
529 Label LisNull, LnotOOR; | |
530 | |
531 // Array nullcheck | |
532 if (!ImplicitNullChecks) { | |
533 cmpdi(CCR0, Rarray, 0); | |
534 beq(CCR0, LisNull); | |
535 } else { | |
536 null_check_throw(Rarray, arrayOopDesc::length_offset_in_bytes(), /*temp*/RsxtIndex); | |
537 } | |
538 | |
539 // Rindex might contain garbage in upper bits (remember that we don't sign extend | |
540 // during integer arithmetic operations). So kill them and put value into same register | |
541 // where ArrayIndexOutOfBounds would expect the index in. | |
542 rldicl(RsxtIndex, Rindex, 0, 32); // zero extend 32 bit -> 64 bit | |
543 | |
544 // Index check | |
545 lwz(Rlength, arrayOopDesc::length_offset_in_bytes(), Rarray); | |
546 cmplw(CCR0, Rindex, Rlength); | |
547 sldi(RsxtIndex, RsxtIndex, index_shift); | |
548 blt(CCR0, LnotOOR); | |
549 load_dispatch_table(Rtmp, (address*)Interpreter::_throw_ArrayIndexOutOfBoundsException_entry); | |
550 mtctr(Rtmp); | |
551 bctr(); | |
552 | |
553 if (!ImplicitNullChecks) { | |
554 bind(LisNull); | |
555 load_dispatch_table(Rtmp, (address*)Interpreter::_throw_NullPointerException_entry); | |
556 mtctr(Rtmp); | |
557 bctr(); | |
558 } | |
559 | |
560 align(32, 16); | |
561 bind(LnotOOR); | |
562 | |
563 // Calc address | |
564 add(Rres, RsxtIndex, Rarray); | |
565 } | |
566 | |
567 void InterpreterMacroAssembler::index_check(Register array, Register index, int index_shift, Register tmp, Register res) { | |
568 // pop array | |
569 pop_ptr(array); | |
570 | |
571 // check array | |
572 index_check_without_pop(array, index, index_shift, tmp, res); | |
573 } | |
574 | |
575 void InterpreterMacroAssembler::get_const(Register Rdst) { | |
576 ld(Rdst, in_bytes(Method::const_offset()), R19_method); | |
577 } | |
578 | |
579 void InterpreterMacroAssembler::get_constant_pool(Register Rdst) { | |
580 get_const(Rdst); | |
581 ld(Rdst, in_bytes(ConstMethod::constants_offset()), Rdst); | |
582 } | |
583 | |
584 void InterpreterMacroAssembler::get_constant_pool_cache(Register Rdst) { | |
585 get_constant_pool(Rdst); | |
586 ld(Rdst, ConstantPool::cache_offset_in_bytes(), Rdst); | |
587 } | |
588 | |
589 void InterpreterMacroAssembler::get_cpool_and_tags(Register Rcpool, Register Rtags) { | |
590 get_constant_pool(Rcpool); | |
591 ld(Rtags, ConstantPool::tags_offset_in_bytes(), Rcpool); | |
592 } | |
593 | |
594 // Unlock if synchronized method. | |
595 // | |
596 // Unlock the receiver if this is a synchronized method. | |
597 // Unlock any Java monitors from synchronized blocks. | |
598 // | |
599 // If there are locked Java monitors | |
600 // If throw_monitor_exception | |
601 // throws IllegalMonitorStateException | |
602 // Else if install_monitor_exception | |
603 // installs IllegalMonitorStateException | |
604 // Else | |
605 // no error processing | |
606 void InterpreterMacroAssembler::unlock_if_synchronized_method(TosState state, | |
607 bool throw_monitor_exception, | |
608 bool install_monitor_exception) { | |
609 Label Lunlocked, Lno_unlock; | |
610 { | |
611 Register Rdo_not_unlock_flag = R11_scratch1; | |
612 Register Raccess_flags = R12_scratch2; | |
613 | |
614 // Check if synchronized method or unlocking prevented by | |
615 // JavaThread::do_not_unlock_if_synchronized flag. | |
616 lbz(Rdo_not_unlock_flag, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread); | |
617 lwz(Raccess_flags, in_bytes(Method::access_flags_offset()), R19_method); | |
618 li(R0, 0); | |
619 stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread); // reset flag | |
620 | |
621 push(state); | |
622 | |
623 // Skip if we don't have to unlock. | |
624 rldicl_(R0, Raccess_flags, 64-JVM_ACC_SYNCHRONIZED_BIT, 63); // Extract bit and compare to 0. | |
625 beq(CCR0, Lunlocked); | |
626 | |
627 cmpwi(CCR0, Rdo_not_unlock_flag, 0); | |
628 bne(CCR0, Lno_unlock); | |
629 } | |
630 | |
631 // Unlock | |
632 { | |
633 Register Rmonitor_base = R11_scratch1; | |
634 | |
635 Label Lunlock; | |
636 // If it's still locked, everything is ok, unlock it. | |
637 ld(Rmonitor_base, 0, R1_SP); | |
638 addi(Rmonitor_base, Rmonitor_base, - (frame::ijava_state_size + frame::interpreter_frame_monitor_size_in_bytes())); // Monitor base | |
639 | |
640 ld(R0, BasicObjectLock::obj_offset_in_bytes(), Rmonitor_base); | |
641 cmpdi(CCR0, R0, 0); | |
642 bne(CCR0, Lunlock); | |
643 | |
644 // If it's already unlocked, throw exception. | |
645 if (throw_monitor_exception) { | |
646 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception)); | |
647 should_not_reach_here(); | |
648 } else { | |
649 if (install_monitor_exception) { | |
650 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::new_illegal_monitor_state_exception)); | |
651 b(Lunlocked); | |
652 } | |
653 } | |
654 | |
655 bind(Lunlock); | |
656 unlock_object(Rmonitor_base); | |
657 } | |
658 | |
659 // Check that all other monitors are unlocked. Throw IllegelMonitorState exception if not. | |
660 bind(Lunlocked); | |
661 { | |
662 Label Lexception, Lrestart; | |
663 Register Rcurrent_obj_addr = R11_scratch1; | |
664 const int delta = frame::interpreter_frame_monitor_size_in_bytes(); | |
665 assert((delta & LongAlignmentMask) == 0, "sizeof BasicObjectLock must be even number of doublewords"); | |
666 | |
667 bind(Lrestart); | |
668 // Set up search loop: Calc num of iterations. | |
669 { | |
670 Register Riterations = R12_scratch2; | |
671 Register Rmonitor_base = Rcurrent_obj_addr; | |
672 ld(Rmonitor_base, 0, R1_SP); | |
673 addi(Rmonitor_base, Rmonitor_base, - frame::ijava_state_size); // Monitor base | |
674 | |
675 subf_(Riterations, R26_monitor, Rmonitor_base); | |
676 ble(CCR0, Lno_unlock); | |
677 | |
678 addi(Rcurrent_obj_addr, Rmonitor_base, BasicObjectLock::obj_offset_in_bytes() - frame::interpreter_frame_monitor_size_in_bytes()); | |
679 // Check if any monitor is on stack, bail out if not | |
680 srdi(Riterations, Riterations, exact_log2(delta)); | |
681 mtctr(Riterations); | |
682 } | |
683 | |
684 // The search loop: Look for locked monitors. | |
685 { | |
686 const Register Rcurrent_obj = R0; | |
687 Label Lloop; | |
688 | |
689 ld(Rcurrent_obj, 0, Rcurrent_obj_addr); | |
690 addi(Rcurrent_obj_addr, Rcurrent_obj_addr, -delta); | |
691 bind(Lloop); | |
692 | |
693 // Check if current entry is used. | |
694 cmpdi(CCR0, Rcurrent_obj, 0); | |
695 bne(CCR0, Lexception); | |
696 // Preload next iteration's compare value. | |
697 ld(Rcurrent_obj, 0, Rcurrent_obj_addr); | |
698 addi(Rcurrent_obj_addr, Rcurrent_obj_addr, -delta); | |
699 bdnz(Lloop); | |
700 } | |
701 // Fell through: Everything's unlocked => finish. | |
702 b(Lno_unlock); | |
703 | |
704 // An object is still locked => need to throw exception. | |
705 bind(Lexception); | |
706 if (throw_monitor_exception) { | |
707 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception)); | |
708 should_not_reach_here(); | |
709 } else { | |
710 // Stack unrolling. Unlock object and if requested, install illegal_monitor_exception. | |
711 // Unlock does not block, so don't have to worry about the frame. | |
712 Register Rmonitor_addr = R11_scratch1; | |
713 addi(Rmonitor_addr, Rcurrent_obj_addr, -BasicObjectLock::obj_offset_in_bytes() + delta); | |
714 unlock_object(Rmonitor_addr); | |
715 if (install_monitor_exception) { | |
716 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::new_illegal_monitor_state_exception)); | |
717 } | |
718 b(Lrestart); | |
719 } | |
720 } | |
721 | |
722 align(32, 12); | |
723 bind(Lno_unlock); | |
724 pop(state); | |
725 } | |
726 | |
727 // Support function for remove_activation & Co. | |
728 void InterpreterMacroAssembler::merge_frames(Register Rsender_sp, Register return_pc, Register Rscratch1, Register Rscratch2) { | |
729 // Pop interpreter frame. | |
730 ld(Rscratch1, 0, R1_SP); // *SP | |
731 ld(Rsender_sp, _ijava_state_neg(sender_sp), Rscratch1); // top_frame_sp | |
732 ld(Rscratch2, 0, Rscratch1); // **SP | |
733 #ifdef ASSERT | |
734 { | |
735 Label Lok; | |
736 ld(R0, _ijava_state_neg(ijava_reserved), Rscratch1); | |
737 cmpdi(CCR0, R0, 0x5afe); | |
738 beq(CCR0, Lok); | |
739 stop("frame corrupted (remove activation)", 0x5afe); | |
740 bind(Lok); | |
741 } | |
742 #endif | |
743 if (return_pc!=noreg) { | |
744 ld(return_pc, _abi(lr), Rscratch1); // LR | |
745 } | |
746 | |
747 // Merge top frames. | |
748 subf(Rscratch1, R1_SP, Rsender_sp); // top_frame_sp - SP | |
749 stdux(Rscratch2, R1_SP, Rscratch1); // atomically set *(SP = top_frame_sp) = **SP | |
750 } | |
751 | |
752 // Remove activation. | |
753 // | |
754 // Unlock the receiver if this is a synchronized method. | |
755 // Unlock any Java monitors from synchronized blocks. | |
756 // Remove the activation from the stack. | |
757 // | |
758 // If there are locked Java monitors | |
759 // If throw_monitor_exception | |
760 // throws IllegalMonitorStateException | |
761 // Else if install_monitor_exception | |
762 // installs IllegalMonitorStateException | |
763 // Else | |
764 // no error processing | |
765 void InterpreterMacroAssembler::remove_activation(TosState state, | |
766 bool throw_monitor_exception, | |
767 bool install_monitor_exception) { | |
768 unlock_if_synchronized_method(state, throw_monitor_exception, install_monitor_exception); | |
769 | |
770 // Save result (push state before jvmti call and pop it afterwards) and notify jvmti. | |
771 notify_method_exit(false, state, NotifyJVMTI, true); | |
772 | |
773 verify_oop(R17_tos, state); | |
774 verify_thread(); | |
775 | |
776 merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ R0, R11_scratch1, R12_scratch2); | |
777 mtlr(R0); | |
778 } | |
779 | |
780 #endif // !CC_INTERP | |
781 | |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
782 // Lock object |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
783 // |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
784 // Registers alive |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
785 // monitor - Address of the BasicObjectLock to be used for locking, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
786 // which must be initialized with the object to lock. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
787 // object - Address of the object to be locked. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
788 // |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
789 void InterpreterMacroAssembler::lock_object(Register monitor, Register object) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
790 if (UseHeavyMonitors) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
791 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), |
14445 | 792 monitor, /*check_for_exceptions=*/true CC_INTERP_ONLY(&& false)); |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
793 } else { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
794 // template code: |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
795 // |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
796 // markOop displaced_header = obj->mark().set_unlocked(); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
797 // monitor->lock()->set_displaced_header(displaced_header); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
798 // if (Atomic::cmpxchg_ptr(/*ex=*/monitor, /*addr*/obj->mark_addr(), /*cmp*/displaced_header) == displaced_header) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
799 // // We stored the monitor address into the object's mark word. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
800 // } else if (THREAD->is_lock_owned((address)displaced_header)) |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
801 // // Simple recursive case. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
802 // monitor->lock()->set_displaced_header(NULL); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
803 // } else { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
804 // // Slow path. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
805 // InterpreterRuntime::monitorenter(THREAD, monitor); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
806 // } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
807 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
808 const Register displaced_header = R7_ARG5; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
809 const Register object_mark_addr = R8_ARG6; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
810 const Register current_header = R9_ARG7; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
811 const Register tmp = R10_ARG8; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
812 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
813 Label done; |
14445 | 814 Label cas_failed, slow_case; |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
815 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
816 assert_different_registers(displaced_header, object_mark_addr, current_header, tmp); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
817 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
818 // markOop displaced_header = obj->mark().set_unlocked(); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
819 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
820 // Load markOop from object into displaced_header. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
821 ld(displaced_header, oopDesc::mark_offset_in_bytes(), object); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
822 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
823 if (UseBiasedLocking) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
824 biased_locking_enter(CCR0, object, displaced_header, tmp, current_header, done, &slow_case); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
825 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
826 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
827 // Set displaced_header to be (markOop of object | UNLOCK_VALUE). |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
828 ori(displaced_header, displaced_header, markOopDesc::unlocked_value); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
829 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
830 // monitor->lock()->set_displaced_header(displaced_header); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
831 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
832 // Initialize the box (Must happen before we update the object mark!). |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
833 std(displaced_header, BasicObjectLock::lock_offset_in_bytes() + |
14445 | 834 BasicLock::displaced_header_offset_in_bytes(), monitor); |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
835 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
836 // if (Atomic::cmpxchg_ptr(/*ex=*/monitor, /*addr*/obj->mark_addr(), /*cmp*/displaced_header) == displaced_header) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
837 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
838 // Store stack address of the BasicObjectLock (this is monitor) into object. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
839 addi(object_mark_addr, object, oopDesc::mark_offset_in_bytes()); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
840 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
841 // Must fence, otherwise, preceding store(s) may float below cmpxchg. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
842 // CmpxchgX sets CCR0 to cmpX(current, displaced). |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
843 fence(); // TODO: replace by MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq ? |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
844 cmpxchgd(/*flag=*/CCR0, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
845 /*current_value=*/current_header, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
846 /*compare_value=*/displaced_header, /*exchange_value=*/monitor, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
847 /*where=*/object_mark_addr, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
848 MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq, |
14445 | 849 MacroAssembler::cmpxchgx_hint_acquire_lock(), |
850 noreg, | |
851 &cas_failed); | |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
852 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
853 // If the compare-and-exchange succeeded, then we found an unlocked |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
854 // object and we have now locked it. |
14445 | 855 b(done); |
856 bind(cas_failed); | |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
857 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
858 // } else if (THREAD->is_lock_owned((address)displaced_header)) |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
859 // // Simple recursive case. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
860 // monitor->lock()->set_displaced_header(NULL); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
861 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
862 // We did not see an unlocked object so try the fast recursive case. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
863 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
864 // Check if owner is self by comparing the value in the markOop of object |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
865 // (current_header) with the stack pointer. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
866 sub(current_header, current_header, R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
867 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
868 assert(os::vm_page_size() > 0xfff, "page size too small - change the constant"); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
869 load_const_optimized(tmp, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
870 (address) (~(os::vm_page_size()-1) | |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
871 markOopDesc::lock_mask_in_place)); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
872 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
873 and_(R0/*==0?*/, current_header, tmp); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
874 // If condition is true we are done and hence we can store 0 in the displaced |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
875 // header indicating it is a recursive lock. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
876 bne(CCR0, slow_case); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
877 release(); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
878 std(R0/*==0!*/, BasicObjectLock::lock_offset_in_bytes() + |
14445 | 879 BasicLock::displaced_header_offset_in_bytes(), monitor); |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
880 b(done); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
881 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
882 // } else { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
883 // // Slow path. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
884 // InterpreterRuntime::monitorenter(THREAD, monitor); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
885 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
886 // None of the above fast optimizations worked so we have to get into the |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
887 // slow case of monitor enter. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
888 bind(slow_case); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
889 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), |
14445 | 890 monitor, /*check_for_exceptions=*/true CC_INTERP_ONLY(&& false)); |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
891 // } |
17804 | 892 align(32, 12); |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
893 bind(done); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
894 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
895 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
896 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
897 // Unlocks an object. Used in monitorexit bytecode and remove_activation. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
898 // |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
899 // Registers alive |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
900 // monitor - Address of the BasicObjectLock to be used for locking, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
901 // which must be initialized with the object to lock. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
902 // |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
903 // Throw IllegalMonitorException if object is not locked by current thread. |
14445 | 904 void InterpreterMacroAssembler::unlock_object(Register monitor, bool check_for_exceptions) { |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
905 if (UseHeavyMonitors) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
906 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), |
17804 | 907 monitor, check_for_exceptions CC_INTERP_ONLY(&& false)); |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
908 } else { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
909 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
910 // template code: |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
911 // |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
912 // if ((displaced_header = monitor->displaced_header()) == NULL) { |
17804 | 913 // // Recursive unlock. Mark the monitor unlocked by setting the object field to NULL. |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
914 // monitor->set_obj(NULL); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
915 // } else if (Atomic::cmpxchg_ptr(displaced_header, obj->mark_addr(), monitor) == monitor) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
916 // // We swapped the unlocked mark in displaced_header into the object's mark word. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
917 // monitor->set_obj(NULL); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
918 // } else { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
919 // // Slow path. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
920 // InterpreterRuntime::monitorexit(THREAD, monitor); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
921 // } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
922 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
923 const Register object = R7_ARG5; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
924 const Register displaced_header = R8_ARG6; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
925 const Register object_mark_addr = R9_ARG7; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
926 const Register current_header = R10_ARG8; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
927 |
14445 | 928 Label free_slot; |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
929 Label slow_case; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
930 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
931 assert_different_registers(object, displaced_header, object_mark_addr, current_header); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
932 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
933 if (UseBiasedLocking) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
934 // The object address from the monitor is in object. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
935 ld(object, BasicObjectLock::obj_offset_in_bytes(), monitor); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
936 assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0"); |
14445 | 937 biased_locking_exit(CCR0, object, displaced_header, free_slot); |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
938 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
939 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
940 // Test first if we are in the fast recursive case. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
941 ld(displaced_header, BasicObjectLock::lock_offset_in_bytes() + |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
942 BasicLock::displaced_header_offset_in_bytes(), monitor); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
943 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
944 // If the displaced header is zero, we have a recursive unlock. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
945 cmpdi(CCR0, displaced_header, 0); |
14445 | 946 beq(CCR0, free_slot); // recursive unlock |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
947 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
948 // } else if (Atomic::cmpxchg_ptr(displaced_header, obj->mark_addr(), monitor) == monitor) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
949 // // We swapped the unlocked mark in displaced_header into the object's mark word. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
950 // monitor->set_obj(NULL); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
951 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
952 // If we still have a lightweight lock, unlock the object and be done. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
953 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
954 // The object address from the monitor is in object. |
17804 | 955 if (!UseBiasedLocking) { ld(object, BasicObjectLock::obj_offset_in_bytes(), monitor); } |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
956 addi(object_mark_addr, object, oopDesc::mark_offset_in_bytes()); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
957 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
958 // We have the displaced header in displaced_header. If the lock is still |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
959 // lightweight, it will contain the monitor address and we'll store the |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
960 // displaced header back into the object's mark word. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
961 // CmpxchgX sets CCR0 to cmpX(current, monitor). |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
962 cmpxchgd(/*flag=*/CCR0, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
963 /*current_value=*/current_header, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
964 /*compare_value=*/monitor, /*exchange_value=*/displaced_header, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
965 /*where=*/object_mark_addr, |
14445 | 966 MacroAssembler::MemBarRel, |
967 MacroAssembler::cmpxchgx_hint_release_lock(), | |
968 noreg, | |
969 &slow_case); | |
970 b(free_slot); | |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
971 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
972 // } else { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
973 // // Slow path. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
974 // InterpreterRuntime::monitorexit(THREAD, monitor); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
975 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
976 // The lock has been converted into a heavy lock and hence |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
977 // we need to get into the slow case. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
978 bind(slow_case); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
979 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), |
14445 | 980 monitor, check_for_exceptions CC_INTERP_ONLY(&& false)); |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
981 // } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
982 |
14445 | 983 Label done; |
984 b(done); // Monitor register may be overwritten! Runtime has already freed the slot. | |
985 | |
986 // Exchange worked, do monitor->set_obj(NULL); | |
987 align(32, 12); | |
988 bind(free_slot); | |
989 li(R0, 0); | |
990 std(R0, BasicObjectLock::obj_offset_in_bytes(), monitor); | |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
991 bind(done); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
992 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
993 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
994 |
17804 | 995 #ifndef CC_INTERP |
996 | |
997 // Load compiled (i2c) or interpreter entry when calling from interpreted and | |
998 // do the call. Centralized so that all interpreter calls will do the same actions. | |
999 // If jvmti single stepping is on for a thread we must not call compiled code. | |
1000 // | |
1001 // Input: | |
1002 // - Rtarget_method: method to call | |
1003 // - Rret_addr: return address | |
1004 // - 2 scratch regs | |
1005 // | |
1006 void InterpreterMacroAssembler::call_from_interpreter(Register Rtarget_method, Register Rret_addr, Register Rscratch1, Register Rscratch2) { | |
1007 assert_different_registers(Rscratch1, Rscratch2, Rtarget_method, Rret_addr); | |
1008 // Assume we want to go compiled if available. | |
1009 const Register Rtarget_addr = Rscratch1; | |
1010 const Register Rinterp_only = Rscratch2; | |
1011 | |
1012 ld(Rtarget_addr, in_bytes(Method::from_interpreted_offset()), Rtarget_method); | |
1013 | |
1014 if (JvmtiExport::can_post_interpreter_events()) { | |
1015 lwz(Rinterp_only, in_bytes(JavaThread::interp_only_mode_offset()), R16_thread); | |
1016 | |
1017 // JVMTI events, such as single-stepping, are implemented partly by avoiding running | |
1018 // compiled code in threads for which the event is enabled. Check here for | |
1019 // interp_only_mode if these events CAN be enabled. | |
1020 Label done; | |
1021 verify_thread(); | |
1022 cmpwi(CCR0, Rinterp_only, 0); | |
1023 beq(CCR0, done); | |
1024 ld(Rtarget_addr, in_bytes(Method::interpreter_entry_offset()), Rtarget_method); | |
1025 align(32, 12); | |
1026 bind(done); | |
1027 } | |
1028 | |
1029 #ifdef ASSERT | |
1030 { | |
1031 Label Lok; | |
1032 cmpdi(CCR0, Rtarget_addr, 0); | |
1033 bne(CCR0, Lok); | |
1034 stop("null entry point"); | |
1035 bind(Lok); | |
1036 } | |
1037 #endif // ASSERT | |
1038 | |
1039 mr(R21_sender_SP, R1_SP); | |
1040 | |
1041 // Calc a precise SP for the call. The SP value we calculated in | |
1042 // generate_fixed_frame() is based on the max_stack() value, so we would waste stack space | |
1043 // if esp is not max. Also, the i2c adapter extends the stack space without restoring | |
1044 // our pre-calced value, so repeating calls via i2c would result in stack overflow. | |
1045 // Since esp already points to an empty slot, we just have to sub 1 additional slot | |
1046 // to meet the abi scratch requirements. | |
1047 // The max_stack pointer will get restored by means of the GR_Lmax_stack local in | |
1048 // the return entry of the interpreter. | |
1049 addi(Rscratch2, R15_esp, Interpreter::stackElementSize - frame::abi_reg_args_size); | |
1050 clrrdi(Rscratch2, Rscratch2, exact_log2(frame::alignment_in_bytes)); // round towards smaller address | |
1051 resize_frame_absolute(Rscratch2, Rscratch2, R0); | |
1052 | |
1053 mr_if_needed(R19_method, Rtarget_method); | |
1054 mtctr(Rtarget_addr); | |
1055 mtlr(Rret_addr); | |
1056 | |
1057 save_interpreter_state(Rscratch2); | |
1058 #ifdef ASSERT | |
1059 ld(Rscratch1, _ijava_state_neg(top_frame_sp), Rscratch2); // Rscratch2 contains fp | |
1060 cmpd(CCR0, R21_sender_SP, Rscratch1); | |
1061 asm_assert_eq("top_frame_sp incorrect", 0x951); | |
1062 #endif | |
1063 | |
1064 bctr(); | |
1065 } | |
1066 | |
1067 // Set the method data pointer for the current bcp. | |
1068 void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() { | |
1069 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1070 Label get_continue; | |
1071 ld(R28_mdx, in_bytes(Method::method_data_offset()), R19_method); | |
1072 test_method_data_pointer(get_continue); | |
1073 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), R19_method, R14_bcp); | |
1074 | |
1075 addi(R28_mdx, R28_mdx, in_bytes(MethodData::data_offset())); | |
1076 add(R28_mdx, R28_mdx, R3_RET); | |
1077 bind(get_continue); | |
1078 } | |
1079 | |
1080 // Test ImethodDataPtr. If it is null, continue at the specified label. | |
1081 void InterpreterMacroAssembler::test_method_data_pointer(Label& zero_continue) { | |
1082 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1083 cmpdi(CCR0, R28_mdx, 0); | |
1084 beq(CCR0, zero_continue); | |
1085 } | |
1086 | |
1087 void InterpreterMacroAssembler::verify_method_data_pointer() { | |
1088 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1089 #ifdef ASSERT | |
1090 Label verify_continue; | |
1091 test_method_data_pointer(verify_continue); | |
1092 | |
1093 // If the mdp is valid, it will point to a DataLayout header which is | |
1094 // consistent with the bcp. The converse is highly probable also. | |
1095 lhz(R11_scratch1, in_bytes(DataLayout::bci_offset()), R28_mdx); | |
1096 ld(R12_scratch2, in_bytes(Method::const_offset()), R19_method); | |
1097 addi(R11_scratch1, R11_scratch1, in_bytes(ConstMethod::codes_offset())); | |
1098 add(R11_scratch1, R12_scratch2, R12_scratch2); | |
1099 cmpd(CCR0, R11_scratch1, R14_bcp); | |
1100 beq(CCR0, verify_continue); | |
1101 | |
1102 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp ), R19_method, R14_bcp, R28_mdx); | |
1103 | |
1104 bind(verify_continue); | |
1105 #endif | |
1106 } | |
1107 | |
1108 void InterpreterMacroAssembler::test_invocation_counter_for_mdp(Register invocation_count, | |
1109 Register Rscratch, | |
1110 Label &profile_continue) { | |
1111 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1112 // Control will flow to "profile_continue" if the counter is less than the | |
1113 // limit or if we call profile_method(). | |
1114 Label done; | |
1115 | |
1116 // If no method data exists, and the counter is high enough, make one. | |
1117 int ipl_offs = load_const_optimized(Rscratch, &InvocationCounter::InterpreterProfileLimit, R0, true); | |
1118 lwz(Rscratch, ipl_offs, Rscratch); | |
1119 | |
1120 cmpdi(CCR0, R28_mdx, 0); | |
1121 // Test to see if we should create a method data oop. | |
1122 cmpd(CCR1, Rscratch /* InterpreterProfileLimit */, invocation_count); | |
1123 bne(CCR0, done); | |
1124 bge(CCR1, profile_continue); | |
1125 | |
1126 // Build it now. | |
1127 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method)); | |
1128 set_method_data_pointer_for_bcp(); | |
1129 b(profile_continue); | |
1130 | |
1131 align(32, 12); | |
1132 bind(done); | |
1133 } | |
1134 | |
1135 void InterpreterMacroAssembler::test_backedge_count_for_osr(Register backedge_count, Register branch_bcp, Register Rtmp) { | |
1136 assert_different_registers(backedge_count, Rtmp, branch_bcp); | |
1137 assert(UseOnStackReplacement,"Must UseOnStackReplacement to test_backedge_count_for_osr"); | |
1138 | |
1139 Label did_not_overflow; | |
1140 Label overflow_with_error; | |
1141 | |
1142 int ibbl_offs = load_const_optimized(Rtmp, &InvocationCounter::InterpreterBackwardBranchLimit, R0, true); | |
1143 lwz(Rtmp, ibbl_offs, Rtmp); | |
1144 cmpw(CCR0, backedge_count, Rtmp); | |
1145 | |
1146 blt(CCR0, did_not_overflow); | |
1147 | |
1148 // When ProfileInterpreter is on, the backedge_count comes from the | |
1149 // methodDataOop, which value does not get reset on the call to | |
1150 // frequency_counter_overflow(). To avoid excessive calls to the overflow | |
1151 // routine while the method is being compiled, add a second test to make sure | |
1152 // the overflow function is called only once every overflow_frequency. | |
1153 if (ProfileInterpreter) { | |
1154 const int overflow_frequency = 1024; | |
1155 li(Rtmp, overflow_frequency-1); | |
1156 andr(Rtmp, Rtmp, backedge_count); | |
1157 cmpwi(CCR0, Rtmp, 0); | |
1158 bne(CCR0, did_not_overflow); | |
1159 } | |
1160 | |
1161 // Overflow in loop, pass branch bytecode. | |
1162 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), branch_bcp, true); | |
1163 | |
1164 // Was an OSR adapter generated? | |
1165 // O0 = osr nmethod | |
1166 cmpdi(CCR0, R3_RET, 0); | |
1167 beq(CCR0, overflow_with_error); | |
1168 | |
1169 // Has the nmethod been invalidated already? | |
1170 lwz(Rtmp, nmethod::entry_bci_offset(), R3_RET); | |
1171 cmpwi(CCR0, Rtmp, InvalidOSREntryBci); | |
1172 beq(CCR0, overflow_with_error); | |
1173 | |
1174 // Migrate the interpreter frame off of the stack. | |
1175 // We can use all registers because we will not return to interpreter from this point. | |
1176 | |
1177 // Save nmethod. | |
1178 const Register osr_nmethod = R31; | |
1179 mr(osr_nmethod, R3_RET); | |
1180 set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R11_scratch1); | |
1181 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_begin), R16_thread); | |
1182 reset_last_Java_frame(); | |
1183 // OSR buffer is in ARG1 | |
1184 | |
1185 // Remove the interpreter frame. | |
1186 merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ R0, R11_scratch1, R12_scratch2); | |
1187 | |
1188 // Jump to the osr code. | |
1189 ld(R11_scratch1, nmethod::osr_entry_point_offset(), osr_nmethod); | |
1190 mtlr(R0); | |
1191 mtctr(R11_scratch1); | |
1192 bctr(); | |
1193 | |
1194 align(32, 12); | |
1195 bind(overflow_with_error); | |
1196 bind(did_not_overflow); | |
1197 } | |
1198 | |
1199 // Store a value at some constant offset from the method data pointer. | |
1200 void InterpreterMacroAssembler::set_mdp_data_at(int constant, Register value) { | |
1201 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1202 | |
1203 std(value, constant, R28_mdx); | |
1204 } | |
1205 | |
1206 // Increment the value at some constant offset from the method data pointer. | |
1207 void InterpreterMacroAssembler::increment_mdp_data_at(int constant, | |
1208 Register counter_addr, | |
1209 Register Rbumped_count, | |
1210 bool decrement) { | |
1211 // Locate the counter at a fixed offset from the mdp: | |
1212 addi(counter_addr, R28_mdx, constant); | |
1213 increment_mdp_data_at(counter_addr, Rbumped_count, decrement); | |
1214 } | |
1215 | |
1216 // Increment the value at some non-fixed (reg + constant) offset from | |
1217 // the method data pointer. | |
1218 void InterpreterMacroAssembler::increment_mdp_data_at(Register reg, | |
1219 int constant, | |
1220 Register scratch, | |
1221 Register Rbumped_count, | |
1222 bool decrement) { | |
1223 // Add the constant to reg to get the offset. | |
1224 add(scratch, R28_mdx, reg); | |
1225 // Then calculate the counter address. | |
1226 addi(scratch, scratch, constant); | |
1227 increment_mdp_data_at(scratch, Rbumped_count, decrement); | |
1228 } | |
1229 | |
1230 void InterpreterMacroAssembler::increment_mdp_data_at(Register counter_addr, | |
1231 Register Rbumped_count, | |
1232 bool decrement) { | |
1233 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1234 | |
1235 // Load the counter. | |
1236 ld(Rbumped_count, 0, counter_addr); | |
1237 | |
1238 if (decrement) { | |
1239 // Decrement the register. Set condition codes. | |
1240 addi(Rbumped_count, Rbumped_count, - DataLayout::counter_increment); | |
1241 // Store the decremented counter, if it is still negative. | |
1242 std(Rbumped_count, 0, counter_addr); | |
1243 // Note: add/sub overflow check are not ported, since 64 bit | |
1244 // calculation should never overflow. | |
1245 } else { | |
1246 // Increment the register. Set carry flag. | |
1247 addi(Rbumped_count, Rbumped_count, DataLayout::counter_increment); | |
1248 // Store the incremented counter. | |
1249 std(Rbumped_count, 0, counter_addr); | |
1250 } | |
1251 } | |
1252 | |
1253 // Set a flag value at the current method data pointer position. | |
1254 void InterpreterMacroAssembler::set_mdp_flag_at(int flag_constant, | |
1255 Register scratch) { | |
1256 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1257 // Load the data header. | |
1258 lbz(scratch, in_bytes(DataLayout::flags_offset()), R28_mdx); | |
1259 // Set the flag. | |
1260 ori(scratch, scratch, flag_constant); | |
1261 // Store the modified header. | |
1262 stb(scratch, in_bytes(DataLayout::flags_offset()), R28_mdx); | |
1263 } | |
1264 | |
1265 // Test the location at some offset from the method data pointer. | |
1266 // If it is not equal to value, branch to the not_equal_continue Label. | |
1267 void InterpreterMacroAssembler::test_mdp_data_at(int offset, | |
1268 Register value, | |
1269 Label& not_equal_continue, | |
1270 Register test_out) { | |
1271 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1272 | |
1273 ld(test_out, offset, R28_mdx); | |
1274 cmpd(CCR0, value, test_out); | |
1275 bne(CCR0, not_equal_continue); | |
1276 } | |
1277 | |
1278 // Update the method data pointer by the displacement located at some fixed | |
1279 // offset from the method data pointer. | |
1280 void InterpreterMacroAssembler::update_mdp_by_offset(int offset_of_disp, | |
1281 Register scratch) { | |
1282 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1283 | |
1284 ld(scratch, offset_of_disp, R28_mdx); | |
1285 add(R28_mdx, scratch, R28_mdx); | |
1286 } | |
1287 | |
1288 // Update the method data pointer by the displacement located at the | |
1289 // offset (reg + offset_of_disp). | |
1290 void InterpreterMacroAssembler::update_mdp_by_offset(Register reg, | |
1291 int offset_of_disp, | |
1292 Register scratch) { | |
1293 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1294 | |
1295 add(scratch, reg, R28_mdx); | |
1296 ld(scratch, offset_of_disp, scratch); | |
1297 add(R28_mdx, scratch, R28_mdx); | |
1298 } | |
1299 | |
1300 // Update the method data pointer by a simple constant displacement. | |
1301 void InterpreterMacroAssembler::update_mdp_by_constant(int constant) { | |
1302 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1303 addi(R28_mdx, R28_mdx, constant); | |
1304 } | |
1305 | |
1306 // Update the method data pointer for a _ret bytecode whose target | |
1307 // was not among our cached targets. | |
1308 void InterpreterMacroAssembler::update_mdp_for_ret(TosState state, | |
1309 Register return_bci) { | |
1310 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1311 | |
1312 push(state); | |
1313 assert(return_bci->is_nonvolatile(), "need to protect return_bci"); | |
1314 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret), return_bci); | |
1315 pop(state); | |
1316 } | |
1317 | |
1318 // Increments the backedge counter. | |
1319 // Returns backedge counter + invocation counter in Rdst. | |
1320 void InterpreterMacroAssembler::increment_backedge_counter(const Register Rcounters, const Register Rdst, | |
1321 const Register Rtmp1, Register Rscratch) { | |
1322 assert(UseCompiler, "incrementing must be useful"); | |
1323 assert_different_registers(Rdst, Rtmp1); | |
1324 const Register invocation_counter = Rtmp1; | |
1325 const Register counter = Rdst; | |
1326 // TODO ppc port assert(4 == InvocationCounter::sz_counter(), "unexpected field size."); | |
1327 | |
1328 // Load backedge counter. | |
1329 lwz(counter, in_bytes(MethodCounters::backedge_counter_offset()) + | |
1330 in_bytes(InvocationCounter::counter_offset()), Rcounters); | |
1331 // Load invocation counter. | |
1332 lwz(invocation_counter, in_bytes(MethodCounters::invocation_counter_offset()) + | |
1333 in_bytes(InvocationCounter::counter_offset()), Rcounters); | |
1334 | |
1335 // Add the delta to the backedge counter. | |
1336 addi(counter, counter, InvocationCounter::count_increment); | |
1337 | |
1338 // Mask the invocation counter. | |
1339 li(Rscratch, InvocationCounter::count_mask_value); | |
1340 andr(invocation_counter, invocation_counter, Rscratch); | |
1341 | |
1342 // Store new counter value. | |
1343 stw(counter, in_bytes(MethodCounters::backedge_counter_offset()) + | |
1344 in_bytes(InvocationCounter::counter_offset()), Rcounters); | |
1345 // Return invocation counter + backedge counter. | |
1346 add(counter, counter, invocation_counter); | |
1347 } | |
1348 | |
1349 // Count a taken branch in the bytecodes. | |
1350 void InterpreterMacroAssembler::profile_taken_branch(Register scratch, Register bumped_count) { | |
1351 if (ProfileInterpreter) { | |
1352 Label profile_continue; | |
1353 | |
1354 // If no method data exists, go to profile_continue. | |
1355 test_method_data_pointer(profile_continue); | |
1356 | |
1357 // We are taking a branch. Increment the taken count. | |
1358 increment_mdp_data_at(in_bytes(JumpData::taken_offset()), scratch, bumped_count); | |
1359 | |
1360 // The method data pointer needs to be updated to reflect the new target. | |
1361 update_mdp_by_offset(in_bytes(JumpData::displacement_offset()), scratch); | |
1362 bind (profile_continue); | |
1363 } | |
1364 } | |
1365 | |
1366 // Count a not-taken branch in the bytecodes. | |
1367 void InterpreterMacroAssembler::profile_not_taken_branch(Register scratch1, Register scratch2) { | |
1368 if (ProfileInterpreter) { | |
1369 Label profile_continue; | |
1370 | |
1371 // If no method data exists, go to profile_continue. | |
1372 test_method_data_pointer(profile_continue); | |
1373 | |
1374 // We are taking a branch. Increment the not taken count. | |
1375 increment_mdp_data_at(in_bytes(BranchData::not_taken_offset()), scratch1, scratch2); | |
1376 | |
1377 // The method data pointer needs to be updated to correspond to the | |
1378 // next bytecode. | |
1379 update_mdp_by_constant(in_bytes(BranchData::branch_data_size())); | |
1380 bind (profile_continue); | |
1381 } | |
1382 } | |
1383 | |
1384 // Count a non-virtual call in the bytecodes. | |
1385 void InterpreterMacroAssembler::profile_call(Register scratch1, Register scratch2) { | |
1386 if (ProfileInterpreter) { | |
1387 Label profile_continue; | |
1388 | |
1389 // If no method data exists, go to profile_continue. | |
1390 test_method_data_pointer(profile_continue); | |
1391 | |
1392 // We are making a call. Increment the count. | |
1393 increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch1, scratch2); | |
1394 | |
1395 // The method data pointer needs to be updated to reflect the new target. | |
1396 update_mdp_by_constant(in_bytes(CounterData::counter_data_size())); | |
1397 bind (profile_continue); | |
1398 } | |
1399 } | |
1400 | |
1401 // Count a final call in the bytecodes. | |
1402 void InterpreterMacroAssembler::profile_final_call(Register scratch1, Register scratch2) { | |
1403 if (ProfileInterpreter) { | |
1404 Label profile_continue; | |
1405 | |
1406 // If no method data exists, go to profile_continue. | |
1407 test_method_data_pointer(profile_continue); | |
1408 | |
1409 // We are making a call. Increment the count. | |
1410 increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch1, scratch2); | |
1411 | |
1412 // The method data pointer needs to be updated to reflect the new target. | |
1413 update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size())); | |
1414 bind (profile_continue); | |
1415 } | |
1416 } | |
1417 | |
1418 // Count a virtual call in the bytecodes. | |
1419 void InterpreterMacroAssembler::profile_virtual_call(Register Rreceiver, | |
1420 Register Rscratch1, | |
1421 Register Rscratch2, | |
1422 bool receiver_can_be_null) { | |
1423 if (!ProfileInterpreter) { return; } | |
1424 Label profile_continue; | |
1425 | |
1426 // If no method data exists, go to profile_continue. | |
1427 test_method_data_pointer(profile_continue); | |
1428 | |
1429 Label skip_receiver_profile; | |
1430 if (receiver_can_be_null) { | |
1431 Label not_null; | |
1432 cmpdi(CCR0, Rreceiver, 0); | |
1433 bne(CCR0, not_null); | |
1434 // We are making a call. Increment the count for null receiver. | |
1435 increment_mdp_data_at(in_bytes(CounterData::count_offset()), Rscratch1, Rscratch2); | |
1436 b(skip_receiver_profile); | |
1437 bind(not_null); | |
1438 } | |
1439 | |
1440 // Record the receiver type. | |
1441 record_klass_in_profile(Rreceiver, Rscratch1, Rscratch2, true); | |
1442 bind(skip_receiver_profile); | |
1443 | |
1444 // The method data pointer needs to be updated to reflect the new target. | |
1445 update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size())); | |
1446 bind (profile_continue); | |
1447 } | |
1448 | |
1449 void InterpreterMacroAssembler::profile_typecheck(Register Rklass, Register Rscratch1, Register Rscratch2) { | |
1450 if (ProfileInterpreter) { | |
1451 Label profile_continue; | |
1452 | |
1453 // If no method data exists, go to profile_continue. | |
1454 test_method_data_pointer(profile_continue); | |
1455 | |
1456 int mdp_delta = in_bytes(BitData::bit_data_size()); | |
1457 if (TypeProfileCasts) { | |
1458 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); | |
1459 | |
1460 // Record the object type. | |
1461 record_klass_in_profile(Rklass, Rscratch1, Rscratch2, false); | |
1462 } | |
1463 | |
1464 // The method data pointer needs to be updated. | |
1465 update_mdp_by_constant(mdp_delta); | |
1466 | |
1467 bind (profile_continue); | |
1468 } | |
1469 } | |
1470 | |
1471 void InterpreterMacroAssembler::profile_typecheck_failed(Register Rscratch1, Register Rscratch2) { | |
1472 if (ProfileInterpreter && TypeProfileCasts) { | |
1473 Label profile_continue; | |
1474 | |
1475 // If no method data exists, go to profile_continue. | |
1476 test_method_data_pointer(profile_continue); | |
1477 | |
1478 int count_offset = in_bytes(CounterData::count_offset()); | |
1479 // Back up the address, since we have already bumped the mdp. | |
1480 count_offset -= in_bytes(VirtualCallData::virtual_call_data_size()); | |
1481 | |
1482 // *Decrement* the counter. We expect to see zero or small negatives. | |
1483 increment_mdp_data_at(count_offset, Rscratch1, Rscratch2, true); | |
1484 | |
1485 bind (profile_continue); | |
1486 } | |
1487 } | |
1488 | |
1489 // Count a ret in the bytecodes. | |
1490 void InterpreterMacroAssembler::profile_ret(TosState state, Register return_bci, Register scratch1, Register scratch2) { | |
1491 if (ProfileInterpreter) { | |
1492 Label profile_continue; | |
1493 uint row; | |
1494 | |
1495 // If no method data exists, go to profile_continue. | |
1496 test_method_data_pointer(profile_continue); | |
1497 | |
1498 // Update the total ret count. | |
1499 increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch1, scratch2 ); | |
1500 | |
1501 for (row = 0; row < RetData::row_limit(); row++) { | |
1502 Label next_test; | |
1503 | |
1504 // See if return_bci is equal to bci[n]: | |
1505 test_mdp_data_at(in_bytes(RetData::bci_offset(row)), return_bci, next_test, scratch1); | |
1506 | |
1507 // return_bci is equal to bci[n]. Increment the count. | |
1508 increment_mdp_data_at(in_bytes(RetData::bci_count_offset(row)), scratch1, scratch2); | |
1509 | |
1510 // The method data pointer needs to be updated to reflect the new target. | |
1511 update_mdp_by_offset(in_bytes(RetData::bci_displacement_offset(row)), scratch1); | |
1512 b(profile_continue); | |
1513 bind(next_test); | |
1514 } | |
1515 | |
1516 update_mdp_for_ret(state, return_bci); | |
1517 | |
1518 bind (profile_continue); | |
1519 } | |
1520 } | |
1521 | |
1522 // Count the default case of a switch construct. | |
1523 void InterpreterMacroAssembler::profile_switch_default(Register scratch1, Register scratch2) { | |
1524 if (ProfileInterpreter) { | |
1525 Label profile_continue; | |
1526 | |
1527 // If no method data exists, go to profile_continue. | |
1528 test_method_data_pointer(profile_continue); | |
1529 | |
1530 // Update the default case count | |
1531 increment_mdp_data_at(in_bytes(MultiBranchData::default_count_offset()), | |
1532 scratch1, scratch2); | |
1533 | |
1534 // The method data pointer needs to be updated. | |
1535 update_mdp_by_offset(in_bytes(MultiBranchData::default_displacement_offset()), | |
1536 scratch1); | |
1537 | |
1538 bind (profile_continue); | |
1539 } | |
1540 } | |
1541 | |
1542 // Count the index'th case of a switch construct. | |
1543 void InterpreterMacroAssembler::profile_switch_case(Register index, | |
1544 Register scratch1, | |
1545 Register scratch2, | |
1546 Register scratch3) { | |
1547 if (ProfileInterpreter) { | |
1548 assert_different_registers(index, scratch1, scratch2, scratch3); | |
1549 Label profile_continue; | |
1550 | |
1551 // If no method data exists, go to profile_continue. | |
1552 test_method_data_pointer(profile_continue); | |
1553 | |
1554 // Build the base (index * per_case_size_in_bytes()) + case_array_offset_in_bytes(). | |
1555 li(scratch3, in_bytes(MultiBranchData::case_array_offset())); | |
1556 | |
1557 assert (in_bytes(MultiBranchData::per_case_size()) == 16, "so that shladd works"); | |
1558 sldi(scratch1, index, exact_log2(in_bytes(MultiBranchData::per_case_size()))); | |
1559 add(scratch1, scratch1, scratch3); | |
1560 | |
1561 // Update the case count. | |
1562 increment_mdp_data_at(scratch1, in_bytes(MultiBranchData::relative_count_offset()), scratch2, scratch3); | |
1563 | |
1564 // The method data pointer needs to be updated. | |
1565 update_mdp_by_offset(scratch1, in_bytes(MultiBranchData::relative_displacement_offset()), scratch2); | |
1566 | |
1567 bind (profile_continue); | |
1568 } | |
1569 } | |
1570 | |
1571 void InterpreterMacroAssembler::profile_null_seen(Register Rscratch1, Register Rscratch2) { | |
1572 if (ProfileInterpreter) { | |
1573 assert_different_registers(Rscratch1, Rscratch2); | |
1574 Label profile_continue; | |
1575 | |
1576 // If no method data exists, go to profile_continue. | |
1577 test_method_data_pointer(profile_continue); | |
1578 | |
1579 set_mdp_flag_at(BitData::null_seen_byte_constant(), Rscratch1); | |
1580 | |
1581 // The method data pointer needs to be updated. | |
1582 int mdp_delta = in_bytes(BitData::bit_data_size()); | |
1583 if (TypeProfileCasts) { | |
1584 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); | |
1585 } | |
1586 update_mdp_by_constant(mdp_delta); | |
1587 | |
1588 bind (profile_continue); | |
1589 } | |
1590 } | |
1591 | |
1592 void InterpreterMacroAssembler::record_klass_in_profile(Register Rreceiver, | |
1593 Register Rscratch1, Register Rscratch2, | |
1594 bool is_virtual_call) { | |
1595 assert(ProfileInterpreter, "must be profiling"); | |
1596 assert_different_registers(Rreceiver, Rscratch1, Rscratch2); | |
1597 | |
1598 Label done; | |
1599 record_klass_in_profile_helper(Rreceiver, Rscratch1, Rscratch2, 0, done, is_virtual_call); | |
1600 bind (done); | |
1601 } | |
1602 | |
1603 void InterpreterMacroAssembler::record_klass_in_profile_helper( | |
1604 Register receiver, Register scratch1, Register scratch2, | |
1605 int start_row, Label& done, bool is_virtual_call) { | |
1606 if (TypeProfileWidth == 0) { | |
1607 if (is_virtual_call) { | |
1608 increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch1, scratch2); | |
1609 } | |
1610 return; | |
1611 } | |
1612 | |
1613 int last_row = VirtualCallData::row_limit() - 1; | |
1614 assert(start_row <= last_row, "must be work left to do"); | |
1615 // Test this row for both the receiver and for null. | |
1616 // Take any of three different outcomes: | |
1617 // 1. found receiver => increment count and goto done | |
1618 // 2. found null => keep looking for case 1, maybe allocate this cell | |
1619 // 3. found something else => keep looking for cases 1 and 2 | |
1620 // Case 3 is handled by a recursive call. | |
1621 for (int row = start_row; row <= last_row; row++) { | |
1622 Label next_test; | |
1623 bool test_for_null_also = (row == start_row); | |
1624 | |
1625 // See if the receiver is receiver[n]. | |
1626 int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row)); | |
1627 test_mdp_data_at(recvr_offset, receiver, next_test, scratch1); | |
1628 // delayed()->tst(scratch); | |
1629 | |
1630 // The receiver is receiver[n]. Increment count[n]. | |
1631 int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row)); | |
1632 increment_mdp_data_at(count_offset, scratch1, scratch2); | |
1633 b(done); | |
1634 bind(next_test); | |
1635 | |
1636 if (test_for_null_also) { | |
1637 Label found_null; | |
1638 // Failed the equality check on receiver[n]... Test for null. | |
1639 if (start_row == last_row) { | |
1640 // The only thing left to do is handle the null case. | |
1641 if (is_virtual_call) { | |
1642 // Scratch1 contains test_out from test_mdp_data_at. | |
1643 cmpdi(CCR0, scratch1, 0); | |
1644 beq(CCR0, found_null); | |
1645 // Receiver did not match any saved receiver and there is no empty row for it. | |
1646 // Increment total counter to indicate polymorphic case. | |
1647 increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch1, scratch2); | |
1648 b(done); | |
1649 bind(found_null); | |
1650 } else { | |
1651 cmpdi(CCR0, scratch1, 0); | |
1652 bne(CCR0, done); | |
1653 } | |
1654 break; | |
1655 } | |
1656 // Since null is rare, make it be the branch-taken case. | |
1657 cmpdi(CCR0, scratch1, 0); | |
1658 beq(CCR0, found_null); | |
1659 | |
1660 // Put all the "Case 3" tests here. | |
1661 record_klass_in_profile_helper(receiver, scratch1, scratch2, start_row + 1, done, is_virtual_call); | |
1662 | |
1663 // Found a null. Keep searching for a matching receiver, | |
1664 // but remember that this is an empty (unused) slot. | |
1665 bind(found_null); | |
1666 } | |
1667 } | |
1668 | |
1669 // In the fall-through case, we found no matching receiver, but we | |
1670 // observed the receiver[start_row] is NULL. | |
1671 | |
1672 // Fill in the receiver field and increment the count. | |
1673 int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row)); | |
1674 set_mdp_data_at(recvr_offset, receiver); | |
1675 int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row)); | |
1676 li(scratch1, DataLayout::counter_increment); | |
1677 set_mdp_data_at(count_offset, scratch1); | |
1678 if (start_row > 0) { | |
1679 b(done); | |
1680 } | |
1681 } | |
1682 | |
1683 // Add a InterpMonitorElem to stack (see frame_sparc.hpp). | |
1684 void InterpreterMacroAssembler::add_monitor_to_stack(bool stack_is_empty, Register Rtemp1, Register Rtemp2) { | |
1685 | |
1686 // Very-local scratch registers. | |
1687 const Register esp = Rtemp1; | |
1688 const Register slot = Rtemp2; | |
1689 | |
1690 // Extracted monitor_size. | |
1691 int monitor_size = frame::interpreter_frame_monitor_size_in_bytes(); | |
1692 assert(Assembler::is_aligned((unsigned int)monitor_size, | |
1693 (unsigned int)frame::alignment_in_bytes), | |
1694 "size of a monitor must respect alignment of SP"); | |
1695 | |
1696 resize_frame(-monitor_size, /*temp*/esp); // Allocate space for new monitor | |
1697 std(R1_SP, _ijava_state_neg(top_frame_sp), esp); // esp contains fp | |
1698 | |
1699 // Shuffle expression stack down. Recall that stack_base points | |
1700 // just above the new expression stack bottom. Old_tos and new_tos | |
1701 // are used to scan thru the old and new expression stacks. | |
1702 if (!stack_is_empty) { | |
1703 Label copy_slot, copy_slot_finished; | |
1704 const Register n_slots = slot; | |
1705 | |
1706 addi(esp, R15_esp, Interpreter::stackElementSize); // Point to first element (pre-pushed stack). | |
1707 subf(n_slots, esp, R26_monitor); | |
1708 srdi_(n_slots, n_slots, LogBytesPerWord); // Compute number of slots to copy. | |
1709 assert(LogBytesPerWord == 3, "conflicts assembler instructions"); | |
1710 beq(CCR0, copy_slot_finished); // Nothing to copy. | |
1711 | |
1712 mtctr(n_slots); | |
1713 | |
1714 // loop | |
1715 bind(copy_slot); | |
1716 ld(slot, 0, esp); // Move expression stack down. | |
1717 std(slot, -monitor_size, esp); // distance = monitor_size | |
1718 addi(esp, esp, BytesPerWord); | |
1719 bdnz(copy_slot); | |
1720 | |
1721 bind(copy_slot_finished); | |
1722 } | |
1723 | |
1724 addi(R15_esp, R15_esp, -monitor_size); | |
1725 addi(R26_monitor, R26_monitor, -monitor_size); | |
1726 | |
1727 // Restart interpreter | |
1728 } | |
1729 | |
1730 // ============================================================================ | |
1731 // Java locals access | |
1732 | |
1733 // Load a local variable at index in Rindex into register Rdst_value. | |
1734 // Also puts address of local into Rdst_address as a service. | |
1735 // Kills: | |
1736 // - Rdst_value | |
1737 // - Rdst_address | |
1738 void InterpreterMacroAssembler::load_local_int(Register Rdst_value, Register Rdst_address, Register Rindex) { | |
1739 sldi(Rdst_address, Rindex, Interpreter::logStackElementSize); | |
1740 subf(Rdst_address, Rdst_address, R18_locals); | |
1741 lwz(Rdst_value, 0, Rdst_address); | |
1742 } | |
1743 | |
1744 // Load a local variable at index in Rindex into register Rdst_value. | |
1745 // Also puts address of local into Rdst_address as a service. | |
1746 // Kills: | |
1747 // - Rdst_value | |
1748 // - Rdst_address | |
1749 void InterpreterMacroAssembler::load_local_long(Register Rdst_value, Register Rdst_address, Register Rindex) { | |
1750 sldi(Rdst_address, Rindex, Interpreter::logStackElementSize); | |
1751 subf(Rdst_address, Rdst_address, R18_locals); | |
1752 ld(Rdst_value, -8, Rdst_address); | |
1753 } | |
1754 | |
1755 // Load a local variable at index in Rindex into register Rdst_value. | |
1756 // Also puts address of local into Rdst_address as a service. | |
1757 // Input: | |
1758 // - Rindex: slot nr of local variable | |
1759 // Kills: | |
1760 // - Rdst_value | |
1761 // - Rdst_address | |
1762 void InterpreterMacroAssembler::load_local_ptr(Register Rdst_value, Register Rdst_address, Register Rindex) { | |
1763 sldi(Rdst_address, Rindex, Interpreter::logStackElementSize); | |
1764 subf(Rdst_address, Rdst_address, R18_locals); | |
1765 ld(Rdst_value, 0, Rdst_address); | |
1766 } | |
1767 | |
1768 // Load a local variable at index in Rindex into register Rdst_value. | |
1769 // Also puts address of local into Rdst_address as a service. | |
1770 // Kills: | |
1771 // - Rdst_value | |
1772 // - Rdst_address | |
1773 void InterpreterMacroAssembler::load_local_float(FloatRegister Rdst_value, Register Rdst_address, Register Rindex) { | |
1774 sldi(Rdst_address, Rindex, Interpreter::logStackElementSize); | |
1775 subf(Rdst_address, Rdst_address, R18_locals); | |
1776 lfs(Rdst_value, 0, Rdst_address); | |
1777 } | |
1778 | |
1779 // Load a local variable at index in Rindex into register Rdst_value. | |
1780 // Also puts address of local into Rdst_address as a service. | |
1781 // Kills: | |
1782 // - Rdst_value | |
1783 // - Rdst_address | |
1784 void InterpreterMacroAssembler::load_local_double(FloatRegister Rdst_value, Register Rdst_address, Register Rindex) { | |
1785 sldi(Rdst_address, Rindex, Interpreter::logStackElementSize); | |
1786 subf(Rdst_address, Rdst_address, R18_locals); | |
1787 lfd(Rdst_value, -8, Rdst_address); | |
1788 } | |
1789 | |
1790 // Store an int value at local variable slot Rindex. | |
1791 // Kills: | |
1792 // - Rindex | |
1793 void InterpreterMacroAssembler::store_local_int(Register Rvalue, Register Rindex) { | |
1794 sldi(Rindex, Rindex, Interpreter::logStackElementSize); | |
1795 subf(Rindex, Rindex, R18_locals); | |
1796 stw(Rvalue, 0, Rindex); | |
1797 } | |
1798 | |
1799 // Store a long value at local variable slot Rindex. | |
1800 // Kills: | |
1801 // - Rindex | |
1802 void InterpreterMacroAssembler::store_local_long(Register Rvalue, Register Rindex) { | |
1803 sldi(Rindex, Rindex, Interpreter::logStackElementSize); | |
1804 subf(Rindex, Rindex, R18_locals); | |
1805 std(Rvalue, -8, Rindex); | |
1806 } | |
1807 | |
1808 // Store an oop value at local variable slot Rindex. | |
1809 // Kills: | |
1810 // - Rindex | |
1811 void InterpreterMacroAssembler::store_local_ptr(Register Rvalue, Register Rindex) { | |
1812 sldi(Rindex, Rindex, Interpreter::logStackElementSize); | |
1813 subf(Rindex, Rindex, R18_locals); | |
1814 std(Rvalue, 0, Rindex); | |
1815 } | |
1816 | |
1817 // Store an int value at local variable slot Rindex. | |
1818 // Kills: | |
1819 // - Rindex | |
1820 void InterpreterMacroAssembler::store_local_float(FloatRegister Rvalue, Register Rindex) { | |
1821 sldi(Rindex, Rindex, Interpreter::logStackElementSize); | |
1822 subf(Rindex, Rindex, R18_locals); | |
1823 stfs(Rvalue, 0, Rindex); | |
1824 } | |
1825 | |
1826 // Store an int value at local variable slot Rindex. | |
1827 // Kills: | |
1828 // - Rindex | |
1829 void InterpreterMacroAssembler::store_local_double(FloatRegister Rvalue, Register Rindex) { | |
1830 sldi(Rindex, Rindex, Interpreter::logStackElementSize); | |
1831 subf(Rindex, Rindex, R18_locals); | |
1832 stfd(Rvalue, -8, Rindex); | |
1833 } | |
1834 | |
1835 // Read pending exception from thread and jump to interpreter. | |
1836 // Throw exception entry if one if pending. Fall through otherwise. | |
1837 void InterpreterMacroAssembler::check_and_forward_exception(Register Rscratch1, Register Rscratch2) { | |
1838 assert_different_registers(Rscratch1, Rscratch2, R3); | |
1839 Register Rexception = Rscratch1; | |
1840 Register Rtmp = Rscratch2; | |
1841 Label Ldone; | |
1842 // Get pending exception oop. | |
1843 ld(Rexception, thread_(pending_exception)); | |
1844 cmpdi(CCR0, Rexception, 0); | |
1845 beq(CCR0, Ldone); | |
1846 li(Rtmp, 0); | |
1847 mr_if_needed(R3, Rexception); | |
1848 std(Rtmp, thread_(pending_exception)); // Clear exception in thread | |
1849 if (Interpreter::rethrow_exception_entry() != NULL) { | |
1850 // Already got entry address. | |
1851 load_dispatch_table(Rtmp, (address*)Interpreter::rethrow_exception_entry()); | |
1852 } else { | |
1853 // Dynamically load entry address. | |
1854 int simm16_rest = load_const_optimized(Rtmp, &Interpreter::_rethrow_exception_entry, R0, true); | |
1855 ld(Rtmp, simm16_rest, Rtmp); | |
1856 } | |
1857 mtctr(Rtmp); | |
1858 save_interpreter_state(Rtmp); | |
1859 bctr(); | |
1860 | |
1861 align(32, 12); | |
1862 bind(Ldone); | |
1863 } | |
1864 | |
1865 void InterpreterMacroAssembler::call_VM(Register oop_result, address entry_point, bool check_exceptions) { | |
1866 save_interpreter_state(R11_scratch1); | |
1867 | |
1868 MacroAssembler::call_VM(oop_result, entry_point, false); | |
1869 | |
1870 restore_interpreter_state(R11_scratch1, /*bcp_and_mdx_only*/ true); | |
1871 | |
1872 check_and_handle_popframe(R11_scratch1); | |
1873 check_and_handle_earlyret(R11_scratch1); | |
1874 // Now check exceptions manually. | |
1875 if (check_exceptions) { | |
1876 check_and_forward_exception(R11_scratch1, R12_scratch2); | |
1877 } | |
1878 } | |
1879 | |
1880 void InterpreterMacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions) { | |
1881 // ARG1 is reserved for the thread. | |
1882 mr_if_needed(R4_ARG2, arg_1); | |
1883 call_VM(oop_result, entry_point, check_exceptions); | |
1884 } | |
1885 | |
1886 void InterpreterMacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions) { | |
1887 // ARG1 is reserved for the thread. | |
1888 mr_if_needed(R4_ARG2, arg_1); | |
1889 assert(arg_2 != R4_ARG2, "smashed argument"); | |
1890 mr_if_needed(R5_ARG3, arg_2); | |
1891 call_VM(oop_result, entry_point, check_exceptions); | |
1892 } | |
1893 | |
1894 void InterpreterMacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) { | |
1895 // ARG1 is reserved for the thread. | |
1896 mr_if_needed(R4_ARG2, arg_1); | |
1897 assert(arg_2 != R4_ARG2, "smashed argument"); | |
1898 mr_if_needed(R5_ARG3, arg_2); | |
1899 assert(arg_3 != R4_ARG2 && arg_3 != R5_ARG3, "smashed argument"); | |
1900 mr_if_needed(R6_ARG4, arg_3); | |
1901 call_VM(oop_result, entry_point, check_exceptions); | |
1902 } | |
1903 | |
1904 void InterpreterMacroAssembler::save_interpreter_state(Register scratch) { | |
1905 ld(scratch, 0, R1_SP); | |
1906 std(R15_esp, _ijava_state_neg(esp), scratch); | |
1907 std(R14_bcp, _ijava_state_neg(bcp), scratch); | |
1908 std(R26_monitor, _ijava_state_neg(monitors), scratch); | |
1909 if (ProfileInterpreter) { std(R28_mdx, _ijava_state_neg(mdx), scratch); } | |
1910 // Other entries should be unchanged. | |
1911 } | |
1912 | |
1913 void InterpreterMacroAssembler::restore_interpreter_state(Register scratch, bool bcp_and_mdx_only) { | |
1914 ld(scratch, 0, R1_SP); | |
1915 ld(R14_bcp, _ijava_state_neg(bcp), scratch); // Changed by VM code (exception). | |
1916 if (ProfileInterpreter) { ld(R28_mdx, _ijava_state_neg(mdx), scratch); } // Changed by VM code. | |
1917 if (!bcp_and_mdx_only) { | |
1918 // Following ones are Metadata. | |
1919 ld(R19_method, _ijava_state_neg(method), scratch); | |
1920 ld(R27_constPoolCache, _ijava_state_neg(cpoolCache), scratch); | |
1921 // Following ones are stack addresses and don't require reload. | |
1922 ld(R15_esp, _ijava_state_neg(esp), scratch); | |
1923 ld(R18_locals, _ijava_state_neg(locals), scratch); | |
1924 ld(R26_monitor, _ijava_state_neg(monitors), scratch); | |
1925 } | |
1926 #ifdef ASSERT | |
1927 { | |
1928 Label Lok; | |
1929 subf(R0, R1_SP, scratch); | |
1930 cmpdi(CCR0, R0, frame::abi_reg_args_size + frame::ijava_state_size); | |
1931 bge(CCR0, Lok); | |
1932 stop("frame too small (restore istate)", 0x5432); | |
1933 bind(Lok); | |
1934 } | |
1935 { | |
1936 Label Lok; | |
1937 ld(R0, _ijava_state_neg(ijava_reserved), scratch); | |
1938 cmpdi(CCR0, R0, 0x5afe); | |
1939 beq(CCR0, Lok); | |
1940 stop("frame corrupted (restore istate)", 0x5afe); | |
1941 bind(Lok); | |
1942 } | |
1943 #endif | |
1944 } | |
1945 | |
1946 #endif // !CC_INTERP | |
1947 | |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1948 void InterpreterMacroAssembler::get_method_counters(Register method, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1949 Register Rcounters, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1950 Label& skip) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1951 BLOCK_COMMENT("Load and ev. allocate counter object {"); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1952 Label has_counters; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1953 ld(Rcounters, in_bytes(Method::method_counters_offset()), method); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1954 cmpdi(CCR0, Rcounters, 0); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1955 bne(CCR0, has_counters); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1956 call_VM(noreg, CAST_FROM_FN_PTR(address, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1957 InterpreterRuntime::build_method_counters), method, false); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1958 ld(Rcounters, in_bytes(Method::method_counters_offset()), method); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1959 cmpdi(CCR0, Rcounters, 0); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1960 beq(CCR0, skip); // No MethodCounters, OutOfMemory. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1961 BLOCK_COMMENT("} Load and ev. allocate counter object"); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1962 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1963 bind(has_counters); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1964 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1965 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1966 void InterpreterMacroAssembler::increment_invocation_counter(Register Rcounters, Register iv_be_count, Register Rtmp_r0) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1967 assert(UseCompiler, "incrementing must be useful"); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1968 Register invocation_count = iv_be_count; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1969 Register backedge_count = Rtmp_r0; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1970 int delta = InvocationCounter::count_increment; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1971 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1972 // Load each counter in a register. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1973 // ld(inv_counter, Rtmp); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1974 // ld(be_counter, Rtmp2); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1975 int inv_counter_offset = in_bytes(MethodCounters::invocation_counter_offset() + |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1976 InvocationCounter::counter_offset()); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1977 int be_counter_offset = in_bytes(MethodCounters::backedge_counter_offset() + |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1978 InvocationCounter::counter_offset()); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1979 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1980 BLOCK_COMMENT("Increment profiling counters {"); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1981 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1982 // Load the backedge counter. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1983 lwz(backedge_count, be_counter_offset, Rcounters); // is unsigned int |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1984 // Mask the backedge counter. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1985 Register tmp = invocation_count; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1986 li(tmp, InvocationCounter::count_mask_value); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1987 andr(backedge_count, tmp, backedge_count); // Cannot use andi, need sign extension of count_mask_value. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1988 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1989 // Load the invocation counter. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1990 lwz(invocation_count, inv_counter_offset, Rcounters); // is unsigned int |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1991 // Add the delta to the invocation counter and store the result. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1992 addi(invocation_count, invocation_count, delta); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1993 // Store value. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1994 stw(invocation_count, inv_counter_offset, Rcounters); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1995 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1996 // Add invocation counter + backedge counter. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1997 add(iv_be_count, backedge_count, invocation_count); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1998 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1999 // Note that this macro must leave the backedge_count + invocation_count in |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2000 // register iv_be_count! |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2001 BLOCK_COMMENT("} Increment profiling counters"); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2002 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2003 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2004 void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2005 if (state == atos) { MacroAssembler::verify_oop(reg); } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2006 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2007 |
17804 | 2008 #ifndef CC_INTERP |
2009 // Local helper function for the verify_oop_or_return_address macro. | |
2010 static bool verify_return_address(Method* m, int bci) { | |
2011 #ifndef PRODUCT | |
2012 address pc = (address)(m->constMethod()) + in_bytes(ConstMethod::codes_offset()) + bci; | |
2013 // Assume it is a valid return address if it is inside m and is preceded by a jsr. | |
2014 if (!m->contains(pc)) return false; | |
2015 address jsr_pc; | |
2016 jsr_pc = pc - Bytecodes::length_for(Bytecodes::_jsr); | |
2017 if (*jsr_pc == Bytecodes::_jsr && jsr_pc >= m->code_base()) return true; | |
2018 jsr_pc = pc - Bytecodes::length_for(Bytecodes::_jsr_w); | |
2019 if (*jsr_pc == Bytecodes::_jsr_w && jsr_pc >= m->code_base()) return true; | |
2020 #endif // PRODUCT | |
2021 return false; | |
2022 } | |
2023 | |
2024 void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) { | |
2025 if (VerifyFPU) { | |
2026 unimplemented("verfiyFPU"); | |
2027 } | |
2028 } | |
2029 | |
2030 void InterpreterMacroAssembler::verify_oop_or_return_address(Register reg, Register Rtmp) { | |
2031 if (!VerifyOops) return; | |
2032 | |
2033 // The VM documentation for the astore[_wide] bytecode allows | |
2034 // the TOS to be not only an oop but also a return address. | |
2035 Label test; | |
2036 Label skip; | |
2037 // See if it is an address (in the current method): | |
2038 | |
2039 const int log2_bytecode_size_limit = 16; | |
2040 srdi_(Rtmp, reg, log2_bytecode_size_limit); | |
2041 bne(CCR0, test); | |
2042 | |
2043 address fd = CAST_FROM_FN_PTR(address, verify_return_address); | |
2044 unsigned int nbytes_save = 10*8; // 10 volatile gprs | |
2045 | |
2046 save_LR_CR(Rtmp); | |
2047 push_frame_reg_args(nbytes_save, Rtmp); | |
2048 save_volatile_gprs(R1_SP, 112); // except R0 | |
2049 | |
2050 load_const_optimized(Rtmp, fd, R0); | |
2051 mr_if_needed(R4_ARG2, reg); | |
2052 mr(R3_ARG1, R19_method); | |
2053 call_c(Rtmp); // call C | |
2054 | |
2055 restore_volatile_gprs(R1_SP, 112); // except R0 | |
2056 pop_frame(); | |
2057 restore_LR_CR(Rtmp); | |
2058 b(skip); | |
2059 | |
2060 // Perform a more elaborate out-of-line call. | |
2061 // Not an address; verify it: | |
2062 bind(test); | |
2063 verify_oop(reg); | |
2064 bind(skip); | |
2065 } | |
2066 #endif // !CC_INTERP | |
2067 | |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2068 // Inline assembly for: |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2069 // |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2070 // if (thread is in interp_only_mode) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2071 // InterpreterRuntime::post_method_entry(); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2072 // } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2073 // if (*jvmpi::event_flags_array_at_addr(JVMPI_EVENT_METHOD_ENTRY ) || |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2074 // *jvmpi::event_flags_array_at_addr(JVMPI_EVENT_METHOD_ENTRY2) ) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2075 // SharedRuntime::jvmpi_method_entry(method, receiver); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2076 // } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2077 void InterpreterMacroAssembler::notify_method_entry() { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2078 // JVMTI |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2079 // Whenever JVMTI puts a thread in interp_only_mode, method |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2080 // entry/exit events are sent for that thread to track stack |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2081 // depth. If it is possible to enter interp_only_mode we add |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2082 // the code to check if the event should be sent. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2083 if (JvmtiExport::can_post_interpreter_events()) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2084 Label jvmti_post_done; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2085 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2086 lwz(R0, in_bytes(JavaThread::interp_only_mode_offset()), R16_thread); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2087 cmpwi(CCR0, R0, 0); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2088 beq(CCR0, jvmti_post_done); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2089 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_entry), |
17804 | 2090 /*check_exceptions=*/true CC_INTERP_ONLY(&& false)); |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2091 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2092 bind(jvmti_post_done); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2093 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2094 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2095 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2096 // Inline assembly for: |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2097 // |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2098 // if (thread is in interp_only_mode) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2099 // // save result |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2100 // InterpreterRuntime::post_method_exit(); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2101 // // restore result |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2102 // } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2103 // if (*jvmpi::event_flags_array_at_addr(JVMPI_EVENT_METHOD_EXIT)) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2104 // // save result |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2105 // SharedRuntime::jvmpi_method_exit(); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2106 // // restore result |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2107 // } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2108 // |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2109 // Native methods have their result stored in d_tmp and l_tmp. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2110 // Java methods have their result stored in the expression stack. |
17804 | 2111 void InterpreterMacroAssembler::notify_method_exit(bool is_native_method, TosState state, |
2112 NotifyMethodExitMode mode, bool check_exceptions) { | |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2113 // JVMTI |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2114 // Whenever JVMTI puts a thread in interp_only_mode, method |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2115 // entry/exit events are sent for that thread to track stack |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2116 // depth. If it is possible to enter interp_only_mode we add |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2117 // the code to check if the event should be sent. |
17804 | 2118 if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) { |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2119 Label jvmti_post_done; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2120 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2121 lwz(R0, in_bytes(JavaThread::interp_only_mode_offset()), R16_thread); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2122 cmpwi(CCR0, R0, 0); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2123 beq(CCR0, jvmti_post_done); |
17804 | 2124 CC_INTERP_ONLY(assert(is_native_method && !check_exceptions, "must not push state")); |
2125 if (!is_native_method) push(state); // Expose tos to GC. | |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2126 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit), |
17804 | 2127 /*check_exceptions=*/check_exceptions); |
2128 if (!is_native_method) pop(state); | |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2129 |
14445 | 2130 align(32, 12); |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2131 bind(jvmti_post_done); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2132 } |
17804 | 2133 |
2134 // Dtrace support not implemented. | |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2135 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2136 |
17804 | 2137 #ifdef CC_INTERP |
14408
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2138 // Convert the current TOP_IJAVA_FRAME into a PARENT_IJAVA_FRAME |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2139 // (using parent_frame_resize) and push a new interpreter |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2140 // TOP_IJAVA_FRAME (using frame_size). |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2141 void InterpreterMacroAssembler::push_interpreter_frame(Register top_frame_size, Register parent_frame_resize, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2142 Register tmp1, Register tmp2, Register tmp3, |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2143 Register tmp4, Register pc) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2144 assert_different_registers(top_frame_size, parent_frame_resize, tmp1, tmp2, tmp3, tmp4); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2145 ld(tmp1, _top_ijava_frame_abi(frame_manager_lr), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2146 mr(tmp2/*top_frame_sp*/, R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2147 // Move initial_caller_sp. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2148 ld(tmp4, _top_ijava_frame_abi(initial_caller_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2149 neg(parent_frame_resize, parent_frame_resize); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2150 resize_frame(parent_frame_resize/*-parent_frame_resize*/, tmp3); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2151 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2152 // Set LR in new parent frame. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2153 std(tmp1, _abi(lr), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2154 // Set top_frame_sp info for new parent frame. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2155 std(tmp2, _parent_ijava_frame_abi(top_frame_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2156 std(tmp4, _parent_ijava_frame_abi(initial_caller_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2157 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2158 // Push new TOP_IJAVA_FRAME. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2159 push_frame(top_frame_size, tmp2); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2160 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2161 get_PC_trash_LR(tmp3); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2162 std(tmp3, _top_ijava_frame_abi(frame_manager_lr), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2163 // Used for non-initial callers by unextended_sp(). |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2164 std(R1_SP, _top_ijava_frame_abi(initial_caller_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2165 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2166 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2167 // Pop the topmost TOP_IJAVA_FRAME and convert the previous |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2168 // PARENT_IJAVA_FRAME back into a TOP_IJAVA_FRAME. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2169 void InterpreterMacroAssembler::pop_interpreter_frame(Register tmp1, Register tmp2, Register tmp3, Register tmp4) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2170 assert_different_registers(tmp1, tmp2, tmp3, tmp4); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2171 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2172 ld(tmp1/*caller's sp*/, _abi(callers_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2173 ld(tmp3, _abi(lr), tmp1); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2174 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2175 ld(tmp4, _parent_ijava_frame_abi(initial_caller_sp), tmp1); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2176 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2177 ld(tmp2/*caller's caller's sp*/, _abi(callers_sp), tmp1); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2178 // Merge top frame. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2179 std(tmp2, _abi(callers_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2180 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2181 ld(tmp2, _parent_ijava_frame_abi(top_frame_sp), tmp1); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2182 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2183 // Update C stack pointer to caller's top_abi. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2184 resize_frame_absolute(tmp2/*addr*/, tmp1/*tmp*/, tmp2/*tmp*/); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2185 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2186 // Update LR in top_frame. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2187 std(tmp3, _top_ijava_frame_abi(frame_manager_lr), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2188 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2189 std(tmp4, _top_ijava_frame_abi(initial_caller_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2190 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2191 // Store the top-frame stack-pointer for c2i adapters. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2192 std(R1_SP, _top_ijava_frame_abi(top_frame_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2193 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2194 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2195 // Turn state's interpreter frame into the current TOP_IJAVA_FRAME. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2196 void InterpreterMacroAssembler::pop_interpreter_frame_to_state(Register state, Register tmp1, Register tmp2, Register tmp3) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2197 assert_different_registers(R14_state, R15_prev_state, tmp1, tmp2, tmp3); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2198 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2199 if (state == R14_state) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2200 ld(tmp1/*state's fp*/, state_(_last_Java_fp)); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2201 ld(tmp2/*state's sp*/, state_(_last_Java_sp)); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2202 } else if (state == R15_prev_state) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2203 ld(tmp1/*state's fp*/, prev_state_(_last_Java_fp)); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2204 ld(tmp2/*state's sp*/, prev_state_(_last_Java_sp)); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2205 } else { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2206 ShouldNotReachHere(); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2207 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2208 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2209 // Merge top frames. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2210 std(tmp1, _abi(callers_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2211 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2212 // Tmp2 is new SP. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2213 // Tmp1 is parent's SP. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2214 resize_frame_absolute(tmp2/*addr*/, tmp1/*tmp*/, tmp2/*tmp*/); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2215 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2216 // Update LR in top_frame. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2217 // Must be interpreter frame. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2218 get_PC_trash_LR(tmp3); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2219 std(tmp3, _top_ijava_frame_abi(frame_manager_lr), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2220 // Used for non-initial callers by unextended_sp(). |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2221 std(R1_SP, _top_ijava_frame_abi(initial_caller_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2222 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2223 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2224 // Set SP to initial caller's sp, but before fix the back chain. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2225 void InterpreterMacroAssembler::resize_frame_to_initial_caller(Register tmp1, Register tmp2) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2226 ld(tmp1, _parent_ijava_frame_abi(initial_caller_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2227 ld(tmp2, _parent_ijava_frame_abi(callers_sp), R1_SP); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2228 std(tmp2, _parent_ijava_frame_abi(callers_sp), tmp1); // Fix back chain ... |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2229 mr(R1_SP, tmp1); // ... and resize to initial caller. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2230 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2231 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2232 // Pop the current interpreter state (without popping the correspoding |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2233 // frame) and restore R14_state and R15_prev_state accordingly. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2234 // Use prev_state_may_be_0 to indicate whether prev_state may be 0 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2235 // in order to generate an extra check before retrieving prev_state_(_prev_link). |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2236 void InterpreterMacroAssembler::pop_interpreter_state(bool prev_state_may_be_0) |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2237 { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2238 // Move prev_state to state and restore prev_state from state_(_prev_link). |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2239 Label prev_state_is_0; |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2240 mr(R14_state, R15_prev_state); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2241 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2242 // Don't retrieve /*state==*/prev_state_(_prev_link) |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2243 // if /*state==*/prev_state is 0. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2244 if (prev_state_may_be_0) { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2245 cmpdi(CCR0, R15_prev_state, 0); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2246 beq(CCR0, prev_state_is_0); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2247 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2248 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2249 ld(R15_prev_state, /*state==*/prev_state_(_prev_link)); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2250 bind(prev_state_is_0); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2251 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2252 |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2253 void InterpreterMacroAssembler::restore_prev_state() { |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2254 // _prev_link is private, but cInterpreter is a friend. |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2255 ld(R15_prev_state, state_(_prev_link)); |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2256 } |
ec28f9c041ff
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2257 #endif // CC_INTERP |