author | duke |
Wed, 05 Jul 2017 23:10:03 +0200 | |
changeset 44509 | 02253db2ace1 |
parent 44406 | a46a6c4d1dd9 |
child 46369 | 3bf4544bec14 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
2 |
* Copyright (c) 2003, 2017, 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:
5419
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5419
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:
5419
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
13728
diff
changeset
|
26 |
#include "asm/macroAssembler.hpp" |
7397 | 27 |
#include "interpreter/bytecodeHistogram.hpp" |
35214 | 28 |
#include "interpreter/interp_masm.hpp" |
7397 | 29 |
#include "interpreter/interpreter.hpp" |
30 |
#include "interpreter/interpreterRuntime.hpp" |
|
35214 | 31 |
#include "interpreter/templateInterpreterGenerator.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 "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" |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14745
diff
changeset
|
48 |
#include "utilities/macros.hpp" |
1 | 49 |
|
50 |
#define __ _masm-> |
|
51 |
||
35479
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
52 |
// Size of interpreter code. Increase if too small. Interpreter will |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
53 |
// fail with a guarantee ("not enough space for interpreter generation"); |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
54 |
// if too small. |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
55 |
// Run with +PrintInterpreter to get the VM to print out the size. |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
56 |
// Max size with JVMTI |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
57 |
#ifdef AMD64 |
41328
2bea535779f6
8165457: [JVMCI] increase InterpreterCodeSize for JVMCI
dnsimon
parents:
40644
diff
changeset
|
58 |
int TemplateInterpreter::InterpreterCodeSize = JVMCI_ONLY(268) NOT_JVMCI(256) * 1024; |
35479
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
59 |
#else |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
60 |
int TemplateInterpreter::InterpreterCodeSize = 224 * 1024; |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
61 |
#endif // AMD64 |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
62 |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
63 |
// Global Register Names |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
64 |
static const Register rbcp = LP64_ONLY(r13) NOT_LP64(rsi); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
65 |
static const Register rlocals = LP64_ONLY(r14) NOT_LP64(rdi); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
66 |
|
1 | 67 |
const int method_offset = frame::interpreter_frame_method_offset * wordSize; |
25714
87fa6860b5ae
8004128: NPG: remove stackwalking in Threads::gc_prologue and gc_epilogue code
coleenp
parents:
24322
diff
changeset
|
68 |
const int bcp_offset = frame::interpreter_frame_bcp_offset * wordSize; |
1 | 69 |
const int locals_offset = frame::interpreter_frame_locals_offset * wordSize; |
70 |
||
35479
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
71 |
|
1 | 72 |
//----------------------------------------------------------------------------- |
73 |
||
74 |
address TemplateInterpreterGenerator::generate_StackOverflowError_handler() { |
|
75 |
address entry = __ pc(); |
|
76 |
||
77 |
#ifdef ASSERT |
|
78 |
{ |
|
79 |
Label L; |
|
1066 | 80 |
__ lea(rax, Address(rbp, |
81 |
frame::interpreter_frame_monitor_block_top_offset * |
|
82 |
wordSize)); |
|
83 |
__ cmpptr(rax, rsp); // rax = maximal rsp for current rbp (stack |
|
84 |
// grows negative) |
|
1 | 85 |
__ jcc(Assembler::aboveEqual, L); // check if frame is complete |
86 |
__ stop ("interpreter frame not set up"); |
|
87 |
__ bind(L); |
|
88 |
} |
|
89 |
#endif // ASSERT |
|
90 |
// Restore bcp under the assumption that the current frame is still |
|
91 |
// interpreted |
|
92 |
__ restore_bcp(); |
|
93 |
||
94 |
// expression stack must be empty before entering the VM if an |
|
95 |
// exception happened |
|
96 |
__ empty_expression_stack(); |
|
97 |
// throw exception |
|
98 |
__ call_VM(noreg, |
|
99 |
CAST_FROM_FN_PTR(address, |
|
100 |
InterpreterRuntime::throw_StackOverflowError)); |
|
101 |
return entry; |
|
102 |
} |
|
103 |
||
104 |
address TemplateInterpreterGenerator::generate_ArrayIndexOutOfBounds_handler( |
|
105 |
const char* name) { |
|
106 |
address entry = __ pc(); |
|
107 |
// expression stack must be empty before entering the VM if an |
|
108 |
// exception happened |
|
109 |
__ empty_expression_stack(); |
|
110 |
// setup parameters |
|
111 |
// ??? convention: expect aberrant index in register ebx |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
112 |
Register rarg = NOT_LP64(rax) LP64_ONLY(c_rarg1); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
113 |
__ lea(rarg, ExternalAddress((address)name)); |
1 | 114 |
__ call_VM(noreg, |
115 |
CAST_FROM_FN_PTR(address, |
|
116 |
InterpreterRuntime:: |
|
117 |
throw_ArrayIndexOutOfBoundsException), |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
118 |
rarg, rbx); |
1 | 119 |
return entry; |
120 |
} |
|
121 |
||
122 |
address TemplateInterpreterGenerator::generate_ClassCastException_handler() { |
|
123 |
address entry = __ pc(); |
|
124 |
||
125 |
// object is at TOS |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
126 |
Register rarg = NOT_LP64(rax) LP64_ONLY(c_rarg1); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
127 |
__ pop(rarg); |
1 | 128 |
|
129 |
// expression stack must be empty before entering the VM if an |
|
130 |
// exception happened |
|
131 |
__ empty_expression_stack(); |
|
132 |
||
133 |
__ call_VM(noreg, |
|
134 |
CAST_FROM_FN_PTR(address, |
|
135 |
InterpreterRuntime:: |
|
136 |
throw_ClassCastException), |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
137 |
rarg); |
1 | 138 |
return entry; |
139 |
} |
|
140 |
||
141 |
address TemplateInterpreterGenerator::generate_exception_handler_common( |
|
142 |
const char* name, const char* message, bool pass_oop) { |
|
143 |
assert(!pass_oop || message == NULL, "either oop or message but not both"); |
|
144 |
address entry = __ pc(); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
145 |
|
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
146 |
Register rarg = NOT_LP64(rax) LP64_ONLY(c_rarg1); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
147 |
Register rarg2 = NOT_LP64(rbx) LP64_ONLY(c_rarg2); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
148 |
|
1 | 149 |
if (pass_oop) { |
150 |
// object is at TOS |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
151 |
__ pop(rarg2); |
1 | 152 |
} |
153 |
// expression stack must be empty before entering the VM if an |
|
154 |
// exception happened |
|
155 |
__ empty_expression_stack(); |
|
156 |
// setup parameters |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
157 |
__ lea(rarg, ExternalAddress((address)name)); |
1 | 158 |
if (pass_oop) { |
159 |
__ call_VM(rax, CAST_FROM_FN_PTR(address, |
|
160 |
InterpreterRuntime:: |
|
161 |
create_klass_exception), |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
162 |
rarg, rarg2); |
1 | 163 |
} else { |
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
35479
diff
changeset
|
164 |
__ lea(rarg2, ExternalAddress((address)message)); |
1 | 165 |
__ call_VM(rax, |
166 |
CAST_FROM_FN_PTR(address, InterpreterRuntime::create_exception), |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
167 |
rarg, rarg2); |
1 | 168 |
} |
169 |
// throw exception |
|
170 |
__ jump(ExternalAddress(Interpreter::throw_exception_entry())); |
|
171 |
return entry; |
|
172 |
} |
|
173 |
||
174 |
||
175 |
address TemplateInterpreterGenerator::generate_continuation_for(TosState state) { |
|
176 |
address entry = __ pc(); |
|
177 |
// NULL last_sp until next java call |
|
1066 | 178 |
__ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
1 | 179 |
__ dispatch_next(state); |
180 |
return entry; |
|
181 |
} |
|
182 |
||
183 |
||
21198
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
21095
diff
changeset
|
184 |
address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step, size_t index_size) { |
1 | 185 |
address entry = __ pc(); |
186 |
||
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
187 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
188 |
#ifdef COMPILER2 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
189 |
// The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
190 |
if ((state == ftos && UseSSE < 1) || (state == dtos && UseSSE < 2)) { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
191 |
for (int i = 1; i < 8; i++) { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
192 |
__ ffree(i); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
193 |
} |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
194 |
} else if (UseSSE < 2) { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
195 |
__ empty_FPU_stack(); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
196 |
} |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
197 |
#endif // COMPILER2 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
198 |
if ((state == ftos && UseSSE < 1) || (state == dtos && UseSSE < 2)) { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
199 |
__ MacroAssembler::verify_FPU(1, "generate_return_entry_for compiled"); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
200 |
} else { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
201 |
__ MacroAssembler::verify_FPU(0, "generate_return_entry_for compiled"); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
202 |
} |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
203 |
|
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
204 |
if (state == ftos) { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
205 |
__ MacroAssembler::verify_FPU(UseSSE >= 1 ? 0 : 1, "generate_return_entry_for in interpreter"); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
206 |
} else if (state == dtos) { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
207 |
__ MacroAssembler::verify_FPU(UseSSE >= 2 ? 0 : 1, "generate_return_entry_for in interpreter"); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
208 |
} |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
209 |
#endif // _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
210 |
|
1 | 211 |
// Restore stack bottom in case i2c adjusted stack |
1066 | 212 |
__ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); |
1 | 213 |
// and NULL it as marker that esp is now tos until next java call |
1066 | 214 |
__ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
1 | 215 |
|
216 |
__ restore_bcp(); |
|
217 |
__ restore_locals(); |
|
1066 | 218 |
|
20709
034be898bf04
8026054: New type profiling points: type of return values at calls
roland
parents:
19335
diff
changeset
|
219 |
if (state == atos) { |
034be898bf04
8026054: New type profiling points: type of return values at calls
roland
parents:
19335
diff
changeset
|
220 |
Register mdp = rbx; |
034be898bf04
8026054: New type profiling points: type of return values at calls
roland
parents:
19335
diff
changeset
|
221 |
Register tmp = rcx; |
034be898bf04
8026054: New type profiling points: type of return values at calls
roland
parents:
19335
diff
changeset
|
222 |
__ profile_return_type(mdp, rax, tmp); |
034be898bf04
8026054: New type profiling points: type of return values at calls
roland
parents:
19335
diff
changeset
|
223 |
} |
034be898bf04
8026054: New type profiling points: type of return values at calls
roland
parents:
19335
diff
changeset
|
224 |
|
21198
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
21095
diff
changeset
|
225 |
const Register cache = rbx; |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
21095
diff
changeset
|
226 |
const Register index = rcx; |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
21095
diff
changeset
|
227 |
__ get_cache_and_index_at_bcp(cache, index, 1, index_size); |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
21095
diff
changeset
|
228 |
|
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
21095
diff
changeset
|
229 |
const Register flags = cache; |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
21095
diff
changeset
|
230 |
__ movl(flags, Address(cache, index, Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset())); |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
21095
diff
changeset
|
231 |
__ andl(flags, ConstantPoolCacheEntry::parameter_size_mask); |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
21095
diff
changeset
|
232 |
__ lea(rsp, Address(rsp, flags, Interpreter::stackElementScale())); |
1 | 233 |
__ dispatch_next(state, step); |
4478 | 234 |
|
1 | 235 |
return entry; |
236 |
} |
|
237 |
||
238 |
||
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
239 |
address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, int step) { |
1 | 240 |
address entry = __ pc(); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
241 |
|
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
242 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
243 |
if (state == ftos) { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
244 |
__ MacroAssembler::verify_FPU(UseSSE >= 1 ? 0 : 1, "generate_deopt_entry_for in interpreter"); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
245 |
} else if (state == dtos) { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
246 |
__ MacroAssembler::verify_FPU(UseSSE >= 2 ? 0 : 1, "generate_deopt_entry_for in interpreter"); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
247 |
} |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
248 |
#endif // _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
249 |
|
1 | 250 |
// NULL last_sp until next java call |
1066 | 251 |
__ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
1 | 252 |
__ restore_bcp(); |
253 |
__ restore_locals(); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
254 |
const Register thread = NOT_LP64(rcx) LP64_ONLY(r15_thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
255 |
NOT_LP64(__ get_thread(thread)); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
256 |
#if INCLUDE_JVMCI |
41736
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
257 |
// Check if we need to take lock at entry of synchronized method. This can |
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
258 |
// only occur on method entry so emit it only for vtos with step 0. |
42650 | 259 |
if ((UseJVMCICompiler || UseAOT) && state == vtos && step == 0) { |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
260 |
Label L; |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
261 |
__ cmpb(Address(thread, JavaThread::pending_monitorenter_offset()), 0); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
262 |
__ jcc(Assembler::zero, L); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
263 |
// Clear flag. |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
264 |
__ movb(Address(thread, JavaThread::pending_monitorenter_offset()), 0); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
265 |
// Satisfy calling convention for lock_method(). |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
266 |
__ get_method(rbx); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
267 |
// Take lock. |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
268 |
lock_method(); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
269 |
__ bind(L); |
41736
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
270 |
} else { |
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
271 |
#ifdef ASSERT |
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
272 |
if (UseJVMCICompiler) { |
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
273 |
Label L; |
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
274 |
__ cmpb(Address(r15_thread, JavaThread::pending_monitorenter_offset()), 0); |
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
275 |
__ jccb(Assembler::zero, L); |
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
276 |
__ stop("unexpected pending monitor in deopt entry"); |
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
277 |
__ bind(L); |
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
278 |
} |
908e28baf9c2
8166972: [JVMCI] reduce size of interpreter when JVMCI is enabled
never
parents:
41330
diff
changeset
|
279 |
#endif |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
280 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
281 |
#endif |
1 | 282 |
// handle exceptions |
283 |
{ |
|
284 |
Label L; |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
285 |
__ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t) NULL_WORD); |
1 | 286 |
__ jcc(Assembler::zero, L); |
287 |
__ call_VM(noreg, |
|
288 |
CAST_FROM_FN_PTR(address, |
|
289 |
InterpreterRuntime::throw_pending_exception)); |
|
290 |
__ should_not_reach_here(); |
|
291 |
__ bind(L); |
|
292 |
} |
|
293 |
__ dispatch_next(state, step); |
|
294 |
return entry; |
|
295 |
} |
|
296 |
||
297 |
address TemplateInterpreterGenerator::generate_result_handler_for( |
|
298 |
BasicType type) { |
|
299 |
address entry = __ pc(); |
|
300 |
switch (type) { |
|
301 |
case T_BOOLEAN: __ c2bool(rax); break; |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
302 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
303 |
case T_CHAR : __ andptr(rax, 0xFFFF); break; |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
304 |
#else |
1 | 305 |
case T_CHAR : __ movzwl(rax, rax); break; |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
306 |
#endif // _LP64 |
1 | 307 |
case T_BYTE : __ sign_extend_byte(rax); break; |
308 |
case T_SHORT : __ sign_extend_short(rax); break; |
|
309 |
case T_INT : /* nothing to do */ break; |
|
310 |
case T_LONG : /* nothing to do */ break; |
|
311 |
case T_VOID : /* nothing to do */ break; |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
312 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
313 |
case T_DOUBLE : |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
314 |
case T_FLOAT : |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
315 |
{ const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp(); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
316 |
__ pop(t); // remove return address first |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
317 |
// Must return a result for interpreter or compiler. In SSE |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
318 |
// mode, results are returned in xmm0 and the FPU stack must |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
319 |
// be empty. |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
320 |
if (type == T_FLOAT && UseSSE >= 1) { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
321 |
// Load ST0 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
322 |
__ fld_d(Address(rsp, 0)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
323 |
// Store as float and empty fpu stack |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
324 |
__ fstp_s(Address(rsp, 0)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
325 |
// and reload |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
326 |
__ movflt(xmm0, Address(rsp, 0)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
327 |
} else if (type == T_DOUBLE && UseSSE >= 2 ) { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
328 |
__ movdbl(xmm0, Address(rsp, 0)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
329 |
} else { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
330 |
// restore ST0 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
331 |
__ fld_d(Address(rsp, 0)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
332 |
} |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
333 |
// and pop the temp |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
334 |
__ addptr(rsp, 2 * wordSize); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
335 |
__ push(t); // restore return address |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
336 |
} |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
337 |
break; |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
338 |
#else |
1 | 339 |
case T_FLOAT : /* nothing to do */ break; |
340 |
case T_DOUBLE : /* nothing to do */ break; |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
341 |
#endif // _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
342 |
|
1 | 343 |
case T_OBJECT : |
344 |
// retrieve result from frame |
|
1066 | 345 |
__ movptr(rax, Address(rbp, frame::interpreter_frame_oop_temp_offset*wordSize)); |
1 | 346 |
// and verify it |
347 |
__ verify_oop(rax); |
|
348 |
break; |
|
349 |
default : ShouldNotReachHere(); |
|
350 |
} |
|
351 |
__ ret(0); // return from result handler |
|
352 |
return entry; |
|
353 |
} |
|
354 |
||
355 |
address TemplateInterpreterGenerator::generate_safept_entry_for( |
|
356 |
TosState state, |
|
357 |
address runtime_entry) { |
|
358 |
address entry = __ pc(); |
|
359 |
__ push(state); |
|
360 |
__ call_VM(noreg, runtime_entry); |
|
361 |
__ dispatch_via(vtos, Interpreter::_normal_table.table_for(vtos)); |
|
362 |
return entry; |
|
363 |
} |
|
364 |
||
365 |
||
366 |
||
367 |
// Helpers for commoning out cases in the various type of method entries. |
|
368 |
// |
|
369 |
||
370 |
||
371 |
// increment invocation count & check for overflow |
|
372 |
// |
|
373 |
// Note: checking for negative value instead of overflow |
|
374 |
// so we have a 'sticky' overflow test |
|
375 |
// |
|
376 |
// rbx: method |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
377 |
// rcx: invocation counter |
1 | 378 |
// |
35214 | 379 |
void TemplateInterpreterGenerator::generate_counter_incr( |
1 | 380 |
Label* overflow, |
381 |
Label* profile_method, |
|
382 |
Label* profile_method_continue) { |
|
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
383 |
Label done; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
384 |
// Note: In tiered we increment either counters in Method* or in MDO depending if we're profiling or not. |
6453 | 385 |
if (TieredCompilation) { |
386 |
int increment = InvocationCounter::count_increment; |
|
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
387 |
Label no_mdo; |
6453 | 388 |
if (ProfileInterpreter) { |
389 |
// Are we profiling? |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
390 |
__ movptr(rax, Address(rbx, Method::method_data_offset())); |
6453 | 391 |
__ testptr(rax, rax); |
392 |
__ jccb(Assembler::zero, no_mdo); |
|
393 |
// Increment counter in the MDO |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
394 |
const Address mdo_invocation_counter(rax, in_bytes(MethodData::invocation_counter_offset()) + |
6453 | 395 |
in_bytes(InvocationCounter::counter_offset())); |
28650
772aaab2582f
8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents:
25950
diff
changeset
|
396 |
const Address mask(rax, in_bytes(MethodData::invoke_mask_offset())); |
6453 | 397 |
__ increment_mask_and_jump(mdo_invocation_counter, increment, mask, rcx, false, Assembler::zero, overflow); |
17037
34baf792b14d
8013041: guarantee(this->is8bit(imm8)) failed: Short forward jump exceeds 8-bit offset.
jiangli
parents:
17000
diff
changeset
|
398 |
__ jmp(done); |
6453 | 399 |
} |
400 |
__ bind(no_mdo); |
|
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
401 |
// Increment counter in MethodCounters |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
402 |
const Address invocation_counter(rax, |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
403 |
MethodCounters::invocation_counter_offset() + |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
404 |
InvocationCounter::counter_offset()); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
405 |
__ get_method_counters(rbx, rax, done); |
28650
772aaab2582f
8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents:
25950
diff
changeset
|
406 |
const Address mask(rax, in_bytes(MethodCounters::invoke_mask_offset())); |
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
407 |
__ increment_mask_and_jump(invocation_counter, increment, mask, rcx, |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
408 |
false, Assembler::zero, overflow); |
6453 | 409 |
__ bind(done); |
28650
772aaab2582f
8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents:
25950
diff
changeset
|
410 |
} else { // not TieredCompilation |
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
411 |
const Address backedge_counter(rax, |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
412 |
MethodCounters::backedge_counter_offset() + |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
413 |
InvocationCounter::counter_offset()); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
414 |
const Address invocation_counter(rax, |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
415 |
MethodCounters::invocation_counter_offset() + |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
416 |
InvocationCounter::counter_offset()); |
1 | 417 |
|
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
418 |
__ get_method_counters(rbx, rax, done); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
419 |
|
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
420 |
if (ProfileInterpreter) { |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
421 |
__ incrementl(Address(rax, |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
422 |
MethodCounters::interpreter_invocation_counter_offset())); |
6453 | 423 |
} |
424 |
// Update standard invocation counters |
|
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
425 |
__ movl(rcx, invocation_counter); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
426 |
__ incrementl(rcx, InvocationCounter::count_increment); |
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
427 |
__ movl(invocation_counter, rcx); // save invocation count |
1 | 428 |
|
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
429 |
__ movl(rax, backedge_counter); // load backedge counter |
6453 | 430 |
__ andl(rax, InvocationCounter::count_mask_value); // mask out the status bits |
1 | 431 |
|
6453 | 432 |
__ addl(rcx, rax); // add both counters |
1 | 433 |
|
6453 | 434 |
// profile_method is non-null only for interpreted method so |
435 |
// profile_method != NULL == !native_call |
|
436 |
||
437 |
if (ProfileInterpreter && profile_method != NULL) { |
|
438 |
// Test to see if we should create a method data oop |
|
28650
772aaab2582f
8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents:
25950
diff
changeset
|
439 |
__ movptr(rax, Address(rbx, Method::method_counters_offset())); |
772aaab2582f
8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents:
25950
diff
changeset
|
440 |
__ cmp32(rcx, Address(rax, in_bytes(MethodCounters::interpreter_profile_limit_offset()))); |
6453 | 441 |
__ jcc(Assembler::less, *profile_method_continue); |
1 | 442 |
|
6453 | 443 |
// if no method data exists, go to profile_method |
444 |
__ test_method_data_pointer(rax, *profile_method); |
|
445 |
} |
|
446 |
||
28650
772aaab2582f
8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents:
25950
diff
changeset
|
447 |
__ movptr(rax, Address(rbx, Method::method_counters_offset())); |
772aaab2582f
8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents:
25950
diff
changeset
|
448 |
__ cmp32(rcx, Address(rax, in_bytes(MethodCounters::interpreter_invocation_limit_offset()))); |
6453 | 449 |
__ jcc(Assembler::aboveEqual, *overflow); |
17000
11bf92e571a2
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
16624
diff
changeset
|
450 |
__ bind(done); |
1 | 451 |
} |
452 |
} |
|
453 |
||
35214 | 454 |
void TemplateInterpreterGenerator::generate_counter_overflow(Label& do_continue) { |
1 | 455 |
|
456 |
// Asm interpreter on entry |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
457 |
// r14/rdi - locals |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
458 |
// r13/rsi - bcp |
1 | 459 |
// rbx - method |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
460 |
// rdx - cpool --- DOES NOT APPEAR TO BE TRUE |
1 | 461 |
// rbp - interpreter frame |
462 |
||
463 |
// On return (i.e. jump to entry_point) [ back to invocation of interpreter ] |
|
464 |
// Everything as it was on entry |
|
465 |
// rdx is not restored. Doesn't appear to really be set. |
|
466 |
||
467 |
// InterpreterRuntime::frequency_counter_overflow takes two |
|
468 |
// arguments, the first (thread) is passed by call_VM, the second |
|
469 |
// indicates if the counter overflow occurs at a backwards branch |
|
470 |
// (NULL bcp). We pass zero for it. The call returns the address |
|
471 |
// of the verified entry point for the method or NULL if the |
|
472 |
// compilation did not complete (either went background or bailed |
|
473 |
// out). |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
474 |
Register rarg = NOT_LP64(rax) LP64_ONLY(c_rarg1); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
475 |
__ movl(rarg, 0); |
1 | 476 |
__ call_VM(noreg, |
477 |
CAST_FROM_FN_PTR(address, |
|
478 |
InterpreterRuntime::frequency_counter_overflow), |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
479 |
rarg); |
1 | 480 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
481 |
__ movptr(rbx, Address(rbp, method_offset)); // restore Method* |
1 | 482 |
// Preserve invariant that r13/r14 contain bcp/locals of sender frame |
483 |
// and jump to the interpreted entry. |
|
35214 | 484 |
__ jmp(do_continue, relocInfo::none); |
1 | 485 |
} |
486 |
||
39390
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
487 |
// See if we've got enough room on the stack for locals plus overhead below |
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
488 |
// JavaThread::stack_overflow_limit(). If not, throw a StackOverflowError |
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
489 |
// without going through the signal handler, i.e., reserved and yellow zones |
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
490 |
// will not be made usable. The shadow zone must suffice to handle the |
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
491 |
// overflow. |
1 | 492 |
// The expression stack grows down incrementally, so the normal guard |
493 |
// page mechanism will work for that. |
|
494 |
// |
|
495 |
// NOTE: Since the additional locals are also always pushed (wasn't |
|
25950
b5c40ed1d349
8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents:
25717
diff
changeset
|
496 |
// obvious in generate_fixed_frame) so the guard should work for them |
1 | 497 |
// too. |
498 |
// |
|
499 |
// Args: |
|
500 |
// rdx: number of additional locals this frame needs (what we must check) |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
501 |
// rbx: Method* |
1 | 502 |
// |
503 |
// Kills: |
|
504 |
// rax |
|
35214 | 505 |
void TemplateInterpreterGenerator::generate_stack_overflow_check(void) { |
1 | 506 |
|
25950
b5c40ed1d349
8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents:
25717
diff
changeset
|
507 |
// monitor entry size: see picture of stack in frame_x86.hpp |
1 | 508 |
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; |
509 |
||
510 |
// total overhead size: entry_size + (saved rbp through expr stack |
|
511 |
// bottom). be sure to change this if you add/subtract anything |
|
512 |
// to/from the overhead area |
|
513 |
const int overhead_size = |
|
514 |
-(frame::interpreter_frame_initial_sp_offset * wordSize) + entry_size; |
|
515 |
||
516 |
const int page_size = os::vm_page_size(); |
|
517 |
||
518 |
Label after_frame_check; |
|
519 |
||
520 |
// see if the frame is greater than one page in size. If so, |
|
521 |
// then we need to verify there is enough stack space remaining |
|
522 |
// for the additional locals. |
|
5419 | 523 |
__ cmpl(rdx, (page_size - overhead_size) / Interpreter::stackElementSize); |
1 | 524 |
__ jcc(Assembler::belowEqual, after_frame_check); |
525 |
||
526 |
// compute rsp as if this were going to be the last frame on |
|
527 |
// the stack before the red zone |
|
528 |
||
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
529 |
Label after_frame_check_pop; |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
530 |
const Register thread = NOT_LP64(rsi) LP64_ONLY(r15_thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
531 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
532 |
__ push(thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
533 |
__ get_thread(thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
534 |
#endif |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
535 |
|
39390
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
536 |
const Address stack_limit(thread, JavaThread::stack_overflow_limit_offset()); |
1 | 537 |
|
538 |
// locals + overhead, in bytes |
|
1066 | 539 |
__ mov(rax, rdx); |
39390
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
540 |
__ shlptr(rax, Interpreter::logStackElementSize); // Convert parameter count to bytes. |
1066 | 541 |
__ addptr(rax, overhead_size); |
1 | 542 |
|
543 |
#ifdef ASSERT |
|
39390
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
544 |
Label limit_okay; |
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
545 |
// Verify that thread stack overflow limit is non-zero. |
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
546 |
__ cmpptr(stack_limit, (int32_t)NULL_WORD); |
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
547 |
__ jcc(Assembler::notEqual, limit_okay); |
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
548 |
__ stop("stack overflow limit is zero"); |
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
549 |
__ bind(limit_okay); |
1 | 550 |
#endif |
551 |
||
39390
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
552 |
// Add locals/frame size to stack limit. |
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
553 |
__ addptr(rax, stack_limit); |
1 | 554 |
|
39390
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
555 |
// Check against the current stack bottom. |
1066 | 556 |
__ cmpptr(rsp, rax); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
557 |
|
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
558 |
__ jcc(Assembler::above, after_frame_check_pop); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
559 |
NOT_LP64(__ pop(rsi)); // get saved bcp |
1 | 560 |
|
11411 | 561 |
// Restore sender's sp as SP. This is necessary if the sender's |
562 |
// frame is an extended compiled frame (see gen_c2i_adapter()) |
|
563 |
// and safer anyway in case of JSR292 adaptations. |
|
564 |
||
565 |
__ pop(rax); // return address must be moved if SP is changed |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
566 |
__ mov(rsp, rbcp); |
11411 | 567 |
__ push(rax); |
568 |
||
569 |
// Note: the restored frame is not necessarily interpreted. |
|
570 |
// Use the shared runtime version of the StackOverflowError. |
|
571 |
assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "stub not yet generated"); |
|
572 |
__ jump(ExternalAddress(StubRoutines::throw_StackOverflowError_entry())); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
573 |
// all done with frame size check |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
574 |
__ bind(after_frame_check_pop); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
575 |
NOT_LP64(__ pop(rsi)); |
1 | 576 |
|
577 |
// all done with frame size check |
|
578 |
__ bind(after_frame_check); |
|
579 |
} |
|
580 |
||
581 |
// Allocate monitor and lock method (asm interpreter) |
|
582 |
// |
|
583 |
// Args: |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
584 |
// rbx: Method* |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
585 |
// r14/rdi: locals |
1 | 586 |
// |
587 |
// Kills: |
|
588 |
// rax |
|
589 |
// c_rarg0, c_rarg1, c_rarg2, c_rarg3, ...(param regs) |
|
590 |
// rscratch1, rscratch2 (scratch regs) |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33070
diff
changeset
|
591 |
void TemplateInterpreterGenerator::lock_method() { |
1 | 592 |
// synchronize method |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
593 |
const Address access_flags(rbx, Method::access_flags_offset()); |
1 | 594 |
const Address monitor_block_top( |
595 |
rbp, |
|
596 |
frame::interpreter_frame_monitor_block_top_offset * wordSize); |
|
597 |
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; |
|
598 |
||
599 |
#ifdef ASSERT |
|
600 |
{ |
|
601 |
Label L; |
|
602 |
__ movl(rax, access_flags); |
|
603 |
__ testl(rax, JVM_ACC_SYNCHRONIZED); |
|
604 |
__ jcc(Assembler::notZero, L); |
|
605 |
__ stop("method doesn't need synchronization"); |
|
606 |
__ bind(L); |
|
607 |
} |
|
608 |
#endif // ASSERT |
|
609 |
||
610 |
// get synchronization object |
|
611 |
{ |
|
612 |
Label done; |
|
613 |
__ movl(rax, access_flags); |
|
614 |
__ testl(rax, JVM_ACC_STATIC); |
|
615 |
// get receiver (assume this is frequent case) |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
616 |
__ movptr(rax, Address(rlocals, Interpreter::local_offset_in_bytes(0))); |
1 | 617 |
__ jcc(Assembler::zero, done); |
38074
8475fdc6dcc3
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents:
37152
diff
changeset
|
618 |
__ load_mirror(rax, rbx); |
1 | 619 |
|
620 |
#ifdef ASSERT |
|
621 |
{ |
|
622 |
Label L; |
|
1066 | 623 |
__ testptr(rax, rax); |
1 | 624 |
__ jcc(Assembler::notZero, L); |
625 |
__ stop("synchronization object is NULL"); |
|
626 |
__ bind(L); |
|
627 |
} |
|
628 |
#endif // ASSERT |
|
629 |
||
630 |
__ bind(done); |
|
631 |
} |
|
632 |
||
633 |
// add space for monitor & lock |
|
1066 | 634 |
__ subptr(rsp, entry_size); // add space for a monitor entry |
635 |
__ movptr(monitor_block_top, rsp); // set new monitor block top |
|
1 | 636 |
// store object |
1066 | 637 |
__ movptr(Address(rsp, BasicObjectLock::obj_offset_in_bytes()), rax); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
638 |
const Register lockreg = NOT_LP64(rdx) LP64_ONLY(c_rarg1); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
639 |
__ movptr(lockreg, rsp); // object address |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
640 |
__ lock_object(lockreg); |
1 | 641 |
} |
642 |
||
643 |
// Generate a fixed interpreter frame. This is identical setup for |
|
644 |
// interpreted methods and for native methods hence the shared code. |
|
645 |
// |
|
646 |
// Args: |
|
647 |
// rax: return address |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
648 |
// rbx: Method* |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
649 |
// r14/rdi: pointer to locals |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
650 |
// r13/rsi: sender sp |
1 | 651 |
// rdx: cp cache |
652 |
void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { |
|
653 |
// initialize fixed part of activation frame |
|
1066 | 654 |
__ push(rax); // save return address |
1 | 655 |
__ enter(); // save old & set new rbp |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
656 |
__ push(rbcp); // set sender sp |
1066 | 657 |
__ push((int)NULL_WORD); // leave last_sp as null |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
658 |
__ movptr(rbcp, Address(rbx, Method::const_offset())); // get ConstMethod* |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
659 |
__ lea(rbcp, Address(rbcp, ConstMethod::codes_offset())); // get codebase |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
660 |
__ push(rbx); // save Method* |
38074
8475fdc6dcc3
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents:
37152
diff
changeset
|
661 |
// Get mirror and store it in the frame as GC root for this Method* |
8475fdc6dcc3
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents:
37152
diff
changeset
|
662 |
__ load_mirror(rdx, rbx); |
8475fdc6dcc3
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents:
37152
diff
changeset
|
663 |
__ push(rdx); |
1 | 664 |
if (ProfileInterpreter) { |
665 |
Label method_data_continue; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
666 |
__ movptr(rdx, Address(rbx, in_bytes(Method::method_data_offset()))); |
1066 | 667 |
__ testptr(rdx, rdx); |
1 | 668 |
__ jcc(Assembler::zero, method_data_continue); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
669 |
__ addptr(rdx, in_bytes(MethodData::data_offset())); |
1 | 670 |
__ bind(method_data_continue); |
1066 | 671 |
__ push(rdx); // set the mdp (method data pointer) |
1 | 672 |
} else { |
1066 | 673 |
__ push(0); |
1 | 674 |
} |
675 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
676 |
__ movptr(rdx, Address(rbx, Method::const_offset())); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
677 |
__ movptr(rdx, Address(rdx, ConstMethod::constants_offset())); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
678 |
__ movptr(rdx, Address(rdx, ConstantPool::cache_offset_in_bytes())); |
1066 | 679 |
__ push(rdx); // set constant pool cache |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
680 |
__ push(rlocals); // set locals pointer |
1 | 681 |
if (native_call) { |
1066 | 682 |
__ push(0); // no bcp |
1 | 683 |
} else { |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
684 |
__ push(rbcp); // set bcp |
1 | 685 |
} |
1066 | 686 |
__ push(0); // reserve word for pointer to expression stack bottom |
687 |
__ movptr(Address(rsp, 0), rsp); // set expression stack bottom |
|
1 | 688 |
} |
689 |
||
690 |
// End of helpers |
|
691 |
||
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
692 |
// Method entry for java.lang.ref.Reference.get. |
35214 | 693 |
address TemplateInterpreterGenerator::generate_Reference_get_entry(void) { |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14745
diff
changeset
|
694 |
#if INCLUDE_ALL_GCS |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
695 |
// Code: _aload_0, _getfield, _areturn |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
696 |
// parameter size = 1 |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
697 |
// |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
698 |
// The code that gets generated by this routine is split into 2 parts: |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
699 |
// 1. The "intrinsified" code for G1 (or any SATB based GC), |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
700 |
// 2. The slow path - which is an expansion of the regular method entry. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
701 |
// |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
702 |
// Notes:- |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
703 |
// * In the G1 code we do not check whether we need to block for |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
704 |
// a safepoint. If G1 is enabled then we must execute the specialized |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
705 |
// code for Reference.get (except when the Reference object is null) |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
706 |
// so that we can log the value in the referent field with an SATB |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
707 |
// update buffer. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
708 |
// If the code for the getfield template is modified so that the |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
709 |
// G1 pre-barrier code is executed when the current method is |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
710 |
// Reference.get() then going through the normal method entry |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
711 |
// will be fine. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
712 |
// * The G1 code can, however, check the receiver object (the instance |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
713 |
// of java.lang.Reference) and jump to the slow path if null. If the |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
714 |
// Reference object is null then we obviously cannot fetch the referent |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
715 |
// and so we don't need to call the G1 pre-barrier. Thus we can use the |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
716 |
// regular method entry code to generate the NPE. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
717 |
// |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
718 |
// rbx: Method* |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
719 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
720 |
// r13: senderSP must preserve for slow path, set SP to it on fast path |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
721 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
722 |
address entry = __ pc(); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
723 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
724 |
const int referent_offset = java_lang_ref_Reference::referent_offset; |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
725 |
guarantee(referent_offset > 0, "referent offset not initialized"); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
726 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
727 |
if (UseG1GC) { |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
728 |
Label slow_path; |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
729 |
// rbx: method |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
730 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
731 |
// Check if local 0 != NULL |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
732 |
// If the receiver is null then it is OK to jump to the slow path. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
733 |
__ movptr(rax, Address(rsp, wordSize)); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
734 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
735 |
__ testptr(rax, rax); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
736 |
__ jcc(Assembler::zero, slow_path); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
737 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
738 |
// rax: local 0 |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
739 |
// rbx: method (but can be used as scratch now) |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
740 |
// rdx: scratch |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
741 |
// rdi: scratch |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
742 |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
743 |
// Preserve the sender sp in case the pre-barrier |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
744 |
// calls the runtime |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
745 |
NOT_LP64(__ push(rsi)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
746 |
|
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
747 |
// Generate the G1 pre-barrier code to log the value of |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
748 |
// the referent field in an SATB buffer. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
749 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
750 |
// Load the value of the referent field. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
751 |
const Address field_address(rax, referent_offset); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
752 |
__ load_heap_oop(rax, field_address); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
753 |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
754 |
const Register sender_sp = NOT_LP64(rsi) LP64_ONLY(r13); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
755 |
const Register thread = NOT_LP64(rcx) LP64_ONLY(r15_thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
756 |
NOT_LP64(__ get_thread(thread)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
757 |
|
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
758 |
// Generate the G1 pre-barrier code to log the value of |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
759 |
// the referent field in an SATB buffer. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
760 |
__ g1_write_barrier_pre(noreg /* obj */, |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
761 |
rax /* pre_val */, |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
762 |
thread /* thread */, |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
763 |
rbx /* tmp */, |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
764 |
true /* tosca_live */, |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
765 |
true /* expand_call */); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
766 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
767 |
// _areturn |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
768 |
NOT_LP64(__ pop(rsi)); // get sender sp |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
769 |
__ pop(rdi); // get return address |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
770 |
__ mov(rsp, sender_sp); // set sp to sender sp |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
771 |
__ jmp(rdi); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
772 |
__ ret(0); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
773 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
774 |
// generate a vanilla interpreter entry as the slow path |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
775 |
__ bind(slow_path); |
33070
54f3f085b165
8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents:
33066
diff
changeset
|
776 |
__ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals)); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
777 |
return entry; |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
778 |
} |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14745
diff
changeset
|
779 |
#endif // INCLUDE_ALL_GCS |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
780 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
781 |
// If G1 is not enabled then attempt to go through the accessor entry point |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
782 |
// Reference.get is an accessor |
33070
54f3f085b165
8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents:
33066
diff
changeset
|
783 |
return NULL; |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
784 |
} |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8315
diff
changeset
|
785 |
|
35479
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
786 |
void TemplateInterpreterGenerator::bang_stack_shadow_pages(bool native_call) { |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
787 |
// Quick & dirty stack overflow checking: bang the stack & handle trap. |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
788 |
// Note that we do the banging after the frame is setup, since the exception |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
789 |
// handling code expects to find a valid interpreter frame on the stack. |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
790 |
// Doing the banging earlier fails if the caller frame is not an interpreter |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
791 |
// frame. |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
792 |
// (Also, the exception throwing code expects to unlock any synchronized |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
793 |
// method receiever, so do the banging after locking the receiver.) |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
794 |
|
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
795 |
// Bang each page in the shadow zone. We can't assume it's been done for |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
796 |
// an interpreter frame with greater than a page of locals, so each page |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
797 |
// needs to be checked. Only true for non-native. |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
798 |
if (UseStackBanging) { |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
799 |
const int page_size = os::vm_page_size(); |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
800 |
const int n_shadow_pages = ((int)JavaThread::stack_shadow_zone_size()) / page_size; |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
801 |
const int start_page = native_call ? n_shadow_pages : 1; |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
802 |
for (int pages = start_page; pages <= n_shadow_pages; pages++) { |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
803 |
__ bang_stack_with_offset(pages*page_size); |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
804 |
} |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
805 |
} |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
806 |
} |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
807 |
|
1 | 808 |
// Interpreter stub for calling a native method. (asm interpreter) |
809 |
// This sets up a somewhat different looking stack for calling the |
|
810 |
// native method than the typical interpreter frame setup. |
|
35214 | 811 |
address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { |
1 | 812 |
// determine code generation flags |
31790 | 813 |
bool inc_counter = UseCompiler || CountCompiledCalls || LogTouchedMethods; |
1 | 814 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
815 |
// rbx: Method* |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
816 |
// rbcp: sender sp |
1 | 817 |
|
818 |
address entry_point = __ pc(); |
|
819 |
||
14745
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
820 |
const Address constMethod (rbx, Method::const_offset()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
821 |
const Address access_flags (rbx, Method::access_flags_offset()); |
14745
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
822 |
const Address size_of_parameters(rcx, ConstMethod:: |
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
823 |
size_of_parameters_offset()); |
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
824 |
|
1 | 825 |
|
826 |
// get parameter size (always needed) |
|
14745
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
827 |
__ movptr(rcx, constMethod); |
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
828 |
__ load_unsigned_short(rcx, size_of_parameters); |
1 | 829 |
|
830 |
// native calls don't need the stack size check since they have no |
|
831 |
// expression stack and the arguments are already on the stack and |
|
832 |
// we only add a handful of words to the stack |
|
833 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
834 |
// rbx: Method* |
1 | 835 |
// rcx: size of parameters |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
836 |
// rbcp: sender sp |
1066 | 837 |
__ pop(rax); // get return address |
1 | 838 |
|
839 |
// for natives the size of locals is zero |
|
840 |
||
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
841 |
// compute beginning of parameters |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
842 |
__ lea(rlocals, Address(rsp, rcx, Interpreter::stackElementScale(), -wordSize)); |
1 | 843 |
|
844 |
// add 2 zero-initialized slots for native calls |
|
845 |
// initialize result_handler slot |
|
1066 | 846 |
__ push((int) NULL_WORD); |
1 | 847 |
// slot for oop temp |
848 |
// (static native method holder mirror/jni oop result) |
|
1066 | 849 |
__ push((int) NULL_WORD); |
1 | 850 |
|
851 |
// initialize fixed part of activation frame |
|
852 |
generate_fixed_frame(true); |
|
853 |
||
854 |
// make sure method is native & not abstract |
|
855 |
#ifdef ASSERT |
|
856 |
__ movl(rax, access_flags); |
|
857 |
{ |
|
858 |
Label L; |
|
859 |
__ testl(rax, JVM_ACC_NATIVE); |
|
860 |
__ jcc(Assembler::notZero, L); |
|
861 |
__ stop("tried to execute non-native method as native"); |
|
862 |
__ bind(L); |
|
863 |
} |
|
864 |
{ |
|
865 |
Label L; |
|
866 |
__ testl(rax, JVM_ACC_ABSTRACT); |
|
867 |
__ jcc(Assembler::zero, L); |
|
868 |
__ stop("tried to execute abstract method in interpreter"); |
|
869 |
__ bind(L); |
|
870 |
} |
|
871 |
#endif |
|
872 |
||
873 |
// Since at this point in the method invocation the exception handler |
|
874 |
// would try to exit the monitor of synchronized methods which hasn't |
|
875 |
// been entered yet, we set the thread local variable |
|
876 |
// _do_not_unlock_if_synchronized to true. The remove_activation will |
|
877 |
// check this flag. |
|
878 |
||
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
879 |
const Register thread1 = NOT_LP64(rax) LP64_ONLY(r15_thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
880 |
NOT_LP64(__ get_thread(thread1)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
881 |
const Address do_not_unlock_if_synchronized(thread1, |
1 | 882 |
in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); |
883 |
__ movbool(do_not_unlock_if_synchronized, true); |
|
884 |
||
885 |
// increment invocation count & check for overflow |
|
886 |
Label invocation_counter_overflow; |
|
887 |
if (inc_counter) { |
|
888 |
generate_counter_incr(&invocation_counter_overflow, NULL, NULL); |
|
889 |
} |
|
890 |
||
891 |
Label continue_after_compile; |
|
892 |
__ bind(continue_after_compile); |
|
893 |
||
894 |
bang_stack_shadow_pages(true); |
|
895 |
||
896 |
// reset the _do_not_unlock_if_synchronized flag |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
897 |
NOT_LP64(__ get_thread(thread1)); |
1 | 898 |
__ movbool(do_not_unlock_if_synchronized, false); |
899 |
||
900 |
// check for synchronized methods |
|
901 |
// Must happen AFTER invocation_counter check and stack overflow check, |
|
902 |
// so method is not locked if overflows. |
|
903 |
if (synchronized) { |
|
904 |
lock_method(); |
|
905 |
} else { |
|
906 |
// no synchronization necessary |
|
907 |
#ifdef ASSERT |
|
908 |
{ |
|
909 |
Label L; |
|
910 |
__ movl(rax, access_flags); |
|
911 |
__ testl(rax, JVM_ACC_SYNCHRONIZED); |
|
912 |
__ jcc(Assembler::zero, L); |
|
913 |
__ stop("method needs synchronization"); |
|
914 |
__ bind(L); |
|
915 |
} |
|
916 |
#endif |
|
917 |
} |
|
918 |
||
919 |
// start execution |
|
920 |
#ifdef ASSERT |
|
921 |
{ |
|
922 |
Label L; |
|
923 |
const Address monitor_block_top(rbp, |
|
924 |
frame::interpreter_frame_monitor_block_top_offset * wordSize); |
|
1066 | 925 |
__ movptr(rax, monitor_block_top); |
926 |
__ cmpptr(rax, rsp); |
|
1 | 927 |
__ jcc(Assembler::equal, L); |
928 |
__ stop("broken stack frame setup in interpreter"); |
|
929 |
__ bind(L); |
|
930 |
} |
|
931 |
#endif |
|
932 |
||
933 |
// jvmti support |
|
934 |
__ notify_method_entry(); |
|
935 |
||
936 |
// work registers |
|
937 |
const Register method = rbx; |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
938 |
const Register thread = NOT_LP64(rdi) LP64_ONLY(r15_thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
939 |
const Register t = NOT_LP64(rcx) LP64_ONLY(r11); |
1 | 940 |
|
941 |
// allocate space for parameters |
|
942 |
__ get_method(method); |
|
14745
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
943 |
__ movptr(t, Address(method, Method::const_offset())); |
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
944 |
__ load_unsigned_short(t, Address(t, ConstMethod::size_of_parameters_offset())); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
945 |
|
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
946 |
#ifndef _LP64 |
39390
edf6a424a8b7
8159335: Fix problems with stack overflow handling.
goetz
parents:
38074
diff
changeset
|
947 |
__ shlptr(t, Interpreter::logStackElementSize); // Convert parameter count to bytes. |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
948 |
__ addptr(t, 2*wordSize); // allocate two more slots for JNIEnv and possible mirror |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
949 |
__ subptr(rsp, t); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
950 |
__ andptr(rsp, -(StackAlignmentInBytes)); // gcc needs 16 byte aligned stacks to do XMM intrinsics |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
951 |
#else |
5419 | 952 |
__ shll(t, Interpreter::logStackElementSize); |
1 | 953 |
|
1066 | 954 |
__ subptr(rsp, t); |
955 |
__ subptr(rsp, frame::arg_reg_save_area_bytes); // windows |
|
2131 | 956 |
__ andptr(rsp, -16); // must be 16 byte boundary (see amd64 ABI) |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
957 |
#endif // _LP64 |
1 | 958 |
|
959 |
// get signature handler |
|
960 |
{ |
|
961 |
Label L; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
962 |
__ movptr(t, Address(method, Method::signature_handler_offset())); |
1066 | 963 |
__ testptr(t, t); |
1 | 964 |
__ jcc(Assembler::notZero, L); |
965 |
__ call_VM(noreg, |
|
966 |
CAST_FROM_FN_PTR(address, |
|
967 |
InterpreterRuntime::prepare_native_call), |
|
968 |
method); |
|
969 |
__ get_method(method); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
970 |
__ movptr(t, Address(method, Method::signature_handler_offset())); |
1 | 971 |
__ bind(L); |
972 |
} |
|
973 |
||
974 |
// call signature handler |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
975 |
assert(InterpreterRuntime::SignatureHandlerGenerator::from() == rlocals, |
1 | 976 |
"adjust this code"); |
977 |
assert(InterpreterRuntime::SignatureHandlerGenerator::to() == rsp, |
|
978 |
"adjust this code"); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
979 |
assert(InterpreterRuntime::SignatureHandlerGenerator::temp() == NOT_LP64(t) LP64_ONLY(rscratch1), |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
980 |
"adjust this code"); |
1 | 981 |
|
982 |
// The generated handlers do not touch RBX (the method oop). |
|
983 |
// However, large signatures cannot be cached and are generated |
|
984 |
// each time here. The slow-path generator can do a GC on return, |
|
985 |
// so we must reload it after the call. |
|
986 |
__ call(t); |
|
987 |
__ get_method(method); // slow path can do a GC, reload RBX |
|
988 |
||
989 |
||
990 |
// result handler is in rax |
|
991 |
// set result handler |
|
1066 | 992 |
__ movptr(Address(rbp, |
993 |
(frame::interpreter_frame_result_handler_offset) * wordSize), |
|
994 |
rax); |
|
1 | 995 |
|
996 |
// pass mirror handle if static call |
|
997 |
{ |
|
998 |
Label L; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
999 |
__ movl(t, Address(method, Method::access_flags_offset())); |
1 | 1000 |
__ testl(t, JVM_ACC_STATIC); |
1001 |
__ jcc(Assembler::zero, L); |
|
1002 |
// get mirror |
|
38074
8475fdc6dcc3
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents:
37152
diff
changeset
|
1003 |
__ load_mirror(t, method); |
1 | 1004 |
// copy mirror into activation frame |
1066 | 1005 |
__ movptr(Address(rbp, frame::interpreter_frame_oop_temp_offset * wordSize), |
1 | 1006 |
t); |
1007 |
// pass handle to mirror |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1008 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1009 |
__ lea(t, Address(rbp, frame::interpreter_frame_oop_temp_offset * wordSize)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1010 |
__ movptr(Address(rsp, wordSize), t); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1011 |
#else |
1066 | 1012 |
__ lea(c_rarg1, |
1013 |
Address(rbp, frame::interpreter_frame_oop_temp_offset * wordSize)); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1014 |
#endif // _LP64 |
1 | 1015 |
__ bind(L); |
1016 |
} |
|
1017 |
||
1018 |
// get native function entry point |
|
1019 |
{ |
|
1020 |
Label L; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1021 |
__ movptr(rax, Address(method, Method::native_function_offset())); |
1 | 1022 |
ExternalAddress unsatisfied(SharedRuntime::native_method_throw_unsatisfied_link_error_entry()); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1023 |
__ cmpptr(rax, unsatisfied.addr()); |
1 | 1024 |
__ jcc(Assembler::notEqual, L); |
1025 |
__ call_VM(noreg, |
|
1026 |
CAST_FROM_FN_PTR(address, |
|
1027 |
InterpreterRuntime::prepare_native_call), |
|
1028 |
method); |
|
1029 |
__ get_method(method); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1030 |
__ movptr(rax, Address(method, Method::native_function_offset())); |
1 | 1031 |
__ bind(L); |
1032 |
} |
|
1033 |
||
1034 |
// pass JNIEnv |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1035 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1036 |
__ get_thread(thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1037 |
__ lea(t, Address(thread, JavaThread::jni_environment_offset())); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1038 |
__ movptr(Address(rsp, 0), t); |
1 | 1039 |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1040 |
// set_last_Java_frame_before_call |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1041 |
// It is enough that the pc() |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1042 |
// points into the right code segment. It does not have to be the correct return pc. |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1043 |
__ set_last_Java_frame(thread, noreg, rbp, __ pc()); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1044 |
#else |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1045 |
__ lea(c_rarg0, Address(r15_thread, JavaThread::jni_environment_offset())); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1046 |
|
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1047 |
// It is enough that the pc() points into the right code |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1048 |
// segment. It does not have to be the correct return pc. |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1049 |
__ set_last_Java_frame(rsp, rbp, (address) __ pc()); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1050 |
#endif // _LP64 |
1 | 1051 |
|
1052 |
// change thread state |
|
1053 |
#ifdef ASSERT |
|
1054 |
{ |
|
1055 |
Label L; |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1056 |
__ movl(t, Address(thread, JavaThread::thread_state_offset())); |
1 | 1057 |
__ cmpl(t, _thread_in_Java); |
1058 |
__ jcc(Assembler::equal, L); |
|
1059 |
__ stop("Wrong thread state in native stub"); |
|
1060 |
__ bind(L); |
|
1061 |
} |
|
1062 |
#endif |
|
1063 |
||
1064 |
// Change state to native |
|
1065 |
||
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1066 |
__ movl(Address(thread, JavaThread::thread_state_offset()), |
1 | 1067 |
_thread_in_native); |
1068 |
||
1069 |
// Call the native method. |
|
1070 |
__ call(rax); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1071 |
// 32: result potentially in rdx:rax or ST0 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1072 |
// 64: result potentially in rax or xmm0 |
1 | 1073 |
|
16624
9dbd4b210bf9
8011102: Clear AVX registers after return from JNI call
kvn
parents:
15943
diff
changeset
|
1074 |
// Verify or restore cpu control state after JNI call |
9dbd4b210bf9
8011102: Clear AVX registers after return from JNI call
kvn
parents:
15943
diff
changeset
|
1075 |
__ restore_cpu_control_state_after_jni(); |
1 | 1076 |
|
1077 |
// NOTE: The order of these pushes is known to frame::interpreter_frame_result |
|
1078 |
// in order to extract the result of a method call. If the order of these |
|
1079 |
// pushes change or anything else is added to the stack then the code in |
|
1080 |
// interpreter_frame_result must also change. |
|
1081 |
||
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1082 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1083 |
// save potential result in ST(0) & rdx:rax |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1084 |
// (if result handler is the T_FLOAT or T_DOUBLE handler, result must be in ST0 - |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1085 |
// the check is necessary to avoid potential Intel FPU overflow problems by saving/restoring 'empty' FPU registers) |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1086 |
// It is safe to do this push because state is _thread_in_native and return address will be found |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1087 |
// via _last_native_pc and not via _last_jave_sp |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1088 |
|
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1089 |
// NOTE: the order of theses push(es) is known to frame::interpreter_frame_result. |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1090 |
// If the order changes or anything else is added to the stack the code in |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1091 |
// interpreter_frame_result will have to be changed. |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1092 |
|
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1093 |
{ Label L; |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1094 |
Label push_double; |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1095 |
ExternalAddress float_handler(AbstractInterpreter::result_handler(T_FLOAT)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1096 |
ExternalAddress double_handler(AbstractInterpreter::result_handler(T_DOUBLE)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1097 |
__ cmpptr(Address(rbp, (frame::interpreter_frame_oop_temp_offset + 1)*wordSize), |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1098 |
float_handler.addr()); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1099 |
__ jcc(Assembler::equal, push_double); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1100 |
__ cmpptr(Address(rbp, (frame::interpreter_frame_oop_temp_offset + 1)*wordSize), |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1101 |
double_handler.addr()); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1102 |
__ jcc(Assembler::notEqual, L); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1103 |
__ bind(push_double); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1104 |
__ push_d(); // FP values are returned using the FPU, so push FPU contents (even if UseSSE > 0). |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1105 |
__ bind(L); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1106 |
} |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1107 |
#else |
1 | 1108 |
__ push(dtos); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1109 |
#endif // _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1110 |
|
1 | 1111 |
__ push(ltos); |
1112 |
||
1113 |
// change thread state |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1114 |
NOT_LP64(__ get_thread(thread)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1115 |
__ movl(Address(thread, JavaThread::thread_state_offset()), |
1 | 1116 |
_thread_in_native_trans); |
1117 |
||
1118 |
if (os::is_MP()) { |
|
1119 |
if (UseMembar) { |
|
1120 |
// Force this write out before the read below |
|
1121 |
__ membar(Assembler::Membar_mask_bits( |
|
1122 |
Assembler::LoadLoad | Assembler::LoadStore | |
|
1123 |
Assembler::StoreLoad | Assembler::StoreStore)); |
|
1124 |
} else { |
|
1125 |
// Write serialization page so VM thread can do a pseudo remote membar. |
|
1126 |
// We use the current thread pointer to calculate a thread specific |
|
1127 |
// offset to write to within the page. This minimizes bus traffic |
|
1128 |
// due to cache line collision. |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1129 |
__ serialize_memory(thread, rcx); |
1 | 1130 |
} |
1131 |
} |
|
1132 |
||
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1133 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1134 |
if (AlwaysRestoreFPU) { |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1135 |
// Make sure the control word is correct. |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1136 |
__ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std())); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1137 |
} |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1138 |
#endif // _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1139 |
|
1 | 1140 |
// check for safepoint operation in progress and/or pending suspend requests |
1141 |
{ |
|
1142 |
Label Continue; |
|
1143 |
__ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), |
|
1144 |
SafepointSynchronize::_not_synchronized); |
|
1145 |
||
1146 |
Label L; |
|
1147 |
__ jcc(Assembler::notEqual, L); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1148 |
__ cmpl(Address(thread, JavaThread::suspend_flags_offset()), 0); |
1 | 1149 |
__ jcc(Assembler::equal, Continue); |
1150 |
__ bind(L); |
|
1151 |
||
1152 |
// Don't use call_VM as it will see a possible pending exception |
|
1153 |
// and forward it and never return here preventing us from |
|
1154 |
// clearing _last_native_pc down below. Also can't use |
|
1155 |
// call_VM_leaf either as it will check to see if r13 & r14 are |
|
1156 |
// preserved and correspond to the bcp/locals pointers. So we do a |
|
1157 |
// runtime call by hand. |
|
1158 |
// |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1159 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1160 |
__ push(thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1161 |
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1162 |
JavaThread::check_special_condition_for_native_trans))); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1163 |
__ increment(rsp, wordSize); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1164 |
__ get_thread(thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1165 |
#else |
1066 | 1166 |
__ mov(c_rarg0, r15_thread); |
7401
ebde7415b521
6780143: hs203t003 hits SIGSEGV/EXCEPTION_ACCESS_VIOLATION with -XX:+UseCompressedOops
coleenp
parents:
7397
diff
changeset
|
1167 |
__ mov(r12, rsp); // remember sp (can only use r12 if not using call_VM) |
1066 | 1168 |
__ subptr(rsp, frame::arg_reg_save_area_bytes); // windows |
1169 |
__ andptr(rsp, -16); // align stack as required by ABI |
|
1 | 1170 |
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans))); |
1066 | 1171 |
__ mov(rsp, r12); // restore sp |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
1172 |
__ reinit_heapbase(); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1173 |
#endif // _LP64 |
1 | 1174 |
__ bind(Continue); |
1175 |
} |
|
1176 |
||
1177 |
// change thread state |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1178 |
__ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_Java); |
1 | 1179 |
|
1180 |
// reset_last_Java_frame |
|
40644
39e631ed7145
8161598: Kitchensink fails: assert(nm->insts_contains(original_pc)) failed: original PC must be in nmethod/CompiledMethod
dlong
parents:
39390
diff
changeset
|
1181 |
__ reset_last_Java_frame(thread, true); |
1 | 1182 |
|
41084
fc5db29fa08e
8164086: Checked JNI pending exception check should be cleared when returning to Java frame
dsimms
parents:
40644
diff
changeset
|
1183 |
if (CheckJNICalls) { |
fc5db29fa08e
8164086: Checked JNI pending exception check should be cleared when returning to Java frame
dsimms
parents:
40644
diff
changeset
|
1184 |
// clear_pending_jni_exception_check |
fc5db29fa08e
8164086: Checked JNI pending exception check should be cleared when returning to Java frame
dsimms
parents:
40644
diff
changeset
|
1185 |
__ movptr(Address(thread, JavaThread::pending_jni_exception_check_fn_offset()), NULL_WORD); |
fc5db29fa08e
8164086: Checked JNI pending exception check should be cleared when returning to Java frame
dsimms
parents:
40644
diff
changeset
|
1186 |
} |
fc5db29fa08e
8164086: Checked JNI pending exception check should be cleared when returning to Java frame
dsimms
parents:
40644
diff
changeset
|
1187 |
|
1 | 1188 |
// reset handle block |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1189 |
__ movptr(t, Address(thread, JavaThread::active_handles_offset())); |
23844
0c29a324ae14
8039146: Fix 64-bit store to int JNIHandleBlock::_top
goetz
parents:
21198
diff
changeset
|
1190 |
__ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD); |
1 | 1191 |
|
1192 |
// If result is an oop unbox and store it in frame where gc will see it |
|
1193 |
// and result handler will pick it up |
|
1194 |
||
1195 |
{ |
|
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1196 |
Label no_oop, not_weak, store_result; |
1 | 1197 |
__ lea(t, ExternalAddress(AbstractInterpreter::result_handler(T_OBJECT))); |
1066 | 1198 |
__ cmpptr(t, Address(rbp, frame::interpreter_frame_result_handler_offset*wordSize)); |
1 | 1199 |
__ jcc(Assembler::notEqual, no_oop); |
1200 |
// retrieve result |
|
1201 |
__ pop(ltos); |
|
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1202 |
// Unbox oop result, e.g. JNIHandles::resolve value. |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1203 |
__ resolve_jobject(rax /* value */, |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1204 |
thread /* thread */, |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
1205 |
t /* tmp */); |
1066 | 1206 |
__ movptr(Address(rbp, frame::interpreter_frame_oop_temp_offset*wordSize), rax); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1207 |
// keep stack depth as expected by pushing oop which will eventually be discarded |
1 | 1208 |
__ push(ltos); |
1209 |
__ bind(no_oop); |
|
1210 |
} |
|
1211 |
||
1212 |
||
1213 |
{ |
|
1214 |
Label no_reguard; |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1215 |
__ cmpl(Address(thread, JavaThread::stack_guard_state_offset()), |
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35071
diff
changeset
|
1216 |
JavaThread::stack_guard_yellow_reserved_disabled); |
1 | 1217 |
__ jcc(Assembler::notEqual, no_reguard); |
1218 |
||
1066 | 1219 |
__ pusha(); // XXX only save smashed registers |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1220 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1221 |
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages))); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1222 |
__ popa(); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1223 |
#else |
7401
ebde7415b521
6780143: hs203t003 hits SIGSEGV/EXCEPTION_ACCESS_VIOLATION with -XX:+UseCompressedOops
coleenp
parents:
7397
diff
changeset
|
1224 |
__ mov(r12, rsp); // remember sp (can only use r12 if not using call_VM) |
1066 | 1225 |
__ subptr(rsp, frame::arg_reg_save_area_bytes); // windows |
1226 |
__ andptr(rsp, -16); // align stack as required by ABI |
|
1 | 1227 |
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages))); |
1066 | 1228 |
__ mov(rsp, r12); // restore sp |
1229 |
__ popa(); // XXX only restore smashed registers |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
1230 |
__ reinit_heapbase(); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1231 |
#endif // _LP64 |
1 | 1232 |
|
1233 |
__ bind(no_reguard); |
|
1234 |
} |
|
1235 |
||
1236 |
||
1237 |
// The method register is junk from after the thread_in_native transition |
|
1238 |
// until here. Also can't call_VM until the bcp has been |
|
1239 |
// restored. Need bcp for throwing exception below so get it now. |
|
1240 |
__ get_method(method); |
|
1241 |
||
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1242 |
// restore to have legal interpreter frame, i.e., bci == 0 <=> code_base() |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1243 |
__ movptr(rbcp, Address(method, Method::const_offset())); // get ConstMethod* |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1244 |
__ lea(rbcp, Address(rbcp, ConstMethod::codes_offset())); // get codebase |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1245 |
|
1 | 1246 |
// handle exceptions (exception handling will handle unlocking!) |
1247 |
{ |
|
1248 |
Label L; |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1249 |
__ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t) NULL_WORD); |
1 | 1250 |
__ jcc(Assembler::zero, L); |
1251 |
// Note: At some point we may want to unify this with the code |
|
1252 |
// used in call_VM_base(); i.e., we should use the |
|
1253 |
// StubRoutines::forward_exception code. For now this doesn't work |
|
1254 |
// here because the rsp is not correctly set at this point. |
|
1255 |
__ MacroAssembler::call_VM(noreg, |
|
1256 |
CAST_FROM_FN_PTR(address, |
|
1257 |
InterpreterRuntime::throw_pending_exception)); |
|
1258 |
__ should_not_reach_here(); |
|
1259 |
__ bind(L); |
|
1260 |
} |
|
1261 |
||
1262 |
// do unlocking if necessary |
|
1263 |
{ |
|
1264 |
Label L; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1265 |
__ movl(t, Address(method, Method::access_flags_offset())); |
1 | 1266 |
__ testl(t, JVM_ACC_SYNCHRONIZED); |
1267 |
__ jcc(Assembler::zero, L); |
|
1268 |
// the code below should be shared with interpreter macro |
|
1269 |
// assembler implementation |
|
1270 |
{ |
|
1271 |
Label unlock; |
|
1272 |
// BasicObjectLock will be first in list, since this is a |
|
1273 |
// synchronized method. However, need to check that the object |
|
1274 |
// has not been unlocked by an explicit monitorexit bytecode. |
|
1275 |
const Address monitor(rbp, |
|
1276 |
(intptr_t)(frame::interpreter_frame_initial_sp_offset * |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1277 |
wordSize - (int)sizeof(BasicObjectLock))); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1278 |
|
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1279 |
const Register regmon = NOT_LP64(rdx) LP64_ONLY(c_rarg1); |
1 | 1280 |
|
1281 |
// monitor expect in c_rarg1 for slow unlock path |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1282 |
__ lea(regmon, monitor); // address of first monitor |
1 | 1283 |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1284 |
__ movptr(t, Address(regmon, BasicObjectLock::obj_offset_in_bytes())); |
1066 | 1285 |
__ testptr(t, t); |
1 | 1286 |
__ jcc(Assembler::notZero, unlock); |
1287 |
||
1288 |
// Entry already unlocked, need to throw exception |
|
1289 |
__ MacroAssembler::call_VM(noreg, |
|
1290 |
CAST_FROM_FN_PTR(address, |
|
1291 |
InterpreterRuntime::throw_illegal_monitor_state_exception)); |
|
1292 |
__ should_not_reach_here(); |
|
1293 |
||
1294 |
__ bind(unlock); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1295 |
__ unlock_object(regmon); |
1 | 1296 |
} |
1297 |
__ bind(L); |
|
1298 |
} |
|
1299 |
||
1300 |
// jvmti support |
|
1301 |
// Note: This must happen _after_ handling/throwing any exceptions since |
|
1302 |
// the exception handler code notifies the runtime of method exits |
|
1303 |
// too. If this happens before, method entry/exit notifications are |
|
1304 |
// not properly paired (was bug - gri 11/22/99). |
|
1305 |
__ notify_method_exit(vtos, InterpreterMacroAssembler::NotifyJVMTI); |
|
1306 |
||
1307 |
// restore potential result in edx:eax, call result handler to |
|
1308 |
// restore potential result in ST0 & handle result |
|
1309 |
||
1310 |
__ pop(ltos); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1311 |
LP64_ONLY( __ pop(dtos)); |
1 | 1312 |
|
1066 | 1313 |
__ movptr(t, Address(rbp, |
1314 |
(frame::interpreter_frame_result_handler_offset) * wordSize)); |
|
1 | 1315 |
__ call(t); |
1316 |
||
1317 |
// remove activation |
|
1066 | 1318 |
__ movptr(t, Address(rbp, |
1319 |
frame::interpreter_frame_sender_sp_offset * |
|
1320 |
wordSize)); // get sender sp |
|
1 | 1321 |
__ leave(); // remove frame anchor |
1066 | 1322 |
__ pop(rdi); // get return address |
1323 |
__ mov(rsp, t); // set sp to sender sp |
|
1 | 1324 |
__ jmp(rdi); |
1325 |
||
1326 |
if (inc_counter) { |
|
1327 |
// Handle overflow of counter and compile method |
|
1328 |
__ bind(invocation_counter_overflow); |
|
35214 | 1329 |
generate_counter_overflow(continue_after_compile); |
1 | 1330 |
} |
1331 |
||
1332 |
return entry_point; |
|
1333 |
} |
|
1334 |
||
35479
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1335 |
// Abstract method entry |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1336 |
// Attempt to execute abstract method. Throw exception |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1337 |
address TemplateInterpreterGenerator::generate_abstract_entry(void) { |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1338 |
|
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1339 |
address entry_point = __ pc(); |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1340 |
|
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1341 |
// abstract method entry |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1342 |
|
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1343 |
// pop return address, reset last_sp to NULL |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1344 |
__ empty_expression_stack(); |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1345 |
__ restore_bcp(); // rsi must be correct for exception handler (was destroyed) |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1346 |
__ restore_locals(); // make sure locals pointer is correct as well (was destroyed) |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1347 |
|
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1348 |
// throw exception |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1349 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError)); |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1350 |
// the call_VM checks for exception, so we should never return here. |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1351 |
__ should_not_reach_here(); |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1352 |
|
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1353 |
return entry_point; |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1354 |
} |
62c12ca7a45e
8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents:
35214
diff
changeset
|
1355 |
|
1 | 1356 |
// |
1357 |
// Generic interpreted method entry to (asm) interpreter |
|
1358 |
// |
|
35214 | 1359 |
address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { |
1 | 1360 |
// determine code generation flags |
31790 | 1361 |
bool inc_counter = UseCompiler || CountCompiledCalls || LogTouchedMethods; |
1 | 1362 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1363 |
// ebx: Method* |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1364 |
// rbcp: sender sp |
1 | 1365 |
address entry_point = __ pc(); |
1366 |
||
14745
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
1367 |
const Address constMethod(rbx, Method::const_offset()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1368 |
const Address access_flags(rbx, Method::access_flags_offset()); |
14745
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
1369 |
const Address size_of_parameters(rdx, |
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
1370 |
ConstMethod::size_of_parameters_offset()); |
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
1371 |
const Address size_of_locals(rdx, ConstMethod::size_of_locals_offset()); |
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
1372 |
|
1 | 1373 |
|
1374 |
// get parameter size (always needed) |
|
14745
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
1375 |
__ movptr(rdx, constMethod); |
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
1376 |
__ load_unsigned_short(rcx, size_of_parameters); |
1 | 1377 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1378 |
// rbx: Method* |
1 | 1379 |
// rcx: size of parameters |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1380 |
// rbcp: sender_sp (could differ from sp+wordSize if we were called via c2i ) |
1 | 1381 |
|
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
2131
diff
changeset
|
1382 |
__ load_unsigned_short(rdx, size_of_locals); // get size of locals in words |
1 | 1383 |
__ subl(rdx, rcx); // rdx = no. of additional locals |
1384 |
||
1385 |
// YYY |
|
1386 |
// __ incrementl(rdx); |
|
1387 |
// __ andl(rdx, -2); |
|
1388 |
||
1389 |
// see if we've got enough room on the stack for locals plus overhead. |
|
1390 |
generate_stack_overflow_check(); |
|
1391 |
||
1392 |
// get return address |
|
1066 | 1393 |
__ pop(rax); |
1 | 1394 |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1395 |
// compute beginning of parameters |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1396 |
__ lea(rlocals, Address(rsp, rcx, Interpreter::stackElementScale(), -wordSize)); |
1 | 1397 |
|
1398 |
// rdx - # of additional locals |
|
1399 |
// allocate space for locals |
|
1400 |
// explicitly initialize locals |
|
1401 |
{ |
|
1402 |
Label exit, loop; |
|
1403 |
__ testl(rdx, rdx); |
|
1404 |
__ jcc(Assembler::lessEqual, exit); // do nothing if rdx <= 0 |
|
1405 |
__ bind(loop); |
|
1066 | 1406 |
__ push((int) NULL_WORD); // initialize local variables |
1 | 1407 |
__ decrementl(rdx); // until everything initialized |
1408 |
__ jcc(Assembler::greater, loop); |
|
1409 |
__ bind(exit); |
|
1410 |
} |
|
1411 |
||
1412 |
// initialize fixed part of activation frame |
|
1413 |
generate_fixed_frame(false); |
|
1414 |
||
1415 |
// make sure method is not native & not abstract |
|
1416 |
#ifdef ASSERT |
|
1417 |
__ movl(rax, access_flags); |
|
1418 |
{ |
|
1419 |
Label L; |
|
1420 |
__ testl(rax, JVM_ACC_NATIVE); |
|
1421 |
__ jcc(Assembler::zero, L); |
|
1422 |
__ stop("tried to execute native method as non-native"); |
|
1423 |
__ bind(L); |
|
1424 |
} |
|
1425 |
{ |
|
1426 |
Label L; |
|
1427 |
__ testl(rax, JVM_ACC_ABSTRACT); |
|
1428 |
__ jcc(Assembler::zero, L); |
|
1429 |
__ stop("tried to execute abstract method in interpreter"); |
|
1430 |
__ bind(L); |
|
1431 |
} |
|
1432 |
#endif |
|
1433 |
||
1434 |
// Since at this point in the method invocation the exception |
|
1435 |
// handler would try to exit the monitor of synchronized methods |
|
1436 |
// which hasn't been entered yet, we set the thread local variable |
|
1437 |
// _do_not_unlock_if_synchronized to true. The remove_activation |
|
1438 |
// will check this flag. |
|
1439 |
||
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1440 |
const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1441 |
NOT_LP64(__ get_thread(thread)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1442 |
const Address do_not_unlock_if_synchronized(thread, |
1 | 1443 |
in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); |
1444 |
__ movbool(do_not_unlock_if_synchronized, true); |
|
1445 |
||
21095
1a04f7b3946e
8026251: New type profiling points: parameters to methods
roland
parents:
20709
diff
changeset
|
1446 |
__ profile_parameters_type(rax, rcx, rdx); |
1 | 1447 |
// increment invocation count & check for overflow |
1448 |
Label invocation_counter_overflow; |
|
1449 |
Label profile_method; |
|
1450 |
Label profile_method_continue; |
|
1451 |
if (inc_counter) { |
|
1452 |
generate_counter_incr(&invocation_counter_overflow, |
|
1453 |
&profile_method, |
|
1454 |
&profile_method_continue); |
|
1455 |
if (ProfileInterpreter) { |
|
1456 |
__ bind(profile_method_continue); |
|
1457 |
} |
|
1458 |
} |
|
1459 |
||
1460 |
Label continue_after_compile; |
|
1461 |
__ bind(continue_after_compile); |
|
1462 |
||
1463 |
// check for synchronized interpreted methods |
|
1464 |
bang_stack_shadow_pages(false); |
|
1465 |
||
1466 |
// reset the _do_not_unlock_if_synchronized flag |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1467 |
NOT_LP64(__ get_thread(thread)); |
1 | 1468 |
__ movbool(do_not_unlock_if_synchronized, false); |
1469 |
||
1470 |
// check for synchronized methods |
|
1471 |
// Must happen AFTER invocation_counter check and stack overflow check, |
|
1472 |
// so method is not locked if overflows. |
|
1473 |
if (synchronized) { |
|
1474 |
// Allocate monitor and lock method |
|
1475 |
lock_method(); |
|
1476 |
} else { |
|
1477 |
// no synchronization necessary |
|
1478 |
#ifdef ASSERT |
|
1479 |
{ |
|
1480 |
Label L; |
|
1481 |
__ movl(rax, access_flags); |
|
1482 |
__ testl(rax, JVM_ACC_SYNCHRONIZED); |
|
1483 |
__ jcc(Assembler::zero, L); |
|
1484 |
__ stop("method needs synchronization"); |
|
1485 |
__ bind(L); |
|
1486 |
} |
|
1487 |
#endif |
|
1488 |
} |
|
1489 |
||
1490 |
// start execution |
|
1491 |
#ifdef ASSERT |
|
1492 |
{ |
|
1493 |
Label L; |
|
1494 |
const Address monitor_block_top (rbp, |
|
1495 |
frame::interpreter_frame_monitor_block_top_offset * wordSize); |
|
1066 | 1496 |
__ movptr(rax, monitor_block_top); |
1497 |
__ cmpptr(rax, rsp); |
|
1 | 1498 |
__ jcc(Assembler::equal, L); |
1499 |
__ stop("broken stack frame setup in interpreter"); |
|
1500 |
__ bind(L); |
|
1501 |
} |
|
1502 |
#endif |
|
1503 |
||
1504 |
// jvmti support |
|
1505 |
__ notify_method_entry(); |
|
1506 |
||
1507 |
__ dispatch_next(vtos); |
|
1508 |
||
1509 |
// invocation counter overflow |
|
1510 |
if (inc_counter) { |
|
1511 |
if (ProfileInterpreter) { |
|
1512 |
// We have decided to profile this method in the interpreter |
|
1513 |
__ bind(profile_method); |
|
7889
02144432d0e1
4930919: race condition in MDO creation at back branch locations
iveresov
parents:
7401
diff
changeset
|
1514 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method)); |
02144432d0e1
4930919: race condition in MDO creation at back branch locations
iveresov
parents:
7401
diff
changeset
|
1515 |
__ set_method_data_pointer_for_bcp(); |
7912
6d73dee171ea
7012766: assert(false) failed: DEBUG MESSAGE in MacroAssembler::debug32
iveresov
parents:
7889
diff
changeset
|
1516 |
__ get_method(rbx); |
1 | 1517 |
__ jmp(profile_method_continue); |
1518 |
} |
|
1519 |
// Handle overflow of counter and compile method |
|
1520 |
__ bind(invocation_counter_overflow); |
|
35214 | 1521 |
generate_counter_overflow(continue_after_compile); |
1 | 1522 |
} |
1523 |
||
1524 |
return entry_point; |
|
1525 |
} |
|
1526 |
||
1527 |
//----------------------------------------------------------------------------- |
|
1528 |
// Exceptions |
|
1529 |
||
1530 |
void TemplateInterpreterGenerator::generate_throw_exception() { |
|
1531 |
// Entry point in previous activation (i.e., if the caller was |
|
1532 |
// interpreted) |
|
1533 |
Interpreter::_rethrow_exception_entry = __ pc(); |
|
1534 |
// Restore sp to interpreter_frame_last_sp even though we are going |
|
1535 |
// to empty the expression stack for the exception processing. |
|
1066 | 1536 |
__ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
1 | 1537 |
// rax: exception |
1538 |
// rdx: return address/pc that threw exception |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1539 |
__ restore_bcp(); // r13/rsi points to call/send |
1 | 1540 |
__ restore_locals(); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1541 |
LP64_ONLY(__ reinit_heapbase()); // restore r12 as heapbase. |
1 | 1542 |
// Entry point for exceptions thrown within interpreter code |
1543 |
Interpreter::_throw_exception_entry = __ pc(); |
|
1544 |
// expression stack is undefined here |
|
1545 |
// rax: exception |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1546 |
// r13/rsi: exception bcp |
1 | 1547 |
__ verify_oop(rax); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1548 |
Register rarg = NOT_LP64(rax) LP64_ONLY(c_rarg1); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1549 |
LP64_ONLY(__ mov(c_rarg1, rax)); |
1 | 1550 |
|
1551 |
// expression stack must be empty before entering the VM in case of |
|
1552 |
// an exception |
|
1553 |
__ empty_expression_stack(); |
|
1554 |
// find exception handler address and preserve exception oop |
|
1555 |
__ call_VM(rdx, |
|
1556 |
CAST_FROM_FN_PTR(address, |
|
1557 |
InterpreterRuntime::exception_handler_for_exception), |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1558 |
rarg); |
1 | 1559 |
// rax: exception handler entry point |
1560 |
// rdx: preserved exception oop |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1561 |
// r13/rsi: bcp for exception handler |
1 | 1562 |
__ push_ptr(rdx); // push exception which is now the only value on the stack |
1563 |
__ jmp(rax); // jump to exception handler (may be _remove_activation_entry!) |
|
1564 |
||
1565 |
// If the exception is not handled in the current frame the frame is |
|
1566 |
// removed and the exception is rethrown (i.e. exception |
|
1567 |
// continuation is _rethrow_exception). |
|
1568 |
// |
|
1569 |
// Note: At this point the bci is still the bxi for the instruction |
|
1570 |
// which caused the exception and the expression stack is |
|
1571 |
// empty. Thus, for any VM calls at this point, GC will find a legal |
|
1572 |
// oop map (with empty expression stack). |
|
1573 |
||
1574 |
// In current activation |
|
1575 |
// tos: exception |
|
1576 |
// esi: exception bcp |
|
1577 |
||
1578 |
// |
|
1579 |
// JVMTI PopFrame support |
|
1580 |
// |
|
1581 |
||
1582 |
Interpreter::_remove_activation_preserving_args_entry = __ pc(); |
|
1583 |
__ empty_expression_stack(); |
|
1584 |
// Set the popframe_processing bit in pending_popframe_condition |
|
1585 |
// indicating that we are currently handling popframe, so that |
|
1586 |
// call_VMs that may happen later do not trigger new popframe |
|
1587 |
// handling cycles. |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1588 |
const Register thread = NOT_LP64(rcx) LP64_ONLY(r15_thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1589 |
NOT_LP64(__ get_thread(thread)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1590 |
__ movl(rdx, Address(thread, JavaThread::popframe_condition_offset())); |
1 | 1591 |
__ orl(rdx, JavaThread::popframe_processing_bit); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1592 |
__ movl(Address(thread, JavaThread::popframe_condition_offset()), rdx); |
1 | 1593 |
|
1594 |
{ |
|
1595 |
// Check to see whether we are returning to a deoptimized frame. |
|
1596 |
// (The PopFrame call ensures that the caller of the popped frame is |
|
1597 |
// either interpreted or compiled and deoptimizes it if compiled.) |
|
1598 |
// In this case, we can't call dispatch_next() after the frame is |
|
1599 |
// popped, but instead must save the incoming arguments and restore |
|
1600 |
// them after deoptimization has occurred. |
|
1601 |
// |
|
1602 |
// Note that we don't compare the return PC against the |
|
1603 |
// deoptimization blob's unpack entry because of the presence of |
|
1604 |
// adapter frames in C2. |
|
1605 |
Label caller_not_deoptimized; |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1606 |
Register rarg = NOT_LP64(rdx) LP64_ONLY(c_rarg1); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1607 |
__ movptr(rarg, Address(rbp, frame::return_addr_offset * wordSize)); |
1 | 1608 |
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1609 |
InterpreterRuntime::interpreter_contains), rarg); |
1 | 1610 |
__ testl(rax, rax); |
1611 |
__ jcc(Assembler::notZero, caller_not_deoptimized); |
|
1612 |
||
1613 |
// Compute size of arguments for saving when returning to |
|
1614 |
// deoptimized caller |
|
1615 |
__ get_method(rax); |
|
14745
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
1616 |
__ movptr(rax, Address(rax, Method::const_offset())); |
03904dd8649b
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
14626
diff
changeset
|
1617 |
__ load_unsigned_short(rax, Address(rax, in_bytes(ConstMethod:: |
1 | 1618 |
size_of_parameters_offset()))); |
5419 | 1619 |
__ shll(rax, Interpreter::logStackElementSize); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1620 |
__ restore_locals(); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1621 |
__ subptr(rlocals, rax); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1622 |
__ addptr(rlocals, wordSize); |
1 | 1623 |
// Save these arguments |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1624 |
NOT_LP64(__ get_thread(thread)); |
1 | 1625 |
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, |
1626 |
Deoptimization:: |
|
1627 |
popframe_preserve_args), |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1628 |
thread, rax, rlocals); |
1 | 1629 |
|
1630 |
__ remove_activation(vtos, rdx, |
|
1631 |
/* throw_monitor_exception */ false, |
|
1632 |
/* install_monitor_exception */ false, |
|
1633 |
/* notify_jvmdi */ false); |
|
1634 |
||
1635 |
// Inform deoptimization that it is responsible for restoring |
|
1636 |
// these arguments |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1637 |
NOT_LP64(__ get_thread(thread)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1638 |
__ movl(Address(thread, JavaThread::popframe_condition_offset()), |
1 | 1639 |
JavaThread::popframe_force_deopt_reexecution_bit); |
1640 |
||
1641 |
// Continue in deoptimization handler |
|
1642 |
__ jmp(rdx); |
|
1643 |
||
1644 |
__ bind(caller_not_deoptimized); |
|
1645 |
} |
|
1646 |
||
1647 |
__ remove_activation(vtos, rdx, /* rdx result (retaddr) is not used */ |
|
1648 |
/* throw_monitor_exception */ false, |
|
1649 |
/* install_monitor_exception */ false, |
|
1650 |
/* notify_jvmdi */ false); |
|
1651 |
||
1652 |
// Finish with popframe handling |
|
1653 |
// A previous I2C followed by a deoptimization might have moved the |
|
1654 |
// outgoing arguments further up the stack. PopFrame expects the |
|
1655 |
// mutations to those outgoing arguments to be preserved and other |
|
1656 |
// constraints basically require this frame to look exactly as |
|
1657 |
// though it had previously invoked an interpreted activation with |
|
1658 |
// no space between the top of the expression stack (current |
|
1659 |
// last_sp) and the top of stack. Rather than force deopt to |
|
1660 |
// maintain this kind of invariant all the time we call a small |
|
1661 |
// fixup routine to move the mutated arguments onto the top of our |
|
1662 |
// expression stack if necessary. |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1663 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1664 |
__ mov(rax, rsp); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1665 |
__ movptr(rbx, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1666 |
__ get_thread(thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1667 |
// PC must point into interpreter here |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1668 |
__ set_last_Java_frame(thread, noreg, rbp, __ pc()); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1669 |
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), thread, rax, rbx); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1670 |
__ get_thread(thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1671 |
#else |
1066 | 1672 |
__ mov(c_rarg1, rsp); |
1673 |
__ movptr(c_rarg2, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); |
|
1 | 1674 |
// PC must point into interpreter here |
1675 |
__ set_last_Java_frame(noreg, rbp, __ pc()); |
|
1676 |
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), r15_thread, c_rarg1, c_rarg2); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1677 |
#endif |
40644
39e631ed7145
8161598: Kitchensink fails: assert(nm->insts_contains(original_pc)) failed: original PC must be in nmethod/CompiledMethod
dlong
parents:
39390
diff
changeset
|
1678 |
__ reset_last_Java_frame(thread, true); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1679 |
|
1 | 1680 |
// Restore the last_sp and null it out |
1066 | 1681 |
__ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); |
1682 |
__ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
|
1 | 1683 |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1684 |
__ restore_bcp(); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1685 |
__ restore_locals(); |
1 | 1686 |
// The method data pointer was incremented already during |
1687 |
// call profiling. We have to restore the mdp for the current bcp. |
|
1688 |
if (ProfileInterpreter) { |
|
1689 |
__ set_method_data_pointer_for_bcp(); |
|
1690 |
} |
|
1691 |
||
1692 |
// Clear the popframe condition flag |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1693 |
NOT_LP64(__ get_thread(thread)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1694 |
__ movl(Address(thread, JavaThread::popframe_condition_offset()), |
1 | 1695 |
JavaThread::popframe_inactive); |
1696 |
||
19266
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1697 |
#if INCLUDE_JVMTI |
24322 | 1698 |
{ |
19266
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1699 |
Label L_done; |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1700 |
const Register local0 = rlocals; |
19266
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1701 |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1702 |
__ cmpb(Address(rbcp, 0), Bytecodes::_invokestatic); |
19266
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1703 |
__ jcc(Assembler::notEqual, L_done); |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1704 |
|
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1705 |
// The member name argument must be restored if _invokestatic is re-executed after a PopFrame call. |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1706 |
// Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL. |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1707 |
|
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1708 |
__ get_method(rdx); |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1709 |
__ movptr(rax, Address(local0, 0)); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1710 |
__ call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null), rax, rdx, rbcp); |
19266
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1711 |
|
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1712 |
__ testptr(rax, rax); |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1713 |
__ jcc(Assembler::zero, L_done); |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1714 |
|
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1715 |
__ movptr(Address(rbx, 0), rax); |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1716 |
__ bind(L_done); |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1717 |
} |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1718 |
#endif // INCLUDE_JVMTI |
bb0324cbe0aa
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
18507
diff
changeset
|
1719 |
|
1 | 1720 |
__ dispatch_next(vtos); |
1721 |
// end of PopFrame support |
|
1722 |
||
1723 |
Interpreter::_remove_activation_entry = __ pc(); |
|
1724 |
||
1725 |
// preserve exception over this code sequence |
|
1726 |
__ pop_ptr(rax); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1727 |
NOT_LP64(__ get_thread(thread)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1728 |
__ movptr(Address(thread, JavaThread::vm_result_offset()), rax); |
1 | 1729 |
// remove the activation (without doing throws on illegalMonitorExceptions) |
1730 |
__ remove_activation(vtos, rdx, false, true, false); |
|
1731 |
// restore exception |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1732 |
NOT_LP64(__ get_thread(thread)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1733 |
__ get_vm_result(rax, thread); |
1 | 1734 |
|
1735 |
// In between activations - previous activation type unknown yet |
|
1736 |
// compute continuation point - the continuation point expects the |
|
1737 |
// following registers set up: |
|
1738 |
// |
|
1739 |
// rax: exception |
|
1740 |
// rdx: return address/pc that threw exception |
|
1741 |
// rsp: expression stack of caller |
|
1742 |
// rbp: ebp of caller |
|
1066 | 1743 |
__ push(rax); // save exception |
1744 |
__ push(rdx); // save return address |
|
1 | 1745 |
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, |
1746 |
SharedRuntime::exception_handler_for_return_address), |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1747 |
thread, rdx); |
1066 | 1748 |
__ mov(rbx, rax); // save exception handler |
1749 |
__ pop(rdx); // restore return address |
|
1750 |
__ pop(rax); // restore exception |
|
1 | 1751 |
// Note that an "issuing PC" is actually the next PC after the call |
1752 |
__ jmp(rbx); // jump to exception |
|
1753 |
// handler of caller |
|
1754 |
} |
|
1755 |
||
1756 |
||
1757 |
// |
|
1758 |
// JVMTI ForceEarlyReturn support |
|
1759 |
// |
|
1760 |
address TemplateInterpreterGenerator::generate_earlyret_entry_for(TosState state) { |
|
1761 |
address entry = __ pc(); |
|
1762 |
||
1763 |
__ restore_bcp(); |
|
1764 |
__ restore_locals(); |
|
1765 |
__ empty_expression_stack(); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1766 |
__ load_earlyret_value(state); // 32 bits returns value in rdx, so don't reuse |
1 | 1767 |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1768 |
const Register thread = NOT_LP64(rcx) LP64_ONLY(r15_thread); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1769 |
NOT_LP64(__ get_thread(thread)); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1770 |
__ movptr(rcx, Address(thread, JavaThread::jvmti_thread_state_offset())); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1771 |
Address cond_addr(rcx, JvmtiThreadState::earlyret_state_offset()); |
1 | 1772 |
|
1773 |
// Clear the earlyret state |
|
1774 |
__ movl(cond_addr, JvmtiThreadState::earlyret_inactive); |
|
1775 |
||
1776 |
__ remove_activation(state, rsi, |
|
1777 |
false, /* throw_monitor_exception */ |
|
1778 |
false, /* install_monitor_exception */ |
|
1779 |
true); /* notify_jvmdi */ |
|
1780 |
__ jmp(rsi); |
|
1781 |
||
1782 |
return entry; |
|
1783 |
} // end of ForceEarlyReturn support |
|
1784 |
||
1785 |
||
1786 |
//----------------------------------------------------------------------------- |
|
1787 |
// Helper for vtos entry point generation |
|
1788 |
||
1789 |
void TemplateInterpreterGenerator::set_vtos_entry_points(Template* t, |
|
1790 |
address& bep, |
|
1791 |
address& cep, |
|
1792 |
address& sep, |
|
1793 |
address& aep, |
|
1794 |
address& iep, |
|
1795 |
address& lep, |
|
1796 |
address& fep, |
|
1797 |
address& dep, |
|
1798 |
address& vep) { |
|
1799 |
assert(t->is_valid() && t->tos_in() == vtos, "illegal template"); |
|
1800 |
Label L; |
|
32391
01e2f5e916c7
8076373: In 32-bit VM interpreter and compiled code process NaN values differently
zmajo
parents:
31790
diff
changeset
|
1801 |
aep = __ pc(); __ push_ptr(); __ jmp(L); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1802 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1803 |
fep = __ pc(); __ push(ftos); __ jmp(L); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1804 |
dep = __ pc(); __ push(dtos); __ jmp(L); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1805 |
#else |
32391
01e2f5e916c7
8076373: In 32-bit VM interpreter and compiled code process NaN values differently
zmajo
parents:
31790
diff
changeset
|
1806 |
fep = __ pc(); __ push_f(xmm0); __ jmp(L); |
01e2f5e916c7
8076373: In 32-bit VM interpreter and compiled code process NaN values differently
zmajo
parents:
31790
diff
changeset
|
1807 |
dep = __ pc(); __ push_d(xmm0); __ jmp(L); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1808 |
#endif // _LP64 |
32391
01e2f5e916c7
8076373: In 32-bit VM interpreter and compiled code process NaN values differently
zmajo
parents:
31790
diff
changeset
|
1809 |
lep = __ pc(); __ push_l(); __ jmp(L); |
1 | 1810 |
bep = cep = sep = |
1811 |
iep = __ pc(); __ push_i(); |
|
1812 |
vep = __ pc(); |
|
1813 |
__ bind(L); |
|
1814 |
generate_and_dispatch(t); |
|
1815 |
} |
|
1816 |
||
1817 |
//----------------------------------------------------------------------------- |
|
1818 |
||
1819 |
// Non-product code |
|
1820 |
#ifndef PRODUCT |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1821 |
|
1 | 1822 |
address TemplateInterpreterGenerator::generate_trace_code(TosState state) { |
1823 |
address entry = __ pc(); |
|
1824 |
||
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1825 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1826 |
// prepare expression stack |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1827 |
__ pop(rcx); // pop return address so expression stack is 'pure' |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1828 |
__ push(state); // save tosca |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1829 |
|
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1830 |
// pass tosca registers as arguments & call tracer |
37152
29e68f1d35bb
8152065: TraceBytecodes breaks the interpreter expression stack
coleenp
parents:
36301
diff
changeset
|
1831 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), rcx, rax, rdx); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1832 |
__ mov(rcx, rax); // make sure return address is not destroyed by pop(state) |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1833 |
__ pop(state); // restore tosca |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1834 |
|
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1835 |
// return |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1836 |
__ jmp(rcx); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1837 |
#else |
1 | 1838 |
__ push(state); |
1066 | 1839 |
__ push(c_rarg0); |
1840 |
__ push(c_rarg1); |
|
1841 |
__ push(c_rarg2); |
|
1842 |
__ push(c_rarg3); |
|
1843 |
__ mov(c_rarg2, rax); // Pass itos |
|
1 | 1844 |
#ifdef _WIN64 |
1845 |
__ movflt(xmm3, xmm0); // Pass ftos |
|
1846 |
#endif |
|
1847 |
__ call_VM(noreg, |
|
37152
29e68f1d35bb
8152065: TraceBytecodes breaks the interpreter expression stack
coleenp
parents:
36301
diff
changeset
|
1848 |
CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), |
1 | 1849 |
c_rarg1, c_rarg2, c_rarg3); |
1066 | 1850 |
__ pop(c_rarg3); |
1851 |
__ pop(c_rarg2); |
|
1852 |
__ pop(c_rarg1); |
|
1853 |
__ pop(c_rarg0); |
|
1 | 1854 |
__ pop(state); |
1855 |
__ ret(0); // return from result handler |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1856 |
#endif // _LP64 |
1 | 1857 |
|
1858 |
return entry; |
|
1859 |
} |
|
1860 |
||
1861 |
void TemplateInterpreterGenerator::count_bytecode() { |
|
1862 |
__ incrementl(ExternalAddress((address) &BytecodeCounter::_counter_value)); |
|
1863 |
} |
|
1864 |
||
1865 |
void TemplateInterpreterGenerator::histogram_bytecode(Template* t) { |
|
1866 |
__ incrementl(ExternalAddress((address) &BytecodeHistogram::_counters[t->bytecode()])); |
|
1867 |
} |
|
1868 |
||
1869 |
void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) { |
|
1870 |
__ mov32(rbx, ExternalAddress((address) &BytecodePairHistogram::_index)); |
|
1871 |
__ shrl(rbx, BytecodePairHistogram::log2_number_of_codes); |
|
1872 |
__ orl(rbx, |
|
1873 |
((int) t->bytecode()) << |
|
1874 |
BytecodePairHistogram::log2_number_of_codes); |
|
1875 |
__ mov32(ExternalAddress((address) &BytecodePairHistogram::_index), rbx); |
|
1876 |
__ lea(rscratch1, ExternalAddress((address) BytecodePairHistogram::_counters)); |
|
1877 |
__ incrementl(Address(rscratch1, rbx, Address::times_4)); |
|
1878 |
} |
|
1879 |
||
1880 |
||
1881 |
void TemplateInterpreterGenerator::trace_bytecode(Template* t) { |
|
1882 |
// Call a little run-time stub to avoid blow-up for each bytecode. |
|
1883 |
// The run-time runtime saves the right registers, depending on |
|
1884 |
// the tosca in-state for the given template. |
|
1885 |
||
1886 |
assert(Interpreter::trace_code(t->tos_in()) != NULL, |
|
1887 |
"entry must have been generated"); |
|
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1888 |
#ifndef _LP64 |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1889 |
__ call(RuntimeAddress(Interpreter::trace_code(t->tos_in()))); |
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1890 |
#else |
7401
ebde7415b521
6780143: hs203t003 hits SIGSEGV/EXCEPTION_ACCESS_VIOLATION with -XX:+UseCompressedOops
coleenp
parents:
7397
diff
changeset
|
1891 |
__ mov(r12, rsp); // remember sp (can only use r12 if not using call_VM) |
1066 | 1892 |
__ andptr(rsp, -16); // align stack as required by ABI |
1 | 1893 |
__ call(RuntimeAddress(Interpreter::trace_code(t->tos_in()))); |
1066 | 1894 |
__ mov(rsp, r12); // restore sp |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
1895 |
__ reinit_heapbase(); |
34651
07b1cc0f6040
8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents:
33160
diff
changeset
|
1896 |
#endif // _LP64 |
1 | 1897 |
} |
1898 |
||
1899 |
||
1900 |
void TemplateInterpreterGenerator::stop_interpreter_at() { |
|
1901 |
Label L; |
|
1902 |
__ cmp32(ExternalAddress((address) &BytecodeCounter::_counter_value), |
|
1903 |
StopInterpreterAt); |
|
1904 |
__ jcc(Assembler::notEqual, L); |
|
1905 |
__ int3(); |
|
1906 |
__ bind(L); |
|
1907 |
} |
|
1908 |
#endif // !PRODUCT |