annotate src/cpu/ppc/vm/interp_masm_ppc_64.cpp @ 23627:47cd96b2510f

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