Mercurial > hg > truffle
annotate src/cpu/x86/vm/templateTable_x86_32.cpp @ 1913:3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
Summary: Allow CONSTANT_InvokeDynamic nodes to have any number of extra operands.
Reviewed-by: twisti
author | jrose |
---|---|
date | Sat, 30 Oct 2010 13:08:23 -0700 |
parents | d55217dc206f |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_templateTable_x86_32.cpp.incl" | |
27 | |
28 #ifndef CC_INTERP | |
29 #define __ _masm-> | |
30 | |
31 //---------------------------------------------------------------------------------------------------- | |
32 // Platform-dependent initialization | |
33 | |
34 void TemplateTable::pd_initialize() { | |
35 // No i486 specific initialization | |
36 } | |
37 | |
38 //---------------------------------------------------------------------------------------------------- | |
39 // Address computation | |
40 | |
41 // local variables | |
42 static inline Address iaddress(int n) { | |
43 return Address(rdi, Interpreter::local_offset_in_bytes(n)); | |
44 } | |
45 | |
46 static inline Address laddress(int n) { return iaddress(n + 1); } | |
47 static inline Address haddress(int n) { return iaddress(n + 0); } | |
48 static inline Address faddress(int n) { return iaddress(n); } | |
49 static inline Address daddress(int n) { return laddress(n); } | |
50 static inline Address aaddress(int n) { return iaddress(n); } | |
51 | |
52 static inline Address iaddress(Register r) { | |
1506 | 53 return Address(rdi, r, Interpreter::stackElementScale()); |
0 | 54 } |
55 static inline Address laddress(Register r) { | |
56 return Address(rdi, r, Interpreter::stackElementScale(), Interpreter::local_offset_in_bytes(1)); | |
57 } | |
58 static inline Address haddress(Register r) { | |
59 return Address(rdi, r, Interpreter::stackElementScale(), Interpreter::local_offset_in_bytes(0)); | |
60 } | |
61 | |
1506 | 62 static inline Address faddress(Register r) { return iaddress(r); } |
63 static inline Address daddress(Register r) { return laddress(r); } | |
64 static inline Address aaddress(Register r) { return iaddress(r); } | |
0 | 65 |
66 // expression stack | |
67 // (Note: Must not use symmetric equivalents at_rsp_m1/2 since they store | |
68 // data beyond the rsp which is potentially unsafe in an MT environment; | |
69 // an interrupt may overwrite that data.) | |
70 static inline Address at_rsp () { | |
71 return Address(rsp, 0); | |
72 } | |
73 | |
74 // At top of Java expression stack which may be different than rsp(). It | |
75 // isn't for category 1 objects. | |
76 static inline Address at_tos () { | |
77 Address tos = Address(rsp, Interpreter::expr_offset_in_bytes(0)); | |
78 return tos; | |
79 } | |
80 | |
81 static inline Address at_tos_p1() { | |
82 return Address(rsp, Interpreter::expr_offset_in_bytes(1)); | |
83 } | |
84 | |
85 static inline Address at_tos_p2() { | |
86 return Address(rsp, Interpreter::expr_offset_in_bytes(2)); | |
87 } | |
88 | |
89 // Condition conversion | |
90 static Assembler::Condition j_not(TemplateTable::Condition cc) { | |
91 switch (cc) { | |
92 case TemplateTable::equal : return Assembler::notEqual; | |
93 case TemplateTable::not_equal : return Assembler::equal; | |
94 case TemplateTable::less : return Assembler::greaterEqual; | |
95 case TemplateTable::less_equal : return Assembler::greater; | |
96 case TemplateTable::greater : return Assembler::lessEqual; | |
97 case TemplateTable::greater_equal: return Assembler::less; | |
98 } | |
99 ShouldNotReachHere(); | |
100 return Assembler::zero; | |
101 } | |
102 | |
103 | |
104 //---------------------------------------------------------------------------------------------------- | |
105 // Miscelaneous helper routines | |
106 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
107 // Store an oop (or NULL) at the address described by obj. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
108 // If val == noreg this means store a NULL |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
109 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
110 static void do_oop_store(InterpreterMacroAssembler* _masm, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
111 Address obj, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
112 Register val, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
113 BarrierSet::Name barrier, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
114 bool precise) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
115 assert(val == noreg || val == rax, "parameter is just for looks"); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
116 switch (barrier) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
117 #ifndef SERIALGC |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
118 case BarrierSet::G1SATBCT: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
119 case BarrierSet::G1SATBCTLogging: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
120 { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
121 // flatten object address if needed |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
122 // We do it regardless of precise because we need the registers |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
123 if (obj.index() == noreg && obj.disp() == 0) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
124 if (obj.base() != rdx) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
125 __ movl(rdx, obj.base()); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
126 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
127 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
128 __ leal(rdx, obj); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
129 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
130 __ get_thread(rcx); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
131 __ save_bcp(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
132 __ g1_write_barrier_pre(rdx, rcx, rsi, rbx, val != noreg); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
133 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
134 // Do the actual store |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
135 // noreg means NULL |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
136 if (val == noreg) { |
533
dc3ad84615cf
6795913: A few remaining wrong casts need to be fixed for building hotspot successfully on Mac OS.
xlu
parents:
512
diff
changeset
|
137 __ movptr(Address(rdx, 0), NULL_WORD); |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
138 // No post barrier for NULL |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
139 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
140 __ movl(Address(rdx, 0), val); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
141 __ g1_write_barrier_post(rdx, rax, rcx, rbx, rsi); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
142 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
143 __ restore_bcp(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
144 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
145 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
146 break; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
147 #endif // SERIALGC |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
148 case BarrierSet::CardTableModRef: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
149 case BarrierSet::CardTableExtension: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
150 { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
151 if (val == noreg) { |
533
dc3ad84615cf
6795913: A few remaining wrong casts need to be fixed for building hotspot successfully on Mac OS.
xlu
parents:
512
diff
changeset
|
152 __ movptr(obj, NULL_WORD); |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
153 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
154 __ movl(obj, val); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
155 // flatten object address if needed |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
156 if (!precise || (obj.index() == noreg && obj.disp() == 0)) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
157 __ store_check(obj.base()); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
158 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
159 __ leal(rdx, obj); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
160 __ store_check(rdx); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
161 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
162 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
163 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
164 break; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
165 case BarrierSet::ModRef: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
166 case BarrierSet::Other: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
167 if (val == noreg) { |
533
dc3ad84615cf
6795913: A few remaining wrong casts need to be fixed for building hotspot successfully on Mac OS.
xlu
parents:
512
diff
changeset
|
168 __ movptr(obj, NULL_WORD); |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
169 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
170 __ movl(obj, val); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
171 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
172 break; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
173 default : |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
174 ShouldNotReachHere(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
175 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
176 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
177 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
178 |
0 | 179 Address TemplateTable::at_bcp(int offset) { |
180 assert(_desc->uses_bcp(), "inconsistent uses_bcp information"); | |
181 return Address(rsi, offset); | |
182 } | |
183 | |
184 | |
185 void TemplateTable::patch_bytecode(Bytecodes::Code bytecode, Register bc, | |
186 Register scratch, | |
187 bool load_bc_into_scratch/*=true*/) { | |
188 | |
189 if (!RewriteBytecodes) return; | |
190 // the pair bytecodes have already done the load. | |
304 | 191 if (load_bc_into_scratch) { |
192 __ movl(bc, bytecode); | |
193 } | |
0 | 194 Label patch_done; |
195 if (JvmtiExport::can_post_breakpoint()) { | |
196 Label fast_patch; | |
197 // if a breakpoint is present we can't rewrite the stream directly | |
304 | 198 __ movzbl(scratch, at_bcp(0)); |
0 | 199 __ cmpl(scratch, Bytecodes::_breakpoint); |
200 __ jcc(Assembler::notEqual, fast_patch); | |
201 __ get_method(scratch); | |
202 // Let breakpoint table handling rewrite to quicker bytecode | |
203 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::set_original_bytecode_at), scratch, rsi, bc); | |
204 #ifndef ASSERT | |
205 __ jmpb(patch_done); | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
206 #else |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
207 __ jmp(patch_done); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
208 #endif |
0 | 209 __ bind(fast_patch); |
210 } | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
211 #ifdef ASSERT |
0 | 212 Label okay; |
213 __ load_unsigned_byte(scratch, at_bcp(0)); | |
214 __ cmpl(scratch, (int)Bytecodes::java_code(bytecode)); | |
215 __ jccb(Assembler::equal, okay); | |
216 __ cmpl(scratch, bc); | |
217 __ jcc(Assembler::equal, okay); | |
218 __ stop("patching the wrong bytecode"); | |
219 __ bind(okay); | |
220 #endif | |
221 // patch bytecode | |
222 __ movb(at_bcp(0), bc); | |
223 __ bind(patch_done); | |
224 } | |
225 | |
226 //---------------------------------------------------------------------------------------------------- | |
227 // Individual instructions | |
228 | |
229 void TemplateTable::nop() { | |
230 transition(vtos, vtos); | |
231 // nothing to do | |
232 } | |
233 | |
234 void TemplateTable::shouldnotreachhere() { | |
235 transition(vtos, vtos); | |
236 __ stop("shouldnotreachhere bytecode"); | |
237 } | |
238 | |
239 | |
240 | |
241 void TemplateTable::aconst_null() { | |
242 transition(vtos, atos); | |
304 | 243 __ xorptr(rax, rax); |
0 | 244 } |
245 | |
246 | |
247 void TemplateTable::iconst(int value) { | |
248 transition(vtos, itos); | |
249 if (value == 0) { | |
304 | 250 __ xorptr(rax, rax); |
0 | 251 } else { |
304 | 252 __ movptr(rax, value); |
0 | 253 } |
254 } | |
255 | |
256 | |
257 void TemplateTable::lconst(int value) { | |
258 transition(vtos, ltos); | |
259 if (value == 0) { | |
304 | 260 __ xorptr(rax, rax); |
0 | 261 } else { |
304 | 262 __ movptr(rax, value); |
0 | 263 } |
264 assert(value >= 0, "check this code"); | |
304 | 265 __ xorptr(rdx, rdx); |
0 | 266 } |
267 | |
268 | |
269 void TemplateTable::fconst(int value) { | |
270 transition(vtos, ftos); | |
271 if (value == 0) { __ fldz(); | |
272 } else if (value == 1) { __ fld1(); | |
273 } else if (value == 2) { __ fld1(); __ fld1(); __ faddp(); // should do a better solution here | |
274 } else { ShouldNotReachHere(); | |
275 } | |
276 } | |
277 | |
278 | |
279 void TemplateTable::dconst(int value) { | |
280 transition(vtos, dtos); | |
281 if (value == 0) { __ fldz(); | |
282 } else if (value == 1) { __ fld1(); | |
283 } else { ShouldNotReachHere(); | |
284 } | |
285 } | |
286 | |
287 | |
288 void TemplateTable::bipush() { | |
289 transition(vtos, itos); | |
290 __ load_signed_byte(rax, at_bcp(1)); | |
291 } | |
292 | |
293 | |
294 void TemplateTable::sipush() { | |
295 transition(vtos, itos); | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
296 __ load_unsigned_short(rax, at_bcp(1)); |
304 | 297 __ bswapl(rax); |
0 | 298 __ sarl(rax, 16); |
299 } | |
300 | |
301 void TemplateTable::ldc(bool wide) { | |
302 transition(vtos, vtos); | |
303 Label call_ldc, notFloat, notClass, Done; | |
304 | |
305 if (wide) { | |
306 __ get_unsigned_2_byte_index_at_bcp(rbx, 1); | |
307 } else { | |
308 __ load_unsigned_byte(rbx, at_bcp(1)); | |
309 } | |
310 __ get_cpool_and_tags(rcx, rax); | |
311 const int base_offset = constantPoolOopDesc::header_size() * wordSize; | |
312 const int tags_offset = typeArrayOopDesc::header_size(T_BYTE) * wordSize; | |
313 | |
314 // get type | |
304 | 315 __ xorptr(rdx, rdx); |
0 | 316 __ movb(rdx, Address(rax, rbx, Address::times_1, tags_offset)); |
317 | |
318 // unresolved string - get the resolved string | |
319 __ cmpl(rdx, JVM_CONSTANT_UnresolvedString); | |
320 __ jccb(Assembler::equal, call_ldc); | |
321 | |
322 // unresolved class - get the resolved class | |
323 __ cmpl(rdx, JVM_CONSTANT_UnresolvedClass); | |
324 __ jccb(Assembler::equal, call_ldc); | |
325 | |
326 // unresolved class in error (resolution failed) - call into runtime | |
327 // so that the same error from first resolution attempt is thrown. | |
328 __ cmpl(rdx, JVM_CONSTANT_UnresolvedClassInError); | |
329 __ jccb(Assembler::equal, call_ldc); | |
330 | |
331 // resolved class - need to call vm to get java mirror of the class | |
332 __ cmpl(rdx, JVM_CONSTANT_Class); | |
333 __ jcc(Assembler::notEqual, notClass); | |
334 | |
335 __ bind(call_ldc); | |
336 __ movl(rcx, wide); | |
337 call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), rcx); | |
338 __ push(atos); | |
339 __ jmp(Done); | |
340 | |
341 __ bind(notClass); | |
342 __ cmpl(rdx, JVM_CONSTANT_Float); | |
343 __ jccb(Assembler::notEqual, notFloat); | |
344 // ftos | |
304 | 345 __ fld_s( Address(rcx, rbx, Address::times_ptr, base_offset)); |
0 | 346 __ push(ftos); |
347 __ jmp(Done); | |
348 | |
349 __ bind(notFloat); | |
350 #ifdef ASSERT | |
351 { Label L; | |
352 __ cmpl(rdx, JVM_CONSTANT_Integer); | |
353 __ jcc(Assembler::equal, L); | |
354 __ cmpl(rdx, JVM_CONSTANT_String); | |
355 __ jcc(Assembler::equal, L); | |
356 __ stop("unexpected tag type in ldc"); | |
357 __ bind(L); | |
358 } | |
359 #endif | |
360 Label isOop; | |
361 // atos and itos | |
362 // String is only oop type we will see here | |
363 __ cmpl(rdx, JVM_CONSTANT_String); | |
364 __ jccb(Assembler::equal, isOop); | |
304 | 365 __ movl(rax, Address(rcx, rbx, Address::times_ptr, base_offset)); |
0 | 366 __ push(itos); |
367 __ jmp(Done); | |
368 __ bind(isOop); | |
304 | 369 __ movptr(rax, Address(rcx, rbx, Address::times_ptr, base_offset)); |
0 | 370 __ push(atos); |
371 | |
372 if (VerifyOops) { | |
373 __ verify_oop(rax); | |
374 } | |
375 __ bind(Done); | |
376 } | |
377 | |
1602 | 378 // Fast path for caching oop constants. |
379 // %%% We should use this to handle Class and String constants also. | |
380 // %%% It will simplify the ldc/primitive path considerably. | |
381 void TemplateTable::fast_aldc(bool wide) { | |
382 transition(vtos, atos); | |
383 | |
384 if (!EnableMethodHandles) { | |
385 // We should not encounter this bytecode if !EnableMethodHandles. | |
386 // The verifier will stop it. However, if we get past the verifier, | |
387 // this will stop the thread in a reasonable way, without crashing the JVM. | |
388 __ call_VM(noreg, CAST_FROM_FN_PTR(address, | |
389 InterpreterRuntime::throw_IncompatibleClassChangeError)); | |
390 // the call_VM checks for exception, so we should never return here. | |
391 __ should_not_reach_here(); | |
392 return; | |
393 } | |
394 | |
395 const Register cache = rcx; | |
396 const Register index = rdx; | |
397 | |
398 resolve_cache_and_index(f1_oop, rax, cache, index, wide ? sizeof(u2) : sizeof(u1)); | |
399 if (VerifyOops) { | |
400 __ verify_oop(rax); | |
401 } | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
402 |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
403 Label L_done, L_throw_exception; |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
404 const Register con_klass_temp = rcx; // same as Rcache |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
405 __ movptr(con_klass_temp, Address(rax, oopDesc::klass_offset_in_bytes())); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
406 __ cmpptr(con_klass_temp, ExternalAddress((address)Universe::systemObjArrayKlassObj_addr())); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
407 __ jcc(Assembler::notEqual, L_done); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
408 __ cmpl(Address(rax, arrayOopDesc::length_offset_in_bytes()), 0); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
409 __ jcc(Assembler::notEqual, L_throw_exception); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
410 __ xorptr(rax, rax); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
411 __ jmp(L_done); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
412 |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
413 // Load the exception from the system-array which wraps it: |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
414 __ bind(L_throw_exception); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
415 __ movptr(rax, Address(rax, arrayOopDesc::base_offset_in_bytes(T_OBJECT))); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
416 __ jump(ExternalAddress(Interpreter::throw_exception_entry())); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
417 |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1846
diff
changeset
|
418 __ bind(L_done); |
1602 | 419 } |
420 | |
0 | 421 void TemplateTable::ldc2_w() { |
422 transition(vtos, vtos); | |
423 Label Long, Done; | |
424 __ get_unsigned_2_byte_index_at_bcp(rbx, 1); | |
425 | |
426 __ get_cpool_and_tags(rcx, rax); | |
427 const int base_offset = constantPoolOopDesc::header_size() * wordSize; | |
428 const int tags_offset = typeArrayOopDesc::header_size(T_BYTE) * wordSize; | |
429 | |
430 // get type | |
431 __ cmpb(Address(rax, rbx, Address::times_1, tags_offset), JVM_CONSTANT_Double); | |
432 __ jccb(Assembler::notEqual, Long); | |
433 // dtos | |
304 | 434 __ fld_d( Address(rcx, rbx, Address::times_ptr, base_offset)); |
0 | 435 __ push(dtos); |
436 __ jmpb(Done); | |
437 | |
438 __ bind(Long); | |
439 // ltos | |
304 | 440 __ movptr(rax, Address(rcx, rbx, Address::times_ptr, base_offset + 0 * wordSize)); |
441 NOT_LP64(__ movptr(rdx, Address(rcx, rbx, Address::times_ptr, base_offset + 1 * wordSize))); | |
0 | 442 |
443 __ push(ltos); | |
444 | |
445 __ bind(Done); | |
446 } | |
447 | |
448 | |
449 void TemplateTable::locals_index(Register reg, int offset) { | |
450 __ load_unsigned_byte(reg, at_bcp(offset)); | |
304 | 451 __ negptr(reg); |
0 | 452 } |
453 | |
454 | |
455 void TemplateTable::iload() { | |
456 transition(vtos, itos); | |
457 if (RewriteFrequentPairs) { | |
458 Label rewrite, done; | |
459 | |
460 // get next byte | |
461 __ load_unsigned_byte(rbx, at_bcp(Bytecodes::length_for(Bytecodes::_iload))); | |
462 // if _iload, wait to rewrite to iload2. We only want to rewrite the | |
463 // last two iloads in a pair. Comparing against fast_iload means that | |
464 // the next bytecode is neither an iload or a caload, and therefore | |
465 // an iload pair. | |
466 __ cmpl(rbx, Bytecodes::_iload); | |
467 __ jcc(Assembler::equal, done); | |
468 | |
469 __ cmpl(rbx, Bytecodes::_fast_iload); | |
470 __ movl(rcx, Bytecodes::_fast_iload2); | |
471 __ jccb(Assembler::equal, rewrite); | |
472 | |
473 // if _caload, rewrite to fast_icaload | |
474 __ cmpl(rbx, Bytecodes::_caload); | |
475 __ movl(rcx, Bytecodes::_fast_icaload); | |
476 __ jccb(Assembler::equal, rewrite); | |
477 | |
478 // rewrite so iload doesn't check again. | |
479 __ movl(rcx, Bytecodes::_fast_iload); | |
480 | |
481 // rewrite | |
482 // rcx: fast bytecode | |
483 __ bind(rewrite); | |
484 patch_bytecode(Bytecodes::_iload, rcx, rbx, false); | |
485 __ bind(done); | |
486 } | |
487 | |
488 // Get the local value into tos | |
489 locals_index(rbx); | |
490 __ movl(rax, iaddress(rbx)); | |
491 } | |
492 | |
493 | |
494 void TemplateTable::fast_iload2() { | |
495 transition(vtos, itos); | |
496 locals_index(rbx); | |
497 __ movl(rax, iaddress(rbx)); | |
498 __ push(itos); | |
499 locals_index(rbx, 3); | |
500 __ movl(rax, iaddress(rbx)); | |
501 } | |
502 | |
503 void TemplateTable::fast_iload() { | |
504 transition(vtos, itos); | |
505 locals_index(rbx); | |
506 __ movl(rax, iaddress(rbx)); | |
507 } | |
508 | |
509 | |
510 void TemplateTable::lload() { | |
511 transition(vtos, ltos); | |
512 locals_index(rbx); | |
304 | 513 __ movptr(rax, laddress(rbx)); |
514 NOT_LP64(__ movl(rdx, haddress(rbx))); | |
0 | 515 } |
516 | |
517 | |
518 void TemplateTable::fload() { | |
519 transition(vtos, ftos); | |
520 locals_index(rbx); | |
521 __ fld_s(faddress(rbx)); | |
522 } | |
523 | |
524 | |
525 void TemplateTable::dload() { | |
526 transition(vtos, dtos); | |
527 locals_index(rbx); | |
1506 | 528 __ fld_d(daddress(rbx)); |
0 | 529 } |
530 | |
531 | |
532 void TemplateTable::aload() { | |
533 transition(vtos, atos); | |
534 locals_index(rbx); | |
304 | 535 __ movptr(rax, aaddress(rbx)); |
0 | 536 } |
537 | |
538 | |
539 void TemplateTable::locals_index_wide(Register reg) { | |
540 __ movl(reg, at_bcp(2)); | |
304 | 541 __ bswapl(reg); |
0 | 542 __ shrl(reg, 16); |
304 | 543 __ negptr(reg); |
0 | 544 } |
545 | |
546 | |
547 void TemplateTable::wide_iload() { | |
548 transition(vtos, itos); | |
549 locals_index_wide(rbx); | |
550 __ movl(rax, iaddress(rbx)); | |
551 } | |
552 | |
553 | |
554 void TemplateTable::wide_lload() { | |
555 transition(vtos, ltos); | |
556 locals_index_wide(rbx); | |
304 | 557 __ movptr(rax, laddress(rbx)); |
558 NOT_LP64(__ movl(rdx, haddress(rbx))); | |
0 | 559 } |
560 | |
561 | |
562 void TemplateTable::wide_fload() { | |
563 transition(vtos, ftos); | |
564 locals_index_wide(rbx); | |
565 __ fld_s(faddress(rbx)); | |
566 } | |
567 | |
568 | |
569 void TemplateTable::wide_dload() { | |
570 transition(vtos, dtos); | |
571 locals_index_wide(rbx); | |
1506 | 572 __ fld_d(daddress(rbx)); |
0 | 573 } |
574 | |
575 | |
576 void TemplateTable::wide_aload() { | |
577 transition(vtos, atos); | |
578 locals_index_wide(rbx); | |
304 | 579 __ movptr(rax, aaddress(rbx)); |
0 | 580 } |
581 | |
582 void TemplateTable::index_check(Register array, Register index) { | |
583 // Pop ptr into array | |
584 __ pop_ptr(array); | |
585 index_check_without_pop(array, index); | |
586 } | |
587 | |
588 void TemplateTable::index_check_without_pop(Register array, Register index) { | |
589 // destroys rbx, | |
590 // check array | |
591 __ null_check(array, arrayOopDesc::length_offset_in_bytes()); | |
304 | 592 LP64_ONLY(__ movslq(index, index)); |
0 | 593 // check index |
594 __ cmpl(index, Address(array, arrayOopDesc::length_offset_in_bytes())); | |
595 if (index != rbx) { | |
596 // ??? convention: move aberrant index into rbx, for exception message | |
597 assert(rbx != array, "different registers"); | |
304 | 598 __ mov(rbx, index); |
0 | 599 } |
600 __ jump_cc(Assembler::aboveEqual, | |
601 ExternalAddress(Interpreter::_throw_ArrayIndexOutOfBoundsException_entry)); | |
602 } | |
603 | |
604 | |
605 void TemplateTable::iaload() { | |
606 transition(itos, itos); | |
607 // rdx: array | |
608 index_check(rdx, rax); // kills rbx, | |
609 // rax,: index | |
610 __ movl(rax, Address(rdx, rax, Address::times_4, arrayOopDesc::base_offset_in_bytes(T_INT))); | |
611 } | |
612 | |
613 | |
614 void TemplateTable::laload() { | |
615 transition(itos, ltos); | |
616 // rax,: index | |
617 // rdx: array | |
618 index_check(rdx, rax); | |
304 | 619 __ mov(rbx, rax); |
0 | 620 // rbx,: index |
304 | 621 __ movptr(rax, Address(rdx, rbx, Address::times_8, arrayOopDesc::base_offset_in_bytes(T_LONG) + 0 * wordSize)); |
622 NOT_LP64(__ movl(rdx, Address(rdx, rbx, Address::times_8, arrayOopDesc::base_offset_in_bytes(T_LONG) + 1 * wordSize))); | |
0 | 623 } |
624 | |
625 | |
626 void TemplateTable::faload() { | |
627 transition(itos, ftos); | |
628 // rdx: array | |
629 index_check(rdx, rax); // kills rbx, | |
630 // rax,: index | |
631 __ fld_s(Address(rdx, rax, Address::times_4, arrayOopDesc::base_offset_in_bytes(T_FLOAT))); | |
632 } | |
633 | |
634 | |
635 void TemplateTable::daload() { | |
636 transition(itos, dtos); | |
637 // rdx: array | |
638 index_check(rdx, rax); // kills rbx, | |
639 // rax,: index | |
640 __ fld_d(Address(rdx, rax, Address::times_8, arrayOopDesc::base_offset_in_bytes(T_DOUBLE))); | |
641 } | |
642 | |
643 | |
644 void TemplateTable::aaload() { | |
645 transition(itos, atos); | |
646 // rdx: array | |
647 index_check(rdx, rax); // kills rbx, | |
648 // rax,: index | |
304 | 649 __ movptr(rax, Address(rdx, rax, Address::times_ptr, arrayOopDesc::base_offset_in_bytes(T_OBJECT))); |
0 | 650 } |
651 | |
652 | |
653 void TemplateTable::baload() { | |
654 transition(itos, itos); | |
655 // rdx: array | |
656 index_check(rdx, rax); // kills rbx, | |
657 // rax,: index | |
658 // can do better code for P5 - fix this at some point | |
659 __ load_signed_byte(rbx, Address(rdx, rax, Address::times_1, arrayOopDesc::base_offset_in_bytes(T_BYTE))); | |
304 | 660 __ mov(rax, rbx); |
0 | 661 } |
662 | |
663 | |
664 void TemplateTable::caload() { | |
665 transition(itos, itos); | |
666 // rdx: array | |
667 index_check(rdx, rax); // kills rbx, | |
668 // rax,: index | |
669 // can do better code for P5 - may want to improve this at some point | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
670 __ load_unsigned_short(rbx, Address(rdx, rax, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR))); |
304 | 671 __ mov(rax, rbx); |
0 | 672 } |
673 | |
674 // iload followed by caload frequent pair | |
675 void TemplateTable::fast_icaload() { | |
676 transition(vtos, itos); | |
677 // load index out of locals | |
678 locals_index(rbx); | |
679 __ movl(rax, iaddress(rbx)); | |
680 | |
681 // rdx: array | |
682 index_check(rdx, rax); | |
683 // rax,: index | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
684 __ load_unsigned_short(rbx, Address(rdx, rax, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR))); |
304 | 685 __ mov(rax, rbx); |
0 | 686 } |
687 | |
688 void TemplateTable::saload() { | |
689 transition(itos, itos); | |
690 // rdx: array | |
691 index_check(rdx, rax); // kills rbx, | |
692 // rax,: index | |
693 // can do better code for P5 - may want to improve this at some point | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
694 __ load_signed_short(rbx, Address(rdx, rax, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_SHORT))); |
304 | 695 __ mov(rax, rbx); |
0 | 696 } |
697 | |
698 | |
699 void TemplateTable::iload(int n) { | |
700 transition(vtos, itos); | |
701 __ movl(rax, iaddress(n)); | |
702 } | |
703 | |
704 | |
705 void TemplateTable::lload(int n) { | |
706 transition(vtos, ltos); | |
304 | 707 __ movptr(rax, laddress(n)); |
708 NOT_LP64(__ movptr(rdx, haddress(n))); | |
0 | 709 } |
710 | |
711 | |
712 void TemplateTable::fload(int n) { | |
713 transition(vtos, ftos); | |
714 __ fld_s(faddress(n)); | |
715 } | |
716 | |
717 | |
718 void TemplateTable::dload(int n) { | |
719 transition(vtos, dtos); | |
1506 | 720 __ fld_d(daddress(n)); |
0 | 721 } |
722 | |
723 | |
724 void TemplateTable::aload(int n) { | |
725 transition(vtos, atos); | |
304 | 726 __ movptr(rax, aaddress(n)); |
0 | 727 } |
728 | |
729 | |
730 void TemplateTable::aload_0() { | |
731 transition(vtos, atos); | |
732 // According to bytecode histograms, the pairs: | |
733 // | |
734 // _aload_0, _fast_igetfield | |
735 // _aload_0, _fast_agetfield | |
736 // _aload_0, _fast_fgetfield | |
737 // | |
738 // occur frequently. If RewriteFrequentPairs is set, the (slow) _aload_0 | |
739 // bytecode checks if the next bytecode is either _fast_igetfield, | |
740 // _fast_agetfield or _fast_fgetfield and then rewrites the | |
741 // current bytecode into a pair bytecode; otherwise it rewrites the current | |
742 // bytecode into _fast_aload_0 that doesn't do the pair check anymore. | |
743 // | |
744 // Note: If the next bytecode is _getfield, the rewrite must be delayed, | |
745 // otherwise we may miss an opportunity for a pair. | |
746 // | |
747 // Also rewrite frequent pairs | |
748 // aload_0, aload_1 | |
749 // aload_0, iload_1 | |
750 // These bytecodes with a small amount of code are most profitable to rewrite | |
751 if (RewriteFrequentPairs) { | |
752 Label rewrite, done; | |
753 // get next byte | |
754 __ load_unsigned_byte(rbx, at_bcp(Bytecodes::length_for(Bytecodes::_aload_0))); | |
755 | |
756 // do actual aload_0 | |
757 aload(0); | |
758 | |
759 // if _getfield then wait with rewrite | |
760 __ cmpl(rbx, Bytecodes::_getfield); | |
761 __ jcc(Assembler::equal, done); | |
762 | |
763 // if _igetfield then reqrite to _fast_iaccess_0 | |
764 assert(Bytecodes::java_code(Bytecodes::_fast_iaccess_0) == Bytecodes::_aload_0, "fix bytecode definition"); | |
765 __ cmpl(rbx, Bytecodes::_fast_igetfield); | |
766 __ movl(rcx, Bytecodes::_fast_iaccess_0); | |
767 __ jccb(Assembler::equal, rewrite); | |
768 | |
769 // if _agetfield then reqrite to _fast_aaccess_0 | |
770 assert(Bytecodes::java_code(Bytecodes::_fast_aaccess_0) == Bytecodes::_aload_0, "fix bytecode definition"); | |
771 __ cmpl(rbx, Bytecodes::_fast_agetfield); | |
772 __ movl(rcx, Bytecodes::_fast_aaccess_0); | |
773 __ jccb(Assembler::equal, rewrite); | |
774 | |
775 // if _fgetfield then reqrite to _fast_faccess_0 | |
776 assert(Bytecodes::java_code(Bytecodes::_fast_faccess_0) == Bytecodes::_aload_0, "fix bytecode definition"); | |
777 __ cmpl(rbx, Bytecodes::_fast_fgetfield); | |
778 __ movl(rcx, Bytecodes::_fast_faccess_0); | |
779 __ jccb(Assembler::equal, rewrite); | |
780 | |
781 // else rewrite to _fast_aload0 | |
782 assert(Bytecodes::java_code(Bytecodes::_fast_aload_0) == Bytecodes::_aload_0, "fix bytecode definition"); | |
783 __ movl(rcx, Bytecodes::_fast_aload_0); | |
784 | |
785 // rewrite | |
786 // rcx: fast bytecode | |
787 __ bind(rewrite); | |
788 patch_bytecode(Bytecodes::_aload_0, rcx, rbx, false); | |
789 | |
790 __ bind(done); | |
791 } else { | |
792 aload(0); | |
793 } | |
794 } | |
795 | |
796 void TemplateTable::istore() { | |
797 transition(itos, vtos); | |
798 locals_index(rbx); | |
799 __ movl(iaddress(rbx), rax); | |
800 } | |
801 | |
802 | |
803 void TemplateTable::lstore() { | |
804 transition(ltos, vtos); | |
805 locals_index(rbx); | |
304 | 806 __ movptr(laddress(rbx), rax); |
807 NOT_LP64(__ movptr(haddress(rbx), rdx)); | |
0 | 808 } |
809 | |
810 | |
811 void TemplateTable::fstore() { | |
812 transition(ftos, vtos); | |
813 locals_index(rbx); | |
814 __ fstp_s(faddress(rbx)); | |
815 } | |
816 | |
817 | |
818 void TemplateTable::dstore() { | |
819 transition(dtos, vtos); | |
820 locals_index(rbx); | |
1506 | 821 __ fstp_d(daddress(rbx)); |
0 | 822 } |
823 | |
824 | |
825 void TemplateTable::astore() { | |
826 transition(vtos, vtos); | |
1506 | 827 __ pop_ptr(rax); |
0 | 828 locals_index(rbx); |
304 | 829 __ movptr(aaddress(rbx), rax); |
0 | 830 } |
831 | |
832 | |
833 void TemplateTable::wide_istore() { | |
834 transition(vtos, vtos); | |
835 __ pop_i(rax); | |
836 locals_index_wide(rbx); | |
837 __ movl(iaddress(rbx), rax); | |
838 } | |
839 | |
840 | |
841 void TemplateTable::wide_lstore() { | |
842 transition(vtos, vtos); | |
843 __ pop_l(rax, rdx); | |
844 locals_index_wide(rbx); | |
304 | 845 __ movptr(laddress(rbx), rax); |
846 NOT_LP64(__ movl(haddress(rbx), rdx)); | |
0 | 847 } |
848 | |
849 | |
850 void TemplateTable::wide_fstore() { | |
851 wide_istore(); | |
852 } | |
853 | |
854 | |
855 void TemplateTable::wide_dstore() { | |
856 wide_lstore(); | |
857 } | |
858 | |
859 | |
860 void TemplateTable::wide_astore() { | |
861 transition(vtos, vtos); | |
1506 | 862 __ pop_ptr(rax); |
0 | 863 locals_index_wide(rbx); |
304 | 864 __ movptr(aaddress(rbx), rax); |
0 | 865 } |
866 | |
867 | |
868 void TemplateTable::iastore() { | |
869 transition(itos, vtos); | |
870 __ pop_i(rbx); | |
871 // rax,: value | |
872 // rdx: array | |
873 index_check(rdx, rbx); // prefer index in rbx, | |
874 // rbx,: index | |
875 __ movl(Address(rdx, rbx, Address::times_4, arrayOopDesc::base_offset_in_bytes(T_INT)), rax); | |
876 } | |
877 | |
878 | |
879 void TemplateTable::lastore() { | |
880 transition(ltos, vtos); | |
881 __ pop_i(rbx); | |
882 // rax,: low(value) | |
883 // rcx: array | |
884 // rdx: high(value) | |
885 index_check(rcx, rbx); // prefer index in rbx, | |
886 // rbx,: index | |
304 | 887 __ movptr(Address(rcx, rbx, Address::times_8, arrayOopDesc::base_offset_in_bytes(T_LONG) + 0 * wordSize), rax); |
888 NOT_LP64(__ movl(Address(rcx, rbx, Address::times_8, arrayOopDesc::base_offset_in_bytes(T_LONG) + 1 * wordSize), rdx)); | |
0 | 889 } |
890 | |
891 | |
892 void TemplateTable::fastore() { | |
893 transition(ftos, vtos); | |
894 __ pop_i(rbx); | |
895 // rdx: array | |
896 // st0: value | |
897 index_check(rdx, rbx); // prefer index in rbx, | |
898 // rbx,: index | |
899 __ fstp_s(Address(rdx, rbx, Address::times_4, arrayOopDesc::base_offset_in_bytes(T_FLOAT))); | |
900 } | |
901 | |
902 | |
903 void TemplateTable::dastore() { | |
904 transition(dtos, vtos); | |
905 __ pop_i(rbx); | |
906 // rdx: array | |
907 // st0: value | |
908 index_check(rdx, rbx); // prefer index in rbx, | |
909 // rbx,: index | |
910 __ fstp_d(Address(rdx, rbx, Address::times_8, arrayOopDesc::base_offset_in_bytes(T_DOUBLE))); | |
911 } | |
912 | |
913 | |
914 void TemplateTable::aastore() { | |
915 Label is_null, ok_is_subtype, done; | |
916 transition(vtos, vtos); | |
917 // stack: ..., array, index, value | |
304 | 918 __ movptr(rax, at_tos()); // Value |
0 | 919 __ movl(rcx, at_tos_p1()); // Index |
304 | 920 __ movptr(rdx, at_tos_p2()); // Array |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
921 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
922 Address element_address(rdx, rcx, Address::times_4, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); |
0 | 923 index_check_without_pop(rdx, rcx); // kills rbx, |
924 // do array store check - check for NULL value first | |
304 | 925 __ testptr(rax, rax); |
0 | 926 __ jcc(Assembler::zero, is_null); |
927 | |
928 // Move subklass into EBX | |
304 | 929 __ movptr(rbx, Address(rax, oopDesc::klass_offset_in_bytes())); |
0 | 930 // Move superklass into EAX |
304 | 931 __ movptr(rax, Address(rdx, oopDesc::klass_offset_in_bytes())); |
932 __ movptr(rax, Address(rax, sizeof(oopDesc) + objArrayKlass::element_klass_offset_in_bytes())); | |
933 // Compress array+index*wordSize+12 into a single register. Frees ECX. | |
362 | 934 __ lea(rdx, element_address); |
0 | 935 |
936 // Generate subtype check. Blows ECX. Resets EDI to locals. | |
937 // Superklass in EAX. Subklass in EBX. | |
938 __ gen_subtype_check( rbx, ok_is_subtype ); | |
939 | |
940 // Come here on failure | |
941 // object is at TOS | |
942 __ jump(ExternalAddress(Interpreter::_throw_ArrayStoreException_entry)); | |
943 | |
944 // Come here on success | |
945 __ bind(ok_is_subtype); | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
946 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
947 // Get the value to store |
362 | 948 __ movptr(rax, at_rsp()); |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
949 // and store it with appropriate barrier |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
950 do_oop_store(_masm, Address(rdx, 0), rax, _bs->kind(), true); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
951 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
952 __ jmp(done); |
0 | 953 |
954 // Have a NULL in EAX, EDX=array, ECX=index. Store NULL at ary[idx] | |
955 __ bind(is_null); | |
956 __ profile_null_seen(rbx); | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
957 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
958 // Store NULL, (noreg means NULL to do_oop_store) |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
959 do_oop_store(_masm, element_address, noreg, _bs->kind(), true); |
0 | 960 |
961 // Pop stack arguments | |
962 __ bind(done); | |
1506 | 963 __ addptr(rsp, 3 * Interpreter::stackElementSize); |
0 | 964 } |
965 | |
966 | |
967 void TemplateTable::bastore() { | |
968 transition(itos, vtos); | |
969 __ pop_i(rbx); | |
970 // rax,: value | |
971 // rdx: array | |
972 index_check(rdx, rbx); // prefer index in rbx, | |
973 // rbx,: index | |
974 __ movb(Address(rdx, rbx, Address::times_1, arrayOopDesc::base_offset_in_bytes(T_BYTE)), rax); | |
975 } | |
976 | |
977 | |
978 void TemplateTable::castore() { | |
979 transition(itos, vtos); | |
980 __ pop_i(rbx); | |
981 // rax,: value | |
982 // rdx: array | |
983 index_check(rdx, rbx); // prefer index in rbx, | |
984 // rbx,: index | |
985 __ movw(Address(rdx, rbx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR)), rax); | |
986 } | |
987 | |
988 | |
989 void TemplateTable::sastore() { | |
990 castore(); | |
991 } | |
992 | |
993 | |
994 void TemplateTable::istore(int n) { | |
995 transition(itos, vtos); | |
996 __ movl(iaddress(n), rax); | |
997 } | |
998 | |
999 | |
1000 void TemplateTable::lstore(int n) { | |
1001 transition(ltos, vtos); | |
304 | 1002 __ movptr(laddress(n), rax); |
1003 NOT_LP64(__ movptr(haddress(n), rdx)); | |
0 | 1004 } |
1005 | |
1006 | |
1007 void TemplateTable::fstore(int n) { | |
1008 transition(ftos, vtos); | |
1009 __ fstp_s(faddress(n)); | |
1010 } | |
1011 | |
1012 | |
1013 void TemplateTable::dstore(int n) { | |
1014 transition(dtos, vtos); | |
1506 | 1015 __ fstp_d(daddress(n)); |
0 | 1016 } |
1017 | |
1018 | |
1019 void TemplateTable::astore(int n) { | |
1020 transition(vtos, vtos); | |
1506 | 1021 __ pop_ptr(rax); |
304 | 1022 __ movptr(aaddress(n), rax); |
0 | 1023 } |
1024 | |
1025 | |
1026 void TemplateTable::pop() { | |
1027 transition(vtos, vtos); | |
1506 | 1028 __ addptr(rsp, Interpreter::stackElementSize); |
0 | 1029 } |
1030 | |
1031 | |
1032 void TemplateTable::pop2() { | |
1033 transition(vtos, vtos); | |
1506 | 1034 __ addptr(rsp, 2*Interpreter::stackElementSize); |
0 | 1035 } |
1036 | |
1037 | |
1038 void TemplateTable::dup() { | |
1039 transition(vtos, vtos); | |
1040 // stack: ..., a | |
1506 | 1041 __ load_ptr(0, rax); |
1042 __ push_ptr(rax); | |
0 | 1043 // stack: ..., a, a |
1044 } | |
1045 | |
1046 | |
1047 void TemplateTable::dup_x1() { | |
1048 transition(vtos, vtos); | |
1049 // stack: ..., a, b | |
1506 | 1050 __ load_ptr( 0, rax); // load b |
1051 __ load_ptr( 1, rcx); // load a | |
1052 __ store_ptr(1, rax); // store b | |
1053 __ store_ptr(0, rcx); // store a | |
1054 __ push_ptr(rax); // push b | |
0 | 1055 // stack: ..., b, a, b |
1056 } | |
1057 | |
1058 | |
1059 void TemplateTable::dup_x2() { | |
1060 transition(vtos, vtos); | |
1061 // stack: ..., a, b, c | |
1506 | 1062 __ load_ptr( 0, rax); // load c |
1063 __ load_ptr( 2, rcx); // load a | |
1064 __ store_ptr(2, rax); // store c in a | |
1065 __ push_ptr(rax); // push c | |
0 | 1066 // stack: ..., c, b, c, c |
1506 | 1067 __ load_ptr( 2, rax); // load b |
1068 __ store_ptr(2, rcx); // store a in b | |
0 | 1069 // stack: ..., c, a, c, c |
1506 | 1070 __ store_ptr(1, rax); // store b in c |
0 | 1071 // stack: ..., c, a, b, c |
1072 } | |
1073 | |
1074 | |
1075 void TemplateTable::dup2() { | |
1076 transition(vtos, vtos); | |
1077 // stack: ..., a, b | |
1506 | 1078 __ load_ptr(1, rax); // load a |
1079 __ push_ptr(rax); // push a | |
1080 __ load_ptr(1, rax); // load b | |
1081 __ push_ptr(rax); // push b | |
0 | 1082 // stack: ..., a, b, a, b |
1083 } | |
1084 | |
1085 | |
1086 void TemplateTable::dup2_x1() { | |
1087 transition(vtos, vtos); | |
1088 // stack: ..., a, b, c | |
1506 | 1089 __ load_ptr( 0, rcx); // load c |
1090 __ load_ptr( 1, rax); // load b | |
1091 __ push_ptr(rax); // push b | |
1092 __ push_ptr(rcx); // push c | |
0 | 1093 // stack: ..., a, b, c, b, c |
1506 | 1094 __ store_ptr(3, rcx); // store c in b |
0 | 1095 // stack: ..., a, c, c, b, c |
1506 | 1096 __ load_ptr( 4, rcx); // load a |
1097 __ store_ptr(2, rcx); // store a in 2nd c | |
0 | 1098 // stack: ..., a, c, a, b, c |
1506 | 1099 __ store_ptr(4, rax); // store b in a |
0 | 1100 // stack: ..., b, c, a, b, c |
1101 // stack: ..., b, c, a, b, c | |
1102 } | |
1103 | |
1104 | |
1105 void TemplateTable::dup2_x2() { | |
1106 transition(vtos, vtos); | |
1107 // stack: ..., a, b, c, d | |
1506 | 1108 __ load_ptr( 0, rcx); // load d |
1109 __ load_ptr( 1, rax); // load c | |
1110 __ push_ptr(rax); // push c | |
1111 __ push_ptr(rcx); // push d | |
0 | 1112 // stack: ..., a, b, c, d, c, d |
1506 | 1113 __ load_ptr( 4, rax); // load b |
1114 __ store_ptr(2, rax); // store b in d | |
1115 __ store_ptr(4, rcx); // store d in b | |
0 | 1116 // stack: ..., a, d, c, b, c, d |
1506 | 1117 __ load_ptr( 5, rcx); // load a |
1118 __ load_ptr( 3, rax); // load c | |
1119 __ store_ptr(3, rcx); // store a in c | |
1120 __ store_ptr(5, rax); // store c in a | |
0 | 1121 // stack: ..., c, d, a, b, c, d |
1122 // stack: ..., c, d, a, b, c, d | |
1123 } | |
1124 | |
1125 | |
1126 void TemplateTable::swap() { | |
1127 transition(vtos, vtos); | |
1128 // stack: ..., a, b | |
1506 | 1129 __ load_ptr( 1, rcx); // load a |
1130 __ load_ptr( 0, rax); // load b | |
1131 __ store_ptr(0, rcx); // store a in b | |
1132 __ store_ptr(1, rax); // store b in a | |
0 | 1133 // stack: ..., b, a |
1134 } | |
1135 | |
1136 | |
1137 void TemplateTable::iop2(Operation op) { | |
1138 transition(itos, itos); | |
1139 switch (op) { | |
1506 | 1140 case add : __ pop_i(rdx); __ addl (rax, rdx); break; |
304 | 1141 case sub : __ mov(rdx, rax); __ pop_i(rax); __ subl (rax, rdx); break; |
1506 | 1142 case mul : __ pop_i(rdx); __ imull(rax, rdx); break; |
1143 case _and : __ pop_i(rdx); __ andl (rax, rdx); break; | |
1144 case _or : __ pop_i(rdx); __ orl (rax, rdx); break; | |
1145 case _xor : __ pop_i(rdx); __ xorl (rax, rdx); break; | |
304 | 1146 case shl : __ mov(rcx, rax); __ pop_i(rax); __ shll (rax); break; // implicit masking of lower 5 bits by Intel shift instr. |
1147 case shr : __ mov(rcx, rax); __ pop_i(rax); __ sarl (rax); break; // implicit masking of lower 5 bits by Intel shift instr. | |
1148 case ushr : __ mov(rcx, rax); __ pop_i(rax); __ shrl (rax); break; // implicit masking of lower 5 bits by Intel shift instr. | |
0 | 1149 default : ShouldNotReachHere(); |
1150 } | |
1151 } | |
1152 | |
1153 | |
1154 void TemplateTable::lop2(Operation op) { | |
1155 transition(ltos, ltos); | |
1156 __ pop_l(rbx, rcx); | |
1157 switch (op) { | |
1506 | 1158 case add : __ addl(rax, rbx); __ adcl(rdx, rcx); break; |
1159 case sub : __ subl(rbx, rax); __ sbbl(rcx, rdx); | |
1160 __ mov (rax, rbx); __ mov (rdx, rcx); break; | |
1161 case _and : __ andl(rax, rbx); __ andl(rdx, rcx); break; | |
1162 case _or : __ orl (rax, rbx); __ orl (rdx, rcx); break; | |
1163 case _xor : __ xorl(rax, rbx); __ xorl(rdx, rcx); break; | |
1164 default : ShouldNotReachHere(); | |
0 | 1165 } |
1166 } | |
1167 | |
1168 | |
1169 void TemplateTable::idiv() { | |
1170 transition(itos, itos); | |
304 | 1171 __ mov(rcx, rax); |
0 | 1172 __ pop_i(rax); |
1173 // Note: could xor rax, and rcx and compare with (-1 ^ min_int). If | |
1174 // they are not equal, one could do a normal division (no correction | |
1175 // needed), which may speed up this implementation for the common case. | |
1176 // (see also JVM spec., p.243 & p.271) | |
1177 __ corrected_idivl(rcx); | |
1178 } | |
1179 | |
1180 | |
1181 void TemplateTable::irem() { | |
1182 transition(itos, itos); | |
304 | 1183 __ mov(rcx, rax); |
0 | 1184 __ pop_i(rax); |
1185 // Note: could xor rax, and rcx and compare with (-1 ^ min_int). If | |
1186 // they are not equal, one could do a normal division (no correction | |
1187 // needed), which may speed up this implementation for the common case. | |
1188 // (see also JVM spec., p.243 & p.271) | |
1189 __ corrected_idivl(rcx); | |
304 | 1190 __ mov(rax, rdx); |
0 | 1191 } |
1192 | |
1193 | |
1194 void TemplateTable::lmul() { | |
1195 transition(ltos, ltos); | |
1196 __ pop_l(rbx, rcx); | |
304 | 1197 __ push(rcx); __ push(rbx); |
1198 __ push(rdx); __ push(rax); | |
0 | 1199 __ lmul(2 * wordSize, 0); |
304 | 1200 __ addptr(rsp, 4 * wordSize); // take off temporaries |
0 | 1201 } |
1202 | |
1203 | |
1204 void TemplateTable::ldiv() { | |
1205 transition(ltos, ltos); | |
1206 __ pop_l(rbx, rcx); | |
304 | 1207 __ push(rcx); __ push(rbx); |
1208 __ push(rdx); __ push(rax); | |
0 | 1209 // check if y = 0 |
1210 __ orl(rax, rdx); | |
1211 __ jump_cc(Assembler::zero, | |
1212 ExternalAddress(Interpreter::_throw_ArithmeticException_entry)); | |
1213 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::ldiv)); | |
304 | 1214 __ addptr(rsp, 4 * wordSize); // take off temporaries |
0 | 1215 } |
1216 | |
1217 | |
1218 void TemplateTable::lrem() { | |
1219 transition(ltos, ltos); | |
1220 __ pop_l(rbx, rcx); | |
304 | 1221 __ push(rcx); __ push(rbx); |
1222 __ push(rdx); __ push(rax); | |
0 | 1223 // check if y = 0 |
1224 __ orl(rax, rdx); | |
1225 __ jump_cc(Assembler::zero, | |
1226 ExternalAddress(Interpreter::_throw_ArithmeticException_entry)); | |
1227 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::lrem)); | |
304 | 1228 __ addptr(rsp, 4 * wordSize); |
0 | 1229 } |
1230 | |
1231 | |
1232 void TemplateTable::lshl() { | |
1233 transition(itos, ltos); | |
1234 __ movl(rcx, rax); // get shift count | |
1235 __ pop_l(rax, rdx); // get shift value | |
1236 __ lshl(rdx, rax); | |
1237 } | |
1238 | |
1239 | |
1240 void TemplateTable::lshr() { | |
1241 transition(itos, ltos); | |
304 | 1242 __ mov(rcx, rax); // get shift count |
0 | 1243 __ pop_l(rax, rdx); // get shift value |
1244 __ lshr(rdx, rax, true); | |
1245 } | |
1246 | |
1247 | |
1248 void TemplateTable::lushr() { | |
1249 transition(itos, ltos); | |
304 | 1250 __ mov(rcx, rax); // get shift count |
0 | 1251 __ pop_l(rax, rdx); // get shift value |
1252 __ lshr(rdx, rax); | |
1253 } | |
1254 | |
1255 | |
1256 void TemplateTable::fop2(Operation op) { | |
1257 transition(ftos, ftos); | |
1258 switch (op) { | |
1259 case add: __ fadd_s (at_rsp()); break; | |
1260 case sub: __ fsubr_s(at_rsp()); break; | |
1261 case mul: __ fmul_s (at_rsp()); break; | |
1262 case div: __ fdivr_s(at_rsp()); break; | |
1263 case rem: __ fld_s (at_rsp()); __ fremr(rax); break; | |
1264 default : ShouldNotReachHere(); | |
1265 } | |
1266 __ f2ieee(); | |
304 | 1267 __ pop(rax); // pop float thing off |
0 | 1268 } |
1269 | |
1270 | |
1271 void TemplateTable::dop2(Operation op) { | |
1272 transition(dtos, dtos); | |
1273 | |
1274 switch (op) { | |
1275 case add: __ fadd_d (at_rsp()); break; | |
1276 case sub: __ fsubr_d(at_rsp()); break; | |
1277 case mul: { | |
1278 Label L_strict; | |
1279 Label L_join; | |
1280 const Address access_flags (rcx, methodOopDesc::access_flags_offset()); | |
1281 __ get_method(rcx); | |
1282 __ movl(rcx, access_flags); | |
1283 __ testl(rcx, JVM_ACC_STRICT); | |
1284 __ jccb(Assembler::notZero, L_strict); | |
1285 __ fmul_d (at_rsp()); | |
1286 __ jmpb(L_join); | |
1287 __ bind(L_strict); | |
1288 __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias1())); | |
1289 __ fmulp(); | |
1290 __ fmul_d (at_rsp()); | |
1291 __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias2())); | |
1292 __ fmulp(); | |
1293 __ bind(L_join); | |
1294 break; | |
1295 } | |
1296 case div: { | |
1297 Label L_strict; | |
1298 Label L_join; | |
1299 const Address access_flags (rcx, methodOopDesc::access_flags_offset()); | |
1300 __ get_method(rcx); | |
1301 __ movl(rcx, access_flags); | |
1302 __ testl(rcx, JVM_ACC_STRICT); | |
1303 __ jccb(Assembler::notZero, L_strict); | |
1304 __ fdivr_d(at_rsp()); | |
1305 __ jmp(L_join); | |
1306 __ bind(L_strict); | |
1307 __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias1())); | |
1308 __ fmul_d (at_rsp()); | |
1309 __ fdivrp(); | |
1310 __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias2())); | |
1311 __ fmulp(); | |
1312 __ bind(L_join); | |
1313 break; | |
1314 } | |
1315 case rem: __ fld_d (at_rsp()); __ fremr(rax); break; | |
1316 default : ShouldNotReachHere(); | |
1317 } | |
1318 __ d2ieee(); | |
1319 // Pop double precision number from rsp. | |
304 | 1320 __ pop(rax); |
1321 __ pop(rdx); | |
0 | 1322 } |
1323 | |
1324 | |
1325 void TemplateTable::ineg() { | |
1326 transition(itos, itos); | |
1327 __ negl(rax); | |
1328 } | |
1329 | |
1330 | |
1331 void TemplateTable::lneg() { | |
1332 transition(ltos, ltos); | |
1333 __ lneg(rdx, rax); | |
1334 } | |
1335 | |
1336 | |
1337 void TemplateTable::fneg() { | |
1338 transition(ftos, ftos); | |
1339 __ fchs(); | |
1340 } | |
1341 | |
1342 | |
1343 void TemplateTable::dneg() { | |
1344 transition(dtos, dtos); | |
1345 __ fchs(); | |
1346 } | |
1347 | |
1348 | |
1349 void TemplateTable::iinc() { | |
1350 transition(vtos, vtos); | |
1351 __ load_signed_byte(rdx, at_bcp(2)); // get constant | |
1352 locals_index(rbx); | |
1353 __ addl(iaddress(rbx), rdx); | |
1354 } | |
1355 | |
1356 | |
1357 void TemplateTable::wide_iinc() { | |
1358 transition(vtos, vtos); | |
1359 __ movl(rdx, at_bcp(4)); // get constant | |
1360 locals_index_wide(rbx); | |
304 | 1361 __ bswapl(rdx); // swap bytes & sign-extend constant |
0 | 1362 __ sarl(rdx, 16); |
1363 __ addl(iaddress(rbx), rdx); | |
1364 // Note: should probably use only one movl to get both | |
1365 // the index and the constant -> fix this | |
1366 } | |
1367 | |
1368 | |
1369 void TemplateTable::convert() { | |
1370 // Checking | |
1371 #ifdef ASSERT | |
1372 { TosState tos_in = ilgl; | |
1373 TosState tos_out = ilgl; | |
1374 switch (bytecode()) { | |
1375 case Bytecodes::_i2l: // fall through | |
1376 case Bytecodes::_i2f: // fall through | |
1377 case Bytecodes::_i2d: // fall through | |
1378 case Bytecodes::_i2b: // fall through | |
1379 case Bytecodes::_i2c: // fall through | |
1380 case Bytecodes::_i2s: tos_in = itos; break; | |
1381 case Bytecodes::_l2i: // fall through | |
1382 case Bytecodes::_l2f: // fall through | |
1383 case Bytecodes::_l2d: tos_in = ltos; break; | |
1384 case Bytecodes::_f2i: // fall through | |
1385 case Bytecodes::_f2l: // fall through | |
1386 case Bytecodes::_f2d: tos_in = ftos; break; | |
1387 case Bytecodes::_d2i: // fall through | |
1388 case Bytecodes::_d2l: // fall through | |
1389 case Bytecodes::_d2f: tos_in = dtos; break; | |
1390 default : ShouldNotReachHere(); | |
1391 } | |
1392 switch (bytecode()) { | |
1393 case Bytecodes::_l2i: // fall through | |
1394 case Bytecodes::_f2i: // fall through | |
1395 case Bytecodes::_d2i: // fall through | |
1396 case Bytecodes::_i2b: // fall through | |
1397 case Bytecodes::_i2c: // fall through | |
1398 case Bytecodes::_i2s: tos_out = itos; break; | |
1399 case Bytecodes::_i2l: // fall through | |
1400 case Bytecodes::_f2l: // fall through | |
1401 case Bytecodes::_d2l: tos_out = ltos; break; | |
1402 case Bytecodes::_i2f: // fall through | |
1403 case Bytecodes::_l2f: // fall through | |
1404 case Bytecodes::_d2f: tos_out = ftos; break; | |
1405 case Bytecodes::_i2d: // fall through | |
1406 case Bytecodes::_l2d: // fall through | |
1407 case Bytecodes::_f2d: tos_out = dtos; break; | |
1408 default : ShouldNotReachHere(); | |
1409 } | |
1410 transition(tos_in, tos_out); | |
1411 } | |
1412 #endif // ASSERT | |
1413 | |
1414 // Conversion | |
304 | 1415 // (Note: use push(rcx)/pop(rcx) for 1/2-word stack-ptr manipulation) |
0 | 1416 switch (bytecode()) { |
1417 case Bytecodes::_i2l: | |
1418 __ extend_sign(rdx, rax); | |
1419 break; | |
1420 case Bytecodes::_i2f: | |
304 | 1421 __ push(rax); // store int on tos |
0 | 1422 __ fild_s(at_rsp()); // load int to ST0 |
1423 __ f2ieee(); // truncate to float size | |
304 | 1424 __ pop(rcx); // adjust rsp |
0 | 1425 break; |
1426 case Bytecodes::_i2d: | |
304 | 1427 __ push(rax); // add one slot for d2ieee() |
1428 __ push(rax); // store int on tos | |
0 | 1429 __ fild_s(at_rsp()); // load int to ST0 |
1430 __ d2ieee(); // truncate to double size | |
304 | 1431 __ pop(rcx); // adjust rsp |
1432 __ pop(rcx); | |
0 | 1433 break; |
1434 case Bytecodes::_i2b: | |
1435 __ shll(rax, 24); // truncate upper 24 bits | |
1436 __ sarl(rax, 24); // and sign-extend byte | |
304 | 1437 LP64_ONLY(__ movsbl(rax, rax)); |
0 | 1438 break; |
1439 case Bytecodes::_i2c: | |
1440 __ andl(rax, 0xFFFF); // truncate upper 16 bits | |
304 | 1441 LP64_ONLY(__ movzwl(rax, rax)); |
0 | 1442 break; |
1443 case Bytecodes::_i2s: | |
1444 __ shll(rax, 16); // truncate upper 16 bits | |
1445 __ sarl(rax, 16); // and sign-extend short | |
304 | 1446 LP64_ONLY(__ movswl(rax, rax)); |
0 | 1447 break; |
1448 case Bytecodes::_l2i: | |
1449 /* nothing to do */ | |
1450 break; | |
1451 case Bytecodes::_l2f: | |
304 | 1452 __ push(rdx); // store long on tos |
1453 __ push(rax); | |
0 | 1454 __ fild_d(at_rsp()); // load long to ST0 |
1455 __ f2ieee(); // truncate to float size | |
304 | 1456 __ pop(rcx); // adjust rsp |
1457 __ pop(rcx); | |
0 | 1458 break; |
1459 case Bytecodes::_l2d: | |
304 | 1460 __ push(rdx); // store long on tos |
1461 __ push(rax); | |
0 | 1462 __ fild_d(at_rsp()); // load long to ST0 |
1463 __ d2ieee(); // truncate to double size | |
304 | 1464 __ pop(rcx); // adjust rsp |
1465 __ pop(rcx); | |
0 | 1466 break; |
1467 case Bytecodes::_f2i: | |
304 | 1468 __ push(rcx); // reserve space for argument |
0 | 1469 __ fstp_s(at_rsp()); // pass float argument on stack |
1470 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::f2i), 1); | |
1471 break; | |
1472 case Bytecodes::_f2l: | |
304 | 1473 __ push(rcx); // reserve space for argument |
0 | 1474 __ fstp_s(at_rsp()); // pass float argument on stack |
1475 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::f2l), 1); | |
1476 break; | |
1477 case Bytecodes::_f2d: | |
1478 /* nothing to do */ | |
1479 break; | |
1480 case Bytecodes::_d2i: | |
304 | 1481 __ push(rcx); // reserve space for argument |
1482 __ push(rcx); | |
0 | 1483 __ fstp_d(at_rsp()); // pass double argument on stack |
1484 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::d2i), 2); | |
1485 break; | |
1486 case Bytecodes::_d2l: | |
304 | 1487 __ push(rcx); // reserve space for argument |
1488 __ push(rcx); | |
0 | 1489 __ fstp_d(at_rsp()); // pass double argument on stack |
1490 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::d2l), 2); | |
1491 break; | |
1492 case Bytecodes::_d2f: | |
304 | 1493 __ push(rcx); // reserve space for f2ieee() |
0 | 1494 __ f2ieee(); // truncate to float size |
304 | 1495 __ pop(rcx); // adjust rsp |
0 | 1496 break; |
1497 default : | |
1498 ShouldNotReachHere(); | |
1499 } | |
1500 } | |
1501 | |
1502 | |
1503 void TemplateTable::lcmp() { | |
1504 transition(ltos, itos); | |
1505 // y = rdx:rax | |
1506 __ pop_l(rbx, rcx); // get x = rcx:rbx | |
1507 __ lcmp2int(rcx, rbx, rdx, rax);// rcx := cmp(x, y) | |
304 | 1508 __ mov(rax, rcx); |
0 | 1509 } |
1510 | |
1511 | |
1512 void TemplateTable::float_cmp(bool is_float, int unordered_result) { | |
1513 if (is_float) { | |
1514 __ fld_s(at_rsp()); | |
1515 } else { | |
1516 __ fld_d(at_rsp()); | |
304 | 1517 __ pop(rdx); |
0 | 1518 } |
304 | 1519 __ pop(rcx); |
0 | 1520 __ fcmp2int(rax, unordered_result < 0); |
1521 } | |
1522 | |
1523 | |
1524 void TemplateTable::branch(bool is_jsr, bool is_wide) { | |
1525 __ get_method(rcx); // ECX holds method | |
1526 __ profile_taken_branch(rax,rbx); // EAX holds updated MDP, EBX holds bumped taken count | |
1527 | |
1528 const ByteSize be_offset = methodOopDesc::backedge_counter_offset() + InvocationCounter::counter_offset(); | |
1529 const ByteSize inv_offset = methodOopDesc::invocation_counter_offset() + InvocationCounter::counter_offset(); | |
1530 const int method_offset = frame::interpreter_frame_method_offset * wordSize; | |
1531 | |
1532 // Load up EDX with the branch displacement | |
1533 __ movl(rdx, at_bcp(1)); | |
304 | 1534 __ bswapl(rdx); |
0 | 1535 if (!is_wide) __ sarl(rdx, 16); |
304 | 1536 LP64_ONLY(__ movslq(rdx, rdx)); |
1537 | |
0 | 1538 |
1539 // Handle all the JSR stuff here, then exit. | |
1540 // It's much shorter and cleaner than intermingling with the | |
605 | 1541 // non-JSR normal-branch stuff occurring below. |
0 | 1542 if (is_jsr) { |
1543 // Pre-load the next target bytecode into EBX | |
1544 __ load_unsigned_byte(rbx, Address(rsi, rdx, Address::times_1, 0)); | |
1545 | |
1546 // compute return address as bci in rax, | |
304 | 1547 __ lea(rax, at_bcp((is_wide ? 5 : 3) - in_bytes(constMethodOopDesc::codes_offset()))); |
1548 __ subptr(rax, Address(rcx, methodOopDesc::const_offset())); | |
362 | 1549 // Adjust the bcp in RSI by the displacement in EDX |
304 | 1550 __ addptr(rsi, rdx); |
0 | 1551 // Push return address |
1552 __ push_i(rax); | |
1553 // jsr returns vtos | |
1554 __ dispatch_only_noverify(vtos); | |
1555 return; | |
1556 } | |
1557 | |
1558 // Normal (non-jsr) branch handling | |
1559 | |
362 | 1560 // Adjust the bcp in RSI by the displacement in EDX |
304 | 1561 __ addptr(rsi, rdx); |
0 | 1562 |
1563 assert(UseLoopCounter || !UseOnStackReplacement, "on-stack-replacement requires loop counters"); | |
1564 Label backedge_counter_overflow; | |
1565 Label profile_method; | |
1566 Label dispatch; | |
1567 if (UseLoopCounter) { | |
1568 // increment backedge counter for backward branches | |
1569 // rax,: MDO | |
1570 // rbx,: MDO bumped taken-count | |
1571 // rcx: method | |
1572 // rdx: target offset | |
1573 // rsi: target bcp | |
1574 // rdi: locals pointer | |
1575 __ testl(rdx, rdx); // check if forward or backward branch | |
1576 __ jcc(Assembler::positive, dispatch); // count only if backward branch | |
1577 | |
1783 | 1578 if (TieredCompilation) { |
1579 Label no_mdo; | |
1580 int increment = InvocationCounter::count_increment; | |
1581 int mask = ((1 << Tier0BackedgeNotifyFreqLog) - 1) << InvocationCounter::count_shift; | |
1582 if (ProfileInterpreter) { | |
1583 // Are we profiling? | |
1584 __ movptr(rbx, Address(rcx, in_bytes(methodOopDesc::method_data_offset()))); | |
1585 __ testptr(rbx, rbx); | |
1586 __ jccb(Assembler::zero, no_mdo); | |
1587 // Increment the MDO backedge counter | |
1588 const Address mdo_backedge_counter(rbx, in_bytes(methodDataOopDesc::backedge_counter_offset()) + | |
1589 in_bytes(InvocationCounter::counter_offset())); | |
1590 __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, | |
1591 rax, false, Assembler::zero, &backedge_counter_overflow); | |
1592 __ jmp(dispatch); | |
0 | 1593 } |
1783 | 1594 __ bind(no_mdo); |
1595 // Increment backedge counter in methodOop | |
1596 __ increment_mask_and_jump(Address(rcx, be_offset), increment, mask, | |
1597 rax, false, Assembler::zero, &backedge_counter_overflow); | |
0 | 1598 } else { |
1783 | 1599 // increment counter |
1600 __ movl(rax, Address(rcx, be_offset)); // load backedge counter | |
1601 __ incrementl(rax, InvocationCounter::count_increment); // increment counter | |
1602 __ movl(Address(rcx, be_offset), rax); // store counter | |
1603 | |
1604 __ movl(rax, Address(rcx, inv_offset)); // load invocation counter | |
1605 __ andl(rax, InvocationCounter::count_mask_value); // and the status bits | |
1606 __ addl(rax, Address(rcx, be_offset)); // add both counters | |
1607 | |
1608 if (ProfileInterpreter) { | |
1609 // Test to see if we should create a method data oop | |
0 | 1610 __ cmp32(rax, |
1783 | 1611 ExternalAddress((address) &InvocationCounter::InterpreterProfileLimit)); |
1612 __ jcc(Assembler::less, dispatch); | |
1613 | |
1614 // if no method data exists, go to profile method | |
1615 __ test_method_data_pointer(rax, profile_method); | |
1616 | |
1617 if (UseOnStackReplacement) { | |
1618 // check for overflow against rbx, which is the MDO taken count | |
1619 __ cmp32(rbx, | |
1620 ExternalAddress((address) &InvocationCounter::InterpreterBackwardBranchLimit)); | |
1621 __ jcc(Assembler::below, dispatch); | |
1622 | |
1623 // When ProfileInterpreter is on, the backedge_count comes from the | |
1624 // methodDataOop, which value does not get reset on the call to | |
1625 // frequency_counter_overflow(). To avoid excessive calls to the overflow | |
1626 // routine while the method is being compiled, add a second test to make | |
1627 // sure the overflow function is called only once every overflow_frequency. | |
1628 const int overflow_frequency = 1024; | |
1629 __ andptr(rbx, overflow_frequency-1); | |
1630 __ jcc(Assembler::zero, backedge_counter_overflow); | |
1631 } | |
1632 } else { | |
1633 if (UseOnStackReplacement) { | |
1634 // check for overflow against rax, which is the sum of the counters | |
1635 __ cmp32(rax, | |
1636 ExternalAddress((address) &InvocationCounter::InterpreterBackwardBranchLimit)); | |
1637 __ jcc(Assembler::aboveEqual, backedge_counter_overflow); | |
1638 | |
1639 } | |
0 | 1640 } |
1641 } | |
1642 __ bind(dispatch); | |
1643 } | |
1644 | |
1645 // Pre-load the next target bytecode into EBX | |
1646 __ load_unsigned_byte(rbx, Address(rsi, 0)); | |
1647 | |
1648 // continue with the bytecode @ target | |
1649 // rax,: return bci for jsr's, unused otherwise | |
1650 // rbx,: target bytecode | |
1651 // rsi: target bcp | |
1652 __ dispatch_only(vtos); | |
1653 | |
1654 if (UseLoopCounter) { | |
1655 if (ProfileInterpreter) { | |
1656 // Out-of-line code to allocate method data oop. | |
1657 __ bind(profile_method); | |
1658 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method), rsi); | |
1659 __ load_unsigned_byte(rbx, Address(rsi, 0)); // restore target bytecode | |
304 | 1660 __ movptr(rcx, Address(rbp, method_offset)); |
1661 __ movptr(rcx, Address(rcx, in_bytes(methodOopDesc::method_data_offset()))); | |
1662 __ movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), rcx); | |
0 | 1663 __ test_method_data_pointer(rcx, dispatch); |
1664 // offset non-null mdp by MDO::data_offset() + IR::profile_method() | |
304 | 1665 __ addptr(rcx, in_bytes(methodDataOopDesc::data_offset())); |
1666 __ addptr(rcx, rax); | |
1667 __ movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), rcx); | |
0 | 1668 __ jmp(dispatch); |
1669 } | |
1670 | |
1671 if (UseOnStackReplacement) { | |
1672 | |
1673 // invocation counter overflow | |
1674 __ bind(backedge_counter_overflow); | |
304 | 1675 __ negptr(rdx); |
1676 __ addptr(rdx, rsi); // branch bcp | |
0 | 1677 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), rdx); |
1678 __ load_unsigned_byte(rbx, Address(rsi, 0)); // restore target bytecode | |
1679 | |
1680 // rax,: osr nmethod (osr ok) or NULL (osr not possible) | |
1681 // rbx,: target bytecode | |
1682 // rdx: scratch | |
1683 // rdi: locals pointer | |
1684 // rsi: bcp | |
304 | 1685 __ testptr(rax, rax); // test result |
0 | 1686 __ jcc(Assembler::zero, dispatch); // no osr if null |
1687 // nmethod may have been invalidated (VM may block upon call_VM return) | |
1688 __ movl(rcx, Address(rax, nmethod::entry_bci_offset())); | |
1689 __ cmpl(rcx, InvalidOSREntryBci); | |
1690 __ jcc(Assembler::equal, dispatch); | |
1691 | |
1692 // We have the address of an on stack replacement routine in rax, | |
1693 // We need to prepare to execute the OSR method. First we must | |
1694 // migrate the locals and monitors off of the stack. | |
1695 | |
304 | 1696 __ mov(rbx, rax); // save the nmethod |
0 | 1697 |
1698 const Register thread = rcx; | |
1699 __ get_thread(thread); | |
1700 call_VM(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_begin)); | |
1701 // rax, is OSR buffer, move it to expected parameter location | |
304 | 1702 __ mov(rcx, rax); |
0 | 1703 |
1704 // pop the interpreter frame | |
304 | 1705 __ movptr(rdx, Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize)); // get sender sp |
0 | 1706 __ leave(); // remove frame anchor |
304 | 1707 __ pop(rdi); // get return address |
1708 __ mov(rsp, rdx); // set sp to sender sp | |
0 | 1709 |
1710 | |
1711 Label skip; | |
1712 Label chkint; | |
1713 | |
1714 // The interpreter frame we have removed may be returning to | |
1715 // either the callstub or the interpreter. Since we will | |
1716 // now be returning from a compiled (OSR) nmethod we must | |
1717 // adjust the return to the return were it can handler compiled | |
1718 // results and clean the fpu stack. This is very similar to | |
1719 // what a i2c adapter must do. | |
1720 | |
1721 // Are we returning to the call stub? | |
1722 | |
1723 __ cmp32(rdi, ExternalAddress(StubRoutines::_call_stub_return_address)); | |
1724 __ jcc(Assembler::notEqual, chkint); | |
1725 | |
1726 // yes adjust to the specialized call stub return. | |
304 | 1727 assert(StubRoutines::x86::get_call_stub_compiled_return() != NULL, "must be set"); |
1728 __ lea(rdi, ExternalAddress(StubRoutines::x86::get_call_stub_compiled_return())); | |
0 | 1729 __ jmp(skip); |
1730 | |
1731 __ bind(chkint); | |
1732 | |
1733 // Are we returning to the interpreter? Look for sentinel | |
1734 | |
304 | 1735 __ cmpl(Address(rdi, -2*wordSize), Interpreter::return_sentinel); |
0 | 1736 __ jcc(Assembler::notEqual, skip); |
1737 | |
1738 // Adjust to compiled return back to interpreter | |
1739 | |
304 | 1740 __ movptr(rdi, Address(rdi, -wordSize)); |
0 | 1741 __ bind(skip); |
1742 | |
1743 // Align stack pointer for compiled code (note that caller is | |
1744 // responsible for undoing this fixup by remembering the old SP | |
1745 // in an rbp,-relative location) | |
304 | 1746 __ andptr(rsp, -(StackAlignmentInBytes)); |
0 | 1747 |
1748 // push the (possibly adjusted) return address | |
304 | 1749 __ push(rdi); |
0 | 1750 |
1751 // and begin the OSR nmethod | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
1752 __ jmp(Address(rbx, nmethod::osr_entry_point_offset())); |
0 | 1753 } |
1754 } | |
1755 } | |
1756 | |
1757 | |
1758 void TemplateTable::if_0cmp(Condition cc) { | |
1759 transition(itos, vtos); | |
1760 // assume branch is more often taken than not (loops use backward branches) | |
1761 Label not_taken; | |
1762 __ testl(rax, rax); | |
1763 __ jcc(j_not(cc), not_taken); | |
1764 branch(false, false); | |
1765 __ bind(not_taken); | |
1766 __ profile_not_taken_branch(rax); | |
1767 } | |
1768 | |
1769 | |
1770 void TemplateTable::if_icmp(Condition cc) { | |
1771 transition(itos, vtos); | |
1772 // assume branch is more often taken than not (loops use backward branches) | |
1773 Label not_taken; | |
1774 __ pop_i(rdx); | |
1775 __ cmpl(rdx, rax); | |
1776 __ jcc(j_not(cc), not_taken); | |
1777 branch(false, false); | |
1778 __ bind(not_taken); | |
1779 __ profile_not_taken_branch(rax); | |
1780 } | |
1781 | |
1782 | |
1783 void TemplateTable::if_nullcmp(Condition cc) { | |
1784 transition(atos, vtos); | |
1785 // assume branch is more often taken than not (loops use backward branches) | |
1786 Label not_taken; | |
304 | 1787 __ testptr(rax, rax); |
0 | 1788 __ jcc(j_not(cc), not_taken); |
1789 branch(false, false); | |
1790 __ bind(not_taken); | |
1791 __ profile_not_taken_branch(rax); | |
1792 } | |
1793 | |
1794 | |
1795 void TemplateTable::if_acmp(Condition cc) { | |
1796 transition(atos, vtos); | |
1797 // assume branch is more often taken than not (loops use backward branches) | |
1798 Label not_taken; | |
1799 __ pop_ptr(rdx); | |
304 | 1800 __ cmpptr(rdx, rax); |
0 | 1801 __ jcc(j_not(cc), not_taken); |
1802 branch(false, false); | |
1803 __ bind(not_taken); | |
1804 __ profile_not_taken_branch(rax); | |
1805 } | |
1806 | |
1807 | |
1808 void TemplateTable::ret() { | |
1809 transition(vtos, vtos); | |
1810 locals_index(rbx); | |
304 | 1811 __ movptr(rbx, iaddress(rbx)); // get return bci, compute return bcp |
0 | 1812 __ profile_ret(rbx, rcx); |
1813 __ get_method(rax); | |
304 | 1814 __ movptr(rsi, Address(rax, methodOopDesc::const_offset())); |
1815 __ lea(rsi, Address(rsi, rbx, Address::times_1, | |
1816 constMethodOopDesc::codes_offset())); | |
0 | 1817 __ dispatch_next(vtos); |
1818 } | |
1819 | |
1820 | |
1821 void TemplateTable::wide_ret() { | |
1822 transition(vtos, vtos); | |
1823 locals_index_wide(rbx); | |
304 | 1824 __ movptr(rbx, iaddress(rbx)); // get return bci, compute return bcp |
0 | 1825 __ profile_ret(rbx, rcx); |
1826 __ get_method(rax); | |
304 | 1827 __ movptr(rsi, Address(rax, methodOopDesc::const_offset())); |
1828 __ lea(rsi, Address(rsi, rbx, Address::times_1, constMethodOopDesc::codes_offset())); | |
0 | 1829 __ dispatch_next(vtos); |
1830 } | |
1831 | |
1832 | |
1833 void TemplateTable::tableswitch() { | |
1834 Label default_case, continue_execution; | |
1835 transition(itos, vtos); | |
1836 // align rsi | |
304 | 1837 __ lea(rbx, at_bcp(wordSize)); |
1838 __ andptr(rbx, -wordSize); | |
0 | 1839 // load lo & hi |
1840 __ movl(rcx, Address(rbx, 1 * wordSize)); | |
1841 __ movl(rdx, Address(rbx, 2 * wordSize)); | |
304 | 1842 __ bswapl(rcx); |
1843 __ bswapl(rdx); | |
0 | 1844 // check against lo & hi |
1845 __ cmpl(rax, rcx); | |
1846 __ jccb(Assembler::less, default_case); | |
1847 __ cmpl(rax, rdx); | |
1848 __ jccb(Assembler::greater, default_case); | |
1849 // lookup dispatch offset | |
1850 __ subl(rax, rcx); | |
304 | 1851 __ movl(rdx, Address(rbx, rax, Address::times_4, 3 * BytesPerInt)); |
0 | 1852 __ profile_switch_case(rax, rbx, rcx); |
1853 // continue execution | |
1854 __ bind(continue_execution); | |
304 | 1855 __ bswapl(rdx); |
0 | 1856 __ load_unsigned_byte(rbx, Address(rsi, rdx, Address::times_1)); |
304 | 1857 __ addptr(rsi, rdx); |
0 | 1858 __ dispatch_only(vtos); |
1859 // handle default | |
1860 __ bind(default_case); | |
1861 __ profile_switch_default(rax); | |
1862 __ movl(rdx, Address(rbx, 0)); | |
1863 __ jmp(continue_execution); | |
1864 } | |
1865 | |
1866 | |
1867 void TemplateTable::lookupswitch() { | |
1868 transition(itos, itos); | |
1869 __ stop("lookupswitch bytecode should have been rewritten"); | |
1870 } | |
1871 | |
1872 | |
1873 void TemplateTable::fast_linearswitch() { | |
1874 transition(itos, vtos); | |
1875 Label loop_entry, loop, found, continue_execution; | |
304 | 1876 // bswapl rax, so we can avoid bswapping the table entries |
1877 __ bswapl(rax); | |
0 | 1878 // align rsi |
304 | 1879 __ lea(rbx, at_bcp(wordSize)); // btw: should be able to get rid of this instruction (change offsets below) |
1880 __ andptr(rbx, -wordSize); | |
0 | 1881 // set counter |
1882 __ movl(rcx, Address(rbx, wordSize)); | |
304 | 1883 __ bswapl(rcx); |
0 | 1884 __ jmpb(loop_entry); |
1885 // table search | |
1886 __ bind(loop); | |
1887 __ cmpl(rax, Address(rbx, rcx, Address::times_8, 2 * wordSize)); | |
1888 __ jccb(Assembler::equal, found); | |
1889 __ bind(loop_entry); | |
304 | 1890 __ decrementl(rcx); |
0 | 1891 __ jcc(Assembler::greaterEqual, loop); |
1892 // default case | |
1893 __ profile_switch_default(rax); | |
1894 __ movl(rdx, Address(rbx, 0)); | |
1895 __ jmpb(continue_execution); | |
1896 // entry found -> get offset | |
1897 __ bind(found); | |
1898 __ movl(rdx, Address(rbx, rcx, Address::times_8, 3 * wordSize)); | |
1899 __ profile_switch_case(rcx, rax, rbx); | |
1900 // continue execution | |
1901 __ bind(continue_execution); | |
304 | 1902 __ bswapl(rdx); |
0 | 1903 __ load_unsigned_byte(rbx, Address(rsi, rdx, Address::times_1)); |
304 | 1904 __ addptr(rsi, rdx); |
0 | 1905 __ dispatch_only(vtos); |
1906 } | |
1907 | |
1908 | |
1909 void TemplateTable::fast_binaryswitch() { | |
1910 transition(itos, vtos); | |
1911 // Implementation using the following core algorithm: | |
1912 // | |
1913 // int binary_search(int key, LookupswitchPair* array, int n) { | |
1914 // // Binary search according to "Methodik des Programmierens" by | |
1915 // // Edsger W. Dijkstra and W.H.J. Feijen, Addison Wesley Germany 1985. | |
1916 // int i = 0; | |
1917 // int j = n; | |
1918 // while (i+1 < j) { | |
1919 // // invariant P: 0 <= i < j <= n and (a[i] <= key < a[j] or Q) | |
1920 // // with Q: for all i: 0 <= i < n: key < a[i] | |
1921 // // where a stands for the array and assuming that the (inexisting) | |
1922 // // element a[n] is infinitely big. | |
1923 // int h = (i + j) >> 1; | |
1924 // // i < h < j | |
1925 // if (key < array[h].fast_match()) { | |
1926 // j = h; | |
1927 // } else { | |
1928 // i = h; | |
1929 // } | |
1930 // } | |
1931 // // R: a[i] <= key < a[i+1] or Q | |
1932 // // (i.e., if key is within array, i is the correct index) | |
1933 // return i; | |
1934 // } | |
1935 | |
1936 // register allocation | |
1937 const Register key = rax; // already set (tosca) | |
1938 const Register array = rbx; | |
1939 const Register i = rcx; | |
1940 const Register j = rdx; | |
1941 const Register h = rdi; // needs to be restored | |
1942 const Register temp = rsi; | |
1943 // setup array | |
1944 __ save_bcp(); | |
1945 | |
304 | 1946 __ lea(array, at_bcp(3*wordSize)); // btw: should be able to get rid of this instruction (change offsets below) |
1947 __ andptr(array, -wordSize); | |
0 | 1948 // initialize i & j |
1949 __ xorl(i, i); // i = 0; | |
1950 __ movl(j, Address(array, -wordSize)); // j = length(array); | |
1951 // Convert j into native byteordering | |
304 | 1952 __ bswapl(j); |
0 | 1953 // and start |
1954 Label entry; | |
1955 __ jmp(entry); | |
1956 | |
1957 // binary search loop | |
1958 { Label loop; | |
1959 __ bind(loop); | |
1960 // int h = (i + j) >> 1; | |
1961 __ leal(h, Address(i, j, Address::times_1)); // h = i + j; | |
1962 __ sarl(h, 1); // h = (i + j) >> 1; | |
1963 // if (key < array[h].fast_match()) { | |
1964 // j = h; | |
1965 // } else { | |
1966 // i = h; | |
1967 // } | |
1968 // Convert array[h].match to native byte-ordering before compare | |
1969 __ movl(temp, Address(array, h, Address::times_8, 0*wordSize)); | |
304 | 1970 __ bswapl(temp); |
0 | 1971 __ cmpl(key, temp); |
1972 if (VM_Version::supports_cmov()) { | |
1973 __ cmovl(Assembler::less , j, h); // j = h if (key < array[h].fast_match()) | |
1974 __ cmovl(Assembler::greaterEqual, i, h); // i = h if (key >= array[h].fast_match()) | |
1975 } else { | |
1976 Label set_i, end_of_if; | |
304 | 1977 __ jccb(Assembler::greaterEqual, set_i); // { |
1978 __ mov(j, h); // j = h; | |
1979 __ jmp(end_of_if); // } | |
1980 __ bind(set_i); // else { | |
1981 __ mov(i, h); // i = h; | |
1982 __ bind(end_of_if); // } | |
0 | 1983 } |
1984 // while (i+1 < j) | |
1985 __ bind(entry); | |
1986 __ leal(h, Address(i, 1)); // i+1 | |
1987 __ cmpl(h, j); // i+1 < j | |
1988 __ jcc(Assembler::less, loop); | |
1989 } | |
1990 | |
1991 // end of binary search, result index is i (must check again!) | |
1992 Label default_case; | |
1993 // Convert array[i].match to native byte-ordering before compare | |
1994 __ movl(temp, Address(array, i, Address::times_8, 0*wordSize)); | |
304 | 1995 __ bswapl(temp); |
0 | 1996 __ cmpl(key, temp); |
1997 __ jcc(Assembler::notEqual, default_case); | |
1998 | |
1999 // entry found -> j = offset | |
2000 __ movl(j , Address(array, i, Address::times_8, 1*wordSize)); | |
2001 __ profile_switch_case(i, key, array); | |
304 | 2002 __ bswapl(j); |
2003 LP64_ONLY(__ movslq(j, j)); | |
0 | 2004 __ restore_bcp(); |
2005 __ restore_locals(); // restore rdi | |
2006 __ load_unsigned_byte(rbx, Address(rsi, j, Address::times_1)); | |
2007 | |
304 | 2008 __ addptr(rsi, j); |
0 | 2009 __ dispatch_only(vtos); |
2010 | |
2011 // default case -> j = default offset | |
2012 __ bind(default_case); | |
2013 __ profile_switch_default(i); | |
2014 __ movl(j, Address(array, -2*wordSize)); | |
304 | 2015 __ bswapl(j); |
2016 LP64_ONLY(__ movslq(j, j)); | |
0 | 2017 __ restore_bcp(); |
2018 __ restore_locals(); // restore rdi | |
2019 __ load_unsigned_byte(rbx, Address(rsi, j, Address::times_1)); | |
304 | 2020 __ addptr(rsi, j); |
0 | 2021 __ dispatch_only(vtos); |
2022 } | |
2023 | |
2024 | |
2025 void TemplateTable::_return(TosState state) { | |
2026 transition(state, state); | |
2027 assert(_desc->calls_vm(), "inconsistent calls_vm information"); // call in remove_activation | |
2028 | |
2029 if (_desc->bytecode() == Bytecodes::_return_register_finalizer) { | |
2030 assert(state == vtos, "only valid state"); | |
304 | 2031 __ movptr(rax, aaddress(0)); |
2032 __ movptr(rdi, Address(rax, oopDesc::klass_offset_in_bytes())); | |
0 | 2033 __ movl(rdi, Address(rdi, Klass::access_flags_offset_in_bytes() + sizeof(oopDesc))); |
2034 __ testl(rdi, JVM_ACC_HAS_FINALIZER); | |
2035 Label skip_register_finalizer; | |
2036 __ jcc(Assembler::zero, skip_register_finalizer); | |
2037 | |
2038 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), rax); | |
2039 | |
2040 __ bind(skip_register_finalizer); | |
2041 } | |
2042 | |
2043 __ remove_activation(state, rsi); | |
2044 __ jmp(rsi); | |
2045 } | |
2046 | |
2047 | |
2048 // ---------------------------------------------------------------------------- | |
2049 // Volatile variables demand their effects be made known to all CPU's in | |
2050 // order. Store buffers on most chips allow reads & writes to reorder; the | |
2051 // JMM's ReadAfterWrite.java test fails in -Xint mode without some kind of | |
2052 // memory barrier (i.e., it's not sufficient that the interpreter does not | |
2053 // reorder volatile references, the hardware also must not reorder them). | |
2054 // | |
2055 // According to the new Java Memory Model (JMM): | |
2056 // (1) All volatiles are serialized wrt to each other. | |
2057 // ALSO reads & writes act as aquire & release, so: | |
2058 // (2) A read cannot let unrelated NON-volatile memory refs that happen after | |
2059 // the read float up to before the read. It's OK for non-volatile memory refs | |
2060 // that happen before the volatile read to float down below it. | |
2061 // (3) Similar a volatile write cannot let unrelated NON-volatile memory refs | |
2062 // that happen BEFORE the write float down to after the write. It's OK for | |
2063 // non-volatile memory refs that happen after the volatile write to float up | |
2064 // before it. | |
2065 // | |
2066 // We only put in barriers around volatile refs (they are expensive), not | |
2067 // _between_ memory refs (that would require us to track the flavor of the | |
2068 // previous memory refs). Requirements (2) and (3) require some barriers | |
2069 // before volatile stores and after volatile loads. These nearly cover | |
2070 // requirement (1) but miss the volatile-store-volatile-load case. This final | |
2071 // case is placed after volatile-stores although it could just as well go | |
2072 // before volatile-loads. | |
304 | 2073 void TemplateTable::volatile_barrier(Assembler::Membar_mask_bits order_constraint ) { |
0 | 2074 // Helper function to insert a is-volatile test and memory barrier |
2075 if( !os::is_MP() ) return; // Not needed on single CPU | |
304 | 2076 __ membar(order_constraint); |
0 | 2077 } |
2078 | |
1565 | 2079 void TemplateTable::resolve_cache_and_index(int byte_no, |
2080 Register result, | |
2081 Register Rcache, | |
2082 Register index, | |
2083 size_t index_size) { | |
0 | 2084 Register temp = rbx; |
2085 | |
1565 | 2086 assert_different_registers(result, Rcache, index, temp); |
2087 | |
0 | 2088 Label resolved; |
1565 | 2089 __ get_cache_and_index_at_bcp(Rcache, index, 1, index_size); |
2090 if (byte_no == f1_oop) { | |
2091 // We are resolved if the f1 field contains a non-null object (CallSite, etc.) | |
2092 // This kind of CP cache entry does not need to match the flags byte, because | |
2093 // there is a 1-1 relation between bytecode type and CP entry type. | |
2094 assert(result != noreg, ""); //else do cmpptr(Address(...), (int32_t) NULL_WORD) | |
2095 __ movptr(result, Address(Rcache, index, Address::times_ptr, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::f1_offset())); | |
2096 __ testptr(result, result); | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2097 __ jcc(Assembler::notEqual, resolved); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2098 } else { |
1565 | 2099 assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range"); |
2100 assert(result == noreg, ""); //else change code for setting result | |
2101 const int shift_count = (1 + byte_no)*BitsPerByte; | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2102 __ movl(temp, Address(Rcache, index, Address::times_4, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::indices_offset())); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2103 __ shrl(temp, shift_count); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2104 // have we resolved this bytecode? |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2105 __ andl(temp, 0xFF); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2106 __ cmpl(temp, (int)bytecode()); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2107 __ jcc(Assembler::equal, resolved); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2108 } |
0 | 2109 |
2110 // resolve first time through | |
2111 address entry; | |
2112 switch (bytecode()) { | |
2113 case Bytecodes::_getstatic : // fall through | |
2114 case Bytecodes::_putstatic : // fall through | |
2115 case Bytecodes::_getfield : // fall through | |
2116 case Bytecodes::_putfield : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_get_put); break; | |
2117 case Bytecodes::_invokevirtual : // fall through | |
2118 case Bytecodes::_invokespecial : // fall through | |
2119 case Bytecodes::_invokestatic : // fall through | |
2120 case Bytecodes::_invokeinterface: entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invoke); break; | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2121 case Bytecodes::_invokedynamic : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokedynamic); break; |
1602 | 2122 case Bytecodes::_fast_aldc : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc); break; |
2123 case Bytecodes::_fast_aldc_w : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc); break; | |
0 | 2124 default : ShouldNotReachHere(); break; |
2125 } | |
2126 __ movl(temp, (int)bytecode()); | |
2127 __ call_VM(noreg, entry, temp); | |
2128 // Update registers with resolved info | |
1565 | 2129 __ get_cache_and_index_at_bcp(Rcache, index, 1, index_size); |
2130 if (result != noreg) | |
2131 __ movptr(result, Address(Rcache, index, Address::times_ptr, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::f1_offset())); | |
0 | 2132 __ bind(resolved); |
2133 } | |
2134 | |
2135 | |
2136 // The cache and index registers must be set before call | |
2137 void TemplateTable::load_field_cp_cache_entry(Register obj, | |
2138 Register cache, | |
2139 Register index, | |
2140 Register off, | |
2141 Register flags, | |
2142 bool is_static = false) { | |
2143 assert_different_registers(cache, index, flags, off); | |
2144 | |
2145 ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset(); | |
2146 // Field offset | |
304 | 2147 __ movptr(off, Address(cache, index, Address::times_ptr, |
2148 in_bytes(cp_base_offset + ConstantPoolCacheEntry::f2_offset()))); | |
0 | 2149 // Flags |
304 | 2150 __ movl(flags, Address(cache, index, Address::times_ptr, |
0 | 2151 in_bytes(cp_base_offset + ConstantPoolCacheEntry::flags_offset()))); |
2152 | |
2153 // klass overwrite register | |
2154 if (is_static) { | |
304 | 2155 __ movptr(obj, Address(cache, index, Address::times_ptr, |
2156 in_bytes(cp_base_offset + ConstantPoolCacheEntry::f1_offset()))); | |
0 | 2157 } |
2158 } | |
2159 | |
2160 void TemplateTable::load_invoke_cp_cache_entry(int byte_no, | |
2161 Register method, | |
2162 Register itable_index, | |
2163 Register flags, | |
2164 bool is_invokevirtual, | |
1565 | 2165 bool is_invokevfinal /*unused*/, |
2166 bool is_invokedynamic) { | |
0 | 2167 // setup registers |
2168 const Register cache = rcx; | |
2169 const Register index = rdx; | |
2170 assert_different_registers(method, flags); | |
2171 assert_different_registers(method, cache, index); | |
2172 assert_different_registers(itable_index, flags); | |
2173 assert_different_registers(itable_index, cache, index); | |
2174 // determine constant pool cache field offsets | |
2175 const int method_offset = in_bytes( | |
2176 constantPoolCacheOopDesc::base_offset() + | |
2177 (is_invokevirtual | |
2178 ? ConstantPoolCacheEntry::f2_offset() | |
2179 : ConstantPoolCacheEntry::f1_offset() | |
2180 ) | |
2181 ); | |
2182 const int flags_offset = in_bytes(constantPoolCacheOopDesc::base_offset() + | |
2183 ConstantPoolCacheEntry::flags_offset()); | |
2184 // access constant pool cache fields | |
2185 const int index_offset = in_bytes(constantPoolCacheOopDesc::base_offset() + | |
2186 ConstantPoolCacheEntry::f2_offset()); | |
2187 | |
1565 | 2188 if (byte_no == f1_oop) { |
2189 // Resolved f1_oop goes directly into 'method' register. | |
2190 assert(is_invokedynamic, ""); | |
2191 resolve_cache_and_index(byte_no, method, cache, index, sizeof(u4)); | |
2192 } else { | |
2193 resolve_cache_and_index(byte_no, noreg, cache, index, sizeof(u2)); | |
2194 __ movptr(method, Address(cache, index, Address::times_ptr, method_offset)); | |
2195 } | |
0 | 2196 if (itable_index != noreg) { |
304 | 2197 __ movptr(itable_index, Address(cache, index, Address::times_ptr, index_offset)); |
0 | 2198 } |
1565 | 2199 __ movl(flags, Address(cache, index, Address::times_ptr, flags_offset)); |
0 | 2200 } |
2201 | |
2202 | |
2203 // The registers cache and index expected to be set before call. | |
2204 // Correct values of the cache and index registers are preserved. | |
2205 void TemplateTable::jvmti_post_field_access(Register cache, | |
2206 Register index, | |
2207 bool is_static, | |
2208 bool has_tos) { | |
2209 if (JvmtiExport::can_post_field_access()) { | |
2210 // Check to see if a field access watch has been set before we take | |
2211 // the time to call into the VM. | |
2212 Label L1; | |
2213 assert_different_registers(cache, index, rax); | |
2214 __ mov32(rax, ExternalAddress((address) JvmtiExport::get_field_access_count_addr())); | |
2215 __ testl(rax,rax); | |
2216 __ jcc(Assembler::zero, L1); | |
2217 | |
2218 // cache entry pointer | |
304 | 2219 __ addptr(cache, in_bytes(constantPoolCacheOopDesc::base_offset())); |
0 | 2220 __ shll(index, LogBytesPerWord); |
304 | 2221 __ addptr(cache, index); |
0 | 2222 if (is_static) { |
304 | 2223 __ xorptr(rax, rax); // NULL object reference |
0 | 2224 } else { |
2225 __ pop(atos); // Get the object | |
2226 __ verify_oop(rax); | |
2227 __ push(atos); // Restore stack state | |
2228 } | |
2229 // rax,: object pointer or NULL | |
2230 // cache: cache entry pointer | |
2231 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_access), | |
2232 rax, cache); | |
2233 __ get_cache_and_index_at_bcp(cache, index, 1); | |
2234 __ bind(L1); | |
2235 } | |
2236 } | |
2237 | |
2238 void TemplateTable::pop_and_check_object(Register r) { | |
2239 __ pop_ptr(r); | |
2240 __ null_check(r); // for field access must check obj. | |
2241 __ verify_oop(r); | |
2242 } | |
2243 | |
2244 void TemplateTable::getfield_or_static(int byte_no, bool is_static) { | |
2245 transition(vtos, vtos); | |
2246 | |
2247 const Register cache = rcx; | |
2248 const Register index = rdx; | |
2249 const Register obj = rcx; | |
2250 const Register off = rbx; | |
2251 const Register flags = rax; | |
2252 | |
1565 | 2253 resolve_cache_and_index(byte_no, noreg, cache, index, sizeof(u2)); |
0 | 2254 jvmti_post_field_access(cache, index, is_static, false); |
2255 load_field_cp_cache_entry(obj, cache, index, off, flags, is_static); | |
2256 | |
2257 if (!is_static) pop_and_check_object(obj); | |
2258 | |
2259 const Address lo(obj, off, Address::times_1, 0*wordSize); | |
2260 const Address hi(obj, off, Address::times_1, 1*wordSize); | |
2261 | |
2262 Label Done, notByte, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; | |
2263 | |
2264 __ shrl(flags, ConstantPoolCacheEntry::tosBits); | |
2265 assert(btos == 0, "change code, btos != 0"); | |
2266 // btos | |
304 | 2267 __ andptr(flags, 0x0f); |
0 | 2268 __ jcc(Assembler::notZero, notByte); |
2269 | |
2270 __ load_signed_byte(rax, lo ); | |
2271 __ push(btos); | |
2272 // Rewrite bytecode to be faster | |
2273 if (!is_static) { | |
2274 patch_bytecode(Bytecodes::_fast_bgetfield, rcx, rbx); | |
2275 } | |
2276 __ jmp(Done); | |
2277 | |
2278 __ bind(notByte); | |
2279 // itos | |
2280 __ cmpl(flags, itos ); | |
2281 __ jcc(Assembler::notEqual, notInt); | |
2282 | |
2283 __ movl(rax, lo ); | |
2284 __ push(itos); | |
2285 // Rewrite bytecode to be faster | |
2286 if (!is_static) { | |
2287 patch_bytecode(Bytecodes::_fast_igetfield, rcx, rbx); | |
2288 } | |
2289 __ jmp(Done); | |
2290 | |
2291 __ bind(notInt); | |
2292 // atos | |
2293 __ cmpl(flags, atos ); | |
2294 __ jcc(Assembler::notEqual, notObj); | |
2295 | |
2296 __ movl(rax, lo ); | |
2297 __ push(atos); | |
2298 if (!is_static) { | |
2299 patch_bytecode(Bytecodes::_fast_agetfield, rcx, rbx); | |
2300 } | |
2301 __ jmp(Done); | |
2302 | |
2303 __ bind(notObj); | |
2304 // ctos | |
2305 __ cmpl(flags, ctos ); | |
2306 __ jcc(Assembler::notEqual, notChar); | |
2307 | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
2308 __ load_unsigned_short(rax, lo ); |
0 | 2309 __ push(ctos); |
2310 if (!is_static) { | |
2311 patch_bytecode(Bytecodes::_fast_cgetfield, rcx, rbx); | |
2312 } | |
2313 __ jmp(Done); | |
2314 | |
2315 __ bind(notChar); | |
2316 // stos | |
2317 __ cmpl(flags, stos ); | |
2318 __ jcc(Assembler::notEqual, notShort); | |
2319 | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
2320 __ load_signed_short(rax, lo ); |
0 | 2321 __ push(stos); |
2322 if (!is_static) { | |
2323 patch_bytecode(Bytecodes::_fast_sgetfield, rcx, rbx); | |
2324 } | |
2325 __ jmp(Done); | |
2326 | |
2327 __ bind(notShort); | |
2328 // ltos | |
2329 __ cmpl(flags, ltos ); | |
2330 __ jcc(Assembler::notEqual, notLong); | |
2331 | |
2332 // Generate code as if volatile. There just aren't enough registers to | |
2333 // save that information and this code is faster than the test. | |
2334 __ fild_d(lo); // Must load atomically | |
304 | 2335 __ subptr(rsp,2*wordSize); // Make space for store |
0 | 2336 __ fistp_d(Address(rsp,0)); |
304 | 2337 __ pop(rax); |
2338 __ pop(rdx); | |
0 | 2339 |
2340 __ push(ltos); | |
2341 // Don't rewrite to _fast_lgetfield for potential volatile case. | |
2342 __ jmp(Done); | |
2343 | |
2344 __ bind(notLong); | |
2345 // ftos | |
2346 __ cmpl(flags, ftos ); | |
2347 __ jcc(Assembler::notEqual, notFloat); | |
2348 | |
2349 __ fld_s(lo); | |
2350 __ push(ftos); | |
2351 if (!is_static) { | |
2352 patch_bytecode(Bytecodes::_fast_fgetfield, rcx, rbx); | |
2353 } | |
2354 __ jmp(Done); | |
2355 | |
2356 __ bind(notFloat); | |
2357 // dtos | |
2358 __ cmpl(flags, dtos ); | |
2359 __ jcc(Assembler::notEqual, notDouble); | |
2360 | |
2361 __ fld_d(lo); | |
2362 __ push(dtos); | |
2363 if (!is_static) { | |
2364 patch_bytecode(Bytecodes::_fast_dgetfield, rcx, rbx); | |
2365 } | |
2366 __ jmpb(Done); | |
2367 | |
2368 __ bind(notDouble); | |
2369 | |
2370 __ stop("Bad state"); | |
2371 | |
2372 __ bind(Done); | |
2373 // Doug Lea believes this is not needed with current Sparcs (TSO) and Intel (PSO). | |
2374 // volatile_barrier( ); | |
2375 } | |
2376 | |
2377 | |
2378 void TemplateTable::getfield(int byte_no) { | |
2379 getfield_or_static(byte_no, false); | |
2380 } | |
2381 | |
2382 | |
2383 void TemplateTable::getstatic(int byte_no) { | |
2384 getfield_or_static(byte_no, true); | |
2385 } | |
2386 | |
2387 // The registers cache and index expected to be set before call. | |
2388 // The function may destroy various registers, just not the cache and index registers. | |
2389 void TemplateTable::jvmti_post_field_mod(Register cache, Register index, bool is_static) { | |
2390 | |
2391 ByteSize cp_base_offset = constantPoolCacheOopDesc::base_offset(); | |
2392 | |
2393 if (JvmtiExport::can_post_field_modification()) { | |
2394 // Check to see if a field modification watch has been set before we take | |
2395 // the time to call into the VM. | |
2396 Label L1; | |
2397 assert_different_registers(cache, index, rax); | |
2398 __ mov32(rax, ExternalAddress((address)JvmtiExport::get_field_modification_count_addr())); | |
2399 __ testl(rax, rax); | |
2400 __ jcc(Assembler::zero, L1); | |
2401 | |
2402 // The cache and index registers have been already set. | |
2403 // This allows to eliminate this call but the cache and index | |
2404 // registers have to be correspondingly used after this line. | |
2405 __ get_cache_and_index_at_bcp(rax, rdx, 1); | |
2406 | |
2407 if (is_static) { | |
2408 // Life is simple. Null out the object pointer. | |
304 | 2409 __ xorptr(rbx, rbx); |
0 | 2410 } else { |
2411 // Life is harder. The stack holds the value on top, followed by the object. | |
2412 // We don't know the size of the value, though; it could be one or two words | |
2413 // depending on its type. As a result, we must find the type to determine where | |
2414 // the object is. | |
2415 Label two_word, valsize_known; | |
304 | 2416 __ movl(rcx, Address(rax, rdx, Address::times_ptr, in_bytes(cp_base_offset + |
0 | 2417 ConstantPoolCacheEntry::flags_offset()))); |
304 | 2418 __ mov(rbx, rsp); |
0 | 2419 __ shrl(rcx, ConstantPoolCacheEntry::tosBits); |
2420 // Make sure we don't need to mask rcx for tosBits after the above shift | |
2421 ConstantPoolCacheEntry::verify_tosBits(); | |
2422 __ cmpl(rcx, ltos); | |
2423 __ jccb(Assembler::equal, two_word); | |
2424 __ cmpl(rcx, dtos); | |
2425 __ jccb(Assembler::equal, two_word); | |
304 | 2426 __ addptr(rbx, Interpreter::expr_offset_in_bytes(1)); // one word jvalue (not ltos, dtos) |
0 | 2427 __ jmpb(valsize_known); |
2428 | |
2429 __ bind(two_word); | |
304 | 2430 __ addptr(rbx, Interpreter::expr_offset_in_bytes(2)); // two words jvalue |
0 | 2431 |
2432 __ bind(valsize_known); | |
2433 // setup object pointer | |
304 | 2434 __ movptr(rbx, Address(rbx, 0)); |
0 | 2435 } |
2436 // cache entry pointer | |
304 | 2437 __ addptr(rax, in_bytes(cp_base_offset)); |
0 | 2438 __ shll(rdx, LogBytesPerWord); |
304 | 2439 __ addptr(rax, rdx); |
0 | 2440 // object (tos) |
304 | 2441 __ mov(rcx, rsp); |
0 | 2442 // rbx,: object pointer set up above (NULL if static) |
2443 // rax,: cache entry pointer | |
2444 // rcx: jvalue object on the stack | |
2445 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification), | |
2446 rbx, rax, rcx); | |
2447 __ get_cache_and_index_at_bcp(cache, index, 1); | |
2448 __ bind(L1); | |
2449 } | |
2450 } | |
2451 | |
2452 | |
2453 void TemplateTable::putfield_or_static(int byte_no, bool is_static) { | |
2454 transition(vtos, vtos); | |
2455 | |
2456 const Register cache = rcx; | |
2457 const Register index = rdx; | |
2458 const Register obj = rcx; | |
2459 const Register off = rbx; | |
2460 const Register flags = rax; | |
2461 | |
1565 | 2462 resolve_cache_and_index(byte_no, noreg, cache, index, sizeof(u2)); |
0 | 2463 jvmti_post_field_mod(cache, index, is_static); |
2464 load_field_cp_cache_entry(obj, cache, index, off, flags, is_static); | |
2465 | |
2466 // Doug Lea believes this is not needed with current Sparcs (TSO) and Intel (PSO). | |
2467 // volatile_barrier( ); | |
2468 | |
2469 Label notVolatile, Done; | |
2470 __ movl(rdx, flags); | |
2471 __ shrl(rdx, ConstantPoolCacheEntry::volatileField); | |
2472 __ andl(rdx, 0x1); | |
2473 | |
2474 // field addresses | |
2475 const Address lo(obj, off, Address::times_1, 0*wordSize); | |
2476 const Address hi(obj, off, Address::times_1, 1*wordSize); | |
2477 | |
2478 Label notByte, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; | |
2479 | |
2480 __ shrl(flags, ConstantPoolCacheEntry::tosBits); | |
2481 assert(btos == 0, "change code, btos != 0"); | |
2482 // btos | |
2483 __ andl(flags, 0x0f); | |
2484 __ jcc(Assembler::notZero, notByte); | |
2485 | |
2486 __ pop(btos); | |
2487 if (!is_static) pop_and_check_object(obj); | |
2488 __ movb(lo, rax ); | |
2489 if (!is_static) { | |
2490 patch_bytecode(Bytecodes::_fast_bputfield, rcx, rbx); | |
2491 } | |
2492 __ jmp(Done); | |
2493 | |
2494 __ bind(notByte); | |
2495 // itos | |
2496 __ cmpl(flags, itos ); | |
2497 __ jcc(Assembler::notEqual, notInt); | |
2498 | |
2499 __ pop(itos); | |
2500 if (!is_static) pop_and_check_object(obj); | |
2501 | |
2502 __ movl(lo, rax ); | |
2503 if (!is_static) { | |
2504 patch_bytecode(Bytecodes::_fast_iputfield, rcx, rbx); | |
2505 } | |
2506 __ jmp(Done); | |
2507 | |
2508 __ bind(notInt); | |
2509 // atos | |
2510 __ cmpl(flags, atos ); | |
2511 __ jcc(Assembler::notEqual, notObj); | |
2512 | |
2513 __ pop(atos); | |
2514 if (!is_static) pop_and_check_object(obj); | |
2515 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2516 do_oop_store(_masm, lo, rax, _bs->kind(), false); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2517 |
0 | 2518 if (!is_static) { |
2519 patch_bytecode(Bytecodes::_fast_aputfield, rcx, rbx); | |
2520 } | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2521 |
0 | 2522 __ jmp(Done); |
2523 | |
2524 __ bind(notObj); | |
2525 // ctos | |
2526 __ cmpl(flags, ctos ); | |
2527 __ jcc(Assembler::notEqual, notChar); | |
2528 | |
2529 __ pop(ctos); | |
2530 if (!is_static) pop_and_check_object(obj); | |
2531 __ movw(lo, rax ); | |
2532 if (!is_static) { | |
2533 patch_bytecode(Bytecodes::_fast_cputfield, rcx, rbx); | |
2534 } | |
2535 __ jmp(Done); | |
2536 | |
2537 __ bind(notChar); | |
2538 // stos | |
2539 __ cmpl(flags, stos ); | |
2540 __ jcc(Assembler::notEqual, notShort); | |
2541 | |
2542 __ pop(stos); | |
2543 if (!is_static) pop_and_check_object(obj); | |
2544 __ movw(lo, rax ); | |
2545 if (!is_static) { | |
2546 patch_bytecode(Bytecodes::_fast_sputfield, rcx, rbx); | |
2547 } | |
2548 __ jmp(Done); | |
2549 | |
2550 __ bind(notShort); | |
2551 // ltos | |
2552 __ cmpl(flags, ltos ); | |
2553 __ jcc(Assembler::notEqual, notLong); | |
2554 | |
2555 Label notVolatileLong; | |
2556 __ testl(rdx, rdx); | |
2557 __ jcc(Assembler::zero, notVolatileLong); | |
2558 | |
2559 __ pop(ltos); // overwrites rdx, do this after testing volatile. | |
2560 if (!is_static) pop_and_check_object(obj); | |
2561 | |
2562 // Replace with real volatile test | |
304 | 2563 __ push(rdx); |
2564 __ push(rax); // Must update atomically with FIST | |
0 | 2565 __ fild_d(Address(rsp,0)); // So load into FPU register |
2566 __ fistp_d(lo); // and put into memory atomically | |
304 | 2567 __ addptr(rsp, 2*wordSize); |
2568 // volatile_barrier(); | |
2569 volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad | | |
2570 Assembler::StoreStore)); | |
0 | 2571 // Don't rewrite volatile version |
2572 __ jmp(notVolatile); | |
2573 | |
2574 __ bind(notVolatileLong); | |
2575 | |
2576 __ pop(ltos); // overwrites rdx | |
2577 if (!is_static) pop_and_check_object(obj); | |
304 | 2578 NOT_LP64(__ movptr(hi, rdx)); |
2579 __ movptr(lo, rax); | |
0 | 2580 if (!is_static) { |
2581 patch_bytecode(Bytecodes::_fast_lputfield, rcx, rbx); | |
2582 } | |
2583 __ jmp(notVolatile); | |
2584 | |
2585 __ bind(notLong); | |
2586 // ftos | |
2587 __ cmpl(flags, ftos ); | |
2588 __ jcc(Assembler::notEqual, notFloat); | |
2589 | |
2590 __ pop(ftos); | |
2591 if (!is_static) pop_and_check_object(obj); | |
2592 __ fstp_s(lo); | |
2593 if (!is_static) { | |
2594 patch_bytecode(Bytecodes::_fast_fputfield, rcx, rbx); | |
2595 } | |
2596 __ jmp(Done); | |
2597 | |
2598 __ bind(notFloat); | |
2599 // dtos | |
2600 __ cmpl(flags, dtos ); | |
2601 __ jcc(Assembler::notEqual, notDouble); | |
2602 | |
2603 __ pop(dtos); | |
2604 if (!is_static) pop_and_check_object(obj); | |
2605 __ fstp_d(lo); | |
2606 if (!is_static) { | |
2607 patch_bytecode(Bytecodes::_fast_dputfield, rcx, rbx); | |
2608 } | |
2609 __ jmp(Done); | |
2610 | |
2611 __ bind(notDouble); | |
2612 | |
2613 __ stop("Bad state"); | |
2614 | |
2615 __ bind(Done); | |
2616 | |
2617 // Check for volatile store | |
2618 __ testl(rdx, rdx); | |
2619 __ jcc(Assembler::zero, notVolatile); | |
304 | 2620 volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad | |
2621 Assembler::StoreStore)); | |
0 | 2622 __ bind(notVolatile); |
2623 } | |
2624 | |
2625 | |
2626 void TemplateTable::putfield(int byte_no) { | |
2627 putfield_or_static(byte_no, false); | |
2628 } | |
2629 | |
2630 | |
2631 void TemplateTable::putstatic(int byte_no) { | |
2632 putfield_or_static(byte_no, true); | |
2633 } | |
2634 | |
2635 void TemplateTable::jvmti_post_fast_field_mod() { | |
2636 if (JvmtiExport::can_post_field_modification()) { | |
2637 // Check to see if a field modification watch has been set before we take | |
2638 // the time to call into the VM. | |
2639 Label L2; | |
2640 __ mov32(rcx, ExternalAddress((address)JvmtiExport::get_field_modification_count_addr())); | |
2641 __ testl(rcx,rcx); | |
2642 __ jcc(Assembler::zero, L2); | |
2643 __ pop_ptr(rbx); // copy the object pointer from tos | |
2644 __ verify_oop(rbx); | |
2645 __ push_ptr(rbx); // put the object pointer back on tos | |
304 | 2646 __ subptr(rsp, sizeof(jvalue)); // add space for a jvalue object |
2647 __ mov(rcx, rsp); | |
0 | 2648 __ push_ptr(rbx); // save object pointer so we can steal rbx, |
304 | 2649 __ xorptr(rbx, rbx); |
0 | 2650 const Address lo_value(rcx, rbx, Address::times_1, 0*wordSize); |
2651 const Address hi_value(rcx, rbx, Address::times_1, 1*wordSize); | |
2652 switch (bytecode()) { // load values into the jvalue object | |
2653 case Bytecodes::_fast_bputfield: __ movb(lo_value, rax); break; | |
2654 case Bytecodes::_fast_sputfield: __ movw(lo_value, rax); break; | |
2655 case Bytecodes::_fast_cputfield: __ movw(lo_value, rax); break; | |
2656 case Bytecodes::_fast_iputfield: __ movl(lo_value, rax); break; | |
304 | 2657 case Bytecodes::_fast_lputfield: |
2658 NOT_LP64(__ movptr(hi_value, rdx)); | |
2659 __ movptr(lo_value, rax); | |
2660 break; | |
2661 | |
0 | 2662 // need to call fld_s() after fstp_s() to restore the value for below |
2663 case Bytecodes::_fast_fputfield: __ fstp_s(lo_value); __ fld_s(lo_value); break; | |
304 | 2664 |
0 | 2665 // need to call fld_d() after fstp_d() to restore the value for below |
2666 case Bytecodes::_fast_dputfield: __ fstp_d(lo_value); __ fld_d(lo_value); break; | |
304 | 2667 |
0 | 2668 // since rcx is not an object we don't call store_check() here |
304 | 2669 case Bytecodes::_fast_aputfield: __ movptr(lo_value, rax); break; |
2670 | |
0 | 2671 default: ShouldNotReachHere(); |
2672 } | |
2673 __ pop_ptr(rbx); // restore copy of object pointer | |
2674 | |
2675 // Save rax, and sometimes rdx because call_VM() will clobber them, | |
2676 // then use them for JVM/DI purposes | |
304 | 2677 __ push(rax); |
2678 if (bytecode() == Bytecodes::_fast_lputfield) __ push(rdx); | |
0 | 2679 // access constant pool cache entry |
2680 __ get_cache_entry_pointer_at_bcp(rax, rdx, 1); | |
2681 __ verify_oop(rbx); | |
2682 // rbx,: object pointer copied above | |
2683 // rax,: cache entry pointer | |
2684 // rcx: jvalue object on the stack | |
2685 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification), rbx, rax, rcx); | |
304 | 2686 if (bytecode() == Bytecodes::_fast_lputfield) __ pop(rdx); // restore high value |
2687 __ pop(rax); // restore lower value | |
2688 __ addptr(rsp, sizeof(jvalue)); // release jvalue object space | |
0 | 2689 __ bind(L2); |
2690 } | |
2691 } | |
2692 | |
2693 void TemplateTable::fast_storefield(TosState state) { | |
2694 transition(state, vtos); | |
2695 | |
2696 ByteSize base = constantPoolCacheOopDesc::base_offset(); | |
2697 | |
2698 jvmti_post_fast_field_mod(); | |
2699 | |
2700 // access constant pool cache | |
2701 __ get_cache_and_index_at_bcp(rcx, rbx, 1); | |
2702 | |
2703 // test for volatile with rdx but rdx is tos register for lputfield. | |
304 | 2704 if (bytecode() == Bytecodes::_fast_lputfield) __ push(rdx); |
2705 __ movl(rdx, Address(rcx, rbx, Address::times_ptr, in_bytes(base + | |
0 | 2706 ConstantPoolCacheEntry::flags_offset()))); |
2707 | |
2708 // replace index with field offset from cache entry | |
304 | 2709 __ movptr(rbx, Address(rcx, rbx, Address::times_ptr, in_bytes(base + ConstantPoolCacheEntry::f2_offset()))); |
0 | 2710 |
2711 // Doug Lea believes this is not needed with current Sparcs (TSO) and Intel (PSO). | |
2712 // volatile_barrier( ); | |
2713 | |
2714 Label notVolatile, Done; | |
2715 __ shrl(rdx, ConstantPoolCacheEntry::volatileField); | |
2716 __ andl(rdx, 0x1); | |
2717 // Check for volatile store | |
2718 __ testl(rdx, rdx); | |
2719 __ jcc(Assembler::zero, notVolatile); | |
2720 | |
304 | 2721 if (bytecode() == Bytecodes::_fast_lputfield) __ pop(rdx); |
0 | 2722 |
2723 // Get object from stack | |
2724 pop_and_check_object(rcx); | |
2725 | |
2726 // field addresses | |
2727 const Address lo(rcx, rbx, Address::times_1, 0*wordSize); | |
2728 const Address hi(rcx, rbx, Address::times_1, 1*wordSize); | |
2729 | |
2730 // access field | |
2731 switch (bytecode()) { | |
2732 case Bytecodes::_fast_bputfield: __ movb(lo, rax); break; | |
2733 case Bytecodes::_fast_sputfield: // fall through | |
2734 case Bytecodes::_fast_cputfield: __ movw(lo, rax); break; | |
2735 case Bytecodes::_fast_iputfield: __ movl(lo, rax); break; | |
304 | 2736 case Bytecodes::_fast_lputfield: |
2737 NOT_LP64(__ movptr(hi, rdx)); | |
2738 __ movptr(lo, rax); | |
2739 break; | |
0 | 2740 case Bytecodes::_fast_fputfield: __ fstp_s(lo); break; |
2741 case Bytecodes::_fast_dputfield: __ fstp_d(lo); break; | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2742 case Bytecodes::_fast_aputfield: { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2743 do_oop_store(_masm, lo, rax, _bs->kind(), false); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2744 break; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2745 } |
0 | 2746 default: |
2747 ShouldNotReachHere(); | |
2748 } | |
2749 | |
2750 Label done; | |
304 | 2751 volatile_barrier(Assembler::Membar_mask_bits(Assembler::StoreLoad | |
2752 Assembler::StoreStore)); | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2753 // Barriers are so large that short branch doesn't reach! |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2754 __ jmp(done); |
0 | 2755 |
2756 // Same code as above, but don't need rdx to test for volatile. | |
2757 __ bind(notVolatile); | |
2758 | |
304 | 2759 if (bytecode() == Bytecodes::_fast_lputfield) __ pop(rdx); |
0 | 2760 |
2761 // Get object from stack | |
2762 pop_and_check_object(rcx); | |
2763 | |
2764 // access field | |
2765 switch (bytecode()) { | |
2766 case Bytecodes::_fast_bputfield: __ movb(lo, rax); break; | |
2767 case Bytecodes::_fast_sputfield: // fall through | |
2768 case Bytecodes::_fast_cputfield: __ movw(lo, rax); break; | |
2769 case Bytecodes::_fast_iputfield: __ movl(lo, rax); break; | |
304 | 2770 case Bytecodes::_fast_lputfield: |
2771 NOT_LP64(__ movptr(hi, rdx)); | |
2772 __ movptr(lo, rax); | |
2773 break; | |
0 | 2774 case Bytecodes::_fast_fputfield: __ fstp_s(lo); break; |
2775 case Bytecodes::_fast_dputfield: __ fstp_d(lo); break; | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2776 case Bytecodes::_fast_aputfield: { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2777 do_oop_store(_masm, lo, rax, _bs->kind(), false); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2778 break; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
2779 } |
0 | 2780 default: |
2781 ShouldNotReachHere(); | |
2782 } | |
2783 __ bind(done); | |
2784 } | |
2785 | |
2786 | |
2787 void TemplateTable::fast_accessfield(TosState state) { | |
2788 transition(atos, state); | |
2789 | |
2790 // do the JVMTI work here to avoid disturbing the register state below | |
2791 if (JvmtiExport::can_post_field_access()) { | |
2792 // Check to see if a field access watch has been set before we take | |
2793 // the time to call into the VM. | |
2794 Label L1; | |
2795 __ mov32(rcx, ExternalAddress((address) JvmtiExport::get_field_access_count_addr())); | |
2796 __ testl(rcx,rcx); | |
2797 __ jcc(Assembler::zero, L1); | |
2798 // access constant pool cache entry | |
2799 __ get_cache_entry_pointer_at_bcp(rcx, rdx, 1); | |
2800 __ push_ptr(rax); // save object pointer before call_VM() clobbers it | |
2801 __ verify_oop(rax); | |
2802 // rax,: object pointer copied above | |
2803 // rcx: cache entry pointer | |
2804 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_access), rax, rcx); | |
2805 __ pop_ptr(rax); // restore object pointer | |
2806 __ bind(L1); | |
2807 } | |
2808 | |
2809 // access constant pool cache | |
2810 __ get_cache_and_index_at_bcp(rcx, rbx, 1); | |
2811 // replace index with field offset from cache entry | |
304 | 2812 __ movptr(rbx, Address(rcx, |
2813 rbx, | |
2814 Address::times_ptr, | |
2815 in_bytes(constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::f2_offset()))); | |
0 | 2816 |
2817 | |
2818 // rax,: object | |
2819 __ verify_oop(rax); | |
2820 __ null_check(rax); | |
2821 // field addresses | |
2822 const Address lo = Address(rax, rbx, Address::times_1, 0*wordSize); | |
2823 const Address hi = Address(rax, rbx, Address::times_1, 1*wordSize); | |
2824 | |
2825 // access field | |
2826 switch (bytecode()) { | |
304 | 2827 case Bytecodes::_fast_bgetfield: __ movsbl(rax, lo ); break; |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
2828 case Bytecodes::_fast_sgetfield: __ load_signed_short(rax, lo ); break; |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
2829 case Bytecodes::_fast_cgetfield: __ load_unsigned_short(rax, lo ); break; |
0 | 2830 case Bytecodes::_fast_igetfield: __ movl(rax, lo); break; |
2831 case Bytecodes::_fast_lgetfield: __ stop("should not be rewritten"); break; | |
2832 case Bytecodes::_fast_fgetfield: __ fld_s(lo); break; | |
2833 case Bytecodes::_fast_dgetfield: __ fld_d(lo); break; | |
304 | 2834 case Bytecodes::_fast_agetfield: __ movptr(rax, lo); __ verify_oop(rax); break; |
0 | 2835 default: |
2836 ShouldNotReachHere(); | |
2837 } | |
2838 | |
2839 // Doug Lea believes this is not needed with current Sparcs(TSO) and Intel(PSO) | |
2840 // volatile_barrier( ); | |
2841 } | |
2842 | |
2843 void TemplateTable::fast_xaccess(TosState state) { | |
2844 transition(vtos, state); | |
2845 // get receiver | |
304 | 2846 __ movptr(rax, aaddress(0)); |
0 | 2847 // access constant pool cache |
2848 __ get_cache_and_index_at_bcp(rcx, rdx, 2); | |
304 | 2849 __ movptr(rbx, Address(rcx, |
2850 rdx, | |
2851 Address::times_ptr, | |
2852 in_bytes(constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::f2_offset()))); | |
0 | 2853 // make sure exception is reported in correct bcp range (getfield is next instruction) |
2854 __ increment(rsi); | |
2855 __ null_check(rax); | |
2856 const Address lo = Address(rax, rbx, Address::times_1, 0*wordSize); | |
2857 if (state == itos) { | |
2858 __ movl(rax, lo); | |
2859 } else if (state == atos) { | |
304 | 2860 __ movptr(rax, lo); |
0 | 2861 __ verify_oop(rax); |
2862 } else if (state == ftos) { | |
2863 __ fld_s(lo); | |
2864 } else { | |
2865 ShouldNotReachHere(); | |
2866 } | |
2867 __ decrement(rsi); | |
2868 } | |
2869 | |
2870 | |
2871 | |
2872 //---------------------------------------------------------------------------------------------------- | |
2873 // Calls | |
2874 | |
2875 void TemplateTable::count_calls(Register method, Register temp) { | |
2876 // implemented elsewhere | |
2877 ShouldNotReachHere(); | |
2878 } | |
2879 | |
2880 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2881 void TemplateTable::prepare_invoke(Register method, Register index, int byte_no) { |
0 | 2882 // determine flags |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2883 Bytecodes::Code code = bytecode(); |
0 | 2884 const bool is_invokeinterface = code == Bytecodes::_invokeinterface; |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2885 const bool is_invokedynamic = code == Bytecodes::_invokedynamic; |
0 | 2886 const bool is_invokevirtual = code == Bytecodes::_invokevirtual; |
2887 const bool is_invokespecial = code == Bytecodes::_invokespecial; | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2888 const bool load_receiver = (code != Bytecodes::_invokestatic && code != Bytecodes::_invokedynamic); |
0 | 2889 const bool receiver_null_check = is_invokespecial; |
2890 const bool save_flags = is_invokeinterface || is_invokevirtual; | |
2891 // setup registers & access constant pool cache | |
2892 const Register recv = rcx; | |
2893 const Register flags = rdx; | |
2894 assert_different_registers(method, index, recv, flags); | |
2895 | |
2896 // save 'interpreter return address' | |
2897 __ save_bcp(); | |
2898 | |
1565 | 2899 load_invoke_cp_cache_entry(byte_no, method, index, flags, is_invokevirtual, false, is_invokedynamic); |
0 | 2900 |
2901 // load receiver if needed (note: no return address pushed yet) | |
2902 if (load_receiver) { | |
1565 | 2903 assert(!is_invokedynamic, ""); |
0 | 2904 __ movl(recv, flags); |
2905 __ andl(recv, 0xFF); | |
2906 // recv count is 0 based? | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2907 Address recv_addr(rsp, recv, Interpreter::stackElementScale(), -Interpreter::expr_offset_in_bytes(1)); |
1304 | 2908 __ movptr(recv, recv_addr); |
2909 __ verify_oop(recv); | |
0 | 2910 } |
2911 | |
2912 // do null check if needed | |
2913 if (receiver_null_check) { | |
2914 __ null_check(recv); | |
2915 } | |
2916 | |
2917 if (save_flags) { | |
304 | 2918 __ mov(rsi, flags); |
0 | 2919 } |
2920 | |
2921 // compute return type | |
2922 __ shrl(flags, ConstantPoolCacheEntry::tosBits); | |
2923 // Make sure we don't need to mask flags for tosBits after the above shift | |
2924 ConstantPoolCacheEntry::verify_tosBits(); | |
2925 // load return address | |
304 | 2926 { |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2927 address table_addr; |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
2928 if (is_invokeinterface || is_invokedynamic) |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2929 table_addr = (address)Interpreter::return_5_addrs_by_index_table(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2930 else |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2931 table_addr = (address)Interpreter::return_3_addrs_by_index_table(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2932 ExternalAddress table(table_addr); |
304 | 2933 __ movptr(flags, ArrayAddress(table, Address(noreg, flags, Address::times_ptr))); |
0 | 2934 } |
2935 | |
2936 // push return address | |
304 | 2937 __ push(flags); |
0 | 2938 |
2939 // Restore flag value from the constant pool cache, and restore rsi | |
2940 // for later null checks. rsi is the bytecode pointer | |
2941 if (save_flags) { | |
304 | 2942 __ mov(flags, rsi); |
0 | 2943 __ restore_bcp(); |
2944 } | |
2945 } | |
2946 | |
2947 | |
2948 void TemplateTable::invokevirtual_helper(Register index, Register recv, | |
2949 Register flags) { | |
2950 | |
2951 // Uses temporary registers rax, rdx | |
2952 assert_different_registers(index, recv, rax, rdx); | |
2953 | |
2954 // Test for an invoke of a final method | |
2955 Label notFinal; | |
2956 __ movl(rax, flags); | |
2957 __ andl(rax, (1 << ConstantPoolCacheEntry::vfinalMethod)); | |
2958 __ jcc(Assembler::zero, notFinal); | |
2959 | |
2960 Register method = index; // method must be rbx, | |
2961 assert(method == rbx, "methodOop must be rbx, for interpreter calling convention"); | |
2962 | |
2963 // do the call - the index is actually the method to call | |
2964 __ verify_oop(method); | |
2965 | |
2966 // It's final, need a null check here! | |
2967 __ null_check(recv); | |
2968 | |
2969 // profile this call | |
2970 __ profile_final_call(rax); | |
2971 | |
2972 __ jump_from_interpreted(method, rax); | |
2973 | |
2974 __ bind(notFinal); | |
2975 | |
2976 // get receiver klass | |
2977 __ null_check(recv, oopDesc::klass_offset_in_bytes()); | |
2978 // Keep recv in rcx for callee expects it there | |
304 | 2979 __ movptr(rax, Address(recv, oopDesc::klass_offset_in_bytes())); |
0 | 2980 __ verify_oop(rax); |
2981 | |
2982 // profile this call | |
2983 __ profile_virtual_call(rax, rdi, rdx); | |
2984 | |
2985 // get target methodOop & entry point | |
2986 const int base = instanceKlass::vtable_start_offset() * wordSize; | |
2987 assert(vtableEntry::size() * wordSize == 4, "adjust the scaling in the code below"); | |
304 | 2988 __ movptr(method, Address(rax, index, Address::times_ptr, base + vtableEntry::method_offset_in_bytes())); |
0 | 2989 __ jump_from_interpreted(method, rdx); |
2990 } | |
2991 | |
2992 | |
2993 void TemplateTable::invokevirtual(int byte_no) { | |
2994 transition(vtos, vtos); | |
1565 | 2995 assert(byte_no == f2_byte, "use this argument"); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
2996 prepare_invoke(rbx, noreg, byte_no); |
0 | 2997 |
2998 // rbx,: index | |
2999 // rcx: receiver | |
3000 // rdx: flags | |
3001 | |
3002 invokevirtual_helper(rbx, rcx, rdx); | |
3003 } | |
3004 | |
3005 | |
3006 void TemplateTable::invokespecial(int byte_no) { | |
3007 transition(vtos, vtos); | |
1565 | 3008 assert(byte_no == f1_byte, "use this argument"); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3009 prepare_invoke(rbx, noreg, byte_no); |
0 | 3010 // do the call |
3011 __ verify_oop(rbx); | |
3012 __ profile_call(rax); | |
3013 __ jump_from_interpreted(rbx, rax); | |
3014 } | |
3015 | |
3016 | |
3017 void TemplateTable::invokestatic(int byte_no) { | |
3018 transition(vtos, vtos); | |
1565 | 3019 assert(byte_no == f1_byte, "use this argument"); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3020 prepare_invoke(rbx, noreg, byte_no); |
0 | 3021 // do the call |
3022 __ verify_oop(rbx); | |
3023 __ profile_call(rax); | |
3024 __ jump_from_interpreted(rbx, rax); | |
3025 } | |
3026 | |
3027 | |
3028 void TemplateTable::fast_invokevfinal(int byte_no) { | |
3029 transition(vtos, vtos); | |
1565 | 3030 assert(byte_no == f2_byte, "use this argument"); |
0 | 3031 __ stop("fast_invokevfinal not used on x86"); |
3032 } | |
3033 | |
3034 | |
3035 void TemplateTable::invokeinterface(int byte_no) { | |
3036 transition(vtos, vtos); | |
1565 | 3037 assert(byte_no == f1_byte, "use this argument"); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3038 prepare_invoke(rax, rbx, byte_no); |
0 | 3039 |
3040 // rax,: Interface | |
3041 // rbx,: index | |
3042 // rcx: receiver | |
3043 // rdx: flags | |
3044 | |
3045 // Special case of invokeinterface called for virtual method of | |
3046 // java.lang.Object. See cpCacheOop.cpp for details. | |
3047 // This code isn't produced by javac, but could be produced by | |
3048 // another compliant java compiler. | |
3049 Label notMethod; | |
3050 __ movl(rdi, rdx); | |
3051 __ andl(rdi, (1 << ConstantPoolCacheEntry::methodInterface)); | |
3052 __ jcc(Assembler::zero, notMethod); | |
3053 | |
3054 invokevirtual_helper(rbx, rcx, rdx); | |
3055 __ bind(notMethod); | |
3056 | |
3057 // Get receiver klass into rdx - also a null check | |
3058 __ restore_locals(); // restore rdi | |
304 | 3059 __ movptr(rdx, Address(rcx, oopDesc::klass_offset_in_bytes())); |
0 | 3060 __ verify_oop(rdx); |
3061 | |
3062 // profile this call | |
3063 __ profile_virtual_call(rdx, rsi, rdi); | |
3064 | |
623
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3065 Label no_such_interface, no_such_method; |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3066 |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3067 __ lookup_interface_method(// inputs: rec. class, interface, itable index |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3068 rdx, rax, rbx, |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3069 // outputs: method, scan temp. reg |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3070 rbx, rsi, |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3071 no_such_interface); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3072 |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3073 // rbx,: methodOop to call |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3074 // rcx: receiver |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3075 // Check for abstract method error |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3076 // Note: This should be done more efficiently via a throw_abstract_method_error |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3077 // interpreter entry point and a conditional jump to it in case of a null |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3078 // method. |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3079 __ testptr(rbx, rbx); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3080 __ jcc(Assembler::zero, no_such_method); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3081 |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3082 // do the call |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3083 // rcx: receiver |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3084 // rbx,: methodOop |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3085 __ jump_from_interpreted(rbx, rdx); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3086 __ should_not_reach_here(); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3087 |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3088 // exception handling code follows... |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3089 // note: must restore interpreter registers to canonical |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3090 // state for exception handling to work correctly! |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3091 |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3092 __ bind(no_such_method); |
0 | 3093 // throw exception |
623
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3094 __ pop(rbx); // pop return address (pushed by prepare_invoke) |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3095 __ restore_bcp(); // rsi must be correct for exception handler (was destroyed) |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3096 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed) |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3097 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError)); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3098 // the call_VM checks for exception, so we should never return here. |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3099 __ should_not_reach_here(); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3100 |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3101 __ bind(no_such_interface); |
9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
622
diff
changeset
|
3102 // throw exception |
304 | 3103 __ pop(rbx); // pop return address (pushed by prepare_invoke) |
0 | 3104 __ restore_bcp(); // rsi must be correct for exception handler (was destroyed) |
3105 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed) | |
3106 __ call_VM(noreg, CAST_FROM_FN_PTR(address, | |
3107 InterpreterRuntime::throw_IncompatibleClassChangeError)); | |
3108 // the call_VM checks for exception, so we should never return here. | |
3109 __ should_not_reach_here(); | |
3110 } | |
3111 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3112 void TemplateTable::invokedynamic(int byte_no) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3113 transition(vtos, vtos); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3114 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3115 if (!EnableInvokeDynamic) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3116 // We should not encounter this bytecode if !EnableInvokeDynamic. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3117 // The verifier will stop it. However, if we get past the verifier, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3118 // this will stop the thread in a reasonable way, without crashing the JVM. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3119 __ call_VM(noreg, CAST_FROM_FN_PTR(address, |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3120 InterpreterRuntime::throw_IncompatibleClassChangeError)); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3121 // the call_VM checks for exception, so we should never return here. |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3122 __ should_not_reach_here(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3123 return; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3124 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3125 |
1565 | 3126 assert(byte_no == f1_oop, "use this argument"); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3127 prepare_invoke(rax, rbx, byte_no); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3128 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3129 // rax: CallSite object (f1) |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3130 // rbx: unused (f2) |
1846 | 3131 // rcx: receiver address |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3132 // rdx: flags (unused) |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3133 |
1846 | 3134 Register rax_callsite = rax; |
3135 Register rcx_method_handle = rcx; | |
3136 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3137 if (ProfileInterpreter) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3138 // %%% should make a type profile for any invokedynamic that takes a ref argument |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3139 // profile this call |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3140 __ profile_call(rsi); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3141 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3142 |
1846 | 3143 __ movptr(rcx_method_handle, Address(rax_callsite, __ delayed_value(java_dyn_CallSite::target_offset_in_bytes, rcx))); |
3144 __ null_check(rcx_method_handle); | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3145 __ prepare_to_jump_from_interpreted(); |
1846 | 3146 __ jump_to_method_handle_entry(rcx_method_handle, rdx); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3147 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
628
diff
changeset
|
3148 |
0 | 3149 //---------------------------------------------------------------------------------------------------- |
3150 // Allocation | |
3151 | |
3152 void TemplateTable::_new() { | |
3153 transition(vtos, atos); | |
3154 __ get_unsigned_2_byte_index_at_bcp(rdx, 1); | |
3155 Label slow_case; | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3156 Label slow_case_no_pop; |
0 | 3157 Label done; |
3158 Label initialize_header; | |
3159 Label initialize_object; // including clearing the fields | |
3160 Label allocate_shared; | |
3161 | |
3162 __ get_cpool_and_tags(rcx, rax); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3163 |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3164 // Make sure the class we're about to instantiate has been resolved. |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3165 // This is done before loading instanceKlass to be consistent with the order |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3166 // how Constant Pool is updated (see constantPoolOopDesc::klass_at_put) |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3167 const int tags_offset = typeArrayOopDesc::header_size(T_BYTE) * wordSize; |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3168 __ cmpb(Address(rax, rdx, Address::times_1, tags_offset), JVM_CONSTANT_Class); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3169 __ jcc(Assembler::notEqual, slow_case_no_pop); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3170 |
0 | 3171 // get instanceKlass |
304 | 3172 __ movptr(rcx, Address(rcx, rdx, Address::times_ptr, sizeof(constantPoolOopDesc))); |
3173 __ push(rcx); // save the contexts of klass for initializing the header | |
0 | 3174 |
3175 // make sure klass is initialized & doesn't have finalizer | |
3176 // make sure klass is fully initialized | |
3177 __ cmpl(Address(rcx, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc)), instanceKlass::fully_initialized); | |
3178 __ jcc(Assembler::notEqual, slow_case); | |
3179 | |
3180 // get instance_size in instanceKlass (scaled to a count of bytes) | |
3181 __ movl(rdx, Address(rcx, Klass::layout_helper_offset_in_bytes() + sizeof(oopDesc))); | |
3182 // test to see if it has a finalizer or is malformed in some way | |
3183 __ testl(rdx, Klass::_lh_instance_slow_path_bit); | |
3184 __ jcc(Assembler::notZero, slow_case); | |
3185 | |
3186 // | |
3187 // Allocate the instance | |
3188 // 1) Try to allocate in the TLAB | |
3189 // 2) if fail and the object is large allocate in the shared Eden | |
3190 // 3) if the above fails (or is not applicable), go to a slow case | |
3191 // (creates a new TLAB, etc.) | |
3192 | |
3193 const bool allow_shared_alloc = | |
3194 Universe::heap()->supports_inline_contig_alloc() && !CMSIncrementalMode; | |
3195 | |
3196 if (UseTLAB) { | |
3197 const Register thread = rcx; | |
3198 | |
3199 __ get_thread(thread); | |
304 | 3200 __ movptr(rax, Address(thread, in_bytes(JavaThread::tlab_top_offset()))); |
3201 __ lea(rbx, Address(rax, rdx, Address::times_1)); | |
3202 __ cmpptr(rbx, Address(thread, in_bytes(JavaThread::tlab_end_offset()))); | |
0 | 3203 __ jcc(Assembler::above, allow_shared_alloc ? allocate_shared : slow_case); |
304 | 3204 __ movptr(Address(thread, in_bytes(JavaThread::tlab_top_offset())), rbx); |
0 | 3205 if (ZeroTLAB) { |
3206 // the fields have been already cleared | |
3207 __ jmp(initialize_header); | |
3208 } else { | |
3209 // initialize both the header and fields | |
3210 __ jmp(initialize_object); | |
3211 } | |
3212 } | |
3213 | |
3214 // Allocation in the shared Eden, if allowed. | |
3215 // | |
3216 // rdx: instance size in bytes | |
3217 if (allow_shared_alloc) { | |
3218 __ bind(allocate_shared); | |
3219 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
3220 ExternalAddress heap_top((address)Universe::heap()->top_addr()); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
107
diff
changeset
|
3221 |
0 | 3222 Label retry; |
3223 __ bind(retry); | |
304 | 3224 __ movptr(rax, heap_top); |
3225 __ lea(rbx, Address(rax, rdx, Address::times_1)); | |
3226 __ cmpptr(rbx, ExternalAddress((address)Universe::heap()->end_addr())); | |
0 | 3227 __ jcc(Assembler::above, slow_case); |
3228 | |
3229 // Compare rax, with the top addr, and if still equal, store the new | |
3230 // top addr in rbx, at the address of the top addr pointer. Sets ZF if was | |
3231 // equal, and clears it otherwise. Use lock prefix for atomicity on MPs. | |
3232 // | |
3233 // rax,: object begin | |
3234 // rbx,: object end | |
3235 // rdx: instance size in bytes | |
304 | 3236 __ locked_cmpxchgptr(rbx, heap_top); |
0 | 3237 |
3238 // if someone beat us on the allocation, try again, otherwise continue | |
3239 __ jcc(Assembler::notEqual, retry); | |
3240 } | |
3241 | |
3242 if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) { | |
3243 // The object is initialized before the header. If the object size is | |
3244 // zero, go directly to the header initialization. | |
3245 __ bind(initialize_object); | |
3246 __ decrement(rdx, sizeof(oopDesc)); | |
3247 __ jcc(Assembler::zero, initialize_header); | |
3248 | |
3249 // Initialize topmost object field, divide rdx by 8, check if odd and | |
3250 // test if zero. | |
3251 __ xorl(rcx, rcx); // use zero reg to clear memory (shorter code) | |
3252 __ shrl(rdx, LogBytesPerLong); // divide by 2*oopSize and set carry flag if odd | |
3253 | |
3254 // rdx must have been multiple of 8 | |
3255 #ifdef ASSERT | |
3256 // make sure rdx was multiple of 8 | |
3257 Label L; | |
3258 // Ignore partial flag stall after shrl() since it is debug VM | |
3259 __ jccb(Assembler::carryClear, L); | |
3260 __ stop("object size is not multiple of 2 - adjust this code"); | |
3261 __ bind(L); | |
3262 // rdx must be > 0, no extra check needed here | |
3263 #endif | |
3264 | |
3265 // initialize remaining object fields: rdx was a multiple of 8 | |
3266 { Label loop; | |
3267 __ bind(loop); | |
304 | 3268 __ movptr(Address(rax, rdx, Address::times_8, sizeof(oopDesc) - 1*oopSize), rcx); |
3269 NOT_LP64(__ movptr(Address(rax, rdx, Address::times_8, sizeof(oopDesc) - 2*oopSize), rcx)); | |
0 | 3270 __ decrement(rdx); |
3271 __ jcc(Assembler::notZero, loop); | |
3272 } | |
3273 | |
3274 // initialize object header only. | |
3275 __ bind(initialize_header); | |
3276 if (UseBiasedLocking) { | |
304 | 3277 __ pop(rcx); // get saved klass back in the register. |
3278 __ movptr(rbx, Address(rcx, Klass::prototype_header_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes())); | |
3279 __ movptr(Address(rax, oopDesc::mark_offset_in_bytes ()), rbx); | |
0 | 3280 } else { |
304 | 3281 __ movptr(Address(rax, oopDesc::mark_offset_in_bytes ()), |
3282 (int32_t)markOopDesc::prototype()); // header | |
3283 __ pop(rcx); // get saved klass back in the register. | |
0 | 3284 } |
304 | 3285 __ movptr(Address(rax, oopDesc::klass_offset_in_bytes()), rcx); // klass |
0 | 3286 |
3287 { | |
3288 SkipIfEqual skip_if(_masm, &DTraceAllocProbes, 0); | |
3289 // Trigger dtrace event for fastpath | |
3290 __ push(atos); | |
3291 __ call_VM_leaf( | |
3292 CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), rax); | |
3293 __ pop(atos); | |
3294 } | |
3295 | |
3296 __ jmp(done); | |
3297 } | |
3298 | |
3299 // slow case | |
3300 __ bind(slow_case); | |
304 | 3301 __ pop(rcx); // restore stack pointer to what it was when we came in. |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1602
diff
changeset
|
3302 __ bind(slow_case_no_pop); |
0 | 3303 __ get_constant_pool(rax); |
3304 __ get_unsigned_2_byte_index_at_bcp(rdx, 1); | |
3305 call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), rax, rdx); | |
3306 | |
3307 // continue | |
3308 __ bind(done); | |
3309 } | |
3310 | |
3311 | |
3312 void TemplateTable::newarray() { | |
3313 transition(itos, atos); | |
3314 __ push_i(rax); // make sure everything is on the stack | |
3315 __ load_unsigned_byte(rdx, at_bcp(1)); | |
3316 call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::newarray), rdx, rax); | |
3317 __ pop_i(rdx); // discard size | |
3318 } | |
3319 | |
3320 | |
3321 void TemplateTable::anewarray() { | |
3322 transition(itos, atos); | |
3323 __ get_unsigned_2_byte_index_at_bcp(rdx, 1); | |
3324 __ get_constant_pool(rcx); | |
3325 call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::anewarray), rcx, rdx, rax); | |
3326 } | |
3327 | |
3328 | |
3329 void TemplateTable::arraylength() { | |
3330 transition(atos, itos); | |
3331 __ null_check(rax, arrayOopDesc::length_offset_in_bytes()); | |
3332 __ movl(rax, Address(rax, arrayOopDesc::length_offset_in_bytes())); | |
3333 } | |
3334 | |
3335 | |
3336 void TemplateTable::checkcast() { | |
3337 transition(atos, atos); | |
3338 Label done, is_null, ok_is_subtype, quicked, resolved; | |
304 | 3339 __ testptr(rax, rax); // Object is in EAX |
0 | 3340 __ jcc(Assembler::zero, is_null); |
3341 | |
3342 // Get cpool & tags index | |
3343 __ get_cpool_and_tags(rcx, rdx); // ECX=cpool, EDX=tags array | |
3344 __ get_unsigned_2_byte_index_at_bcp(rbx, 1); // EBX=index | |
3345 // See if bytecode has already been quicked | |
3346 __ cmpb(Address(rdx, rbx, Address::times_1, typeArrayOopDesc::header_size(T_BYTE) * wordSize), JVM_CONSTANT_Class); | |
3347 __ jcc(Assembler::equal, quicked); | |
3348 | |
3349 __ push(atos); | |
3350 call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc) ); | |
3351 __ pop_ptr(rdx); | |
3352 __ jmpb(resolved); | |
3353 | |
3354 // Get superklass in EAX and subklass in EBX | |
3355 __ bind(quicked); | |
304 | 3356 __ mov(rdx, rax); // Save object in EDX; EAX needed for subtype check |
3357 __ movptr(rax, Address(rcx, rbx, Address::times_ptr, sizeof(constantPoolOopDesc))); | |
0 | 3358 |
3359 __ bind(resolved); | |
304 | 3360 __ movptr(rbx, Address(rdx, oopDesc::klass_offset_in_bytes())); |
0 | 3361 |
3362 // Generate subtype check. Blows ECX. Resets EDI. Object in EDX. | |
3363 // Superklass in EAX. Subklass in EBX. | |
3364 __ gen_subtype_check( rbx, ok_is_subtype ); | |
3365 | |
3366 // Come here on failure | |
304 | 3367 __ push(rdx); |
0 | 3368 // object is at TOS |
3369 __ jump(ExternalAddress(Interpreter::_throw_ClassCastException_entry)); | |
3370 | |
3371 // Come here on success | |
3372 __ bind(ok_is_subtype); | |
304 | 3373 __ mov(rax,rdx); // Restore object in EDX |
0 | 3374 |
3375 // Collect counts on whether this check-cast sees NULLs a lot or not. | |
3376 if (ProfileInterpreter) { | |
3377 __ jmp(done); | |
3378 __ bind(is_null); | |
3379 __ profile_null_seen(rcx); | |
3380 } else { | |
3381 __ bind(is_null); // same as 'done' | |
3382 } | |
3383 __ bind(done); | |
3384 } | |
3385 | |
3386 | |
3387 void TemplateTable::instanceof() { | |
3388 transition(atos, itos); | |
3389 Label done, is_null, ok_is_subtype, quicked, resolved; | |
304 | 3390 __ testptr(rax, rax); |
0 | 3391 __ jcc(Assembler::zero, is_null); |
3392 | |
3393 // Get cpool & tags index | |
3394 __ get_cpool_and_tags(rcx, rdx); // ECX=cpool, EDX=tags array | |
3395 __ get_unsigned_2_byte_index_at_bcp(rbx, 1); // EBX=index | |
3396 // See if bytecode has already been quicked | |
3397 __ cmpb(Address(rdx, rbx, Address::times_1, typeArrayOopDesc::header_size(T_BYTE) * wordSize), JVM_CONSTANT_Class); | |
3398 __ jcc(Assembler::equal, quicked); | |
3399 | |
3400 __ push(atos); | |
3401 call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc) ); | |
3402 __ pop_ptr(rdx); | |
304 | 3403 __ movptr(rdx, Address(rdx, oopDesc::klass_offset_in_bytes())); |
0 | 3404 __ jmp(resolved); |
3405 | |
3406 // Get superklass in EAX and subklass in EDX | |
3407 __ bind(quicked); | |
304 | 3408 __ movptr(rdx, Address(rax, oopDesc::klass_offset_in_bytes())); |
3409 __ movptr(rax, Address(rcx, rbx, Address::times_ptr, sizeof(constantPoolOopDesc))); | |
0 | 3410 |
3411 __ bind(resolved); | |
3412 | |
3413 // Generate subtype check. Blows ECX. Resets EDI. | |
3414 // Superklass in EAX. Subklass in EDX. | |
3415 __ gen_subtype_check( rdx, ok_is_subtype ); | |
3416 | |
3417 // Come here on failure | |
3418 __ xorl(rax,rax); | |
3419 __ jmpb(done); | |
3420 // Come here on success | |
3421 __ bind(ok_is_subtype); | |
3422 __ movl(rax, 1); | |
3423 | |
3424 // Collect counts on whether this test sees NULLs a lot or not. | |
3425 if (ProfileInterpreter) { | |
3426 __ jmp(done); | |
3427 __ bind(is_null); | |
3428 __ profile_null_seen(rcx); | |
3429 } else { | |
3430 __ bind(is_null); // same as 'done' | |
3431 } | |
3432 __ bind(done); | |
3433 // rax, = 0: obj == NULL or obj is not an instanceof the specified klass | |
3434 // rax, = 1: obj != NULL and obj is an instanceof the specified klass | |
3435 } | |
3436 | |
3437 | |
3438 //---------------------------------------------------------------------------------------------------- | |
3439 // Breakpoints | |
3440 void TemplateTable::_breakpoint() { | |
3441 | |
3442 // Note: We get here even if we are single stepping.. | |
3443 // jbug inists on setting breakpoints at every bytecode | |
3444 // even if we are in single step mode. | |
3445 | |
3446 transition(vtos, vtos); | |
3447 | |
3448 // get the unpatched byte code | |
3449 __ get_method(rcx); | |
3450 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::get_original_bytecode_at), rcx, rsi); | |
304 | 3451 __ mov(rbx, rax); |
0 | 3452 |
3453 // post the breakpoint event | |
3454 __ get_method(rcx); | |
3455 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::_breakpoint), rcx, rsi); | |
3456 | |
3457 // complete the execution of original bytecode | |
3458 __ dispatch_only_normal(vtos); | |
3459 } | |
3460 | |
3461 | |
3462 //---------------------------------------------------------------------------------------------------- | |
3463 // Exceptions | |
3464 | |
3465 void TemplateTable::athrow() { | |
3466 transition(atos, vtos); | |
3467 __ null_check(rax); | |
3468 __ jump(ExternalAddress(Interpreter::throw_exception_entry())); | |
3469 } | |
3470 | |
3471 | |
3472 //---------------------------------------------------------------------------------------------------- | |
3473 // Synchronization | |
3474 // | |
3475 // Note: monitorenter & exit are symmetric routines; which is reflected | |
3476 // in the assembly code structure as well | |
3477 // | |
3478 // Stack layout: | |
3479 // | |
3480 // [expressions ] <--- rsp = expression stack top | |
3481 // .. | |
3482 // [expressions ] | |
3483 // [monitor entry] <--- monitor block top = expression stack bot | |
3484 // .. | |
3485 // [monitor entry] | |
3486 // [frame data ] <--- monitor block bot | |
3487 // ... | |
3488 // [saved rbp, ] <--- rbp, | |
3489 | |
3490 | |
3491 void TemplateTable::monitorenter() { | |
3492 transition(atos, vtos); | |
3493 | |
3494 // check for NULL object | |
3495 __ null_check(rax); | |
3496 | |
3497 const Address monitor_block_top(rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
3498 const Address monitor_block_bot(rbp, frame::interpreter_frame_initial_sp_offset * wordSize); | |
3499 const int entry_size = ( frame::interpreter_frame_monitor_size() * wordSize); | |
3500 Label allocated; | |
3501 | |
3502 // initialize entry pointer | |
3503 __ xorl(rdx, rdx); // points to free slot or NULL | |
3504 | |
3505 // find a free slot in the monitor block (result in rdx) | |
3506 { Label entry, loop, exit; | |
304 | 3507 __ movptr(rcx, monitor_block_top); // points to current entry, starting with top-most entry |
3508 __ lea(rbx, monitor_block_bot); // points to word before bottom of monitor block | |
0 | 3509 __ jmpb(entry); |
3510 | |
3511 __ bind(loop); | |
304 | 3512 __ cmpptr(Address(rcx, BasicObjectLock::obj_offset_in_bytes()), (int32_t)NULL_WORD); // check if current entry is used |
0 | 3513 |
3514 // TODO - need new func here - kbt | |
3515 if (VM_Version::supports_cmov()) { | |
304 | 3516 __ cmov(Assembler::equal, rdx, rcx); // if not used then remember entry in rdx |
0 | 3517 } else { |
3518 Label L; | |
3519 __ jccb(Assembler::notEqual, L); | |
304 | 3520 __ mov(rdx, rcx); // if not used then remember entry in rdx |
0 | 3521 __ bind(L); |
3522 } | |
304 | 3523 __ cmpptr(rax, Address(rcx, BasicObjectLock::obj_offset_in_bytes())); // check if current entry is for same object |
3524 __ jccb(Assembler::equal, exit); // if same object then stop searching | |
3525 __ addptr(rcx, entry_size); // otherwise advance to next entry | |
0 | 3526 __ bind(entry); |
304 | 3527 __ cmpptr(rcx, rbx); // check if bottom reached |
0 | 3528 __ jcc(Assembler::notEqual, loop); // if not at bottom then check this entry |
3529 __ bind(exit); | |
3530 } | |
3531 | |
304 | 3532 __ testptr(rdx, rdx); // check if a slot has been found |
3533 __ jccb(Assembler::notZero, allocated); // if found, continue with that one | |
0 | 3534 |
3535 // allocate one if there's no free slot | |
3536 { Label entry, loop; | |
3537 // 1. compute new pointers // rsp: old expression stack top | |
304 | 3538 __ movptr(rdx, monitor_block_bot); // rdx: old expression stack bottom |
3539 __ subptr(rsp, entry_size); // move expression stack top | |
3540 __ subptr(rdx, entry_size); // move expression stack bottom | |
3541 __ mov(rcx, rsp); // set start value for copy loop | |
3542 __ movptr(monitor_block_bot, rdx); // set new monitor block top | |
0 | 3543 __ jmp(entry); |
3544 // 2. move expression stack contents | |
3545 __ bind(loop); | |
304 | 3546 __ movptr(rbx, Address(rcx, entry_size)); // load expression stack word from old location |
3547 __ movptr(Address(rcx, 0), rbx); // and store it at new location | |
3548 __ addptr(rcx, wordSize); // advance to next word | |
0 | 3549 __ bind(entry); |
304 | 3550 __ cmpptr(rcx, rdx); // check if bottom reached |
0 | 3551 __ jcc(Assembler::notEqual, loop); // if not at bottom then copy next word |
3552 } | |
3553 | |
3554 // call run-time routine | |
3555 // rdx: points to monitor entry | |
3556 __ bind(allocated); | |
3557 | |
3558 // Increment bcp to point to the next bytecode, so exception handling for async. exceptions work correctly. | |
3559 // The object has already been poped from the stack, so the expression stack looks correct. | |
3560 __ increment(rsi); | |
3561 | |
304 | 3562 __ movptr(Address(rdx, BasicObjectLock::obj_offset_in_bytes()), rax); // store object |
0 | 3563 __ lock_object(rdx); |
3564 | |
3565 // check to make sure this monitor doesn't cause stack overflow after locking | |
3566 __ save_bcp(); // in case of exception | |
3567 __ generate_stack_overflow_check(0); | |
3568 | |
3569 // The bcp has already been incremented. Just need to dispatch to next instruction. | |
3570 __ dispatch_next(vtos); | |
3571 } | |
3572 | |
3573 | |
3574 void TemplateTable::monitorexit() { | |
3575 transition(atos, vtos); | |
3576 | |
3577 // check for NULL object | |
3578 __ null_check(rax); | |
3579 | |
3580 const Address monitor_block_top(rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
3581 const Address monitor_block_bot(rbp, frame::interpreter_frame_initial_sp_offset * wordSize); | |
3582 const int entry_size = ( frame::interpreter_frame_monitor_size() * wordSize); | |
3583 Label found; | |
3584 | |
3585 // find matching slot | |
3586 { Label entry, loop; | |
304 | 3587 __ movptr(rdx, monitor_block_top); // points to current entry, starting with top-most entry |
3588 __ lea(rbx, monitor_block_bot); // points to word before bottom of monitor block | |
0 | 3589 __ jmpb(entry); |
3590 | |
3591 __ bind(loop); | |
304 | 3592 __ cmpptr(rax, Address(rdx, BasicObjectLock::obj_offset_in_bytes())); // check if current entry is for same object |
0 | 3593 __ jcc(Assembler::equal, found); // if same object then stop searching |
304 | 3594 __ addptr(rdx, entry_size); // otherwise advance to next entry |
0 | 3595 __ bind(entry); |
304 | 3596 __ cmpptr(rdx, rbx); // check if bottom reached |
0 | 3597 __ jcc(Assembler::notEqual, loop); // if not at bottom then check this entry |
3598 } | |
3599 | |
3600 // error handling. Unlocking was not block-structured | |
3601 Label end; | |
3602 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception)); | |
3603 __ should_not_reach_here(); | |
3604 | |
3605 // call run-time routine | |
3606 // rcx: points to monitor entry | |
3607 __ bind(found); | |
3608 __ push_ptr(rax); // make sure object is on stack (contract with oopMaps) | |
3609 __ unlock_object(rdx); | |
3610 __ pop_ptr(rax); // discard object | |
3611 __ bind(end); | |
3612 } | |
3613 | |
3614 | |
3615 //---------------------------------------------------------------------------------------------------- | |
3616 // Wide instructions | |
3617 | |
3618 void TemplateTable::wide() { | |
3619 transition(vtos, vtos); | |
3620 __ load_unsigned_byte(rbx, at_bcp(1)); | |
304 | 3621 ExternalAddress wtable((address)Interpreter::_wentry_point); |
3622 __ jump(ArrayAddress(wtable, Address(noreg, rbx, Address::times_ptr))); | |
0 | 3623 // Note: the rsi increment step is part of the individual wide bytecode implementations |
3624 } | |
3625 | |
3626 | |
3627 //---------------------------------------------------------------------------------------------------- | |
3628 // Multi arrays | |
3629 | |
3630 void TemplateTable::multianewarray() { | |
3631 transition(vtos, atos); | |
3632 __ load_unsigned_byte(rax, at_bcp(3)); // get number of dimensions | |
3633 // last dim is on top of stack; we want address of first one: | |
3634 // first_addr = last_addr + (ndims - 1) * stackElementSize - 1*wordsize | |
3635 // the latter wordSize to point to the beginning of the array. | |
304 | 3636 __ lea( rax, Address(rsp, rax, Interpreter::stackElementScale(), -wordSize)); |
0 | 3637 call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::multianewarray), rax); // pass in rax, |
3638 __ load_unsigned_byte(rbx, at_bcp(3)); | |
304 | 3639 __ lea(rsp, Address(rsp, rbx, Interpreter::stackElementScale())); // get rid of counts |
0 | 3640 } |
3641 | |
3642 #endif /* !CC_INTERP */ |