author | prr |
Wed, 15 Apr 2015 14:28:43 -0700 | |
changeset 30465 | a77083748efc |
parent 25950 | b5c40ed1d349 |
child 33070 | 54f3f085b165 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
14631
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5416
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5416
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5416
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
14631
526804361522
8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
13728
diff
changeset
|
26 |
#include "asm/macroAssembler.hpp" |
7397 | 27 |
#include "interpreter/bytecodeHistogram.hpp" |
28 |
#include "interpreter/interpreter.hpp" |
|
29 |
#include "interpreter/interpreterGenerator.hpp" |
|
30 |
#include "interpreter/interpreterRuntime.hpp" |
|
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
14631
diff
changeset
|
31 |
#include "interpreter/interp_masm.hpp" |
7397 | 32 |
#include "interpreter/templateTable.hpp" |
33 |
#include "oops/arrayOop.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
34 |
#include "oops/methodData.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
35 |
#include "oops/method.hpp" |
7397 | 36 |
#include "oops/oop.inline.hpp" |
37 |
#include "prims/jvmtiExport.hpp" |
|
38 |
#include "prims/jvmtiThreadState.hpp" |
|
39 |
#include "prims/methodHandles.hpp" |
|
40 |
#include "runtime/arguments.hpp" |
|
41 |
#include "runtime/deoptimization.hpp" |
|
42 |
#include "runtime/frame.inline.hpp" |
|
43 |
#include "runtime/sharedRuntime.hpp" |
|
44 |
#include "runtime/stubRoutines.hpp" |
|
45 |
#include "runtime/synchronizer.hpp" |
|
46 |
#include "runtime/timer.hpp" |
|
47 |
#include "runtime/vframeArray.hpp" |
|
48 |
#include "utilities/debug.hpp" |
|
49 |
#ifdef COMPILER1 |
|
50 |
#include "c1/c1_Runtime1.hpp" |
|
51 |
#endif |
|
1 | 52 |
|
53 |
||
54 |
||
55 |
// Generation of Interpreter |
|
56 |
// |
|
57 |
// The InterpreterGenerator generates the interpreter into Interpreter::_code. |
|
58 |
||
59 |
||
60 |
#define __ _masm-> |
|
61 |
||
62 |
||
63 |
//---------------------------------------------------------------------------------------------------- |
|
64 |
||
65 |
||
66 |
||
67 |
||
68 |
int AbstractInterpreter::BasicType_as_index(BasicType type) { |
|
69 |
int i = 0; |
|
70 |
switch (type) { |
|
71 |
case T_BOOLEAN: i = 0; break; |
|
72 |
case T_CHAR : i = 1; break; |
|
73 |
case T_BYTE : i = 2; break; |
|
74 |
case T_SHORT : i = 3; break; |
|
75 |
case T_INT : i = 4; break; |
|
76 |
case T_LONG : i = 5; break; |
|
77 |
case T_VOID : i = 6; break; |
|
78 |
case T_FLOAT : i = 7; break; |
|
79 |
case T_DOUBLE : i = 8; break; |
|
80 |
case T_OBJECT : i = 9; break; |
|
81 |
case T_ARRAY : i = 9; break; |
|
82 |
default : ShouldNotReachHere(); |
|
83 |
} |
|
84 |
assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds"); |
|
85 |
return i; |
|
86 |
} |
|
87 |
||
88 |
||
89 |
#ifndef _LP64 |
|
90 |
address AbstractInterpreterGenerator::generate_slow_signature_handler() { |
|
91 |
address entry = __ pc(); |
|
92 |
Argument argv(0, true); |
|
93 |
||
94 |
// We are in the jni transition frame. Save the last_java_frame corresponding to the |
|
95 |
// outer interpreter frame |
|
96 |
// |
|
97 |
__ set_last_Java_frame(FP, noreg); |
|
98 |
// make sure the interpreter frame we've pushed has a valid return pc |
|
99 |
__ mov(O7, I7); |
|
100 |
__ mov(Lmethod, G3_scratch); |
|
101 |
__ mov(Llocals, G4_scratch); |
|
102 |
__ save_frame(0); |
|
103 |
__ mov(G2_thread, L7_thread_cache); |
|
104 |
__ add(argv.address_in_frame(), O3); |
|
105 |
__ mov(G2_thread, O0); |
|
106 |
__ mov(G3_scratch, O1); |
|
107 |
__ call(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), relocInfo::runtime_call_type); |
|
108 |
__ delayed()->mov(G4_scratch, O2); |
|
109 |
__ mov(L7_thread_cache, G2_thread); |
|
110 |
__ reset_last_Java_frame(); |
|
111 |
||
112 |
// load the register arguments (the C code packed them as varargs) |
|
113 |
for (Argument ldarg = argv.successor(); ldarg.is_register(); ldarg = ldarg.successor()) { |
|
114 |
__ ld_ptr(ldarg.address_in_frame(), ldarg.as_register()); |
|
115 |
} |
|
116 |
__ ret(); |
|
117 |
__ delayed()-> |
|
118 |
restore(O0, 0, Lscratch); // caller's Lscratch gets the result handler |
|
119 |
return entry; |
|
120 |
} |
|
121 |
||
122 |
||
123 |
#else |
|
124 |
// LP64 passes floating point arguments in F1, F3, F5, etc. instead of |
|
125 |
// O0, O1, O2 etc.. |
|
126 |
// Doubles are passed in D0, D2, D4 |
|
127 |
// We store the signature of the first 16 arguments in the first argument |
|
128 |
// slot because it will be overwritten prior to calling the native |
|
129 |
// function, with the pointer to the JNIEnv. |
|
130 |
// If LP64 there can be up to 16 floating point arguments in registers |
|
131 |
// or 6 integer registers. |
|
132 |
address AbstractInterpreterGenerator::generate_slow_signature_handler() { |
|
133 |
||
134 |
enum { |
|
135 |
non_float = 0, |
|
136 |
float_sig = 1, |
|
137 |
double_sig = 2, |
|
138 |
sig_mask = 3 |
|
139 |
}; |
|
140 |
||
141 |
address entry = __ pc(); |
|
142 |
Argument argv(0, true); |
|
143 |
||
144 |
// We are in the jni transition frame. Save the last_java_frame corresponding to the |
|
145 |
// outer interpreter frame |
|
146 |
// |
|
147 |
__ set_last_Java_frame(FP, noreg); |
|
148 |
// make sure the interpreter frame we've pushed has a valid return pc |
|
149 |
__ mov(O7, I7); |
|
150 |
__ mov(Lmethod, G3_scratch); |
|
151 |
__ mov(Llocals, G4_scratch); |
|
152 |
__ save_frame(0); |
|
153 |
__ mov(G2_thread, L7_thread_cache); |
|
154 |
__ add(argv.address_in_frame(), O3); |
|
155 |
__ mov(G2_thread, O0); |
|
156 |
__ mov(G3_scratch, O1); |
|
157 |
__ call(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), relocInfo::runtime_call_type); |
|
158 |
__ delayed()->mov(G4_scratch, O2); |
|
159 |
__ mov(L7_thread_cache, G2_thread); |
|
160 |
__ reset_last_Java_frame(); |
|
161 |
||
162 |
||
163 |
// load the register arguments (the C code packed them as varargs) |
|
164 |
Address Sig = argv.address_in_frame(); // Argument 0 holds the signature |
|
165 |
__ ld_ptr( Sig, G3_scratch ); // Get register argument signature word into G3_scratch |
|
166 |
__ mov( G3_scratch, G4_scratch); |
|
167 |
__ srl( G4_scratch, 2, G4_scratch); // Skip Arg 0 |
|
168 |
Label done; |
|
169 |
for (Argument ldarg = argv.successor(); ldarg.is_float_register(); ldarg = ldarg.successor()) { |
|
170 |
Label NonFloatArg; |
|
171 |
Label LoadFloatArg; |
|
172 |
Label LoadDoubleArg; |
|
173 |
Label NextArg; |
|
174 |
Address a = ldarg.address_in_frame(); |
|
175 |
__ andcc(G4_scratch, sig_mask, G3_scratch); |
|
176 |
__ br(Assembler::zero, false, Assembler::pt, NonFloatArg); |
|
177 |
__ delayed()->nop(); |
|
178 |
||
179 |
__ cmp(G3_scratch, float_sig ); |
|
180 |
__ br(Assembler::equal, false, Assembler::pt, LoadFloatArg); |
|
181 |
__ delayed()->nop(); |
|
182 |
||
183 |
__ cmp(G3_scratch, double_sig ); |
|
184 |
__ br(Assembler::equal, false, Assembler::pt, LoadDoubleArg); |
|
185 |
__ delayed()->nop(); |
|
186 |
||
187 |
__ bind(NonFloatArg); |
|
188 |
// There are only 6 integer register arguments! |
|
189 |
if ( ldarg.is_register() ) |
|
190 |
__ ld_ptr(ldarg.address_in_frame(), ldarg.as_register()); |
|
191 |
else { |
|
192 |
// Optimization, see if there are any more args and get out prior to checking |
|
193 |
// all 16 float registers. My guess is that this is rare. |
|
194 |
// If is_register is false, then we are done the first six integer args. |
|
10252 | 195 |
__ br_null_short(G4_scratch, Assembler::pt, done); |
1 | 196 |
} |
10252 | 197 |
__ ba(NextArg); |
1 | 198 |
__ delayed()->srl( G4_scratch, 2, G4_scratch ); |
199 |
||
200 |
__ bind(LoadFloatArg); |
|
201 |
__ ldf( FloatRegisterImpl::S, a, ldarg.as_float_register(), 4); |
|
10252 | 202 |
__ ba(NextArg); |
1 | 203 |
__ delayed()->srl( G4_scratch, 2, G4_scratch ); |
204 |
||
205 |
__ bind(LoadDoubleArg); |
|
206 |
__ ldf( FloatRegisterImpl::D, a, ldarg.as_double_register() ); |
|
10252 | 207 |
__ ba(NextArg); |
1 | 208 |
__ delayed()->srl( G4_scratch, 2, G4_scratch ); |
209 |
||
210 |
__ bind(NextArg); |
|
211 |
||
212 |
} |
|
213 |
||
214 |
__ bind(done); |
|
215 |
__ ret(); |
|
216 |
__ delayed()-> |
|
217 |
restore(O0, 0, Lscratch); // caller's Lscratch gets the result handler |
|
218 |
return entry; |
|
219 |
} |
|
220 |
#endif |
|
221 |
||
222 |
void InterpreterGenerator::generate_counter_overflow(Label& Lcontinue) { |
|
223 |
||
224 |
// Generate code to initiate compilation on the counter overflow. |
|
225 |
||
226 |
// InterpreterRuntime::frequency_counter_overflow takes two arguments, |
|
227 |
// the first indicates if the counter overflow occurs at a backwards branch (NULL bcp) |
|
228 |
// and the second is only used when the first is true. We pass zero for both. |
|
229 |
// The call returns the address of the verified entry point for the method or NULL |
|
230 |
// if the compilation did not complete (either went background or bailed out). |
|
231 |
__ set((int)false, O2); |
|
232 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), O2, O2, true); |
|
233 |
// returns verified_entry_point or NULL |
|
234 |
// we ignore it in any case |
|
10252 | 235 |
__ ba_short(Lcontinue); |
1 | 236 |
|
237 |
} |
|
238 |
||
239 |
||
240 |
// End of helpers |
|
241 |
||
242 |
// Various method entries |
|
243 |
||
25950
b5c40ed1d349
8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents:
25715
diff
changeset
|
244 |
address InterpreterGenerator::generate_jump_to_normal_entry(void) { |
b5c40ed1d349
8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents:
25715
diff
changeset
|
245 |
address entry = __ pc(); |
b5c40ed1d349
8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents:
25715
diff
changeset
|
246 |
assert(Interpreter::entry_for_kind(Interpreter::zerolocals) != NULL, "should already be generated"); |
b5c40ed1d349
8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents:
25715
diff
changeset
|
247 |
AddressLiteral al(Interpreter::entry_for_kind(Interpreter::zerolocals)); |
b5c40ed1d349
8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents:
25715
diff
changeset
|
248 |
__ jump_to(al, G3_scratch); |
b5c40ed1d349
8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents:
25715
diff
changeset
|
249 |
__ delayed()->nop(); |
b5c40ed1d349
8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents:
25715
diff
changeset
|
250 |
return entry; |
b5c40ed1d349
8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents:
25715
diff
changeset
|
251 |
} |
b5c40ed1d349
8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents:
25715
diff
changeset
|
252 |
|
1 | 253 |
// Abstract method entry |
254 |
// Attempt to execute abstract method. Throw exception |
|
255 |
// |
|
256 |
address InterpreterGenerator::generate_abstract_entry(void) { |
|
257 |
address entry = __ pc(); |
|
258 |
// abstract method entry |
|
259 |
// throw exception |
|
260 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError)); |
|
261 |
// the call_VM checks for exception, so we should never return here. |
|
262 |
__ should_not_reach_here(); |
|
263 |
return entry; |
|
264 |
||
265 |
} |
|
266 |
||
4645
0c5f5b94e93a
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
2534
diff
changeset
|
267 |
bool AbstractInterpreter::can_be_compiled(methodHandle m) { |
0c5f5b94e93a
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
2534
diff
changeset
|
268 |
// No special entry points that preclude compilation |
0c5f5b94e93a
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
2534
diff
changeset
|
269 |
return true; |
0c5f5b94e93a
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
2534
diff
changeset
|
270 |
} |
0c5f5b94e93a
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
2534
diff
changeset
|
271 |
|
1 | 272 |
void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) { |
273 |
||
274 |
// This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in |
|
275 |
// the days we had adapter frames. When we deoptimize a situation where a |
|
276 |
// compiled caller calls a compiled caller will have registers it expects |
|
277 |
// to survive the call to the callee. If we deoptimize the callee the only |
|
278 |
// way we can restore these registers is to have the oldest interpreter |
|
279 |
// frame that we create restore these values. That is what this routine |
|
280 |
// will accomplish. |
|
281 |
||
282 |
// At the moment we have modified c2 to not have any callee save registers |
|
283 |
// so this problem does not exist and this routine is just a place holder. |
|
284 |
||
285 |
assert(f->is_interpreted_frame(), "must be interpreted"); |
|
286 |
} |
|
287 |
||
288 |
||
289 |
//---------------------------------------------------------------------------------------------------- |
|
290 |
// Exceptions |