annotate src/cpu/ppc/vm/templateInterpreter_ppc.cpp @ 20693:31d3306aad29 jdk8u40-b18

Added tag hs25.40-b22 for changeset bc5a90a4db47
author amurillo
date Fri, 05 Dec 2014 09:47:16 -0800
parents b384ba33c9a0
children c5e86c5cd22e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1 /*
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
3 * Copyright 2013, 2014 SAP AG. All rights reserved.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
5 *
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
6 * This code is free software; you can redistribute it and/or modify it
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
7 * under the terms of the GNU General Public License version 2 only, as
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
8 * published by the Free Software Foundation.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
9 *
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
10 * This code is distributed in the hope that it will be useful, but WITHOUT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
13 * version 2 for more details (a copy is included in the LICENSE file that
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
14 * accompanied this code).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
15 *
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License version
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
17 * 2 along with this work; if not, write to the Free Software Foundation,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
19 *
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
21 * or visit www.oracle.com if you need additional information or have any
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
22 * questions.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
23 *
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
24 */
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
25
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
26 #include "precompiled.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
27 #ifndef CC_INTERP
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
28 #include "asm/macroAssembler.inline.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
29 #include "interpreter/bytecodeHistogram.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
30 #include "interpreter/interpreter.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
31 #include "interpreter/interpreterGenerator.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
32 #include "interpreter/interpreterRuntime.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
33 #include "interpreter/templateTable.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
34 #include "oops/arrayOop.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
35 #include "oops/methodData.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
36 #include "oops/method.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
37 #include "oops/oop.inline.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
38 #include "prims/jvmtiExport.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
39 #include "prims/jvmtiThreadState.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
40 #include "runtime/arguments.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
41 #include "runtime/deoptimization.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
42 #include "runtime/frame.inline.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
43 #include "runtime/sharedRuntime.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
44 #include "runtime/stubRoutines.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
45 #include "runtime/synchronizer.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
46 #include "runtime/timer.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
47 #include "runtime/vframeArray.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
48 #include "utilities/debug.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
49 #include "utilities/macros.hpp"
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
50
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
51 #undef __
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
52 #define __ _masm->
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
53
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
54 #ifdef PRODUCT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
55 #define BLOCK_COMMENT(str) /* nothing */
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
56 #else
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
57 #define BLOCK_COMMENT(str) __ block_comment(str)
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
58 #endif
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
59
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
60 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
61
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
62 //-----------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
63
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
64 // Actually we should never reach here since we do stack overflow checks before pushing any frame.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
65 address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
66 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
67 __ unimplemented("generate_StackOverflowError_handler");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
68 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
69 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
70
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
71 address TemplateInterpreterGenerator::generate_ArrayIndexOutOfBounds_handler(const char* name) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
72 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
73 __ empty_expression_stack();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
74 __ load_const_optimized(R4_ARG2, (address) name);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
75 // Index is in R17_tos.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
76 __ mr(R5_ARG3, R17_tos);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
77 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
78 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
79 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
80
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
81 #if 0
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
82 // Call special ClassCastException constructor taking object to cast
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
83 // and target class as arguments.
17917
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
84 address TemplateInterpreterGenerator::generate_ClassCastException_verbose_handler() {
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
85 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
86
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
87 // Expression stack must be empty before entering the VM if an
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
88 // exception happened.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
89 __ empty_expression_stack();
17917
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
90
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
91 // Thread will be loaded to R3_ARG1.
17917
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
92 // Target class oop is in register R5_ARG3 by convention!
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
93 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ClassCastException_verbose, R17_tos, R5_ARG3));
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
94 // Above call must not return here since exception pending.
17917
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
95 DEBUG_ONLY(__ should_not_reach_here();)
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
96 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
97 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
98 #endif
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
99
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
100 address TemplateInterpreterGenerator::generate_ClassCastException_handler() {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
101 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
102 // Expression stack must be empty before entering the VM if an
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
103 // exception happened.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
104 __ empty_expression_stack();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
105
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
106 // Load exception object.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
107 // Thread will be loaded to R3_ARG1.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
108 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ClassCastException), R17_tos);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
109 #ifdef ASSERT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
110 // Above call must not return here since exception pending.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
111 __ should_not_reach_here();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
112 #endif
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
113 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
114 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
115
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
116 address TemplateInterpreterGenerator::generate_exception_handler_common(const char* name, const char* message, bool pass_oop) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
117 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
118 //__ untested("generate_exception_handler_common");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
119 Register Rexception = R17_tos;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
120
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
121 // Expression stack must be empty before entering the VM if an exception happened.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
122 __ empty_expression_stack();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
123
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
124 __ load_const_optimized(R4_ARG2, (address) name, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
125 if (pass_oop) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
126 __ mr(R5_ARG3, Rexception);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
127 __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_klass_exception), false);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
128 } else {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
129 __ load_const_optimized(R5_ARG3, (address) message, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
130 __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_exception), false);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
131 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
132
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
133 // Throw exception.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
134 __ mr(R3_ARG1, Rexception);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
135 __ load_const_optimized(R11_scratch1, Interpreter::throw_exception_entry(), R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
136 __ mtctr(R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
137 __ bctr();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
138
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
139 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
140 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
141
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
142 address TemplateInterpreterGenerator::generate_continuation_for(TosState state) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
143 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
144 __ unimplemented("generate_continuation_for");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
145 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
146 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
147
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
148 // This entry is returned to when a call returns to the interpreter.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
149 // When we arrive here, we expect that the callee stack frame is already popped.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
150 address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step, size_t index_size) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
151 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
152
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
153 // Move the value out of the return register back to the TOS cache of current frame.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
154 switch (state) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
155 case ltos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
156 case btos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
157 case ctos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
158 case stos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
159 case atos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
160 case itos: __ mr(R17_tos, R3_RET); break; // RET -> TOS cache
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
161 case ftos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
162 case dtos: __ fmr(F15_ftos, F1_RET); break; // TOS cache -> GR_FRET
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
163 case vtos: break; // Nothing to do, this was a void return.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
164 default : ShouldNotReachHere();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
165 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
166
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
167 __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
168 __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
169 __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
170
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
171 // Compiled code destroys templateTableBase, reload.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
172 __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
173
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
174 const Register cache = R11_scratch1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
175 const Register size = R12_scratch2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
176 __ get_cache_and_index_at_bcp(cache, 1, index_size);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
177
20418
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
178 // Get least significant byte of 64 bit value:
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
179 #if defined(VM_LITTLE_ENDIAN)
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
180 __ lbz(size, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()), cache);
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
181 #else
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
182 __ lbz(size, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()) + 7, cache);
20418
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
183 #endif
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
184 __ sldi(size, size, Interpreter::logStackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
185 __ add(R15_esp, R15_esp, size);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
186 __ dispatch_next(state, step);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
187 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
188 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
189
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
190 address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, int step) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
191 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
192 // If state != vtos, we're returning from a native method, which put it's result
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
193 // into the result register. So move the value out of the return register back
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
194 // to the TOS cache of current frame.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
195
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
196 switch (state) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
197 case ltos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
198 case btos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
199 case ctos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
200 case stos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
201 case atos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
202 case itos: __ mr(R17_tos, R3_RET); break; // GR_RET -> TOS cache
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
203 case ftos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
204 case dtos: __ fmr(F15_ftos, F1_RET); break; // TOS cache -> GR_FRET
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
205 case vtos: break; // Nothing to do, this was a void return.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
206 default : ShouldNotReachHere();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
207 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
208
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
209 // Load LcpoolCache @@@ should be already set!
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
210 __ get_constant_pool_cache(R27_constPoolCache);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
211
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
212 // Handle a pending exception, fall through if none.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
213 __ check_and_forward_exception(R11_scratch1, R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
214
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
215 // Start executing bytecodes.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
216 __ dispatch_next(state, step);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
217
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
218 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
219 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
220
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
221 // A result handler converts the native result into java format.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
222 // Use the shared code between c++ and template interpreter.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
223 address TemplateInterpreterGenerator::generate_result_handler_for(BasicType type) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
224 return AbstractInterpreterGenerator::generate_result_handler_for(type);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
225 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
226
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
227 address TemplateInterpreterGenerator::generate_safept_entry_for(TosState state, address runtime_entry) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
228 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
229
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
230 __ push(state);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
231 __ call_VM(noreg, runtime_entry);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
232 __ dispatch_via(vtos, Interpreter::_normal_table.table_for(vtos));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
233
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
234 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
235 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
236
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
237 // Helpers for commoning out cases in the various type of method entries.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
238
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
239 // Increment invocation count & check for overflow.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
240 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
241 // Note: checking for negative value instead of overflow
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
242 // so we have a 'sticky' overflow test.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
243 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
244 void TemplateInterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
245 // Note: In tiered we increment either counters in method or in MDO depending if we're profiling or not.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
246 Register Rscratch1 = R11_scratch1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
247 Register Rscratch2 = R12_scratch2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
248 Register R3_counters = R3_ARG1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
249 Label done;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
250
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
251 if (TieredCompilation) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
252 const int increment = InvocationCounter::count_increment;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
253 const int mask = ((1 << Tier0InvokeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
254 Label no_mdo;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
255 if (ProfileInterpreter) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
256 const Register Rmdo = Rscratch1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
257 // If no method data exists, go to profile_continue.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
258 __ ld(Rmdo, in_bytes(Method::method_data_offset()), R19_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
259 __ cmpdi(CCR0, Rmdo, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
260 __ beq(CCR0, no_mdo);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
261
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
262 // Increment backedge counter in the MDO.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
263 const int mdo_bc_offs = in_bytes(MethodData::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
264 __ lwz(Rscratch2, mdo_bc_offs, Rmdo);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
265 __ addi(Rscratch2, Rscratch2, increment);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
266 __ stw(Rscratch2, mdo_bc_offs, Rmdo);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
267 __ load_const_optimized(Rscratch1, mask, R0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
268 __ and_(Rscratch1, Rscratch2, Rscratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
269 __ bne(CCR0, done);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
270 __ b(*overflow);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
271 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
272
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
273 // Increment counter in MethodCounters*.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
274 const int mo_bc_offs = in_bytes(MethodCounters::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
275 __ bind(no_mdo);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
276 __ get_method_counters(R19_method, R3_counters, done);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
277 __ lwz(Rscratch2, mo_bc_offs, R3_counters);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
278 __ addi(Rscratch2, Rscratch2, increment);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
279 __ stw(Rscratch2, mo_bc_offs, R3_counters);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
280 __ load_const_optimized(Rscratch1, mask, R0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
281 __ and_(Rscratch1, Rscratch2, Rscratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
282 __ beq(CCR0, *overflow);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
283
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
284 __ bind(done);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
285
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
286 } else {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
287
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
288 // Update standard invocation counters.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
289 Register Rsum_ivc_bec = R4_ARG2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
290 __ get_method_counters(R19_method, R3_counters, done);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
291 __ increment_invocation_counter(R3_counters, Rsum_ivc_bec, R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
292 // Increment interpreter invocation counter.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
293 if (ProfileInterpreter) { // %%% Merge this into methodDataOop.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
294 __ lwz(R12_scratch2, in_bytes(MethodCounters::interpreter_invocation_counter_offset()), R3_counters);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
295 __ addi(R12_scratch2, R12_scratch2, 1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
296 __ stw(R12_scratch2, in_bytes(MethodCounters::interpreter_invocation_counter_offset()), R3_counters);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
297 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
298 // Check if we must create a method data obj.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
299 if (ProfileInterpreter && profile_method != NULL) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
300 const Register profile_limit = Rscratch1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
301 int pl_offs = __ load_const_optimized(profile_limit, &InvocationCounter::InterpreterProfileLimit, R0, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
302 __ lwz(profile_limit, pl_offs, profile_limit);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
303 // Test to see if we should create a method data oop.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
304 __ cmpw(CCR0, Rsum_ivc_bec, profile_limit);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
305 __ blt(CCR0, *profile_method_continue);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
306 // If no method data exists, go to profile_method.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
307 __ test_method_data_pointer(*profile_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
308 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
309 // Finally check for counter overflow.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
310 if (overflow) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
311 const Register invocation_limit = Rscratch1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
312 int il_offs = __ load_const_optimized(invocation_limit, &InvocationCounter::InterpreterInvocationLimit, R0, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
313 __ lwz(invocation_limit, il_offs, invocation_limit);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
314 assert(4 == sizeof(InvocationCounter::InterpreterInvocationLimit), "unexpected field size");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
315 __ cmpw(CCR0, Rsum_ivc_bec, invocation_limit);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
316 __ bge(CCR0, *overflow);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
317 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
318
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
319 __ bind(done);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
320 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
321 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
322
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
323 // Generate code to initiate compilation on invocation counter overflow.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
324 void TemplateInterpreterGenerator::generate_counter_overflow(Label& continue_entry) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
325 // Generate code to initiate compilation on the counter overflow.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
326
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
327 // InterpreterRuntime::frequency_counter_overflow takes one arguments,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
328 // which indicates if the counter overflow occurs at a backwards branch (NULL bcp)
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
329 // We pass zero in.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
330 // The call returns the address of the verified entry point for the method or NULL
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
331 // if the compilation did not complete (either went background or bailed out).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
332 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
333 // Unlike the C++ interpreter above: Check exceptions!
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
334 // Assumption: Caller must set the flag "do_not_unlock_if_sychronized" if the monitor of a sync'ed
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
335 // method has not yet been created. Thus, no unlocking of a non-existing monitor can occur.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
336
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
337 __ li(R4_ARG2, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
338 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), R4_ARG2, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
339
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
340 // Returns verified_entry_point or NULL.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
341 // We ignore it in any case.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
342 __ b(continue_entry);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
343 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
344
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
345 void TemplateInterpreterGenerator::generate_stack_overflow_check(Register Rmem_frame_size, Register Rscratch1) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
346 assert_different_registers(Rmem_frame_size, Rscratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
347 __ generate_stack_overflow_check_with_compare_and_throw(Rmem_frame_size, Rscratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
348 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
349
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
350 void TemplateInterpreterGenerator::unlock_method(bool check_exceptions) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
351 __ unlock_object(R26_monitor, check_exceptions);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
352 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
353
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
354 // Lock the current method, interpreter register window must be set up!
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
355 void TemplateInterpreterGenerator::lock_method(Register Rflags, Register Rscratch1, Register Rscratch2, bool flags_preloaded) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
356 const Register Robj_to_lock = Rscratch2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
357
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
358 {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
359 if (!flags_preloaded) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
360 __ lwz(Rflags, method_(access_flags));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
361 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
362
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
363 #ifdef ASSERT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
364 // Check if methods needs synchronization.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
365 {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
366 Label Lok;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
367 __ testbitdi(CCR0, R0, Rflags, JVM_ACC_SYNCHRONIZED_BIT);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
368 __ btrue(CCR0,Lok);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
369 __ stop("method doesn't need synchronization");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
370 __ bind(Lok);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
371 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
372 #endif // ASSERT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
373 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
374
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
375 // Get synchronization object to Rscratch2.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
376 {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
377 const int mirror_offset = in_bytes(Klass::java_mirror_offset());
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
378 Label Lstatic;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
379 Label Ldone;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
380
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
381 __ testbitdi(CCR0, R0, Rflags, JVM_ACC_STATIC_BIT);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
382 __ btrue(CCR0, Lstatic);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
383
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
384 // Non-static case: load receiver obj from stack and we're done.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
385 __ ld(Robj_to_lock, R18_locals);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
386 __ b(Ldone);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
387
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
388 __ bind(Lstatic); // Static case: Lock the java mirror
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
389 __ ld(Robj_to_lock, in_bytes(Method::const_offset()), R19_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
390 __ ld(Robj_to_lock, in_bytes(ConstMethod::constants_offset()), Robj_to_lock);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
391 __ ld(Robj_to_lock, ConstantPool::pool_holder_offset_in_bytes(), Robj_to_lock);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
392 __ ld(Robj_to_lock, mirror_offset, Robj_to_lock);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
393
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
394 __ bind(Ldone);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
395 __ verify_oop(Robj_to_lock);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
396 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
397
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
398 // Got the oop to lock => execute!
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
399 __ add_monitor_to_stack(true, Rscratch1, R0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
400
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
401 __ std(Robj_to_lock, BasicObjectLock::obj_offset_in_bytes(), R26_monitor);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
402 __ lock_object(R26_monitor, Robj_to_lock);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
403 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
404
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
405 // Generate a fixed interpreter frame for pure interpreter
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
406 // and I2N native transition frames.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
407 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
408 // Before (stack grows downwards):
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
409 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
410 // | ... |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
411 // |------------- |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
412 // | java arg0 |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
413 // | ... |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
414 // | java argn |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
415 // | | <- R15_esp
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
416 // | |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
417 // |--------------|
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
418 // | abi_112 |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
419 // | | <- R1_SP
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
420 // |==============|
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
421 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
422 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
423 // After:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
424 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
425 // | ... |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
426 // | java arg0 |<- R18_locals
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
427 // | ... |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
428 // | java argn |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
429 // |--------------|
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
430 // | |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
431 // | java locals |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
432 // | |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
433 // |--------------|
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
434 // | abi_48 |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
435 // |==============|
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
436 // | |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
437 // | istate |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
438 // | |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
439 // |--------------|
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
440 // | monitor |<- R26_monitor
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
441 // |--------------|
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
442 // | |<- R15_esp
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
443 // | expression |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
444 // | stack |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
445 // | |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
446 // |--------------|
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
447 // | |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
448 // | abi_112 |<- R1_SP
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
449 // |==============|
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
450 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
451 // The top most frame needs an abi space of 112 bytes. This space is needed,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
452 // since we call to c. The c function may spill their arguments to the caller
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
453 // frame. When we call to java, we don't need these spill slots. In order to save
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
454 // space on the stack, we resize the caller. However, java local reside in
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
455 // the caller frame and the frame has to be increased. The frame_size for the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
456 // current frame was calculated based on max_stack as size for the expression
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
457 // stack. At the call, just a part of the expression stack might be used.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
458 // We don't want to waste this space and cut the frame back accordingly.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
459 // The resulting amount for resizing is calculated as follows:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
460 // resize = (number_of_locals - number_of_arguments) * slot_size
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
461 // + (R1_SP - R15_esp) + 48
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
462 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
463 // The size for the callee frame is calculated:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
464 // framesize = 112 + max_stack + monitor + state_size
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
465 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
466 // maxstack: Max number of slots on the expression stack, loaded from the method.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
467 // monitor: We statically reserve room for one monitor object.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
468 // state_size: We save the current state of the interpreter to this area.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
469 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
470 void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Register Rsize_of_parameters, Register Rsize_of_locals) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
471 Register parent_frame_resize = R6_ARG4, // Frame will grow by this number of bytes.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
472 top_frame_size = R7_ARG5,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
473 Rconst_method = R8_ARG6;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
474
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
475 assert_different_registers(Rsize_of_parameters, Rsize_of_locals, parent_frame_resize, top_frame_size);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
476
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
477 __ ld(Rconst_method, method_(const));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
478 __ lhz(Rsize_of_parameters /* number of params */,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
479 in_bytes(ConstMethod::size_of_parameters_offset()), Rconst_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
480 if (native_call) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
481 // If we're calling a native method, we reserve space for the worst-case signature
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
482 // handler varargs vector, which is max(Argument::n_register_parameters, parameter_count+2).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
483 // We add two slots to the parameter_count, one for the jni
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
484 // environment and one for a possible native mirror.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
485 Label skip_native_calculate_max_stack;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
486 __ addi(top_frame_size, Rsize_of_parameters, 2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
487 __ cmpwi(CCR0, top_frame_size, Argument::n_register_parameters);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
488 __ bge(CCR0, skip_native_calculate_max_stack);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
489 __ li(top_frame_size, Argument::n_register_parameters);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
490 __ bind(skip_native_calculate_max_stack);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
491 __ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
492 __ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
493 __ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
494 assert(Rsize_of_locals == noreg, "Rsize_of_locals not initialized"); // Only relevant value is Rsize_of_parameters.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
495 } else {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
496 __ lhz(Rsize_of_locals /* number of params */, in_bytes(ConstMethod::size_of_locals_offset()), Rconst_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
497 __ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
498 __ sldi(Rsize_of_locals, Rsize_of_locals, Interpreter::logStackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
499 __ lhz(top_frame_size, in_bytes(ConstMethod::max_stack_offset()), Rconst_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
500 __ sub(R11_scratch1, Rsize_of_locals, Rsize_of_parameters); // >=0
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
501 __ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
502 __ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
503 __ add(parent_frame_resize, parent_frame_resize, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
504 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
505
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
506 // Compute top frame size.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
507 __ addi(top_frame_size, top_frame_size, frame::abi_reg_args_size + frame::ijava_state_size);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
508
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
509 // Cut back area between esp and max_stack.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
510 __ addi(parent_frame_resize, parent_frame_resize, frame::abi_minframe_size - Interpreter::stackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
511
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
512 __ round_to(top_frame_size, frame::alignment_in_bytes);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
513 __ round_to(parent_frame_resize, frame::alignment_in_bytes);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
514 // parent_frame_resize = (locals-parameters) - (ESP-SP-ABI48) Rounded to frame alignment size.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
515 // Enlarge by locals-parameters (not in case of native_call), shrink by ESP-SP-ABI48.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
516
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
517 {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
518 // --------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
519 // Stack overflow check
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
520
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
521 Label cont;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
522 __ add(R11_scratch1, parent_frame_resize, top_frame_size);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
523 generate_stack_overflow_check(R11_scratch1, R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
524 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
525
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
526 // Set up interpreter state registers.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
527
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
528 __ add(R18_locals, R15_esp, Rsize_of_parameters);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
529 __ ld(R27_constPoolCache, in_bytes(ConstMethod::constants_offset()), Rconst_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
530 __ ld(R27_constPoolCache, ConstantPool::cache_offset_in_bytes(), R27_constPoolCache);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
531
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
532 // Set method data pointer.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
533 if (ProfileInterpreter) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
534 Label zero_continue;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
535 __ ld(R28_mdx, method_(method_data));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
536 __ cmpdi(CCR0, R28_mdx, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
537 __ beq(CCR0, zero_continue);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
538 __ addi(R28_mdx, R28_mdx, in_bytes(MethodData::data_offset()));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
539 __ bind(zero_continue);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
540 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
541
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
542 if (native_call) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
543 __ li(R14_bcp, 0); // Must initialize.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
544 } else {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
545 __ add(R14_bcp, in_bytes(ConstMethod::codes_offset()), Rconst_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
546 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
547
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
548 // Resize parent frame.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
549 __ mflr(R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
550 __ neg(parent_frame_resize, parent_frame_resize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
551 __ resize_frame(parent_frame_resize, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
552 __ std(R12_scratch2, _abi(lr), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
553
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
554 __ addi(R26_monitor, R1_SP, - frame::ijava_state_size);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
555 __ addi(R15_esp, R26_monitor, - Interpreter::stackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
556
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
557 // Store values.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
558 // R15_esp, R14_bcp, R26_monitor, R28_mdx are saved at java calls
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
559 // in InterpreterMacroAssembler::call_from_interpreter.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
560 __ std(R19_method, _ijava_state_neg(method), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
561 __ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
562 __ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
563 __ std(R18_locals, _ijava_state_neg(locals), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
564
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
565 // Note: esp, bcp, monitor, mdx live in registers. Hence, the correct version can only
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
566 // be found in the frame after save_interpreter_state is done. This is always true
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
567 // for non-top frames. But when a signal occurs, dumping the top frame can go wrong,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
568 // because e.g. frame::interpreter_frame_bcp() will not access the correct value
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
569 // (Enhanced Stack Trace).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
570 // The signal handler does not save the interpreter state into the frame.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
571 __ li(R0, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
572 #ifdef ASSERT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
573 // Fill remaining slots with constants.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
574 __ load_const_optimized(R11_scratch1, 0x5afe);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
575 __ load_const_optimized(R12_scratch2, 0xdead);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
576 #endif
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
577 // We have to initialize some frame slots for native calls (accessed by GC).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
578 if (native_call) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
579 __ std(R26_monitor, _ijava_state_neg(monitors), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
580 __ std(R14_bcp, _ijava_state_neg(bcp), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
581 if (ProfileInterpreter) { __ std(R28_mdx, _ijava_state_neg(mdx), R1_SP); }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
582 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
583 #ifdef ASSERT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
584 else {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
585 __ std(R12_scratch2, _ijava_state_neg(monitors), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
586 __ std(R12_scratch2, _ijava_state_neg(bcp), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
587 __ std(R12_scratch2, _ijava_state_neg(mdx), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
588 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
589 __ std(R11_scratch1, _ijava_state_neg(ijava_reserved), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
590 __ std(R12_scratch2, _ijava_state_neg(esp), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
591 __ std(R12_scratch2, _ijava_state_neg(lresult), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
592 __ std(R12_scratch2, _ijava_state_neg(fresult), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
593 #endif
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
594 __ subf(R12_scratch2, top_frame_size, R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
595 __ std(R0, _ijava_state_neg(oop_tmp), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
596 __ std(R12_scratch2, _ijava_state_neg(top_frame_sp), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
597
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
598 // Push top frame.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
599 __ push_frame(top_frame_size, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
600 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
601
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
602 // End of helpers
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
603
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
604 // ============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
605 // Various method entries
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
606 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
607
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
608 // Empty method, generate a very fast return. We must skip this entry if
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
609 // someone's debugging, indicated by the flag
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
610 // "interp_mode" in the Thread obj.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
611 // Note: empty methods are generated mostly methods that do assertions, which are
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
612 // disabled in the "java opt build".
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
613 address TemplateInterpreterGenerator::generate_empty_entry(void) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
614 if (!UseFastEmptyMethods) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
615 NOT_PRODUCT(__ should_not_reach_here();)
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
616 return Interpreter::entry_for_kind(Interpreter::zerolocals);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
617 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
618
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
619 Label Lslow_path;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
620 const Register Rjvmti_mode = R11_scratch1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
621 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
622
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
623 __ lwz(Rjvmti_mode, thread_(interp_only_mode));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
624 __ cmpwi(CCR0, Rjvmti_mode, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
625 __ bne(CCR0, Lslow_path); // jvmti_mode!=0
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
626
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
627 // Noone's debuggin: Simply return.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
628 // Pop c2i arguments (if any) off when we return.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
629 #ifdef ASSERT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
630 __ ld(R9_ARG7, 0, R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
631 __ ld(R10_ARG8, 0, R21_sender_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
632 __ cmpd(CCR0, R9_ARG7, R10_ARG8);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
633 __ asm_assert_eq("backlink", 0x545);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
634 #endif // ASSERT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
635 __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
636
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
637 // And we're done.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
638 __ blr();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
639
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
640 __ bind(Lslow_path);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
641 __ branch_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
642 __ flush();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
643
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
644 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
645 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
646
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
647 // Support abs and sqrt like in compiler.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
648 // For others we can use a normal (native) entry.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
649
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
650 inline bool math_entry_available(AbstractInterpreter::MethodKind kind) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
651 // Provide math entry with debugging on demand.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
652 // Note: Debugging changes which code will get executed:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
653 // Debugging or disabled InlineIntrinsics: java method will get interpreted and performs a native call.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
654 // Not debugging and enabled InlineIntrinics: processor instruction will get used.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
655 // Result might differ slightly due to rounding etc.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
656 if (!InlineIntrinsics && (!FLAG_IS_ERGO(InlineIntrinsics))) return false; // Generate a vanilla entry.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
657
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
658 return ((kind==Interpreter::java_lang_math_sqrt && VM_Version::has_fsqrt()) ||
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
659 (kind==Interpreter::java_lang_math_abs));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
660 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
661
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
662 address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
663 if (!math_entry_available(kind)) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
664 NOT_PRODUCT(__ should_not_reach_here();)
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
665 return Interpreter::entry_for_kind(Interpreter::zerolocals);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
666 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
667
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
668 Label Lslow_path;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
669 const Register Rjvmti_mode = R11_scratch1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
670 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
671
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
672 // Provide math entry with debugging on demand.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
673 __ lwz(Rjvmti_mode, thread_(interp_only_mode));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
674 __ cmpwi(CCR0, Rjvmti_mode, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
675 __ bne(CCR0, Lslow_path); // jvmti_mode!=0
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
676
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
677 __ lfd(F1_RET, Interpreter::stackElementSize, R15_esp);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
678
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
679 // Pop c2i arguments (if any) off when we return.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
680 #ifdef ASSERT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
681 __ ld(R9_ARG7, 0, R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
682 __ ld(R10_ARG8, 0, R21_sender_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
683 __ cmpd(CCR0, R9_ARG7, R10_ARG8);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
684 __ asm_assert_eq("backlink", 0x545);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
685 #endif // ASSERT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
686 __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
687
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
688 if (kind == Interpreter::java_lang_math_sqrt) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
689 __ fsqrt(F1_RET, F1_RET);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
690 } else if (kind == Interpreter::java_lang_math_abs) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
691 __ fabs(F1_RET, F1_RET);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
692 } else {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
693 ShouldNotReachHere();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
694 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
695
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
696 // And we're done.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
697 __ blr();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
698
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
699 // Provide slow path for JVMTI case.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
700 __ bind(Lslow_path);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
701 __ branch_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals), R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
702 __ flush();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
703
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
704 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
705 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
706
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
707 // Interpreter stub for calling a native method. (asm interpreter)
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
708 // This sets up a somewhat different looking stack for calling the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
709 // native method than the typical interpreter frame setup.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
710 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
711 // On entry:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
712 // R19_method - method
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
713 // R16_thread - JavaThread*
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
714 // R15_esp - intptr_t* sender tos
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
715 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
716 // abstract stack (grows up)
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
717 // [ IJava (caller of JNI callee) ] <-- ASP
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
718 // ...
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
719 address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
720
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
721 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
722
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
723 const bool inc_counter = UseCompiler || CountCompiledCalls;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
724
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
725 // -----------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
726 // Allocate a new frame that represents the native callee (i2n frame).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
727 // This is not a full-blown interpreter frame, but in particular, the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
728 // following registers are valid after this:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
729 // - R19_method
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
730 // - R18_local (points to start of argumuments to native function)
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
731 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
732 // abstract stack (grows up)
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
733 // [ IJava (caller of JNI callee) ] <-- ASP
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
734 // ...
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
735
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
736 const Register signature_handler_fd = R11_scratch1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
737 const Register pending_exception = R0;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
738 const Register result_handler_addr = R31;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
739 const Register native_method_fd = R11_scratch1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
740 const Register access_flags = R22_tmp2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
741 const Register active_handles = R11_scratch1; // R26_monitor saved to state.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
742 const Register sync_state = R12_scratch2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
743 const Register sync_state_addr = sync_state; // Address is dead after use.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
744 const Register suspend_flags = R11_scratch1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
745
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
746 //=============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
747 // Allocate new frame and initialize interpreter state.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
748
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
749 Label exception_return;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
750 Label exception_return_sync_check;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
751 Label stack_overflow_return;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
752
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
753 // Generate new interpreter state and jump to stack_overflow_return in case of
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
754 // a stack overflow.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
755 //generate_compute_interpreter_state(stack_overflow_return);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
756
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
757 Register size_of_parameters = R22_tmp2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
758
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
759 generate_fixed_frame(true, size_of_parameters, noreg /* unused */);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
760
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
761 //=============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
762 // Increment invocation counter. On overflow, entry to JNI method
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
763 // will be compiled.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
764 Label invocation_counter_overflow, continue_after_compile;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
765 if (inc_counter) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
766 if (synchronized) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
767 // Since at this point in the method invocation the exception handler
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
768 // would try to exit the monitor of synchronized methods which hasn't
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
769 // been entered yet, we set the thread local variable
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
770 // _do_not_unlock_if_synchronized to true. If any exception was thrown by
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
771 // runtime, exception handling i.e. unlock_if_synchronized_method will
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
772 // check this thread local flag.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
773 // This flag has two effects, one is to force an unwind in the topmost
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
774 // interpreter frame and not perform an unlock while doing so.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
775 __ li(R0, 1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
776 __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
777 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
778 generate_counter_incr(&invocation_counter_overflow, NULL, NULL);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
779
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
780 __ BIND(continue_after_compile);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
781 // Reset the _do_not_unlock_if_synchronized flag.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
782 if (synchronized) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
783 __ li(R0, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
784 __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
785 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
786 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
787
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
788 // access_flags = method->access_flags();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
789 // Load access flags.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
790 assert(access_flags->is_nonvolatile(),
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
791 "access_flags must be in a non-volatile register");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
792 // Type check.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
793 assert(4 == sizeof(AccessFlags), "unexpected field size");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
794 __ lwz(access_flags, method_(access_flags));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
795
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
796 // We don't want to reload R19_method and access_flags after calls
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
797 // to some helper functions.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
798 assert(R19_method->is_nonvolatile(),
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
799 "R19_method must be a non-volatile register");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
800
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
801 // Check for synchronized methods. Must happen AFTER invocation counter
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
802 // check, so method is not locked if counter overflows.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
803
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
804 if (synchronized) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
805 lock_method(access_flags, R11_scratch1, R12_scratch2, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
806
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
807 // Update monitor in state.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
808 __ ld(R11_scratch1, 0, R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
809 __ std(R26_monitor, _ijava_state_neg(monitors), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
810 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
811
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
812 // jvmti/jvmpi support
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
813 __ notify_method_entry();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
814
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
815 //=============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
816 // Get and call the signature handler.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
817
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
818 __ ld(signature_handler_fd, method_(signature_handler));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
819 Label call_signature_handler;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
820
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
821 __ cmpdi(CCR0, signature_handler_fd, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
822 __ bne(CCR0, call_signature_handler);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
823
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
824 // Method has never been called. Either generate a specialized
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
825 // handler or point to the slow one.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
826 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
827 // Pass parameter 'false' to avoid exception check in call_VM.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
828 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), R19_method, false);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
829
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
830 // Check for an exception while looking up the target method. If we
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
831 // incurred one, bail.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
832 __ ld(pending_exception, thread_(pending_exception));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
833 __ cmpdi(CCR0, pending_exception, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
834 __ bne(CCR0, exception_return_sync_check); // Has pending exception.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
835
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
836 // Reload signature handler, it may have been created/assigned in the meanwhile.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
837 __ ld(signature_handler_fd, method_(signature_handler));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
838 __ twi_0(signature_handler_fd); // Order wrt. load of klass mirror and entry point (isync is below).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
839
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
840 __ BIND(call_signature_handler);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
841
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
842 // Before we call the signature handler we push a new frame to
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
843 // protect the interpreter frame volatile registers when we return
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
844 // from jni but before we can get back to Java.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
845
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
846 // First set the frame anchor while the SP/FP registers are
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
847 // convenient and the slow signature handler can use this same frame
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
848 // anchor.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
849
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
850 // We have a TOP_IJAVA_FRAME here, which belongs to us.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
851 __ set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R12_scratch2/*tmp*/);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
852
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
853 // Now the interpreter frame (and its call chain) have been
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
854 // invalidated and flushed. We are now protected against eager
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
855 // being enabled in native code. Even if it goes eager the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
856 // registers will be reloaded as clean and we will invalidate after
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
857 // the call so no spurious flush should be possible.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
858
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
859 // Call signature handler and pass locals address.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
860 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
861 // Our signature handlers copy required arguments to the C stack
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
862 // (outgoing C args), R3_ARG1 to R10_ARG8, and FARG1 to FARG13.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
863 __ mr(R3_ARG1, R18_locals);
20418
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
864 #if !defined(ABI_ELFv2)
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
865 __ ld(signature_handler_fd, 0, signature_handler_fd);
20418
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
866 #endif
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
867
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
868 __ call_stub(signature_handler_fd);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
869
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
870 // Remove the register parameter varargs slots we allocated in
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
871 // compute_interpreter_state. SP+16 ends up pointing to the ABI
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
872 // outgoing argument area.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
873 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
874 // Not needed on PPC64.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
875 //__ add(SP, SP, Argument::n_register_parameters*BytesPerWord);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
876
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
877 assert(result_handler_addr->is_nonvolatile(), "result_handler_addr must be in a non-volatile register");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
878 // Save across call to native method.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
879 __ mr(result_handler_addr, R3_RET);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
880
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
881 __ isync(); // Acquire signature handler before trying to fetch the native entry point and klass mirror.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
882
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
883 // Set up fixed parameters and call the native method.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
884 // If the method is static, get mirror into R4_ARG2.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
885 {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
886 Label method_is_not_static;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
887 // Access_flags is non-volatile and still, no need to restore it.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
888
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
889 // Restore access flags.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
890 __ testbitdi(CCR0, R0, access_flags, JVM_ACC_STATIC_BIT);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
891 __ bfalse(CCR0, method_is_not_static);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
892
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
893 // constants = method->constants();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
894 __ ld(R11_scratch1, in_bytes(Method::const_offset()), R19_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
895 __ ld(R11_scratch1, in_bytes(ConstMethod::constants_offset()), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
896 // pool_holder = method->constants()->pool_holder();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
897 __ ld(R11_scratch1/*pool_holder*/, ConstantPool::pool_holder_offset_in_bytes(),
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
898 R11_scratch1/*constants*/);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
899
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
900 const int mirror_offset = in_bytes(Klass::java_mirror_offset());
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
901
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
902 // mirror = pool_holder->klass_part()->java_mirror();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
903 __ ld(R0/*mirror*/, mirror_offset, R11_scratch1/*pool_holder*/);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
904 // state->_native_mirror = mirror;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
905
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
906 __ ld(R11_scratch1, 0, R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
907 __ std(R0/*mirror*/, _ijava_state_neg(oop_tmp), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
908 // R4_ARG2 = &state->_oop_temp;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
909 __ addi(R4_ARG2, R11_scratch1, _ijava_state_neg(oop_tmp));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
910 __ BIND(method_is_not_static);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
911 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
912
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
913 // At this point, arguments have been copied off the stack into
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
914 // their JNI positions. Oops are boxed in-place on the stack, with
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
915 // handles copied to arguments. The result handler address is in a
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
916 // register.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
917
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
918 // Pass JNIEnv address as first parameter.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
919 __ addir(R3_ARG1, thread_(jni_environment));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
920
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
921 // Load the native_method entry before we change the thread state.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
922 __ ld(native_method_fd, method_(native_function));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
923
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
924 //=============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
925 // Transition from _thread_in_Java to _thread_in_native. As soon as
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
926 // we make this change the safepoint code needs to be certain that
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
927 // the last Java frame we established is good. The pc in that frame
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
928 // just needs to be near here not an actual return address.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
929
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
930 // We use release_store_fence to update values like the thread state, where
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
931 // we don't want the current thread to continue until all our prior memory
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
932 // accesses (including the new thread state) are visible to other threads.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
933 __ li(R0, _thread_in_native);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
934 __ release();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
935
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
936 // TODO PPC port assert(4 == JavaThread::sz_thread_state(), "unexpected field size");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
937 __ stw(R0, thread_(thread_state));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
938
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
939 if (UseMembar) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
940 __ fence();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
941 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
942
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
943 //=============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
944 // Call the native method. Argument registers must not have been
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
945 // overwritten since "__ call_stub(signature_handler);" (except for
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
946 // ARG1 and ARG2 for static methods).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
947 __ call_c(native_method_fd);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
948
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
949 __ li(R0, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
950 __ ld(R11_scratch1, 0, R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
951 __ std(R3_RET, _ijava_state_neg(lresult), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
952 __ stfd(F1_RET, _ijava_state_neg(fresult), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
953 __ std(R0/*mirror*/, _ijava_state_neg(oop_tmp), R11_scratch1); // reset
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
954
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
955 // Note: C++ interpreter needs the following here:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
956 // The frame_manager_lr field, which we use for setting the last
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
957 // java frame, gets overwritten by the signature handler. Restore
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
958 // it now.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
959 //__ get_PC_trash_LR(R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
960 //__ std(R11_scratch1, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
961
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
962 // Because of GC R19_method may no longer be valid.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
963
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
964 // Block, if necessary, before resuming in _thread_in_Java state.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
965 // In order for GC to work, don't clear the last_Java_sp until after
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
966 // blocking.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
967
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
968 //=============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
969 // Switch thread to "native transition" state before reading the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
970 // synchronization state. This additional state is necessary
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
971 // because reading and testing the synchronization state is not
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
972 // atomic w.r.t. GC, as this scenario demonstrates: Java thread A,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
973 // in _thread_in_native state, loads _not_synchronized and is
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
974 // preempted. VM thread changes sync state to synchronizing and
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
975 // suspends threads for GC. Thread A is resumed to finish this
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
976 // native method, but doesn't block here since it didn't see any
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
977 // synchronization in progress, and escapes.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
978
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
979 // We use release_store_fence to update values like the thread state, where
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
980 // we don't want the current thread to continue until all our prior memory
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
981 // accesses (including the new thread state) are visible to other threads.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
982 __ li(R0/*thread_state*/, _thread_in_native_trans);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
983 __ release();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
984 __ stw(R0/*thread_state*/, thread_(thread_state));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
985 if (UseMembar) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
986 __ fence();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
987 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
988 // Write serialization page so that the VM thread can do a pseudo remote
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
989 // membar. We use the current thread pointer to calculate a thread
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
990 // specific offset to write to within the page. This minimizes bus
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
991 // traffic due to cache line collision.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
992 else {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
993 __ serialize_memory(R16_thread, R11_scratch1, R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
994 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
995
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
996 // Now before we return to java we must look for a current safepoint
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
997 // (a new safepoint can not start since we entered native_trans).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
998 // We must check here because a current safepoint could be modifying
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
999 // the callers registers right this moment.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1000
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1001 // Acquire isn't strictly necessary here because of the fence, but
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1002 // sync_state is declared to be volatile, so we do it anyway
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1003 // (cmp-br-isync on one path, release (same as acquire on PPC64) on the other path).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1004 int sync_state_offs = __ load_const_optimized(sync_state_addr, SafepointSynchronize::address_of_state(), /*temp*/R0, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1005
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1006 // TODO PPC port assert(4 == SafepointSynchronize::sz_state(), "unexpected field size");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1007 __ lwz(sync_state, sync_state_offs, sync_state_addr);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1008
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1009 // TODO PPC port assert(4 == Thread::sz_suspend_flags(), "unexpected field size");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1010 __ lwz(suspend_flags, thread_(suspend_flags));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1011
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1012 Label sync_check_done;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1013 Label do_safepoint;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1014 // No synchronization in progress nor yet synchronized.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1015 __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1016 // Not suspended.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1017 __ cmpwi(CCR1, suspend_flags, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1018
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1019 __ bne(CCR0, do_safepoint);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1020 __ beq(CCR1, sync_check_done);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1021 __ bind(do_safepoint);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1022 __ isync();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1023 // Block. We do the call directly and leave the current
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1024 // last_Java_frame setup undisturbed. We must save any possible
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1025 // native result across the call. No oop is present.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1026
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1027 __ mr(R3_ARG1, R16_thread);
20418
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
1028 #if defined(ABI_ELFv2)
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
1029 __ call_c(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans),
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
1030 relocInfo::none);
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
1031 #else
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1032 __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, JavaThread::check_special_condition_for_native_trans),
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1033 relocInfo::none);
20418
b384ba33c9a0 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 17980
diff changeset
1034 #endif
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1035
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1036 __ bind(sync_check_done);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1037
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1038 //=============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1039 // <<<<<< Back in Interpreter Frame >>>>>
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1040
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1041 // We are in thread_in_native_trans here and back in the normal
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1042 // interpreter frame. We don't have to do anything special about
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1043 // safepoints and we can switch to Java mode anytime we are ready.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1044
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1045 // Note: frame::interpreter_frame_result has a dependency on how the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1046 // method result is saved across the call to post_method_exit. For
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1047 // native methods it assumes that the non-FPU/non-void result is
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1048 // saved in _native_lresult and a FPU result in _native_fresult. If
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1049 // this changes then the interpreter_frame_result implementation
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1050 // will need to be updated too.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1051
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1052 // On PPC64, we have stored the result directly after the native call.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1053
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1054 //=============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1055 // Back in Java
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1056
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1057 // We use release_store_fence to update values like the thread state, where
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1058 // we don't want the current thread to continue until all our prior memory
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1059 // accesses (including the new thread state) are visible to other threads.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1060 __ li(R0/*thread_state*/, _thread_in_Java);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1061 __ release();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1062 __ stw(R0/*thread_state*/, thread_(thread_state));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1063 if (UseMembar) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1064 __ fence();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1065 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1066
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1067 __ reset_last_Java_frame();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1068
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1069 // Jvmdi/jvmpi support. Whether we've got an exception pending or
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1070 // not, and whether unlocking throws an exception or not, we notify
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1071 // on native method exit. If we do have an exception, we'll end up
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1072 // in the caller's context to handle it, so if we don't do the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1073 // notify here, we'll drop it on the floor.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1074 __ notify_method_exit(true/*native method*/,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1075 ilgl /*illegal state (not used for native methods)*/,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1076 InterpreterMacroAssembler::NotifyJVMTI,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1077 false /*check_exceptions*/);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1078
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1079 //=============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1080 // Handle exceptions
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1081
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1082 if (synchronized) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1083 // Don't check for exceptions since we're still in the i2n frame. Do that
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1084 // manually afterwards.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1085 unlock_method(false);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1086 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1087
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1088 // Reset active handles after returning from native.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1089 // thread->active_handles()->clear();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1090 __ ld(active_handles, thread_(active_handles));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1091 // TODO PPC port assert(4 == JNIHandleBlock::top_size_in_bytes(), "unexpected field size");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1092 __ li(R0, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1093 __ stw(R0, JNIHandleBlock::top_offset_in_bytes(), active_handles);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1094
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1095 Label exception_return_sync_check_already_unlocked;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1096 __ ld(R0/*pending_exception*/, thread_(pending_exception));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1097 __ cmpdi(CCR0, R0/*pending_exception*/, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1098 __ bne(CCR0, exception_return_sync_check_already_unlocked);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1099
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1100 //-----------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1101 // No exception pending.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1102
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1103 // Move native method result back into proper registers and return.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1104 // Invoke result handler (may unbox/promote).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1105 __ ld(R11_scratch1, 0, R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1106 __ ld(R3_RET, _ijava_state_neg(lresult), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1107 __ lfd(F1_RET, _ijava_state_neg(fresult), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1108 __ call_stub(result_handler_addr);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1109
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1110 __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ R0, R11_scratch1, R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1111
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1112 // Must use the return pc which was loaded from the caller's frame
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1113 // as the VM uses return-pc-patching for deoptimization.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1114 __ mtlr(R0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1115 __ blr();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1116
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1117 //-----------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1118 // An exception is pending. We call into the runtime only if the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1119 // caller was not interpreted. If it was interpreted the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1120 // interpreter will do the correct thing. If it isn't interpreted
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1121 // (call stub/compiled code) we will change our return and continue.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1122
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1123 __ BIND(exception_return_sync_check);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1124
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1125 if (synchronized) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1126 // Don't check for exceptions since we're still in the i2n frame. Do that
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1127 // manually afterwards.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1128 unlock_method(false);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1129 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1130 __ BIND(exception_return_sync_check_already_unlocked);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1131
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1132 const Register return_pc = R31;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1133
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1134 __ ld(return_pc, 0, R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1135 __ ld(return_pc, _abi(lr), return_pc);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1136
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1137 // Get the address of the exception handler.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1138 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address),
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1139 R16_thread,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1140 return_pc /* return pc */);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1141 __ merge_frames(/*top_frame_sp*/ R21_sender_SP, noreg, R11_scratch1, R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1142
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1143 // Load the PC of the the exception handler into LR.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1144 __ mtlr(R3_RET);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1145
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1146 // Load exception into R3_ARG1 and clear pending exception in thread.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1147 __ ld(R3_ARG1/*exception*/, thread_(pending_exception));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1148 __ li(R4_ARG2, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1149 __ std(R4_ARG2, thread_(pending_exception));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1150
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1151 // Load the original return pc into R4_ARG2.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1152 __ mr(R4_ARG2/*issuing_pc*/, return_pc);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1153
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1154 // Return to exception handler.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1155 __ blr();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1156
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1157 //=============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1158 // Counter overflow.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1159
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1160 if (inc_counter) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1161 // Handle invocation counter overflow.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1162 __ bind(invocation_counter_overflow);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1163
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1164 generate_counter_overflow(continue_after_compile);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1165 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1166
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1167 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1168 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1169
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1170 // Generic interpreted method entry to (asm) interpreter.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1171 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1172 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1173 bool inc_counter = UseCompiler || CountCompiledCalls;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1174 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1175 // Generate the code to allocate the interpreter stack frame.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1176 Register Rsize_of_parameters = R4_ARG2, // Written by generate_fixed_frame.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1177 Rsize_of_locals = R5_ARG3; // Written by generate_fixed_frame.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1178
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1179 generate_fixed_frame(false, Rsize_of_parameters, Rsize_of_locals);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1180
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1181 #ifdef FAST_DISPATCH
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1182 __ unimplemented("Fast dispatch in generate_normal_entry");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1183 #if 0
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1184 __ set((intptr_t)Interpreter::dispatch_table(), IdispatchTables);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1185 // Set bytecode dispatch table base.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1186 #endif
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1187 #endif
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1188
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1189 // --------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1190 // Zero out non-parameter locals.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1191 // Note: *Always* zero out non-parameter locals as Sparc does. It's not
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1192 // worth to ask the flag, just do it.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1193 Register Rslot_addr = R6_ARG4,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1194 Rnum = R7_ARG5;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1195 Label Lno_locals, Lzero_loop;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1196
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1197 // Set up the zeroing loop.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1198 __ subf(Rnum, Rsize_of_parameters, Rsize_of_locals);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1199 __ subf(Rslot_addr, Rsize_of_parameters, R18_locals);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1200 __ srdi_(Rnum, Rnum, Interpreter::logStackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1201 __ beq(CCR0, Lno_locals);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1202 __ li(R0, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1203 __ mtctr(Rnum);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1204
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1205 // The zero locals loop.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1206 __ bind(Lzero_loop);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1207 __ std(R0, 0, Rslot_addr);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1208 __ addi(Rslot_addr, Rslot_addr, -Interpreter::stackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1209 __ bdnz(Lzero_loop);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1210
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1211 __ bind(Lno_locals);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1212
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1213 // --------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1214 // Counter increment and overflow check.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1215 Label invocation_counter_overflow,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1216 profile_method,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1217 profile_method_continue;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1218 if (inc_counter || ProfileInterpreter) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1219
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1220 Register Rdo_not_unlock_if_synchronized_addr = R11_scratch1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1221 if (synchronized) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1222 // Since at this point in the method invocation the exception handler
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1223 // would try to exit the monitor of synchronized methods which hasn't
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1224 // been entered yet, we set the thread local variable
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1225 // _do_not_unlock_if_synchronized to true. If any exception was thrown by
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1226 // runtime, exception handling i.e. unlock_if_synchronized_method will
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1227 // check this thread local flag.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1228 // This flag has two effects, one is to force an unwind in the topmost
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1229 // interpreter frame and not perform an unlock while doing so.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1230 __ li(R0, 1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1231 __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1232 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1233 // Increment invocation counter and check for overflow.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1234 if (inc_counter) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1235 generate_counter_incr(&invocation_counter_overflow, &profile_method, &profile_method_continue);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1236 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1237
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1238 __ bind(profile_method_continue);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1239
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1240 // Reset the _do_not_unlock_if_synchronized flag.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1241 if (synchronized) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1242 __ li(R0, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1243 __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1244 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1245 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1246
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1247 // --------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1248 // Locking of synchronized methods. Must happen AFTER invocation_counter
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1249 // check and stack overflow check, so method is not locked if overflows.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1250 if (synchronized) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1251 lock_method(R3_ARG1, R4_ARG2, R5_ARG3);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1252 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1253 #ifdef ASSERT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1254 else {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1255 Label Lok;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1256 __ lwz(R0, in_bytes(Method::access_flags_offset()), R19_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1257 __ andi_(R0, R0, JVM_ACC_SYNCHRONIZED);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1258 __ asm_assert_eq("method needs synchronization", 0x8521);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1259 __ bind(Lok);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1260 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1261 #endif // ASSERT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1262
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1263 __ verify_thread();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1264
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1265 // --------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1266 // JVMTI support
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1267 __ notify_method_entry();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1268
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1269 // --------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1270 // Start executing instructions.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1271 __ dispatch_next(vtos);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1272
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1273 // --------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1274 // Out of line counter overflow and MDO creation code.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1275 if (ProfileInterpreter) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1276 // We have decided to profile this method in the interpreter.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1277 __ bind(profile_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1278 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1279 __ set_method_data_pointer_for_bcp();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1280 __ b(profile_method_continue);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1281 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1282
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1283 if (inc_counter) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1284 // Handle invocation counter overflow.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1285 __ bind(invocation_counter_overflow);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1286 generate_counter_overflow(profile_method_continue);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1287 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1288 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1289 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1290
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1291 // =============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1292 // Entry points
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1293
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1294 address AbstractInterpreterGenerator::generate_method_entry(
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1295 AbstractInterpreter::MethodKind kind) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1296 // Determine code generation flags.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1297 bool synchronized = false;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1298 address entry_point = NULL;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1299
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1300 switch (kind) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1301 case Interpreter::zerolocals : break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1302 case Interpreter::zerolocals_synchronized: synchronized = true; break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1303 case Interpreter::native : entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false); break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1304 case Interpreter::native_synchronized : entry_point = ((InterpreterGenerator*) this)->generate_native_entry(true); break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1305 case Interpreter::empty : entry_point = ((InterpreterGenerator*) this)->generate_empty_entry(); break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1306 case Interpreter::accessor : entry_point = ((InterpreterGenerator*) this)->generate_accessor_entry(); break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1307 case Interpreter::abstract : entry_point = ((InterpreterGenerator*) this)->generate_abstract_entry(); break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1308
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1309 case Interpreter::java_lang_math_sin : // fall thru
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1310 case Interpreter::java_lang_math_cos : // fall thru
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1311 case Interpreter::java_lang_math_tan : // fall thru
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1312 case Interpreter::java_lang_math_abs : // fall thru
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1313 case Interpreter::java_lang_math_log : // fall thru
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1314 case Interpreter::java_lang_math_log10 : // fall thru
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1315 case Interpreter::java_lang_math_sqrt : // fall thru
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1316 case Interpreter::java_lang_math_pow : // fall thru
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1317 case Interpreter::java_lang_math_exp : entry_point = ((InterpreterGenerator*) this)->generate_math_entry(kind); break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1318 case Interpreter::java_lang_ref_reference_get
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1319 : entry_point = ((InterpreterGenerator*)this)->generate_Reference_get_entry(); break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1320 default : ShouldNotReachHere(); break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1321 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1322
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1323 if (entry_point) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1324 return entry_point;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1325 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1326
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1327 return ((InterpreterGenerator*) this)->generate_normal_entry(synchronized);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1328 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1329
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1330 // These should never be compiled since the interpreter will prefer
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1331 // the compiled version to the intrinsic version.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1332 bool AbstractInterpreter::can_be_compiled(methodHandle m) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1333 return !math_entry_available(method_kind(m));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1334 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1335
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1336 // How much stack a method activation needs in stack slots.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1337 // We must calc this exactly like in generate_fixed_frame.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1338 // Note: This returns the conservative size assuming maximum alignment.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1339 int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1340 const int max_alignment_size = 2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1341 const int abi_scratch = frame::abi_reg_args_size;
17980
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1342 return method->max_locals() + method->max_stack() +
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1343 frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch;
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1344 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1345
17980
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1346 // Returns number of stackElementWords needed for the interpreter frame with the
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1347 // given sections.
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1348 // This overestimates the stack by one slot in case of alignments.
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1349 int AbstractInterpreter::size_activation(int max_stack,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1350 int temps,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1351 int extra_args,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1352 int monitors,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1353 int callee_params,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1354 int callee_locals,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1355 bool is_top_frame) {
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1356 // Note: This calculation must exactly parallel the frame setup
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1357 // in AbstractInterpreterGenerator::generate_method_entry.
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1358 assert(Interpreter::stackElementWords == 1, "sanity");
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1359 const int max_alignment_space = StackAlignmentInBytes / Interpreter::stackElementSize;
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1360 const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1361 (frame::abi_minframe_size / Interpreter::stackElementSize);
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1362 const int size =
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1363 max_stack +
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1364 (callee_locals - callee_params) +
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1365 monitors * frame::interpreter_frame_monitor_size() +
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1366 max_alignment_space +
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1367 abi_scratch +
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1368 frame::ijava_state_size / Interpreter::stackElementSize;
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1369
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1370 // Fixed size of an interpreter frame, align to 16-byte.
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1371 return (size & -2);
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1372 }
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1373
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1374 // Fills a sceletal interpreter frame generated during deoptimizations.
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1375 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1376 // Parameters:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1377 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1378 // interpreter_frame != NULL:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1379 // set up the method, locals, and monitors.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1380 // The frame interpreter_frame, if not NULL, is guaranteed to be the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1381 // right size, as determined by a previous call to this method.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1382 // It is also guaranteed to be walkable even though it is in a skeletal state
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1383 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1384 // is_top_frame == true:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1385 // We're processing the *oldest* interpreter frame!
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1386 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1387 // pop_frame_extra_args:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1388 // If this is != 0 we are returning to a deoptimized frame by popping
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1389 // off the callee frame. We want to re-execute the call that called the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1390 // callee interpreted, but since the return to the interpreter would pop
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1391 // the arguments off advance the esp by dummy popframe_extra_args slots.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1392 // Popping off those will establish the stack layout as it was before the call.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1393 //
17980
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1394 void AbstractInterpreter::layout_activation(Method* method,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1395 int tempcount,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1396 int popframe_extra_args,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1397 int moncount,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1398 int caller_actual_parameters,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1399 int callee_param_count,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1400 int callee_locals_count,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1401 frame* caller,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1402 frame* interpreter_frame,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1403 bool is_top_frame,
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1404 bool is_bottom_frame) {
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1405
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1406 const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
17980
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1407 (frame::abi_minframe_size / Interpreter::stackElementSize);
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1408
17980
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1409 intptr_t* locals_base = (caller->is_interpreted_frame()) ?
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1410 caller->interpreter_frame_esp() + caller_actual_parameters :
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1411 caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize) ;
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1412
17980
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1413 intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize ;
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1414 intptr_t* monitor = monitor_base - (moncount * frame::interpreter_frame_monitor_size());
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1415 intptr_t* esp_base = monitor - 1;
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1416 intptr_t* esp = esp_base - tempcount - popframe_extra_args;
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1417 intptr_t* sp = (intptr_t *) (((intptr_t) (esp_base - callee_locals_count + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes);
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1418 intptr_t* sender_sp = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1419 intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1420
17980
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1421 interpreter_frame->interpreter_frame_set_method(method);
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1422 interpreter_frame->interpreter_frame_set_locals(locals_base);
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1423 interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache());
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1424 interpreter_frame->interpreter_frame_set_esp(esp);
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1425 interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor);
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1426 interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp);
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1427 if (!is_bottom_frame) {
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17917
diff changeset
1428 interpreter_frame->interpreter_frame_set_sender_sp(sender_sp);
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1429 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1430 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1431
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1432 // =============================================================================
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1433 // Exceptions
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1434
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1435 void TemplateInterpreterGenerator::generate_throw_exception() {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1436 Register Rexception = R17_tos,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1437 Rcontinuation = R3_RET;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1438
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1439 // --------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1440 // Entry point if an method returns with a pending exception (rethrow).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1441 Interpreter::_rethrow_exception_entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1442 {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1443 __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1444 __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1445 __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1446
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1447 // Compiled code destroys templateTableBase, reload.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1448 __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1449 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1450
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1451 // Entry point if a interpreted method throws an exception (throw).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1452 Interpreter::_throw_exception_entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1453 {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1454 __ mr(Rexception, R3_RET);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1455
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1456 __ verify_thread();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1457 __ verify_oop(Rexception);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1458
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1459 // Expression stack must be empty before entering the VM in case of an exception.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1460 __ empty_expression_stack();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1461 // Find exception handler address and preserve exception oop.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1462 // Call C routine to find handler and jump to it.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1463 __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::exception_handler_for_exception), Rexception);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1464 __ mtctr(Rcontinuation);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1465 // Push exception for exception handler bytecodes.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1466 __ push_ptr(Rexception);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1467
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1468 // Jump to exception handler (may be remove activation entry!).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1469 __ bctr();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1470 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1471
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1472 // If the exception is not handled in the current frame the frame is
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1473 // removed and the exception is rethrown (i.e. exception
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1474 // continuation is _rethrow_exception).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1475 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1476 // Note: At this point the bci is still the bxi for the instruction
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1477 // which caused the exception and the expression stack is
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1478 // empty. Thus, for any VM calls at this point, GC will find a legal
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1479 // oop map (with empty expression stack).
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1480
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1481 // In current activation
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1482 // tos: exception
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1483 // bcp: exception bcp
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1484
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1485 // --------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1486 // JVMTI PopFrame support
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1487
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1488 Interpreter::_remove_activation_preserving_args_entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1489 {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1490 // Set the popframe_processing bit in popframe_condition indicating that we are
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1491 // currently handling popframe, so that call_VMs that may happen later do not
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1492 // trigger new popframe handling cycles.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1493 __ lwz(R11_scratch1, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1494 __ ori(R11_scratch1, R11_scratch1, JavaThread::popframe_processing_bit);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1495 __ stw(R11_scratch1, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1496
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1497 // Empty the expression stack, as in normal exception handling.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1498 __ empty_expression_stack();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1499 __ unlock_if_synchronized_method(vtos, /* throw_monitor_exception */ false, /* install_monitor_exception */ false);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1500
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1501 // Check to see whether we are returning to a deoptimized frame.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1502 // (The PopFrame call ensures that the caller of the popped frame is
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1503 // either interpreted or compiled and deoptimizes it if compiled.)
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1504 // Note that we don't compare the return PC against the
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1505 // deoptimization blob's unpack entry because of the presence of
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1506 // adapter frames in C2.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1507 Label Lcaller_not_deoptimized;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1508 Register return_pc = R3_ARG1;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1509 __ ld(return_pc, 0, R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1510 __ ld(return_pc, _abi(lr), return_pc);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1511 __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::interpreter_contains), return_pc);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1512 __ cmpdi(CCR0, R3_RET, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1513 __ bne(CCR0, Lcaller_not_deoptimized);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1514
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1515 // The deoptimized case.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1516 // In this case, we can't call dispatch_next() after the frame is
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1517 // popped, but instead must save the incoming arguments and restore
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1518 // them after deoptimization has occurred.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1519 __ ld(R4_ARG2, in_bytes(Method::const_offset()), R19_method);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1520 __ lhz(R4_ARG2 /* number of params */, in_bytes(ConstMethod::size_of_parameters_offset()), R4_ARG2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1521 __ slwi(R4_ARG2, R4_ARG2, Interpreter::logStackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1522 __ addi(R5_ARG3, R18_locals, Interpreter::stackElementSize);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1523 __ subf(R5_ARG3, R4_ARG2, R5_ARG3);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1524 // Save these arguments.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1525 __ call_VM_leaf(CAST_FROM_FN_PTR(address, Deoptimization::popframe_preserve_args), R16_thread, R4_ARG2, R5_ARG3);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1526
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1527 // Inform deoptimization that it is responsible for restoring these arguments.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1528 __ load_const_optimized(R11_scratch1, JavaThread::popframe_force_deopt_reexecution_bit);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1529 __ stw(R11_scratch1, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1530
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1531 // Return from the current method into the deoptimization blob. Will eventually
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1532 // end up in the deopt interpeter entry, deoptimization prepared everything that
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1533 // we will reexecute the call that called us.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1534 __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*reload return_pc*/ return_pc, R11_scratch1, R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1535 __ mtlr(return_pc);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1536 __ blr();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1537
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1538 // The non-deoptimized case.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1539 __ bind(Lcaller_not_deoptimized);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1540
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1541 // Clear the popframe condition flag.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1542 __ li(R0, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1543 __ stw(R0, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1544
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1545 // Get out of the current method and re-execute the call that called us.
17917
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1546 __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ noreg, R11_scratch1, R12_scratch2);
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1547 __ restore_interpreter_state(R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1548 __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1549 __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1550 if (ProfileInterpreter) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1551 __ set_method_data_pointer_for_bcp();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1552 }
17917
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1553 #if INCLUDE_JVMTI
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1554 Label L_done;
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1555
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1556 __ lbz(R11_scratch1, 0, R14_bcp);
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1557 __ cmpwi(CCR0, R11_scratch1, Bytecodes::_invokestatic);
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1558 __ bne(CCR0, L_done);
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1559
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1560 // The member name argument must be restored if _invokestatic is re-executed after a PopFrame call.
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1561 // Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL.
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1562 __ ld(R4_ARG2, 0, R18_locals);
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1563 __ call_VM(R11_scratch1, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null),
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1564 R4_ARG2, R19_method, R14_bcp);
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1565
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1566 __ cmpdi(CCR0, R11_scratch1, 0);
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1567 __ beq(CCR0, L_done);
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1568
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1569 __ std(R11_scratch1, wordSize, R15_esp);
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1570 __ bind(L_done);
63c5920a038d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 17848
diff changeset
1571 #endif // INCLUDE_JVMTI
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1572 __ dispatch_next(vtos);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1573 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1574 // end of JVMTI PopFrame support
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1575
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1576 // --------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1577 // Remove activation exception entry.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1578 // This is jumped to if an interpreted method can't handle an exception itself
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1579 // (we come from the throw/rethrow exception entry above). We're going to call
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1580 // into the VM to find the exception handler in the caller, pop the current
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1581 // frame and return the handler we calculated.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1582 Interpreter::_remove_activation_entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1583 {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1584 __ pop_ptr(Rexception);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1585 __ verify_thread();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1586 __ verify_oop(Rexception);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1587 __ std(Rexception, in_bytes(JavaThread::vm_result_offset()), R16_thread);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1588
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1589 __ unlock_if_synchronized_method(vtos, /* throw_monitor_exception */ false, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1590 __ notify_method_exit(false, vtos, InterpreterMacroAssembler::SkipNotifyJVMTI, false);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1591
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1592 __ get_vm_result(Rexception);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1593
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1594 // We are done with this activation frame; find out where to go next.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1595 // The continuation point will be an exception handler, which expects
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1596 // the following registers set up:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1597 //
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1598 // RET: exception oop
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1599 // ARG2: Issuing PC (see generate_exception_blob()), only used if the caller is compiled.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1600
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1601 Register return_pc = R31; // Needs to survive the runtime call.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1602 __ ld(return_pc, 0, R1_SP);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1603 __ ld(return_pc, _abi(lr), return_pc);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1604 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), R16_thread, return_pc);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1605
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1606 // Remove the current activation.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1607 __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ noreg, R11_scratch1, R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1608
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1609 __ mr(R4_ARG2, return_pc);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1610 __ mtlr(R3_RET);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1611 __ mr(R3_RET, Rexception);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1612 __ blr();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1613 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1614 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1615
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1616 // JVMTI ForceEarlyReturn support.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1617 // Returns "in the middle" of a method with a "fake" return value.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1618 address TemplateInterpreterGenerator::generate_earlyret_entry_for(TosState state) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1619
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1620 Register Rscratch1 = R11_scratch1,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1621 Rscratch2 = R12_scratch2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1622
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1623 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1624 __ empty_expression_stack();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1625
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1626 __ load_earlyret_value(state, Rscratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1627
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1628 __ ld(Rscratch1, in_bytes(JavaThread::jvmti_thread_state_offset()), R16_thread);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1629 // Clear the earlyret state.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1630 __ li(R0, 0);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1631 __ stw(R0, in_bytes(JvmtiThreadState::earlyret_state_offset()), Rscratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1632
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1633 __ remove_activation(state, false, false);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1634 // Copied from TemplateTable::_return.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1635 // Restoration of lr done by remove_activation.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1636 switch (state) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1637 case ltos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1638 case btos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1639 case ctos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1640 case stos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1641 case atos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1642 case itos: __ mr(R3_RET, R17_tos); break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1643 case ftos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1644 case dtos: __ fmr(F1_RET, F15_ftos); break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1645 case vtos: // This might be a constructor. Final fields (and volatile fields on PPC64) need
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1646 // to get visible before the reference to the object gets stored anywhere.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1647 __ membar(Assembler::StoreStore); break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1648 default : ShouldNotReachHere();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1649 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1650 __ blr();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1651
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1652 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1653 } // end of ForceEarlyReturn support
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1654
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1655 //-----------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1656 // Helper for vtos entry point generation
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1657
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1658 void TemplateInterpreterGenerator::set_vtos_entry_points(Template* t,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1659 address& bep,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1660 address& cep,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1661 address& sep,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1662 address& aep,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1663 address& iep,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1664 address& lep,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1665 address& fep,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1666 address& dep,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1667 address& vep) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1668 assert(t->is_valid() && t->tos_in() == vtos, "illegal template");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1669 Label L;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1670
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1671 aep = __ pc(); __ push_ptr(); __ b(L);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1672 fep = __ pc(); __ push_f(); __ b(L);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1673 dep = __ pc(); __ push_d(); __ b(L);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1674 lep = __ pc(); __ push_l(); __ b(L);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1675 __ align(32, 12, 24); // align L
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1676 bep = cep = sep =
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1677 iep = __ pc(); __ push_i();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1678 vep = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1679 __ bind(L);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1680 generate_and_dispatch(t);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1681 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1682
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1683 //-----------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1684 // Generation of individual instructions
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1685
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1686 // helpers for generate_and_dispatch
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1687
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1688 InterpreterGenerator::InterpreterGenerator(StubQueue* code)
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1689 : TemplateInterpreterGenerator(code) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1690 generate_all(); // Down here so it can be "virtual".
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1691 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1692
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1693 //-----------------------------------------------------------------------------
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1694
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1695 // Non-product code
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1696 #ifndef PRODUCT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1697 address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1698 //__ flush_bundle();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1699 address entry = __ pc();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1700
17848
6048424d3865 8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents: 17804
diff changeset
1701 const char *bname = NULL;
17804
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1702 uint tsize = 0;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1703 switch(state) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1704 case ftos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1705 bname = "trace_code_ftos {";
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1706 tsize = 2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1707 break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1708 case btos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1709 bname = "trace_code_btos {";
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1710 tsize = 2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1711 break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1712 case ctos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1713 bname = "trace_code_ctos {";
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1714 tsize = 2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1715 break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1716 case stos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1717 bname = "trace_code_stos {";
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1718 tsize = 2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1719 break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1720 case itos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1721 bname = "trace_code_itos {";
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1722 tsize = 2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1723 break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1724 case ltos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1725 bname = "trace_code_ltos {";
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1726 tsize = 3;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1727 break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1728 case atos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1729 bname = "trace_code_atos {";
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1730 tsize = 2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1731 break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1732 case vtos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1733 // Note: In case of vtos, the topmost of stack value could be a int or doubl
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1734 // In case of a double (2 slots) we won't see the 2nd stack value.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1735 // Maybe we simply should print the topmost 3 stack slots to cope with the problem.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1736 bname = "trace_code_vtos {";
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1737 tsize = 2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1738
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1739 break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1740 case dtos:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1741 bname = "trace_code_dtos {";
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1742 tsize = 3;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1743 break;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1744 default:
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1745 ShouldNotReachHere();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1746 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1747 BLOCK_COMMENT(bname);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1748
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1749 // Support short-cut for TraceBytecodesAt.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1750 // Don't call into the VM if we don't want to trace to speed up things.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1751 Label Lskip_vm_call;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1752 if (TraceBytecodesAt > 0 && TraceBytecodesAt < max_intx) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1753 int offs1 = __ load_const_optimized(R11_scratch1, (address) &TraceBytecodesAt, R0, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1754 int offs2 = __ load_const_optimized(R12_scratch2, (address) &BytecodeCounter::_counter_value, R0, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1755 __ ld(R11_scratch1, offs1, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1756 __ lwa(R12_scratch2, offs2, R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1757 __ cmpd(CCR0, R12_scratch2, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1758 __ blt(CCR0, Lskip_vm_call);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1759 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1760
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1761 __ push(state);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1762 // Load 2 topmost expression stack values.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1763 __ ld(R6_ARG4, tsize*Interpreter::stackElementSize, R15_esp);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1764 __ ld(R5_ARG3, Interpreter::stackElementSize, R15_esp);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1765 __ mflr(R31);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1766 __ call_VM(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::trace_bytecode), /* unused */ R4_ARG2, R5_ARG3, R6_ARG4, false);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1767 __ mtlr(R31);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1768 __ pop(state);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1769
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1770 if (TraceBytecodesAt > 0 && TraceBytecodesAt < max_intx) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1771 __ bind(Lskip_vm_call);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1772 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1773 __ blr();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1774 BLOCK_COMMENT("} trace_code");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1775 return entry;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1776 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1777
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1778 void TemplateInterpreterGenerator::count_bytecode() {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1779 int offs = __ load_const_optimized(R11_scratch1, (address) &BytecodeCounter::_counter_value, R12_scratch2, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1780 __ lwz(R12_scratch2, offs, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1781 __ addi(R12_scratch2, R12_scratch2, 1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1782 __ stw(R12_scratch2, offs, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1783 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1784
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1785 void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1786 int offs = __ load_const_optimized(R11_scratch1, (address) &BytecodeHistogram::_counters[t->bytecode()], R12_scratch2, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1787 __ lwz(R12_scratch2, offs, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1788 __ addi(R12_scratch2, R12_scratch2, 1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1789 __ stw(R12_scratch2, offs, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1790 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1791
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1792 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1793 const Register addr = R11_scratch1,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1794 tmp = R12_scratch2;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1795 // Get index, shift out old bytecode, bring in new bytecode, and store it.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1796 // _index = (_index >> log2_number_of_codes) |
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1797 // (bytecode << log2_number_of_codes);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1798 int offs1 = __ load_const_optimized(addr, (address)&BytecodePairHistogram::_index, tmp, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1799 __ lwz(tmp, offs1, addr);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1800 __ srwi(tmp, tmp, BytecodePairHistogram::log2_number_of_codes);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1801 __ ori(tmp, tmp, ((int) t->bytecode()) << BytecodePairHistogram::log2_number_of_codes);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1802 __ stw(tmp, offs1, addr);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1803
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1804 // Bump bucket contents.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1805 // _counters[_index] ++;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1806 int offs2 = __ load_const_optimized(addr, (address)&BytecodePairHistogram::_counters, R0, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1807 __ sldi(tmp, tmp, LogBytesPerInt);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1808 __ add(addr, tmp, addr);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1809 __ lwz(tmp, offs2, addr);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1810 __ addi(tmp, tmp, 1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1811 __ stw(tmp, offs2, addr);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1812 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1813
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1814 void TemplateInterpreterGenerator::trace_bytecode(Template* t) {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1815 // Call a little run-time stub to avoid blow-up for each bytecode.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1816 // The run-time runtime saves the right registers, depending on
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1817 // the tosca in-state for the given template.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1818
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1819 assert(Interpreter::trace_code(t->tos_in()) != NULL,
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1820 "entry must have been generated");
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1821
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1822 // Note: we destroy LR here.
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1823 __ bl(Interpreter::trace_code(t->tos_in()));
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1824 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1825
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1826 void TemplateInterpreterGenerator::stop_interpreter_at() {
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1827 Label L;
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1828 int offs1 = __ load_const_optimized(R11_scratch1, (address) &StopInterpreterAt, R0, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1829 int offs2 = __ load_const_optimized(R12_scratch2, (address) &BytecodeCounter::_counter_value, R0, true);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1830 __ ld(R11_scratch1, offs1, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1831 __ lwa(R12_scratch2, offs2, R12_scratch2);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1832 __ cmpd(CCR0, R12_scratch2, R11_scratch1);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1833 __ bne(CCR0, L);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1834 __ illtrap();
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1835 __ bind(L);
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1836 }
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1837
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1838 #endif // !PRODUCT
fd1b9f02cc91 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
1839 #endif // !CC_INTERP