Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/cpu/x86/vm/interpreter_x86_32.cpp
+++ new/src/cpu/x86/vm/interpreter_x86_32.cpp
1 1 /*
2 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #include "precompiled.hpp"
26 26 #include "asm/assembler.hpp"
27 27 #include "interpreter/bytecodeHistogram.hpp"
28 28 #include "interpreter/interpreter.hpp"
29 29 #include "interpreter/interpreterGenerator.hpp"
30 30 #include "interpreter/interpreterRuntime.hpp"
31 31 #include "interpreter/templateTable.hpp"
32 32 #include "oops/arrayOop.hpp"
33 33 #include "oops/methodDataOop.hpp"
34 34 #include "oops/methodOop.hpp"
35 35 #include "oops/oop.inline.hpp"
36 36 #include "prims/jvmtiExport.hpp"
37 37 #include "prims/jvmtiThreadState.hpp"
38 38 #include "prims/methodHandles.hpp"
39 39 #include "runtime/arguments.hpp"
40 40 #include "runtime/deoptimization.hpp"
41 41 #include "runtime/frame.inline.hpp"
42 42 #include "runtime/sharedRuntime.hpp"
43 43 #include "runtime/stubRoutines.hpp"
44 44 #include "runtime/synchronizer.hpp"
45 45 #include "runtime/timer.hpp"
46 46 #include "runtime/vframeArray.hpp"
47 47 #include "utilities/debug.hpp"
48 48 #ifdef COMPILER1
49 49 #include "c1/c1_Runtime1.hpp"
50 50 #endif
51 51
52 52 #define __ _masm->
53 53
54 54 //------------------------------------------------------------------------------------------------------------------------
55 55
56 56 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
57 57 address entry = __ pc();
58 58 // rbx,: method
59 59 // rcx: temporary
60 60 // rdi: pointer to locals
61 61 // rsp: end of copied parameters area
62 62 __ mov(rcx, rsp);
63 63 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx);
64 64 __ ret(0);
65 65 return entry;
66 66 }
67 67
68 68
69 69 //
70 70 // Various method entries (that c++ and asm interpreter agree upon)
71 71 //------------------------------------------------------------------------------------------------------------------------
72 72 //
73 73 //
74 74
75 75 // Empty method, generate a very fast return.
76 76
77 77 address InterpreterGenerator::generate_empty_entry(void) {
78 78
79 79 // rbx,: methodOop
80 80 // rcx: receiver (unused)
81 81 // rsi: previous interpreter state (C++ interpreter) must preserve
82 82 // rsi: sender sp must set sp to this value on return
83 83
84 84 if (!UseFastEmptyMethods) return NULL;
85 85
86 86 address entry_point = __ pc();
87 87
88 88 // If we need a safepoint check, generate full interpreter entry.
89 89 Label slow_path;
90 90 ExternalAddress state(SafepointSynchronize::address_of_state());
91 91 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
92 92 SafepointSynchronize::_not_synchronized);
93 93 __ jcc(Assembler::notEqual, slow_path);
94 94
95 95 // do nothing for empty methods (do not even increment invocation counter)
96 96 // Code: _return
97 97 // _return
98 98 // return w/o popping parameters
99 99 __ pop(rax);
100 100 __ mov(rsp, rsi);
101 101 __ jmp(rax);
102 102
103 103 __ bind(slow_path);
104 104 (void) generate_normal_entry(false);
105 105 return entry_point;
106 106 }
107 107
108 108 address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
109 109
110 110 // rbx,: methodOop
111 111 // rcx: scratrch
112 112 // rsi: sender sp
113 113
114 114 if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
115 115
116 116 address entry_point = __ pc();
117 117
118 118 // These don't need a safepoint check because they aren't virtually
119 119 // callable. We won't enter these intrinsics from compiled code.
120 120 // If in the future we added an intrinsic which was virtually callable
121 121 // we'd have to worry about how to safepoint so that this code is used.
122 122
123 123 // mathematical functions inlined by compiler
124 124 // (interpreter must provide identical implementation
125 125 // in order to avoid monotonicity bugs when switching
126 126 // from interpreter to compiler in the middle of some
127 127 // computation)
128 128 //
129 129 // stack: [ ret adr ] <-- rsp
130 130 // [ lo(arg) ]
131 131 // [ hi(arg) ]
132 132 //
133 133
134 134 // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
135 135 // native methods. Interpreter::method_kind(...) does a check for
136 136 // native methods first before checking for intrinsic methods and
137 137 // thus will never select this entry point. Make sure it is not
138 138 // called accidentally since the SharedRuntime entry points will
139 139 // not work for JDK 1.2.
140 140 //
141 141 // We no longer need to check for JDK 1.2 since it's EOL'ed.
142 142 // The following check existed in pre 1.6 implementation,
143 143 // if (Universe::is_jdk12x_version()) {
144 144 // __ should_not_reach_here();
145 145 // }
146 146 // Universe::is_jdk12x_version() always returns false since
147 147 // the JDK version is not yet determined when this method is called.
148 148 // This method is called during interpreter_init() whereas
149 149 // JDK version is only determined when universe2_init() is called.
150 150
151 151 // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
152 152 // java methods. Interpreter::method_kind(...) will select
153 153 // this entry point for the corresponding methods in JDK 1.3.
154 154 // get argument
155 155 __ fld_d(Address(rsp, 1*wordSize));
156 156 switch (kind) {
157 157 case Interpreter::java_lang_math_sin :
158 158 __ trigfunc('s');
159 159 break;
160 160 case Interpreter::java_lang_math_cos :
161 161 __ trigfunc('c');
162 162 break;
163 163 case Interpreter::java_lang_math_tan :
164 164 __ trigfunc('t');
165 165 break;
166 166 case Interpreter::java_lang_math_sqrt:
167 167 __ fsqrt();
168 168 break;
169 169 case Interpreter::java_lang_math_abs:
170 170 __ fabs();
171 171 break;
172 172 case Interpreter::java_lang_math_log:
173 173 __ flog();
174 174 // Store to stack to convert 80bit precision back to 64bits
175 175 __ push_fTOS();
176 176 __ pop_fTOS();
177 177 break;
178 178 case Interpreter::java_lang_math_log10:
179 179 __ flog10();
180 180 // Store to stack to convert 80bit precision back to 64bits
181 181 __ push_fTOS();
182 182 __ pop_fTOS();
183 183 break;
184 184 default :
185 185 ShouldNotReachHere();
186 186 }
187 187
188 188 // return double result in xmm0 for interpreter and compilers.
189 189 if (UseSSE >= 2) {
190 190 __ subptr(rsp, 2*wordSize);
191 191 __ fstp_d(Address(rsp, 0));
192 192 __ movdbl(xmm0, Address(rsp, 0));
193 193 __ addptr(rsp, 2*wordSize);
194 194 }
195 195
196 196 // done, result in FPU ST(0) or XMM0
197 197 __ pop(rdi); // get return address
198 198 __ mov(rsp, rsi); // set sp to sender sp
199 199 __ jmp(rdi);
200 200
201 201 return entry_point;
202 202 }
203 203
204 204
205 205 // Abstract method entry
206 206 // Attempt to execute abstract method. Throw exception
207 207 address InterpreterGenerator::generate_abstract_entry(void) {
208 208
209 209 // rbx,: methodOop
210 210 // rcx: receiver (unused)
211 211 // rsi: previous interpreter state (C++ interpreter) must preserve
212 212
213 213 // rsi: sender SP
214 214
215 215 address entry_point = __ pc();
216 216
217 217 // abstract method entry
218 218
219 219 // pop return address, reset last_sp to NULL
220 220 __ empty_expression_stack();
221 221 __ restore_bcp(); // rsi must be correct for exception handler (was destroyed)
222 222 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed)
223 223
224 224 // throw exception
225 225 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
↓ open down ↓ |
225 lines elided |
↑ open up ↑ |
226 226 // the call_VM checks for exception, so we should never return here.
227 227 __ should_not_reach_here();
228 228
229 229 return entry_point;
230 230 }
231 231
232 232
233 233 // Method handle invoker
234 234 // Dispatch a method of the form java.lang.invoke.MethodHandles::invoke(...)
235 235 address InterpreterGenerator::generate_method_handle_entry(void) {
236 - if (!EnableMethodHandles) {
236 + if (!EnableInvokeDynamic) {
237 237 return generate_abstract_entry();
238 238 }
239 239
240 240 address entry_point = MethodHandles::generate_method_handle_interpreter_entry(_masm);
241 241
242 242 return entry_point;
243 243 }
244 244
245 245
246 246 // This method tells the deoptimizer how big an interpreted frame must be:
247 247 int AbstractInterpreter::size_activation(methodOop method,
248 248 int tempcount,
249 249 int popframe_extra_args,
250 250 int moncount,
251 251 int callee_param_count,
252 252 int callee_locals,
253 253 bool is_top_frame) {
254 254 return layout_activation(method,
255 255 tempcount,
256 256 popframe_extra_args,
257 257 moncount,
258 258 callee_param_count,
259 259 callee_locals,
260 260 (frame*) NULL,
261 261 (frame*) NULL,
262 262 is_top_frame);
263 263 }
264 264
265 265 void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
266 266
267 267 // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
268 268 // the days we had adapter frames. When we deoptimize a situation where a
269 269 // compiled caller calls a compiled caller will have registers it expects
270 270 // to survive the call to the callee. If we deoptimize the callee the only
271 271 // way we can restore these registers is to have the oldest interpreter
272 272 // frame that we create restore these values. That is what this routine
273 273 // will accomplish.
274 274
275 275 // At the moment we have modified c2 to not have any callee save registers
276 276 // so this problem does not exist and this routine is just a place holder.
277 277
278 278 assert(f->is_interpreted_frame(), "must be interpreted");
279 279 }
↓ open down ↓ |
33 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX