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