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