annotate src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @ 20504:6948da6d7c13

8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set Summary: Remove -XX:-G1DeferredRSUpdate functionality as it is racy. During evacuation failure handling, threads where evacuation failure handling occurred may try to add remembered sets to regions which remembered sets are currently being scanned. The iterator to handle the remembered set scan does not support addition of entries during scan and so may skip valid references. Reviewed-by: iveresov, brutisso, mgerdin
author tschatzl
date Tue, 30 Sep 2014 09:44:36 +0200
parents 0bf37f737702
children 52b4284cb496
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
11080
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1491
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1491
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: 1491
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
25 #include "precompiled.hpp"
7199
cd3d6a6b95d9 8003240: x86: move MacroAssembler into separate file
twisti
parents: 6853
diff changeset
26 #include "asm/macroAssembler.hpp"
cd3d6a6b95d9 8003240: x86: move MacroAssembler into separate file
twisti
parents: 6853
diff changeset
27 #include "asm/macroAssembler.inline.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
28 #include "c1/c1_Compilation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
29 #include "c1/c1_LIRAssembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
30 #include "c1/c1_MacroAssembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
31 #include "c1/c1_Runtime1.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
32 #include "c1/c1_ValueStack.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
33 #include "ci/ciArrayKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
34 #include "ci/ciInstance.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
35 #include "gc_interface/collectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
36 #include "memory/barrierSet.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
37 #include "memory/cardTableModRefBS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
38 #include "nativeInst_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
39 #include "oops/objArrayKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1848
diff changeset
40 #include "runtime/sharedRuntime.hpp"
17496
12ad8db39f76 8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a
roland
parents: 12969
diff changeset
41 #include "vmreg_x86.inline.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // These masks are used to provide 128-bit aligned bitmasks to the XMM
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // instructions, to allow sign-masking or sign-bit flipping. They allow
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // fast versions of NegF/NegD and AbsF/AbsD.
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Note: 'double' and 'long long' have 32-bits alignment on x86.
a61af66fc99e Initial load
duke
parents:
diff changeset
49 static jlong* double_quadword(jlong *adr, jlong lo, jlong hi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Use the expression (adr)&(~0xF) to provide 128-bits aligned address
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // of 128-bits operands for SSE instructions.
3401
ccf072cdba91 7046893: LP64 problem with double_quadword in c1_LIRAssembler_x86.cpp
iveresov
parents: 2479
diff changeset
52 jlong *operand = (jlong*)(((intptr_t)adr) & ((intptr_t)(~0xF)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Store the value to a 128-bits operand.
a61af66fc99e Initial load
duke
parents:
diff changeset
54 operand[0] = lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 operand[1] = hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 return operand;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Buffer for 128-bits masks used by SSE instructions.
a61af66fc99e Initial load
duke
parents:
diff changeset
60 static jlong fp_signmask_pool[(4+1)*2]; // 4*128bits(data) + 128bits(alignment)
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Static initialization during VM startup.
a61af66fc99e Initial load
duke
parents:
diff changeset
63 static jlong *float_signmask_pool = double_quadword(&fp_signmask_pool[1*2], CONST64(0x7FFFFFFF7FFFFFFF), CONST64(0x7FFFFFFF7FFFFFFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
64 static jlong *double_signmask_pool = double_quadword(&fp_signmask_pool[2*2], CONST64(0x7FFFFFFFFFFFFFFF), CONST64(0x7FFFFFFFFFFFFFFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
65 static jlong *float_signflip_pool = double_quadword(&fp_signmask_pool[3*2], CONST64(0x8000000080000000), CONST64(0x8000000080000000));
a61af66fc99e Initial load
duke
parents:
diff changeset
66 static jlong *double_signflip_pool = double_quadword(&fp_signmask_pool[4*2], CONST64(0x8000000000000000), CONST64(0x8000000000000000));
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 NEEDS_CLEANUP // remove this definitions ?
a61af66fc99e Initial load
duke
parents:
diff changeset
71 const Register IC_Klass = rax; // where the IC klass is cached
a61af66fc99e Initial load
duke
parents:
diff changeset
72 const Register SYNC_header = rax; // synchronization header
a61af66fc99e Initial load
duke
parents:
diff changeset
73 const Register SHIFT_count = rcx; // where count for shift operations must be
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 #define __ _masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 static void select_different_registers(Register preserve,
a61af66fc99e Initial load
duke
parents:
diff changeset
79 Register extra,
a61af66fc99e Initial load
duke
parents:
diff changeset
80 Register &tmp1,
a61af66fc99e Initial load
duke
parents:
diff changeset
81 Register &tmp2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 if (tmp1 == preserve) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 assert_different_registers(tmp1, tmp2, extra);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 tmp1 = extra;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 } else if (tmp2 == preserve) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 assert_different_registers(tmp1, tmp2, extra);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 tmp2 = extra;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 assert_different_registers(preserve, tmp1, tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 static void select_different_registers(Register preserve,
a61af66fc99e Initial load
duke
parents:
diff changeset
95 Register extra,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 Register &tmp1,
a61af66fc99e Initial load
duke
parents:
diff changeset
97 Register &tmp2,
a61af66fc99e Initial load
duke
parents:
diff changeset
98 Register &tmp3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 if (tmp1 == preserve) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 assert_different_registers(tmp1, tmp2, tmp3, extra);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 tmp1 = extra;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 } else if (tmp2 == preserve) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 assert_different_registers(tmp1, tmp2, tmp3, extra);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 tmp2 = extra;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 } else if (tmp3 == preserve) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 assert_different_registers(tmp1, tmp2, tmp3, extra);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 tmp3 = extra;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 assert_different_registers(preserve, tmp1, tmp2, tmp3);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 bool LIR_Assembler::is_small_constant(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 if (opr->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 LIR_Const* constant = opr->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 switch (constant->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 case T_INT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 LIR_Opr LIR_Assembler::receiverOpr() {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
131 return FrameMap::receiver_opr;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 LIR_Opr LIR_Assembler::osrBufferPointer() {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
135 return FrameMap::as_pointer_opr(receiverOpr()->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 //--------------fpu register translations-----------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 address LIR_Assembler::float_constant(float f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 address const_addr = __ float_constant(f);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if (const_addr == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 bailout("const section overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return __ code()->consts()->start();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 return const_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 address LIR_Assembler::double_constant(double d) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 address const_addr = __ double_constant(d);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 if (const_addr == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 bailout("const section overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return __ code()->consts()->start();
a61af66fc99e Initial load
duke
parents:
diff changeset
157 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 return const_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 void LIR_Assembler::set_24bit_FPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 void LIR_Assembler::reset_FPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 void LIR_Assembler::fpop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 __ fpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 void LIR_Assembler::fxch(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 __ fxch(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 void LIR_Assembler::fld(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 __ fld_s(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 void LIR_Assembler::ffree(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 __ ffree(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 void LIR_Assembler::breakpoint() {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 __ int3();
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 void LIR_Assembler::push(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 if (opr->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 __ push_reg(opr->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
194 } else if (opr->is_double_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
195 NOT_LP64(__ push_reg(opr->as_register_hi()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
196 __ push_reg(opr->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
197 } else if (opr->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 __ push_addr(frame_map()->address_for_slot(opr->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
199 } else if (opr->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 LIR_Const* const_opr = opr->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
201 if (const_opr->type() == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 __ push_oop(const_opr->as_jobject());
a61af66fc99e Initial load
duke
parents:
diff changeset
203 } else if (const_opr->type() == T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 __ push_jint(const_opr->as_jint());
a61af66fc99e Initial load
duke
parents:
diff changeset
205 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 void LIR_Assembler::pop(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (opr->is_single_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
216 __ pop_reg(opr->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
217 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
222 bool LIR_Assembler::is_literal_address(LIR_Address* addr) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
223 return addr->base()->is_illegal() && addr->index()->is_illegal();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
224 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
225
0
a61af66fc99e Initial load
duke
parents:
diff changeset
226 //-------------------------------------------
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
227
0
a61af66fc99e Initial load
duke
parents:
diff changeset
228 Address LIR_Assembler::as_Address(LIR_Address* addr) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
229 return as_Address(addr, rscratch1);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
230 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
231
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
232 Address LIR_Assembler::as_Address(LIR_Address* addr, Register tmp) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if (addr->base()->is_illegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 assert(addr->index()->is_illegal(), "must be illegal too");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
235 AddressLiteral laddr((address)addr->disp(), relocInfo::none);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
236 if (! __ reachable(laddr)) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
237 __ movptr(tmp, laddr.addr());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
238 Address res(tmp, 0);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
239 return res;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
240 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
241 return __ as_Address(laddr);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
242 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
245 Register base = addr->base()->as_pointer_register();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 if (addr->index()->is_illegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 return Address( base, addr->disp());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
249 } else if (addr->index()->is_cpu_register()) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
250 Register index = addr->index()->as_pointer_register();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
251 return Address(base, index, (Address::ScaleFactor) addr->scale(), addr->disp());
a61af66fc99e Initial load
duke
parents:
diff changeset
252 } else if (addr->index()->is_constant()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
253 intptr_t addr_offset = (addr->index()->as_constant_ptr()->as_jint() << addr->scale()) + addr->disp();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
254 assert(Assembler::is_simm32(addr_offset), "must be");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 return Address(base, addr_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
259 return Address();
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 Address LIR_Assembler::as_Address_hi(LIR_Address* addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 Address base = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 return Address(base._base, base._index, base._scale, base._disp + BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 Address LIR_Assembler::as_Address_lo(LIR_Address* addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 return as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 void LIR_Assembler::osr_entry() {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 offsets()->set_value(CodeOffsets::OSR_Entry, code_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
277 BlockBegin* osr_entry = compilation()->hir()->osr_entry();
a61af66fc99e Initial load
duke
parents:
diff changeset
278 ValueStack* entry_state = osr_entry->state();
a61af66fc99e Initial load
duke
parents:
diff changeset
279 int number_of_locks = entry_state->locks_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // we jump here if osr happens with the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // state set up to continue at the beginning of the
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // loop that triggered osr - in particular, we have
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // the following registers setup:
a61af66fc99e Initial load
duke
parents:
diff changeset
285 //
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // rcx: osr buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
287 //
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // build frame
a61af66fc99e Initial load
duke
parents:
diff changeset
290 ciMethod* m = compilation()->method();
17980
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17831
diff changeset
291 __ build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // OSR buffer is
a61af66fc99e Initial load
duke
parents:
diff changeset
294 //
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // locals[nlocals-1..0]
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // monitors[0..number_of_locks]
a61af66fc99e Initial load
duke
parents:
diff changeset
297 //
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // locals is a direct copy of the interpreter frame so in the osr buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // so first slot in the local array is the last local from the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // and last slot is local[0] (receiver) from the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
301 //
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // Similarly with locks. The first lock slot in the osr buffer is the nth lock
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // from the interpreter frame, the nth lock slot in the osr buffer is 0th lock
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // in the interpreter frame (the method lock if a sync method)
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // Initialize monitors in the compiled activation.
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // rcx: pointer to osr buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
308 //
a61af66fc99e Initial load
duke
parents:
diff changeset
309 // All other registers are dead at this point and the locals will be
a61af66fc99e Initial load
duke
parents:
diff changeset
310 // copied into place by code emitted in the IR.
a61af66fc99e Initial load
duke
parents:
diff changeset
311
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
312 Register OSR_buf = osrBufferPointer()->as_pointer_register();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
313 { assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below");
a61af66fc99e Initial load
duke
parents:
diff changeset
314 int monitor_offset = BytesPerWord * method()->max_locals() +
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
315 (2 * BytesPerWord) * (number_of_locks - 1);
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
316 // SharedRuntime::OSR_migration_begin() packs BasicObjectLocks in
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
317 // the OSR buffer using 2 word entries: first the lock and then
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
318 // the oop.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
319 for (int i = 0; i < number_of_locks; i++) {
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
320 int slot_offset = monitor_offset - ((i * 2) * BytesPerWord);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
321 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // verify the interpreter's monitor has a non-null object
a61af66fc99e Initial load
duke
parents:
diff changeset
323 {
a61af66fc99e Initial load
duke
parents:
diff changeset
324 Label L;
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
325 __ cmpptr(Address(OSR_buf, slot_offset + 1*BytesPerWord), (int32_t)NULL_WORD);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
326 __ jcc(Assembler::notZero, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
327 __ stop("locked object is NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
328 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 }
a61af66fc99e Initial load
duke
parents:
diff changeset
330 #endif
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
331 __ movptr(rbx, Address(OSR_buf, slot_offset + 0));
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
332 __ movptr(frame_map()->address_for_monitor_lock(i), rbx);
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
333 __ movptr(rbx, Address(OSR_buf, slot_offset + 1*BytesPerWord));
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
334 __ movptr(frame_map()->address_for_monitor_object(i), rbx);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336 }
a61af66fc99e Initial load
duke
parents:
diff changeset
337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
338
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // inline cache check; done before the frame is built.
a61af66fc99e Initial load
duke
parents:
diff changeset
341 int LIR_Assembler::check_icache() {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 Register receiver = FrameMap::receiver_opr->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
343 Register ic_klass = IC_Klass;
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
344 const int ic_cmp_size = LP64_ONLY(10) NOT_LP64(9);
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
345 const bool do_post_padding = VerifyOops || UseCompressedClassPointers;
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
346 if (!do_post_padding) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
347 // insert some nops so that the verified entry point is aligned on CodeEntryAlignment
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
348 while ((__ offset() + ic_cmp_size) % CodeEntryAlignment != 0) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
349 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
352 int offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
353 __ inline_cache_check(receiver, IC_Klass);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
354 assert(__ offset() % CodeEntryAlignment == 0 || do_post_padding, "alignment must be correct");
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
355 if (do_post_padding) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
356 // force alignment after the cache check.
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // It's been verified to be aligned if !VerifyOops
a61af66fc99e Initial load
duke
parents:
diff changeset
358 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
359 }
a61af66fc99e Initial load
duke
parents:
diff changeset
360 return offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 void LIR_Assembler::jobject2reg_with_patching(Register reg, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
365 jobject o = NULL;
12160
f98f5d48f511 7199175: JSR 292: C1 needs patching when invokedynamic/invokehandle call site is not linked
roland
parents: 11080
diff changeset
366 PatchingStub* patch = new PatchingStub(_masm, patching_id(info));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
367 __ movoop(reg, o);
a61af66fc99e Initial load
duke
parents:
diff changeset
368 patching_epilog(patch, lir_patch_normal, reg, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
370
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
371 void LIR_Assembler::klass2reg_with_patching(Register reg, CodeEmitInfo* info) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
372 Metadata* o = NULL;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
373 PatchingStub* patch = new PatchingStub(_masm, PatchingStub::load_klass_id);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
374 __ mov_metadata(reg, o);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
375 patching_epilog(patch, lir_patch_normal, reg, info);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
376 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 // This specifies the rsp decrement needed to build the frame
17980
0bf37f737702 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 17831
diff changeset
379 int LIR_Assembler::initial_frame_size_in_bytes() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
380 // if rounding, must let FrameMap know!
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
381
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
382 // The frame_map records size in slots (32bit word)
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
383
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
384 // subtract two words to account for return address and link
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
385 return (frame_map()->framesize() - (2*VMRegImpl::slots_per_word)) * VMRegImpl::stack_slot_size;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
386 }
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
389 int LIR_Assembler::emit_exception_handler() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
390 // if the last instruction is a call (typically to do a throw which
a61af66fc99e Initial load
duke
parents:
diff changeset
391 // is coming at the end after block reordering) the return address
a61af66fc99e Initial load
duke
parents:
diff changeset
392 // must still point into the code area in order to avoid assertion
a61af66fc99e Initial load
duke
parents:
diff changeset
393 // failures when searching for the corresponding bci => add a nop
a61af66fc99e Initial load
duke
parents:
diff changeset
394 // (was bug 5/14/1999 - gri)
a61af66fc99e Initial load
duke
parents:
diff changeset
395 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
396
a61af66fc99e Initial load
duke
parents:
diff changeset
397 // generate code for exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
398 address handler_base = __ start_a_stub(exception_handler_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
399 if (handler_base == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
400 // not enough space left for the handler
a61af66fc99e Initial load
duke
parents:
diff changeset
401 bailout("exception handler overflow");
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
402 return -1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
403 }
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
404
0
a61af66fc99e Initial load
duke
parents:
diff changeset
405 int offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
406
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
407 // the exception oop and pc are in rax, and rdx
0
a61af66fc99e Initial load
duke
parents:
diff changeset
408 // no other registers need to be preserved, so invalidate them
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
409 __ invalidate_registers(false, true, true, false, true, true);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // check that there is really an exception
a61af66fc99e Initial load
duke
parents:
diff changeset
412 __ verify_not_null_oop(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
413
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
414 // search an exception handler (rax: exception oop, rdx: throwing pc)
2321
1b4e6a5d98e0 7012914: JSR 292 MethodHandlesTest C1: frame::verify_return_pc(return_address) failed: must be a return pc
twisti
parents: 2112
diff changeset
415 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::handle_exception_from_callee_id)));
1b4e6a5d98e0 7012914: JSR 292 MethodHandlesTest C1: frame::verify_return_pc(return_address) failed: must be a return pc
twisti
parents: 2112
diff changeset
416 __ should_not_reach_here();
4808
898522ae3c32 7131288: COMPILE SKIPPED: deopt handler overflow (retry at different tier)
iveresov
parents: 4771
diff changeset
417 guarantee(code_offset() - offset <= exception_handler_size, "overflow");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
418 __ end_a_stub();
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
419
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
420 return offset;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
421 }
a61af66fc99e Initial load
duke
parents:
diff changeset
422
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
423
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
424 // Emit the code to remove the frame from the stack in the exception
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
425 // unwind path.
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
426 int LIR_Assembler::emit_unwind_handler() {
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
427 #ifndef PRODUCT
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
428 if (CommentedAssembly) {
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
429 _masm->block_comment("Unwind handler");
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
430 }
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
431 #endif
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
432
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
433 int offset = code_offset();
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
434
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
435 // Fetch the exception from TLS and clear out exception related thread state
12969
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
436 Register thread = NOT_LP64(rsi) LP64_ONLY(r15_thread);
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
437 NOT_LP64(__ get_thread(rsi));
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
438 __ movptr(rax, Address(thread, JavaThread::exception_oop_offset()));
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
439 __ movptr(Address(thread, JavaThread::exception_oop_offset()), (intptr_t)NULL_WORD);
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
440 __ movptr(Address(thread, JavaThread::exception_pc_offset()), (intptr_t)NULL_WORD);
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
441
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
442 __ bind(_unwind_handler_entry);
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
443 __ verify_not_null_oop(rax);
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
444 if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
12969
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
445 __ mov(rbx, rax); // Preserve the exception (rbx is always callee-saved)
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
446 }
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
447
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
448 // Preform needed unlocking
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
449 MonitorExitStub* stub = NULL;
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
450 if (method()->is_synchronized()) {
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
451 monitor_address(0, FrameMap::rax_opr);
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
452 stub = new MonitorExitStub(FrameMap::rax_opr, true, 0);
12969
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
453 __ unlock_object(rdi, rsi, rax, *stub->entry());
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
454 __ bind(*stub->continuation());
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
455 }
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
456
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
457 if (compilation()->env()->dtrace_method_probes()) {
12969
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
458 #ifdef _LP64
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
459 __ mov(rdi, r15_thread);
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
460 __ mov_metadata(rsi, method()->constant_encoding());
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
461 #else
1830
a3f7f95b0165 6988018: dtrace/hotspot/MethodInvocation/MethodInvocation002 crashes with client compiler
never
parents: 1791
diff changeset
462 __ get_thread(rax);
a3f7f95b0165 6988018: dtrace/hotspot/MethodInvocation/MethodInvocation002 crashes with client compiler
never
parents: 1791
diff changeset
463 __ movptr(Address(rsp, 0), rax);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
464 __ mov_metadata(Address(rsp, sizeof(void*)), method()->constant_encoding());
12969
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
465 #endif
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
466 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit)));
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
467 }
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
468
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
469 if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
12969
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12955
diff changeset
470 __ mov(rax, rbx); // Restore the exception
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
471 }
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
472
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
473 // remove the activation and dispatch to the unwind handler
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
474 __ remove_frame(initial_frame_size_in_bytes());
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
475 __ jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id)));
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
476
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
477 // Emit the slow path assembly
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
478 if (stub != NULL) {
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
479 stub->emit_code(this);
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
480 }
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
481
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
482 return offset;
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
483 }
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
484
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
485
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
486 int LIR_Assembler::emit_deopt_handler() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
487 // if the last instruction is a call (typically to do a throw which
a61af66fc99e Initial load
duke
parents:
diff changeset
488 // is coming at the end after block reordering) the return address
a61af66fc99e Initial load
duke
parents:
diff changeset
489 // must still point into the code area in order to avoid assertion
a61af66fc99e Initial load
duke
parents:
diff changeset
490 // failures when searching for the corresponding bci => add a nop
a61af66fc99e Initial load
duke
parents:
diff changeset
491 // (was bug 5/14/1999 - gri)
a61af66fc99e Initial load
duke
parents:
diff changeset
492 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
493
a61af66fc99e Initial load
duke
parents:
diff changeset
494 // generate code for exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
495 address handler_base = __ start_a_stub(deopt_handler_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
496 if (handler_base == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
497 // not enough space left for the handler
a61af66fc99e Initial load
duke
parents:
diff changeset
498 bailout("deopt handler overflow");
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
499 return -1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
500 }
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
501
0
a61af66fc99e Initial load
duke
parents:
diff changeset
502 int offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
503 InternalAddress here(__ pc());
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
504
0
a61af66fc99e Initial load
duke
parents:
diff changeset
505 __ pushptr(here.addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
506 __ jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack()));
4808
898522ae3c32 7131288: COMPILE SKIPPED: deopt handler overflow (retry at different tier)
iveresov
parents: 4771
diff changeset
507 guarantee(code_offset() - offset <= deopt_handler_size, "overflow");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
508 __ end_a_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
509
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
510 return offset;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // This is the fast version of java.lang.String.compare; it has not
a61af66fc99e Initial load
duke
parents:
diff changeset
515 // OSR-entry and therefore, we generate a slow version for OSR's
a61af66fc99e Initial load
duke
parents:
diff changeset
516 void LIR_Assembler::emit_string_compare(LIR_Opr arg0, LIR_Opr arg1, LIR_Opr dst, CodeEmitInfo* info) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
517 __ movptr (rbx, rcx); // receiver is in rcx
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
518 __ movptr (rax, arg1->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
519
a61af66fc99e Initial load
duke
parents:
diff changeset
520 // Get addresses of first characters from both Strings
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
521 __ load_heap_oop(rsi, Address(rax, java_lang_String::value_offset_in_bytes()));
6057
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
522 if (java_lang_String::has_offset_field()) {
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
523 __ movptr (rcx, Address(rax, java_lang_String::offset_offset_in_bytes()));
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
524 __ movl (rax, Address(rax, java_lang_String::count_offset_in_bytes()));
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
525 __ lea (rsi, Address(rsi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR)));
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
526 } else {
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
527 __ movl (rax, Address(rsi, arrayOopDesc::length_offset_in_bytes()));
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
528 __ lea (rsi, Address(rsi, arrayOopDesc::base_offset_in_bytes(T_CHAR)));
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
529 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
530
a61af66fc99e Initial load
duke
parents:
diff changeset
531 // rbx, may be NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
532 add_debug_info_for_null_check_here(info);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
533 __ load_heap_oop(rdi, Address(rbx, java_lang_String::value_offset_in_bytes()));
6057
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
534 if (java_lang_String::has_offset_field()) {
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
535 __ movptr (rcx, Address(rbx, java_lang_String::offset_offset_in_bytes()));
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
536 __ movl (rbx, Address(rbx, java_lang_String::count_offset_in_bytes()));
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
537 __ lea (rdi, Address(rdi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR)));
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
538 } else {
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
539 __ movl (rbx, Address(rdi, arrayOopDesc::length_offset_in_bytes()));
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
540 __ lea (rdi, Address(rdi, arrayOopDesc::base_offset_in_bytes(T_CHAR)));
8f972594effc 6924259: Remove String.count/String.offset
kvn
parents: 6041
diff changeset
541 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
542
a61af66fc99e Initial load
duke
parents:
diff changeset
543 // compute minimum length (in rax) and difference of lengths (on top of stack)
2415
09f96c3ff1ad 7032388: guarantee(VM_Version::supports_cmov()) failed: illegal instruction on i586 after 6919934
twisti
parents: 2404
diff changeset
544 __ mov (rcx, rbx);
09f96c3ff1ad 7032388: guarantee(VM_Version::supports_cmov()) failed: illegal instruction on i586 after 6919934
twisti
parents: 2404
diff changeset
545 __ subptr(rbx, rax); // subtract lengths
09f96c3ff1ad 7032388: guarantee(VM_Version::supports_cmov()) failed: illegal instruction on i586 after 6919934
twisti
parents: 2404
diff changeset
546 __ push (rbx); // result
09f96c3ff1ad 7032388: guarantee(VM_Version::supports_cmov()) failed: illegal instruction on i586 after 6919934
twisti
parents: 2404
diff changeset
547 __ cmov (Assembler::lessEqual, rax, rcx);
09f96c3ff1ad 7032388: guarantee(VM_Version::supports_cmov()) failed: illegal instruction on i586 after 6919934
twisti
parents: 2404
diff changeset
548
0
a61af66fc99e Initial load
duke
parents:
diff changeset
549 // is minimum length 0?
a61af66fc99e Initial load
duke
parents:
diff changeset
550 Label noLoop, haveResult;
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
551 __ testptr (rax, rax);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
552 __ jcc (Assembler::zero, noLoop);
a61af66fc99e Initial load
duke
parents:
diff changeset
553
a61af66fc99e Initial load
duke
parents:
diff changeset
554 // compare first characters
622
56aae7be60d4 6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents: 512
diff changeset
555 __ load_unsigned_short(rcx, Address(rdi, 0));
56aae7be60d4 6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents: 512
diff changeset
556 __ load_unsigned_short(rbx, Address(rsi, 0));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
557 __ subl(rcx, rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
558 __ jcc(Assembler::notZero, haveResult);
a61af66fc99e Initial load
duke
parents:
diff changeset
559 // starting loop
a61af66fc99e Initial load
duke
parents:
diff changeset
560 __ decrement(rax); // we already tested index: skip one
a61af66fc99e Initial load
duke
parents:
diff changeset
561 __ jcc(Assembler::zero, noLoop);
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // set rsi.edi to the end of the arrays (arrays have same length)
a61af66fc99e Initial load
duke
parents:
diff changeset
564 // negate the index
a61af66fc99e Initial load
duke
parents:
diff changeset
565
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
566 __ lea(rsi, Address(rsi, rax, Address::times_2, type2aelembytes(T_CHAR)));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
567 __ lea(rdi, Address(rdi, rax, Address::times_2, type2aelembytes(T_CHAR)));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
568 __ negptr(rax);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
569
a61af66fc99e Initial load
duke
parents:
diff changeset
570 // compare the strings in a loop
a61af66fc99e Initial load
duke
parents:
diff changeset
571
a61af66fc99e Initial load
duke
parents:
diff changeset
572 Label loop;
a61af66fc99e Initial load
duke
parents:
diff changeset
573 __ align(wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
574 __ bind(loop);
622
56aae7be60d4 6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents: 512
diff changeset
575 __ load_unsigned_short(rcx, Address(rdi, rax, Address::times_2, 0));
56aae7be60d4 6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents: 512
diff changeset
576 __ load_unsigned_short(rbx, Address(rsi, rax, Address::times_2, 0));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
577 __ subl(rcx, rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
578 __ jcc(Assembler::notZero, haveResult);
a61af66fc99e Initial load
duke
parents:
diff changeset
579 __ increment(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
580 __ jcc(Assembler::notZero, loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
581
a61af66fc99e Initial load
duke
parents:
diff changeset
582 // strings are equal up to min length
a61af66fc99e Initial load
duke
parents:
diff changeset
583
a61af66fc99e Initial load
duke
parents:
diff changeset
584 __ bind(noLoop);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
585 __ pop(rax);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
586 return_op(LIR_OprFact::illegalOpr);
a61af66fc99e Initial load
duke
parents:
diff changeset
587
a61af66fc99e Initial load
duke
parents:
diff changeset
588 __ bind(haveResult);
a61af66fc99e Initial load
duke
parents:
diff changeset
589 // leave instruction is going to discard the TOS value
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
590 __ mov (rax, rcx); // result of call is in rax,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
591 }
a61af66fc99e Initial load
duke
parents:
diff changeset
592
a61af66fc99e Initial load
duke
parents:
diff changeset
593
a61af66fc99e Initial load
duke
parents:
diff changeset
594 void LIR_Assembler::return_op(LIR_Opr result) {
a61af66fc99e Initial load
duke
parents:
diff changeset
595 assert(result->is_illegal() || !result->is_single_cpu() || result->as_register() == rax, "word returns are in rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
596 if (!result->is_illegal() && result->is_float_kind() && !result->is_xmm_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
597 assert(result->fpu() == 0, "result must already be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
598 }
a61af66fc99e Initial load
duke
parents:
diff changeset
599
a61af66fc99e Initial load
duke
parents:
diff changeset
600 // Pop the stack before the safepoint code
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
601 __ remove_frame(initial_frame_size_in_bytes());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
602
a61af66fc99e Initial load
duke
parents:
diff changeset
603 bool result_is_oop = result->is_valid() ? result->is_oop() : false;
a61af66fc99e Initial load
duke
parents:
diff changeset
604
a61af66fc99e Initial load
duke
parents:
diff changeset
605 // Note: we do not need to round double result; float result has the right precision
a61af66fc99e Initial load
duke
parents:
diff changeset
606 // the poll sets the condition code, but no data registers
a61af66fc99e Initial load
duke
parents:
diff changeset
607 AddressLiteral polling_page(os::get_polling_page() + (SafepointPollOffset % os::vm_page_size()),
a61af66fc99e Initial load
duke
parents:
diff changeset
608 relocInfo::poll_return_type);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
609
2404
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
610 if (Assembler::is_polling_page_far()) {
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
611 __ lea(rscratch1, polling_page);
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
612 __ relocate(relocInfo::poll_return_type);
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
613 __ testl(rax, Address(rscratch1, 0));
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
614 } else {
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
615 __ testl(rax, polling_page);
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
616 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
617 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
618 }
a61af66fc99e Initial load
duke
parents:
diff changeset
619
a61af66fc99e Initial load
duke
parents:
diff changeset
620
a61af66fc99e Initial load
duke
parents:
diff changeset
621 int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
622 AddressLiteral polling_page(os::get_polling_page() + (SafepointPollOffset % os::vm_page_size()),
a61af66fc99e Initial load
duke
parents:
diff changeset
623 relocInfo::poll_type);
2404
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
624 guarantee(info != NULL, "Shouldn't be NULL");
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
625 int offset = __ offset();
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
626 if (Assembler::is_polling_page_far()) {
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
627 __ lea(rscratch1, polling_page);
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
628 offset = __ offset();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
629 add_debug_info_for_branch(info);
2404
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
630 __ testl(rax, Address(rscratch1, 0));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
631 } else {
2404
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
632 add_debug_info_for_branch(info);
b40d4fa697bf 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 2321
diff changeset
633 __ testl(rax, polling_page);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
634 }
a61af66fc99e Initial load
duke
parents:
diff changeset
635 return offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
636 }
a61af66fc99e Initial load
duke
parents:
diff changeset
637
a61af66fc99e Initial load
duke
parents:
diff changeset
638
a61af66fc99e Initial load
duke
parents:
diff changeset
639 void LIR_Assembler::move_regs(Register from_reg, Register to_reg) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
640 if (from_reg != to_reg) __ mov(to_reg, from_reg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
641 }
a61af66fc99e Initial load
duke
parents:
diff changeset
642
a61af66fc99e Initial load
duke
parents:
diff changeset
643 void LIR_Assembler::swap_reg(Register a, Register b) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
644 __ xchgptr(a, b);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
645 }
a61af66fc99e Initial load
duke
parents:
diff changeset
646
a61af66fc99e Initial load
duke
parents:
diff changeset
647
a61af66fc99e Initial load
duke
parents:
diff changeset
648 void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
649 assert(src->is_constant(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
650 assert(dest->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
651 LIR_Const* c = src->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
652
a61af66fc99e Initial load
duke
parents:
diff changeset
653 switch (c->type()) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
654 case T_INT: {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
655 assert(patch_code == lir_patch_none, "no patching handled here");
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
656 __ movl(dest->as_register(), c->as_jint());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
657 break;
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
658 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
659
1297
c466efa608d5 6932496: c1: deoptimization of jsr subroutine fails on sparcv9
roland
parents: 1295
diff changeset
660 case T_ADDRESS: {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
661 assert(patch_code == lir_patch_none, "no patching handled here");
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
662 __ movptr(dest->as_register(), c->as_jint());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
663 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
664 }
a61af66fc99e Initial load
duke
parents:
diff changeset
665
a61af66fc99e Initial load
duke
parents:
diff changeset
666 case T_LONG: {
a61af66fc99e Initial load
duke
parents:
diff changeset
667 assert(patch_code == lir_patch_none, "no patching handled here");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
668 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
669 __ movptr(dest->as_register_lo(), (intptr_t)c->as_jlong());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
670 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
671 __ movptr(dest->as_register_lo(), c->as_jint_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
672 __ movptr(dest->as_register_hi(), c->as_jint_hi());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
673 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
674 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
675 }
a61af66fc99e Initial load
duke
parents:
diff changeset
676
a61af66fc99e Initial load
duke
parents:
diff changeset
677 case T_OBJECT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
678 if (patch_code != lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
679 jobject2reg_with_patching(dest->as_register(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
680 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
681 __ movoop(dest->as_register(), c->as_jobject());
a61af66fc99e Initial load
duke
parents:
diff changeset
682 }
a61af66fc99e Initial load
duke
parents:
diff changeset
683 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
684 }
a61af66fc99e Initial load
duke
parents:
diff changeset
685
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
686 case T_METADATA: {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
687 if (patch_code != lir_patch_none) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
688 klass2reg_with_patching(dest->as_register(), info);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
689 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
690 __ mov_metadata(dest->as_register(), c->as_metadata());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
691 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
692 break;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
693 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
694
0
a61af66fc99e Initial load
duke
parents:
diff changeset
695 case T_FLOAT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
696 if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
697 if (c->is_zero_float()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
698 __ xorps(dest->as_xmm_float_reg(), dest->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
699 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
700 __ movflt(dest->as_xmm_float_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
701 InternalAddress(float_constant(c->as_jfloat())));
a61af66fc99e Initial load
duke
parents:
diff changeset
702 }
a61af66fc99e Initial load
duke
parents:
diff changeset
703 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
704 assert(dest->is_single_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
705 assert(dest->fpu_regnr() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
706 if (c->is_zero_float()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
707 __ fldz();
a61af66fc99e Initial load
duke
parents:
diff changeset
708 } else if (c->is_one_float()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
709 __ fld1();
a61af66fc99e Initial load
duke
parents:
diff changeset
710 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
711 __ fld_s (InternalAddress(float_constant(c->as_jfloat())));
a61af66fc99e Initial load
duke
parents:
diff changeset
712 }
a61af66fc99e Initial load
duke
parents:
diff changeset
713 }
a61af66fc99e Initial load
duke
parents:
diff changeset
714 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
715 }
a61af66fc99e Initial load
duke
parents:
diff changeset
716
a61af66fc99e Initial load
duke
parents:
diff changeset
717 case T_DOUBLE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
718 if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
719 if (c->is_zero_double()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
720 __ xorpd(dest->as_xmm_double_reg(), dest->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
721 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
722 __ movdbl(dest->as_xmm_double_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
723 InternalAddress(double_constant(c->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
724 }
a61af66fc99e Initial load
duke
parents:
diff changeset
725 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
726 assert(dest->is_double_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
727 assert(dest->fpu_regnrLo() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
728 if (c->is_zero_double()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
729 __ fldz();
a61af66fc99e Initial load
duke
parents:
diff changeset
730 } else if (c->is_one_double()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
731 __ fld1();
a61af66fc99e Initial load
duke
parents:
diff changeset
732 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
733 __ fld_d (InternalAddress(double_constant(c->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
734 }
a61af66fc99e Initial load
duke
parents:
diff changeset
735 }
a61af66fc99e Initial load
duke
parents:
diff changeset
736 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
737 }
a61af66fc99e Initial load
duke
parents:
diff changeset
738
a61af66fc99e Initial load
duke
parents:
diff changeset
739 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
740 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
741 }
a61af66fc99e Initial load
duke
parents:
diff changeset
742 }
a61af66fc99e Initial load
duke
parents:
diff changeset
743
a61af66fc99e Initial load
duke
parents:
diff changeset
744 void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
745 assert(src->is_constant(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
746 assert(dest->is_stack(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
747 LIR_Const* c = src->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
748
a61af66fc99e Initial load
duke
parents:
diff changeset
749 switch (c->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
750 case T_INT: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
751 case T_FLOAT:
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
752 __ movl(frame_map()->address_for_slot(dest->single_stack_ix()), c->as_jint_bits());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
753 break;
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
754
1297
c466efa608d5 6932496: c1: deoptimization of jsr subroutine fails on sparcv9
roland
parents: 1295
diff changeset
755 case T_ADDRESS:
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
756 __ movptr(frame_map()->address_for_slot(dest->single_stack_ix()), c->as_jint_bits());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
757 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
758
a61af66fc99e Initial load
duke
parents:
diff changeset
759 case T_OBJECT:
a61af66fc99e Initial load
duke
parents:
diff changeset
760 __ movoop(frame_map()->address_for_slot(dest->single_stack_ix()), c->as_jobject());
a61af66fc99e Initial load
duke
parents:
diff changeset
761 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
762
a61af66fc99e Initial load
duke
parents:
diff changeset
763 case T_LONG: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
764 case T_DOUBLE:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
765 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
766 __ movptr(frame_map()->address_for_slot(dest->double_stack_ix(),
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
767 lo_word_offset_in_bytes), (intptr_t)c->as_jlong_bits());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
768 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
769 __ movptr(frame_map()->address_for_slot(dest->double_stack_ix(),
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
770 lo_word_offset_in_bytes), c->as_jint_lo_bits());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
771 __ movptr(frame_map()->address_for_slot(dest->double_stack_ix(),
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
772 hi_word_offset_in_bytes), c->as_jint_hi_bits());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
773 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
774 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
775
a61af66fc99e Initial load
duke
parents:
diff changeset
776 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
777 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
778 }
a61af66fc99e Initial load
duke
parents:
diff changeset
779 }
a61af66fc99e Initial load
duke
parents:
diff changeset
780
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
781 void LIR_Assembler::const2mem(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info, bool wide) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
782 assert(src->is_constant(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
783 assert(dest->is_address(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
784 LIR_Const* c = src->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
785 LIR_Address* addr = dest->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
786
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
787 int null_check_here = code_offset();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
788 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
789 case T_INT: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
790 case T_FLOAT:
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
791 __ movl(as_Address(addr), c->as_jint_bits());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
792 break;
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
793
1297
c466efa608d5 6932496: c1: deoptimization of jsr subroutine fails on sparcv9
roland
parents: 1295
diff changeset
794 case T_ADDRESS:
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
795 __ movptr(as_Address(addr), c->as_jint_bits());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
796 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
797
a61af66fc99e Initial load
duke
parents:
diff changeset
798 case T_OBJECT: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
799 case T_ARRAY:
a61af66fc99e Initial load
duke
parents:
diff changeset
800 if (c->as_jobject() == NULL) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
801 if (UseCompressedOops && !wide) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
802 __ movl(as_Address(addr), (int32_t)NULL_WORD);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
803 } else {
17831
876390ee9b6f 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 17496
diff changeset
804 #ifdef _LP64
876390ee9b6f 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 17496
diff changeset
805 __ xorptr(rscratch1, rscratch1);
876390ee9b6f 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 17496
diff changeset
806 null_check_here = code_offset();
876390ee9b6f 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 17496
diff changeset
807 __ movptr(as_Address(addr), rscratch1);
876390ee9b6f 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 17496
diff changeset
808 #else
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
809 __ movptr(as_Address(addr), NULL_WORD);
17831
876390ee9b6f 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 17496
diff changeset
810 #endif
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
811 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
812 } else {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
813 if (is_literal_address(addr)) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
814 ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
815 __ movoop(as_Address(addr, noreg), c->as_jobject());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
816 } else {
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
817 #ifdef _LP64
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
818 __ movoop(rscratch1, c->as_jobject());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
819 if (UseCompressedOops && !wide) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
820 __ encode_heap_oop(rscratch1);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
821 null_check_here = code_offset();
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
822 __ movl(as_Address_lo(addr), rscratch1);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
823 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
824 null_check_here = code_offset();
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
825 __ movptr(as_Address_lo(addr), rscratch1);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
826 }
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
827 #else
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
828 __ movoop(as_Address(addr), c->as_jobject());
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
829 #endif
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
830 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
831 }
a61af66fc99e Initial load
duke
parents:
diff changeset
832 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
833
a61af66fc99e Initial load
duke
parents:
diff changeset
834 case T_LONG: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
835 case T_DOUBLE:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
836 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
837 if (is_literal_address(addr)) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
838 ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
839 __ movptr(as_Address(addr, r15_thread), (intptr_t)c->as_jlong_bits());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
840 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
841 __ movptr(r10, (intptr_t)c->as_jlong_bits());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
842 null_check_here = code_offset();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
843 __ movptr(as_Address_lo(addr), r10);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
844 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
845 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
846 // Always reachable in 32bit so this doesn't produce useless move literal
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
847 __ movptr(as_Address_hi(addr), c->as_jint_hi_bits());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
848 __ movptr(as_Address_lo(addr), c->as_jint_lo_bits());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
849 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
850 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
851
a61af66fc99e Initial load
duke
parents:
diff changeset
852 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
853 case T_BYTE:
a61af66fc99e Initial load
duke
parents:
diff changeset
854 __ movb(as_Address(addr), c->as_jint() & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
855 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
856
a61af66fc99e Initial load
duke
parents:
diff changeset
857 case T_CHAR: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
858 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
859 __ movw(as_Address(addr), c->as_jint() & 0xFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
860 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
861
a61af66fc99e Initial load
duke
parents:
diff changeset
862 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
863 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
864 };
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
865
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
866 if (info != NULL) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
867 add_debug_info_for_null_check(null_check_here, info);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
868 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
869 }
a61af66fc99e Initial load
duke
parents:
diff changeset
870
a61af66fc99e Initial load
duke
parents:
diff changeset
871
a61af66fc99e Initial load
duke
parents:
diff changeset
872 void LIR_Assembler::reg2reg(LIR_Opr src, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
873 assert(src->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
874 assert(dest->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
875
a61af66fc99e Initial load
duke
parents:
diff changeset
876 // move between cpu-registers
a61af66fc99e Initial load
duke
parents:
diff changeset
877 if (dest->is_single_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
878 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
879 if (src->type() == T_LONG) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
880 // Can do LONG -> OBJECT
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
881 move_regs(src->as_register_lo(), dest->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
882 return;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
883 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
884 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
885 assert(src->is_single_cpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
886 if (src->type() == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
887 __ verify_oop(src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
888 }
a61af66fc99e Initial load
duke
parents:
diff changeset
889 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
890
a61af66fc99e Initial load
duke
parents:
diff changeset
891 } else if (dest->is_double_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
892 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
893 if (src->type() == T_OBJECT || src->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
894 // Surprising to me but we can see move of a long to t_object
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
895 __ verify_oop(src->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
896 move_regs(src->as_register(), dest->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
897 return;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
898 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
899 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
900 assert(src->is_double_cpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
901 Register f_lo = src->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
902 Register f_hi = src->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
903 Register t_lo = dest->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
904 Register t_hi = dest->as_register_hi();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
905 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
906 assert(f_hi == f_lo, "must be same");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
907 assert(t_hi == t_lo, "must be same");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
908 move_regs(f_lo, t_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
909 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
910 assert(f_lo != f_hi && t_lo != t_hi, "invalid register allocation");
a61af66fc99e Initial load
duke
parents:
diff changeset
911
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
912
0
a61af66fc99e Initial load
duke
parents:
diff changeset
913 if (f_lo == t_hi && f_hi == t_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
914 swap_reg(f_lo, f_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
915 } else if (f_hi == t_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
916 assert(f_lo != t_hi, "overwriting register");
a61af66fc99e Initial load
duke
parents:
diff changeset
917 move_regs(f_hi, t_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
918 move_regs(f_lo, t_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
919 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
920 assert(f_hi != t_lo, "overwriting register");
a61af66fc99e Initial load
duke
parents:
diff changeset
921 move_regs(f_lo, t_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
922 move_regs(f_hi, t_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
923 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
924 #endif // LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
925
a61af66fc99e Initial load
duke
parents:
diff changeset
926 // special moves from fpu-register to xmm-register
a61af66fc99e Initial load
duke
parents:
diff changeset
927 // necessary for method results
a61af66fc99e Initial load
duke
parents:
diff changeset
928 } else if (src->is_single_xmm() && !dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
929 __ movflt(Address(rsp, 0), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
930 __ fld_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
931 } else if (src->is_double_xmm() && !dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
932 __ movdbl(Address(rsp, 0), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
933 __ fld_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
934 } else if (dest->is_single_xmm() && !src->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
935 __ fstp_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
936 __ movflt(dest->as_xmm_float_reg(), Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
937 } else if (dest->is_double_xmm() && !src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
938 __ fstp_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
939 __ movdbl(dest->as_xmm_double_reg(), Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
940
a61af66fc99e Initial load
duke
parents:
diff changeset
941 // move between xmm-registers
a61af66fc99e Initial load
duke
parents:
diff changeset
942 } else if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
943 assert(src->is_single_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
944 __ movflt(dest->as_xmm_float_reg(), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
945 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
946 assert(src->is_double_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
947 __ movdbl(dest->as_xmm_double_reg(), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
948
a61af66fc99e Initial load
duke
parents:
diff changeset
949 // move between fpu-registers (no instruction necessary because of fpu-stack)
a61af66fc99e Initial load
duke
parents:
diff changeset
950 } else if (dest->is_single_fpu() || dest->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
951 assert(src->is_single_fpu() || src->is_double_fpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
952 assert(src->fpu() == dest->fpu(), "currently should be nothing to do");
a61af66fc99e Initial load
duke
parents:
diff changeset
953 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
954 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
955 }
a61af66fc99e Initial load
duke
parents:
diff changeset
956 }
a61af66fc99e Initial load
duke
parents:
diff changeset
957
a61af66fc99e Initial load
duke
parents:
diff changeset
958 void LIR_Assembler::reg2stack(LIR_Opr src, LIR_Opr dest, BasicType type, bool pop_fpu_stack) {
a61af66fc99e Initial load
duke
parents:
diff changeset
959 assert(src->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
960 assert(dest->is_stack(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
961
a61af66fc99e Initial load
duke
parents:
diff changeset
962 if (src->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
963 Address dst = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
964 if (type == T_OBJECT || type == T_ARRAY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
965 __ verify_oop(src->as_register());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
966 __ movptr (dst, src->as_register());
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
967 } else if (type == T_METADATA) {
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
968 __ movptr (dst, src->as_register());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
969 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
970 __ movl (dst, src->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
971 }
a61af66fc99e Initial load
duke
parents:
diff changeset
972
a61af66fc99e Initial load
duke
parents:
diff changeset
973 } else if (src->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
974 Address dstLO = frame_map()->address_for_slot(dest->double_stack_ix(), lo_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
975 Address dstHI = frame_map()->address_for_slot(dest->double_stack_ix(), hi_word_offset_in_bytes);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
976 __ movptr (dstLO, src->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
977 NOT_LP64(__ movptr (dstHI, src->as_register_hi()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
978
a61af66fc99e Initial load
duke
parents:
diff changeset
979 } else if (src->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
980 Address dst_addr = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
981 __ movflt(dst_addr, src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
982
a61af66fc99e Initial load
duke
parents:
diff changeset
983 } else if (src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
984 Address dst_addr = frame_map()->address_for_slot(dest->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
985 __ movdbl(dst_addr, src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
986
a61af66fc99e Initial load
duke
parents:
diff changeset
987 } else if (src->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
988 assert(src->fpu_regnr() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
989 Address dst_addr = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
990 if (pop_fpu_stack) __ fstp_s (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
991 else __ fst_s (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
992
a61af66fc99e Initial load
duke
parents:
diff changeset
993 } else if (src->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
994 assert(src->fpu_regnrLo() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
995 Address dst_addr = frame_map()->address_for_slot(dest->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
996 if (pop_fpu_stack) __ fstp_d (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
997 else __ fst_d (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
998
a61af66fc99e Initial load
duke
parents:
diff changeset
999 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1003
a61af66fc99e Initial load
duke
parents:
diff changeset
1004
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1005 void LIR_Assembler::reg2mem(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack, bool wide, bool /* unaligned */) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 LIR_Address* to_addr = dest->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 PatchingStub* patch = NULL;
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1008 Register compressed_src = rscratch1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1009
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 if (type == T_ARRAY || type == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 __ verify_oop(src->as_register());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1012 #ifdef _LP64
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1013 if (UseCompressedOops && !wide) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1014 __ movptr(compressed_src, src->as_register());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1015 __ encode_heap_oop(compressed_src);
17496
12ad8db39f76 8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a
roland
parents: 12969
diff changeset
1016 if (patch_code != lir_patch_none) {
12ad8db39f76 8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a
roland
parents: 12969
diff changeset
1017 info->oop_map()->set_narrowoop(compressed_src->as_VMReg());
12ad8db39f76 8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a
roland
parents: 12969
diff changeset
1018 }
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1019 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1020 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 }
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1022
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 if (patch_code != lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1025 Address toa = as_Address(to_addr);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1026 assert(toa.disp() != 0, "must have");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 }
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1028
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1029 int null_check_here = code_offset();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 case T_FLOAT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 if (src->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 __ movflt(as_Address(to_addr), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 assert(src->is_single_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 assert(src->fpu_regnr() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 if (pop_fpu_stack) __ fstp_s(as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 else __ fst_s (as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1042
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 case T_DOUBLE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 if (src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 __ movdbl(as_Address(to_addr), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 assert(src->is_double_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 assert(src->fpu_regnrLo() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 if (pop_fpu_stack) __ fstp_d(as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 else __ fst_d (as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1054
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 case T_ARRAY: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 case T_OBJECT: // fall through
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1057 if (UseCompressedOops && !wide) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1058 __ movl(as_Address(to_addr), compressed_src);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1059 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1060 __ movptr(as_Address(to_addr), src->as_register());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1061 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1062 break;
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1063 case T_METADATA:
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1064 // We get here to store a method pointer to the stack to pass to
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1065 // a dtrace runtime call. This can't work on 64 bit with
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1066 // compressed klass ptrs: T_METADATA can be a compressed klass
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1067 // ptr or a 64 bit method pointer.
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1068 LP64_ONLY(ShouldNotReachHere());
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1069 __ movptr(as_Address(to_addr), src->as_register());
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1070 break;
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1071 case T_ADDRESS:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1072 __ movptr(as_Address(to_addr), src->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1073 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 __ movl(as_Address(to_addr), src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1077
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 case T_LONG: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 Register from_lo = src->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 Register from_hi = src->as_register_hi();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1081 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1082 __ movptr(as_Address_lo(to_addr), from_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1083 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 Register base = to_addr->base()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 Register index = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 if (to_addr->index()->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 index = to_addr->index()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 if (base == from_lo || index == from_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 assert(base != from_hi, "can't be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 assert(index == noreg || (index != base && index != from_hi), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 __ movl(as_Address_hi(to_addr), from_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 patching_epilog(patch, lir_patch_high, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 patch_code = lir_patch_low;
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 __ movl(as_Address_lo(to_addr), from_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 assert(index == noreg || (index != base && index != from_lo), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 __ movl(as_Address_lo(to_addr), from_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 patching_epilog(patch, lir_patch_low, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 patch_code = lir_patch_high;
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 __ movl(as_Address_hi(to_addr), from_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1109 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1112
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 case T_BYTE: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 case T_BOOLEAN: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 Register src_reg = src->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 Address dst_addr = as_Address(to_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 assert(VM_Version::is_P6() || src_reg->has_byte_register(), "must use byte registers if not P6");
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 __ movb(dst_addr, src_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1121
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 case T_CHAR: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 __ movw(as_Address(to_addr), src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1126
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 }
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1130 if (info != NULL) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1131 add_debug_info_for_null_check(null_check_here, info);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1132 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1133
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 if (patch_code != lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 patching_epilog(patch, patch_code, to_addr->base()->as_register(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1138
a61af66fc99e Initial load
duke
parents:
diff changeset
1139
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 assert(src->is_stack(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 assert(dest->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
1143
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 if (type == T_ARRAY || type == T_OBJECT) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1146 __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 __ verify_oop(dest->as_register());
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1148 } else if (type == T_METADATA) {
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1149 __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1150 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1151 __ movl(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1153
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 } else if (dest->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 Address src_addr_LO = frame_map()->address_for_slot(src->double_stack_ix(), lo_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 Address src_addr_HI = frame_map()->address_for_slot(src->double_stack_ix(), hi_word_offset_in_bytes);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1157 __ movptr(dest->as_register_lo(), src_addr_LO);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1158 NOT_LP64(__ movptr(dest->as_register_hi(), src_addr_HI));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1159
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 } else if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 Address src_addr = frame_map()->address_for_slot(src->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 __ movflt(dest->as_xmm_float_reg(), src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1163
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 Address src_addr = frame_map()->address_for_slot(src->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 __ movdbl(dest->as_xmm_double_reg(), src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1167
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 } else if (dest->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 assert(dest->fpu_regnr() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 Address src_addr = frame_map()->address_for_slot(src->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 __ fld_s(src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1172
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 } else if (dest->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 assert(dest->fpu_regnrLo() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 Address src_addr = frame_map()->address_for_slot(src->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 __ fld_d(src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1177
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1182
a61af66fc99e Initial load
duke
parents:
diff changeset
1183
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 if (src->is_single_stack()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1186 if (type == T_OBJECT || type == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1187 __ pushptr(frame_map()->address_for_slot(src ->single_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1188 __ popptr (frame_map()->address_for_slot(dest->single_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1189 } else {
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1190 #ifndef _LP64
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1191 __ pushl(frame_map()->address_for_slot(src ->single_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1192 __ popl (frame_map()->address_for_slot(dest->single_stack_ix()));
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1193 #else
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1194 //no pushl on 64bits
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1195 __ movl(rscratch1, frame_map()->address_for_slot(src ->single_stack_ix()));
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1196 __ movl(frame_map()->address_for_slot(dest->single_stack_ix()), rscratch1);
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1197 #endif
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1198 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1199
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 } else if (src->is_double_stack()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1201 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1202 __ pushptr(frame_map()->address_for_slot(src ->double_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1203 __ popptr (frame_map()->address_for_slot(dest->double_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1204 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 __ pushl(frame_map()->address_for_slot(src ->double_stack_ix(), 0));
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1206 // push and pop the part at src + wordSize, adding wordSize for the previous push
321
6e7305abe64c 6746320: Hotspot regression test for 6512111 fails in -Xmixed mode
never
parents: 304
diff changeset
1207 __ pushl(frame_map()->address_for_slot(src ->double_stack_ix(), 2 * wordSize));
6e7305abe64c 6746320: Hotspot regression test for 6512111 fails in -Xmixed mode
never
parents: 304
diff changeset
1208 __ popl (frame_map()->address_for_slot(dest->double_stack_ix(), 2 * wordSize));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 __ popl (frame_map()->address_for_slot(dest->double_stack_ix(), 0));
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1210 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1211
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1216
a61af66fc99e Initial load
duke
parents:
diff changeset
1217
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1218 void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool wide, bool /* unaligned */) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 assert(src->is_address(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 assert(dest->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
1221
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 LIR_Address* addr = src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 Address from_addr = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1224
12955
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12875
diff changeset
1225 if (addr->base()->type() == T_OBJECT) {
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12875
diff changeset
1226 __ verify_oop(addr->base()->as_pointer_register());
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12875
diff changeset
1227 }
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12875
diff changeset
1228
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 case T_BYTE: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 case T_CHAR: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 if (!VM_Version::is_P6() && !from_addr.uses(dest->as_register())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 // on pre P6 processors we may get partial register stalls
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 // so blow away the value of to_rinfo before loading a
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 // partial word into it. Do it here so that it precedes
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 // the potential patch point below.
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1239 __ xorptr(dest->as_register(), dest->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1243
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 PatchingStub* patch = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 if (patch_code != lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1247 assert(from_addr.disp() != 0, "must have");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1252
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 case T_FLOAT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 __ movflt(dest->as_xmm_float_reg(), from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 assert(dest->is_single_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 assert(dest->fpu_regnr() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 __ fld_s(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1264
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 case T_DOUBLE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 __ movdbl(dest->as_xmm_double_reg(), from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 assert(dest->is_double_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 assert(dest->fpu_regnrLo() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 __ fld_d(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1275
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 case T_OBJECT: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 case T_ARRAY: // fall through
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1278 if (UseCompressedOops && !wide) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1279 __ movl(dest->as_register(), from_addr);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1280 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1281 __ movptr(dest->as_register(), from_addr);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1282 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1283 break;
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1284
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1285 case T_ADDRESS:
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
1286 if (UseCompressedClassPointers && addr->disp() == oopDesc::klass_offset_in_bytes()) {
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1287 __ movl(dest->as_register(), from_addr);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1288 } else {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1289 __ movptr(dest->as_register(), from_addr);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1290 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1291 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 case T_INT:
1398
314e17ca2c23 6946892: c1 shouldn't sign-extend to upper 32bits on x64
iveresov
parents: 1378
diff changeset
1293 __ movl(dest->as_register(), from_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1295
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 case T_LONG: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 Register to_lo = dest->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 Register to_hi = dest->as_register_hi();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1299 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1300 __ movptr(to_lo, as_Address_lo(addr));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1301 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 Register base = addr->base()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 Register index = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 if (addr->index()->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 index = addr->index()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 if ((base == to_lo && index == to_hi) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 (base == to_hi && index == to_lo)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 // addresses with 2 registers are only formed as a result of
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 // array access so this code will never have to deal with
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 // patches or null checks.
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 assert(info == NULL && patch == NULL, "must be");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1313 __ lea(to_hi, as_Address(addr));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 __ movl(to_lo, Address(to_hi, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 __ movl(to_hi, Address(to_hi, BytesPerWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 } else if (base == to_lo || index == to_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 assert(base != to_hi, "can't be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 assert(index == noreg || (index != base && index != to_hi), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 __ movl(to_hi, as_Address_hi(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 patching_epilog(patch, lir_patch_high, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 patch_code = lir_patch_low;
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 __ movl(to_lo, as_Address_lo(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 assert(index == noreg || (index != base && index != to_lo), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 __ movl(to_lo, as_Address_lo(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 patching_epilog(patch, lir_patch_low, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 patch_code = lir_patch_high;
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 __ movl(to_hi, as_Address_hi(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1336 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1339
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 case T_BYTE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1342 Register dest_reg = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6");
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1345 __ movsbl(dest_reg, from_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 __ movb(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 __ shll(dest_reg, 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 __ sarl(dest_reg, 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1353
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 case T_CHAR: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 Register dest_reg = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6");
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1358 __ movzwl(dest_reg, from_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 __ movw(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1362 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1364
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 case T_SHORT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 Register dest_reg = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1368 __ movswl(dest_reg, from_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 __ movw(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 __ shll(dest_reg, 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 __ sarl(dest_reg, 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1376
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1378 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1380
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1382 patching_epilog(patch, patch_code, addr->base()->as_register(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1384
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 if (type == T_ARRAY || type == T_OBJECT) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1386 #ifdef _LP64
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1387 if (UseCompressedOops && !wide) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1388 __ decode_heap_oop(dest->as_register());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1389 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1390 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 __ verify_oop(dest->as_register());
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1392 } else if (type == T_ADDRESS && addr->disp() == oopDesc::klass_offset_in_bytes()) {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1393 #ifdef _LP64
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
1394 if (UseCompressedClassPointers) {
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1395 __ decode_klass_not_null(dest->as_register());
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1396 }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1397 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1400
a61af66fc99e Initial load
duke
parents:
diff changeset
1401
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 void LIR_Assembler::prefetchr(LIR_Opr src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 LIR_Address* addr = src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 Address from_addr = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1405
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 if (VM_Version::supports_sse()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 switch (ReadPrefetchInstr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 case 0:
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 __ prefetchnta(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 __ prefetcht0(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 __ prefetcht2(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1415 ShouldNotReachHere(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1416 }
2479
15c9a0e16269 7035713: 3DNow Prefetch Instruction Support
kvn
parents: 2446
diff changeset
1417 } else if (VM_Version::supports_3dnow_prefetch()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 __ prefetchr(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1420 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1421
a61af66fc99e Initial load
duke
parents:
diff changeset
1422
a61af66fc99e Initial load
duke
parents:
diff changeset
1423 void LIR_Assembler::prefetchw(LIR_Opr src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1424 LIR_Address* addr = src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1425 Address from_addr = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1426
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 if (VM_Version::supports_sse()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 switch (AllocatePrefetchInstr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 case 0:
a61af66fc99e Initial load
duke
parents:
diff changeset
1430 __ prefetchnta(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 __ prefetcht0(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
1434 __ prefetcht2(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 case 3:
a61af66fc99e Initial load
duke
parents:
diff changeset
1436 __ prefetchw(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 ShouldNotReachHere(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1439 }
2479
15c9a0e16269 7035713: 3DNow Prefetch Instruction Support
kvn
parents: 2446
diff changeset
1440 } else if (VM_Version::supports_3dnow_prefetch()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1441 __ prefetchw(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1442 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1444
a61af66fc99e Initial load
duke
parents:
diff changeset
1445
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 NEEDS_CLEANUP; // This could be static?
a61af66fc99e Initial load
duke
parents:
diff changeset
1447 Address::ScaleFactor LIR_Assembler::array_element_size(BasicType type) const {
29
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
1448 int elem_size = type2aelembytes(type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 switch (elem_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1450 case 1: return Address::times_1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 case 2: return Address::times_2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1452 case 4: return Address::times_4;
a61af66fc99e Initial load
duke
parents:
diff changeset
1453 case 8: return Address::times_8;
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1455 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 return Address::no_scale;
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1458
a61af66fc99e Initial load
duke
parents:
diff changeset
1459
a61af66fc99e Initial load
duke
parents:
diff changeset
1460 void LIR_Assembler::emit_op3(LIR_Op3* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 switch (op->code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1462 case lir_idiv:
a61af66fc99e Initial load
duke
parents:
diff changeset
1463 case lir_irem:
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 arithmetic_idiv(op->code(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1465 op->in_opr1(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1466 op->in_opr2(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 op->in_opr3(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1468 op->result_opr(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
1470 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 default: ShouldNotReachHere(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1472 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1474
a61af66fc99e Initial load
duke
parents:
diff changeset
1475 void LIR_Assembler::emit_opBranch(LIR_OpBranch* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1476 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 assert(op->block() == NULL || op->block()->label() == op->label(), "wrong label");
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 if (op->block() != NULL) _branch_target_blocks.append(op->block());
a61af66fc99e Initial load
duke
parents:
diff changeset
1479 if (op->ublock() != NULL) _branch_target_blocks.append(op->ublock());
a61af66fc99e Initial load
duke
parents:
diff changeset
1480 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1481
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 if (op->cond() == lir_cond_always) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1483 if (op->info() != NULL) add_debug_info_for_branch(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
1484 __ jmp (*(op->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1485 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 Assembler::Condition acond = Assembler::zero;
a61af66fc99e Initial load
duke
parents:
diff changeset
1487 if (op->code() == lir_cond_float_branch) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1488 assert(op->ublock() != NULL, "must have unordered successor");
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 __ jcc(Assembler::parity, *(op->ublock()->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 switch(op->cond()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1491 case lir_cond_equal: acond = Assembler::equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1492 case lir_cond_notEqual: acond = Assembler::notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 case lir_cond_less: acond = Assembler::below; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1494 case lir_cond_lessEqual: acond = Assembler::belowEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 case lir_cond_greaterEqual: acond = Assembler::aboveEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1496 case lir_cond_greater: acond = Assembler::above; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1498 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1499 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1500 switch (op->cond()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 case lir_cond_equal: acond = Assembler::equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1502 case lir_cond_notEqual: acond = Assembler::notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 case lir_cond_less: acond = Assembler::less; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1504 case lir_cond_lessEqual: acond = Assembler::lessEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 case lir_cond_greaterEqual: acond = Assembler::greaterEqual;break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1506 case lir_cond_greater: acond = Assembler::greater; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1507 case lir_cond_belowEqual: acond = Assembler::belowEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 case lir_cond_aboveEqual: acond = Assembler::aboveEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1509 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1510 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1512 __ jcc(acond,*(op->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1513 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1514 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1515
a61af66fc99e Initial load
duke
parents:
diff changeset
1516 void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1517 LIR_Opr src = op->in_opr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1518 LIR_Opr dest = op->result_opr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1519
a61af66fc99e Initial load
duke
parents:
diff changeset
1520 switch (op->bytecode()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1521 case Bytecodes::_i2l:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1522 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1523 __ movl2ptr(dest->as_register_lo(), src->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1524 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1525 move_regs(src->as_register(), dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 move_regs(src->as_register(), dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1527 __ sarl(dest->as_register_hi(), 31);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1528 #endif // LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1529 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1530
a61af66fc99e Initial load
duke
parents:
diff changeset
1531 case Bytecodes::_l2i:
6041
3576af4cb939 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 4966
diff changeset
1532 #ifdef _LP64
3576af4cb939 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 4966
diff changeset
1533 __ movl(dest->as_register(), src->as_register_lo());
3576af4cb939 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 4966
diff changeset
1534 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1535 move_regs(src->as_register_lo(), dest->as_register());
6041
3576af4cb939 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 4966
diff changeset
1536 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1537 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1538
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 case Bytecodes::_i2b:
a61af66fc99e Initial load
duke
parents:
diff changeset
1540 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 __ sign_extend_byte(dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1542 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1543
a61af66fc99e Initial load
duke
parents:
diff changeset
1544 case Bytecodes::_i2c:
a61af66fc99e Initial load
duke
parents:
diff changeset
1545 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1546 __ andl(dest->as_register(), 0xFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1547 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1548
a61af66fc99e Initial load
duke
parents:
diff changeset
1549 case Bytecodes::_i2s:
a61af66fc99e Initial load
duke
parents:
diff changeset
1550 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 __ sign_extend_short(dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1552 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1553
a61af66fc99e Initial load
duke
parents:
diff changeset
1554
a61af66fc99e Initial load
duke
parents:
diff changeset
1555 case Bytecodes::_f2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
1556 case Bytecodes::_d2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
1557 if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1558 __ cvtsd2ss(dest->as_xmm_float_reg(), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1559 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1560 __ cvtss2sd(dest->as_xmm_double_reg(), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1561 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1562 assert(src->fpu() == dest->fpu(), "register must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 // do nothing (float result is rounded later through spilling)
a61af66fc99e Initial load
duke
parents:
diff changeset
1564 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1565 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1566
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 case Bytecodes::_i2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 case Bytecodes::_i2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
1569 if (dest->is_single_xmm()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1570 __ cvtsi2ssl(dest->as_xmm_float_reg(), src->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 } else if (dest->is_double_xmm()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1572 __ cvtsi2sdl(dest->as_xmm_double_reg(), src->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1573 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1574 assert(dest->fpu() == 0, "result must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 __ movl(Address(rsp, 0), src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1576 __ fild_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1578 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1579
a61af66fc99e Initial load
duke
parents:
diff changeset
1580 case Bytecodes::_f2i:
a61af66fc99e Initial load
duke
parents:
diff changeset
1581 case Bytecodes::_d2i:
a61af66fc99e Initial load
duke
parents:
diff changeset
1582 if (src->is_single_xmm()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1583 __ cvttss2sil(dest->as_register(), src->as_xmm_float_reg());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 } else if (src->is_double_xmm()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1585 __ cvttsd2sil(dest->as_register(), src->as_xmm_double_reg());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1587 assert(src->fpu() == 0, "input must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1588 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_trunc()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1589 __ fist_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 __ movl(dest->as_register(), Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1591 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1592 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1593
a61af66fc99e Initial load
duke
parents:
diff changeset
1594 // IA32 conversion instructions do not match JLS for overflow, underflow and NaN -> fixup in stub
a61af66fc99e Initial load
duke
parents:
diff changeset
1595 assert(op->stub() != NULL, "stub required");
a61af66fc99e Initial load
duke
parents:
diff changeset
1596 __ cmpl(dest->as_register(), 0x80000000);
a61af66fc99e Initial load
duke
parents:
diff changeset
1597 __ jcc(Assembler::equal, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1598 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
1599 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1600
a61af66fc99e Initial load
duke
parents:
diff changeset
1601 case Bytecodes::_l2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
1602 case Bytecodes::_l2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
1603 assert(!dest->is_xmm_register(), "result in xmm register not supported (no SSE instruction present)");
a61af66fc99e Initial load
duke
parents:
diff changeset
1604 assert(dest->fpu() == 0, "result must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1605
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1606 __ movptr(Address(rsp, 0), src->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1607 NOT_LP64(__ movl(Address(rsp, BytesPerWord), src->as_register_hi()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1608 __ fild_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 // float result is rounded later through spilling
a61af66fc99e Initial load
duke
parents:
diff changeset
1610 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1611
a61af66fc99e Initial load
duke
parents:
diff changeset
1612 case Bytecodes::_f2l:
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 case Bytecodes::_d2l:
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 assert(!src->is_xmm_register(), "input in xmm register not supported (no SSE instruction present)");
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 assert(src->fpu() == 0, "input must be on TOS");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1616 assert(dest == FrameMap::long0_opr, "runtime stub places result in these registers");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1617
a61af66fc99e Initial load
duke
parents:
diff changeset
1618 // instruction sequence too long to inline it here
a61af66fc99e Initial load
duke
parents:
diff changeset
1619 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::fpu2long_stub_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1621 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1622 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1623
a61af66fc99e Initial load
duke
parents:
diff changeset
1624 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1625 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1626 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1627
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1629 if (op->init_check()) {
4739
52b5d32fbfaf 7117052: instanceKlass::_init_state can be u1 type
coleenp
parents: 3960
diff changeset
1630 __ cmpb(Address(op->klass()->as_register(),
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1631 InstanceKlass::init_state_offset()),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1632 InstanceKlass::fully_initialized);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1633 add_debug_info_for_null_check_here(op->stub()->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
1634 __ jcc(Assembler::notEqual, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 __ allocate_object(op->obj()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 op->tmp1()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 op->tmp2()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1639 op->header_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1640 op->object_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 op->klass()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1642 *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1643 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1645
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) {
2112
55f868e91c3b 7010618: C1: array length should be treated at int on 64bit during array allocation
iveresov
parents: 2089
diff changeset
1647 Register len = op->len()->as_register();
55f868e91c3b 7010618: C1: array length should be treated at int on 64bit during array allocation
iveresov
parents: 2089
diff changeset
1648 LP64_ONLY( __ movslq(len, len); )
55f868e91c3b 7010618: C1: array length should be treated at int on 64bit during array allocation
iveresov
parents: 2089
diff changeset
1649
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1650 if (UseSlowPath ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1651 (!UseFastNewObjectArray && (op->type() == T_OBJECT || op->type() == T_ARRAY)) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1652 (!UseFastNewTypeArray && (op->type() != T_OBJECT && op->type() != T_ARRAY))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 __ jmp(*op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1654 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 Register tmp1 = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 Register tmp2 = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1657 Register tmp3 = op->tmp3()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 if (len == tmp1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1659 tmp1 = tmp3;
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 } else if (len == tmp2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 tmp2 = tmp3;
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 } else if (len == tmp3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1663 // everything is ok
a61af66fc99e Initial load
duke
parents:
diff changeset
1664 } else {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1665 __ mov(tmp3, len);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 __ allocate_array(op->obj()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 len,
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 tmp1,
a61af66fc99e Initial load
duke
parents:
diff changeset
1670 tmp2,
a61af66fc99e Initial load
duke
parents:
diff changeset
1671 arrayOopDesc::header_size(op->type()),
a61af66fc99e Initial load
duke
parents:
diff changeset
1672 array_element_size(op->type()),
a61af66fc99e Initial load
duke
parents:
diff changeset
1673 op->klass()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1674 *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1675 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1676 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1678
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1679 void LIR_Assembler::type_profile_helper(Register mdo,
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1680 ciMethodData *md, ciProfileData *data,
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1681 Register recv, Label* update_done) {
1808
5511edd5d719 6988779: c1_LIRAssembler_x86.cpp crashes VS2010 compiler
iveresov
parents: 1791
diff changeset
1682 for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1683 Label next_test;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1684 // See if the receiver is receiver[n].
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1685 __ cmpptr(recv, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1686 __ jccb(Assembler::notEqual, next_test);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1687 Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1688 __ addptr(data_addr, DataLayout::counter_increment);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1689 __ jmp(*update_done);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1690 __ bind(next_test);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1691 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1692
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1693 // Didn't find receiver; find next empty slot and fill it in
1808
5511edd5d719 6988779: c1_LIRAssembler_x86.cpp crashes VS2010 compiler
iveresov
parents: 1791
diff changeset
1694 for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1695 Label next_test;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1696 Address recv_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1697 __ cmpptr(recv_addr, (intptr_t)NULL_WORD);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1698 __ jccb(Assembler::notEqual, next_test);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1699 __ movptr(recv_addr, recv);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1700 __ movptr(Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i))), DataLayout::counter_increment);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1701 __ jmp(*update_done);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1702 __ bind(next_test);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1703 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1704 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1705
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1706 void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, Label* failure, Label* obj_is_null) {
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1707 // we always need a stub for the failure case.
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1708 CodeStub* stub = op->stub();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1709 Register obj = op->object()->as_register();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1710 Register k_RInfo = op->tmp1()->as_register();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1711 Register klass_RInfo = op->tmp2()->as_register();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1712 Register dst = op->result_opr()->as_register();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1713 ciKlass* k = op->klass();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1714 Register Rtmp1 = noreg;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1715
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1716 // check if it needs to be profiled
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1717 ciMethodData* md;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1718 ciProfileData* data;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1719
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1720 if (op->should_profile()) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1721 ciMethod* method = op->profiled_method();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1722 assert(method != NULL, "Should have method");
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1723 int bci = op->profiled_bci();
2007
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
1724 md = method->method_data_or_null();
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
1725 assert(md != NULL, "Sanity");
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1726 data = md->bci_to_data(bci);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1727 assert(data != NULL, "need data for type check");
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1728 assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check");
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1729 }
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1730 Label profile_cast_success, profile_cast_failure;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1731 Label *success_target = op->should_profile() ? &profile_cast_success : success;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1732 Label *failure_target = op->should_profile() ? &profile_cast_failure : failure;
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1733
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1734 if (obj == k_RInfo) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1735 k_RInfo = dst;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1736 } else if (obj == klass_RInfo) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1737 klass_RInfo = dst;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1738 }
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
1739 if (k->is_loaded() && !UseCompressedClassPointers) {
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1740 select_different_registers(obj, dst, k_RInfo, klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1741 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1742 Rtmp1 = op->tmp3()->as_register();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1743 select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1744 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1745
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1746 assert_different_registers(obj, k_RInfo, klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1747
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1748 __ cmpptr(obj, (int32_t)NULL_WORD);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1749 if (op->should_profile()) {
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1750 Label not_null;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1751 __ jccb(Assembler::notEqual, not_null);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1752 // Object is null; update MDO and exit
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1753 Register mdo = klass_RInfo;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1754 __ mov_metadata(mdo, md->constant_encoding());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1755 Address data_addr(mdo, md->byte_offset_of_slot(data, DataLayout::header_offset()));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1756 int header_bits = DataLayout::flag_mask_to_header_mask(BitData::null_seen_byte_constant());
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1757 __ orl(data_addr, header_bits);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1758 __ jmp(*obj_is_null);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1759 __ bind(not_null);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1760 } else {
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1761 __ jcc(Assembler::equal, *obj_is_null);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1762 }
12268
2795dff62b6c 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 12160
diff changeset
1763
2795dff62b6c 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 12160
diff changeset
1764 if (!k->is_loaded()) {
2795dff62b6c 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 12160
diff changeset
1765 klass2reg_with_patching(k_RInfo, op->info_for_patch());
2795dff62b6c 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 12160
diff changeset
1766 } else {
2795dff62b6c 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 12160
diff changeset
1767 #ifdef _LP64
2795dff62b6c 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 12160
diff changeset
1768 __ mov_metadata(k_RInfo, k->constant_encoding());
2795dff62b6c 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 12160
diff changeset
1769 #endif // _LP64
2795dff62b6c 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 12160
diff changeset
1770 }
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1771 __ verify_oop(obj);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1772
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1773 if (op->fast_check()) {
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1774 // get object class
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1775 // not a safepoint as obj null check happens earlier
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1776 #ifdef _LP64
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
1777 if (UseCompressedClassPointers) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1778 __ load_klass(Rtmp1, obj);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1779 __ cmpptr(k_RInfo, Rtmp1);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1780 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1781 __ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1782 }
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1783 #else
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1784 if (k->is_loaded()) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1785 __ cmpklass(Address(obj, oopDesc::klass_offset_in_bytes()), k->constant_encoding());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1786 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1787 __ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1788 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1789 #endif
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1790 __ jcc(Assembler::notEqual, *failure_target);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1791 // successful cast, fall through to profile or jump
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1792 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1793 // get object class
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1794 // not a safepoint as obj null check happens earlier
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1795 __ load_klass(klass_RInfo, obj);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1796 if (k->is_loaded()) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1797 // See if we get an immediate positive hit
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1798 #ifdef _LP64
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1799 __ cmpptr(k_RInfo, Address(klass_RInfo, k->super_check_offset()));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1800 #else
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1801 __ cmpklass(Address(klass_RInfo, k->super_check_offset()), k->constant_encoding());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1802 #endif // _LP64
4762
069ab3f976d3 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 3960
diff changeset
1803 if ((juint)in_bytes(Klass::secondary_super_cache_offset()) != k->super_check_offset()) {
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1804 __ jcc(Assembler::notEqual, *failure_target);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1805 // successful cast, fall through to profile or jump
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1806 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1807 // See if we get an immediate positive hit
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1808 __ jcc(Assembler::equal, *success_target);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1809 // check for self
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1810 #ifdef _LP64
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1811 __ cmpptr(klass_RInfo, k_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1812 #else
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1813 __ cmpklass(klass_RInfo, k->constant_encoding());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1814 #endif // _LP64
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1815 __ jcc(Assembler::equal, *success_target);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1816
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1817 __ push(klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1818 #ifdef _LP64
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1819 __ push(k_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1820 #else
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1821 __ pushklass(k->constant_encoding());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1822 #endif // _LP64
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1823 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1824 __ pop(klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1825 __ pop(klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1826 // result is a boolean
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1827 __ cmpl(klass_RInfo, 0);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1828 __ jcc(Assembler::equal, *failure_target);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1829 // successful cast, fall through to profile or jump
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1830 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1831 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1832 // perform the fast part of the checking logic
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1833 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, NULL);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1834 // call out-of-line instance of __ check_klass_subtype_slow_path(...):
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1835 __ push(klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1836 __ push(k_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1837 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1838 __ pop(klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1839 __ pop(k_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1840 // result is a boolean
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1841 __ cmpl(k_RInfo, 0);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1842 __ jcc(Assembler::equal, *failure_target);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1843 // successful cast, fall through to profile or jump
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1844 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1845 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1846 if (op->should_profile()) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1847 Register mdo = klass_RInfo, recv = k_RInfo;
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1848 __ bind(profile_cast_success);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1849 __ mov_metadata(mdo, md->constant_encoding());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1850 __ load_klass(recv, obj);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1851 Label update_done;
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1852 type_profile_helper(mdo, md, data, recv, success);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1853 __ jmp(*success);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1854
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1855 __ bind(profile_cast_failure);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1856 __ mov_metadata(mdo, md->constant_encoding());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1857 Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1858 __ subptr(counter_addr, DataLayout::counter_increment);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1859 __ jmp(*failure);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1860 }
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1861 __ jmp(*success);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1862 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1863
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1864
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1865 void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1866 LIR_Code code = op->code();
a61af66fc99e Initial load
duke
parents:
diff changeset
1867 if (code == lir_store_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1868 Register value = op->object()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1869 Register array = op->array()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1870 Register k_RInfo = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1871 Register klass_RInfo = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1872 Register Rtmp1 = op->tmp3()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1873
a61af66fc99e Initial load
duke
parents:
diff changeset
1874 CodeStub* stub = op->stub();
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1875
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1876 // check if it needs to be profiled
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1877 ciMethodData* md;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1878 ciProfileData* data;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1879
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1880 if (op->should_profile()) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1881 ciMethod* method = op->profiled_method();
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1882 assert(method != NULL, "Should have method");
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1883 int bci = op->profiled_bci();
2007
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
1884 md = method->method_data_or_null();
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
1885 assert(md != NULL, "Sanity");
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1886 data = md->bci_to_data(bci);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1887 assert(data != NULL, "need data for type check");
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1888 assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check");
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1889 }
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1890 Label profile_cast_success, profile_cast_failure, done;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1891 Label *success_target = op->should_profile() ? &profile_cast_success : &done;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1892 Label *failure_target = op->should_profile() ? &profile_cast_failure : stub->entry();
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1893
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1894 __ cmpptr(value, (int32_t)NULL_WORD);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1895 if (op->should_profile()) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1896 Label not_null;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1897 __ jccb(Assembler::notEqual, not_null);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1898 // Object is null; update MDO and exit
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1899 Register mdo = klass_RInfo;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1900 __ mov_metadata(mdo, md->constant_encoding());
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1901 Address data_addr(mdo, md->byte_offset_of_slot(data, DataLayout::header_offset()));
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1902 int header_bits = DataLayout::flag_mask_to_header_mask(BitData::null_seen_byte_constant());
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1903 __ orl(data_addr, header_bits);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1904 __ jmp(done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1905 __ bind(not_null);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1906 } else {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1907 __ jcc(Assembler::equal, done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1908 }
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1909
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1910 add_debug_info_for_null_check_here(op->info_for_exception());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1911 __ load_klass(k_RInfo, array);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1912 __ load_klass(klass_RInfo, value);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1913
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1914 // get instance klass (it's already uncompressed)
6831
d8ce2825b193 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 6795
diff changeset
1915 __ movptr(k_RInfo, Address(k_RInfo, ObjArrayKlass::element_klass_offset()));
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 622
diff changeset
1916 // perform the fast part of the checking logic
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1917 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, NULL);
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 622
diff changeset
1918 // call out-of-line instance of __ check_klass_subtype_slow_path(...):
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1919 __ push(klass_RInfo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1920 __ push(k_RInfo);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1921 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1922 __ pop(klass_RInfo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1923 __ pop(k_RInfo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1924 // result is a boolean
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1925 __ cmpl(k_RInfo, 0);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1926 __ jcc(Assembler::equal, *failure_target);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1927 // fall through to the success case
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1928
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1929 if (op->should_profile()) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1930 Register mdo = klass_RInfo, recv = k_RInfo;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1931 __ bind(profile_cast_success);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1932 __ mov_metadata(mdo, md->constant_encoding());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1933 __ load_klass(recv, value);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1934 Label update_done;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1935 type_profile_helper(mdo, md, data, recv, &done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1936 __ jmpb(done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1937
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1938 __ bind(profile_cast_failure);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1939 __ mov_metadata(mdo, md->constant_encoding());
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1940 Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1941 __ subptr(counter_addr, DataLayout::counter_increment);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1942 __ jmp(*stub->entry());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1943 }
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1944
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1945 __ bind(done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1946 } else
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1947 if (code == lir_checkcast) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1948 Register obj = op->object()->as_register();
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1949 Register dst = op->result_opr()->as_register();
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1950 Label success;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1951 emit_typecheck_helper(op, &success, op->stub()->entry(), &success);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1952 __ bind(success);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1953 if (dst != obj) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1954 __ mov(dst, obj);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1955 }
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1956 } else
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1957 if (code == lir_instanceof) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1958 Register obj = op->object()->as_register();
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1959 Register dst = op->result_opr()->as_register();
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1960 Label success, failure, done;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1961 emit_typecheck_helper(op, &success, &failure, &failure);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1962 __ bind(failure);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1963 __ xorptr(dst, dst);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1964 __ jmpb(done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1965 __ bind(success);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1966 __ movptr(dst, 1);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1967 __ bind(done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1968 } else {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1969 ShouldNotReachHere();
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 622
diff changeset
1970 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1971
a61af66fc99e Initial load
duke
parents:
diff changeset
1972 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1973
a61af66fc99e Initial load
duke
parents:
diff changeset
1974
a61af66fc99e Initial load
duke
parents:
diff changeset
1975 void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1976 if (LP64_ONLY(false &&) op->code() == lir_cas_long && VM_Version::supports_cx8()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1977 assert(op->cmp_value()->as_register_lo() == rax, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1978 assert(op->cmp_value()->as_register_hi() == rdx, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1979 assert(op->new_value()->as_register_lo() == rbx, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1980 assert(op->new_value()->as_register_hi() == rcx, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1981 Register addr = op->addr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1982 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1983 __ lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
1984 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1985 NOT_LP64(__ cmpxchg8(Address(addr, 0)));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1986
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1987 } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj ) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1988 NOT_LP64(assert(op->addr()->is_single_cpu(), "must be single");)
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1989 Register addr = (op->addr()->is_single_cpu() ? op->addr()->as_register() : op->addr()->as_register_lo());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1990 Register newval = op->new_value()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1991 Register cmpval = op->cmp_value()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1992 assert(cmpval == rax, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1993 assert(newval != NULL, "new val must be register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1994 assert(cmpval != newval, "cmp and new values must be in different registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1995 assert(cmpval != addr, "cmp and addr must be in different registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1996 assert(newval != addr, "new value and addr must be in different registers");
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1997
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1998 if ( op->code() == lir_cas_obj) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1999 #ifdef _LP64
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2000 if (UseCompressedOops) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2001 __ encode_heap_oop(cmpval);
2013
ec8c74742417 7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops
iveresov
parents: 2007
diff changeset
2002 __ mov(rscratch1, newval);
ec8c74742417 7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops
iveresov
parents: 2007
diff changeset
2003 __ encode_heap_oop(rscratch1);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2004 if (os::is_MP()) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2005 __ lock();
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2006 }
2013
ec8c74742417 7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops
iveresov
parents: 2007
diff changeset
2007 // cmpval (rax) is implicitly used by this instruction
ec8c74742417 7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops
iveresov
parents: 2007
diff changeset
2008 __ cmpxchgl(rscratch1, Address(addr, 0));
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2009 } else
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2010 #endif
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2011 {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2012 if (os::is_MP()) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2013 __ lock();
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2014 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2015 __ cmpxchgptr(newval, Address(addr, 0));
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2016 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2017 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2018 assert(op->code() == lir_cas_int, "lir_cas_int expected");
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2019 if (os::is_MP()) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2020 __ lock();
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2021 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2022 __ cmpxchgl(newval, Address(addr, 0));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2023 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2024 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2025 } else if (op->code() == lir_cas_long) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2026 Register addr = (op->addr()->is_single_cpu() ? op->addr()->as_register() : op->addr()->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2027 Register newval = op->new_value()->as_register_lo();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2028 Register cmpval = op->cmp_value()->as_register_lo();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2029 assert(cmpval == rax, "wrong register");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2030 assert(newval != NULL, "new val must be register");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2031 assert(cmpval != newval, "cmp and new values must be in different registers");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2032 assert(cmpval != addr, "cmp and addr must be in different registers");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2033 assert(newval != addr, "new value and addr must be in different registers");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2034 if (os::is_MP()) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2035 __ lock();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2036 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2037 __ cmpxchgq(newval, Address(addr, 0));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2038 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2039 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2040 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2041 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2042 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2043
2089
037c727f35fb 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 2013
diff changeset
2044 void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2045 Assembler::Condition acond, ncond;
a61af66fc99e Initial load
duke
parents:
diff changeset
2046 switch (condition) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2047 case lir_cond_equal: acond = Assembler::equal; ncond = Assembler::notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2048 case lir_cond_notEqual: acond = Assembler::notEqual; ncond = Assembler::equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2049 case lir_cond_less: acond = Assembler::less; ncond = Assembler::greaterEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2050 case lir_cond_lessEqual: acond = Assembler::lessEqual; ncond = Assembler::greater; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2051 case lir_cond_greaterEqual: acond = Assembler::greaterEqual; ncond = Assembler::less; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2052 case lir_cond_greater: acond = Assembler::greater; ncond = Assembler::lessEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2053 case lir_cond_belowEqual: acond = Assembler::belowEqual; ncond = Assembler::above; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2054 case lir_cond_aboveEqual: acond = Assembler::aboveEqual; ncond = Assembler::below; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2055 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2056 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2057
a61af66fc99e Initial load
duke
parents:
diff changeset
2058 if (opr1->is_cpu_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2059 reg2reg(opr1, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
2060 } else if (opr1->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2061 stack2reg(opr1, result, result->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
2062 } else if (opr1->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2063 const2reg(opr1, result, lir_patch_none, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2064 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2065 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2066 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2067
a61af66fc99e Initial load
duke
parents:
diff changeset
2068 if (VM_Version::supports_cmov() && !opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2069 // optimized version that does not require a branch
a61af66fc99e Initial load
duke
parents:
diff changeset
2070 if (opr2->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2071 assert(opr2->cpu_regnr() != result->cpu_regnr(), "opr2 already overwritten by previous move");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2072 __ cmov(ncond, result->as_register(), opr2->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2073 } else if (opr2->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2074 assert(opr2->cpu_regnrLo() != result->cpu_regnrLo() && opr2->cpu_regnrLo() != result->cpu_regnrHi(), "opr2 already overwritten by previous move");
a61af66fc99e Initial load
duke
parents:
diff changeset
2075 assert(opr2->cpu_regnrHi() != result->cpu_regnrLo() && opr2->cpu_regnrHi() != result->cpu_regnrHi(), "opr2 already overwritten by previous move");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2076 __ cmovptr(ncond, result->as_register_lo(), opr2->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2077 NOT_LP64(__ cmovptr(ncond, result->as_register_hi(), opr2->as_register_hi());)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2078 } else if (opr2->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2079 __ cmovl(ncond, result->as_register(), frame_map()->address_for_slot(opr2->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2080 } else if (opr2->is_double_stack()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2081 __ cmovptr(ncond, result->as_register_lo(), frame_map()->address_for_slot(opr2->double_stack_ix(), lo_word_offset_in_bytes));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2082 NOT_LP64(__ cmovptr(ncond, result->as_register_hi(), frame_map()->address_for_slot(opr2->double_stack_ix(), hi_word_offset_in_bytes));)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2083 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2084 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2085 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2086
a61af66fc99e Initial load
duke
parents:
diff changeset
2087 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2088 Label skip;
a61af66fc99e Initial load
duke
parents:
diff changeset
2089 __ jcc (acond, skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
2090 if (opr2->is_cpu_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2091 reg2reg(opr2, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
2092 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2093 stack2reg(opr2, result, result->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
2094 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2095 const2reg(opr2, result, lir_patch_none, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2096 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2097 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2098 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2099 __ bind(skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
2100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2102
a61af66fc99e Initial load
duke
parents:
diff changeset
2103
a61af66fc99e Initial load
duke
parents:
diff changeset
2104 void LIR_Assembler::arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest, CodeEmitInfo* info, bool pop_fpu_stack) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2105 assert(info == NULL, "should never be used, idiv/irem and ldiv/lrem not handled by this method");
a61af66fc99e Initial load
duke
parents:
diff changeset
2106
a61af66fc99e Initial load
duke
parents:
diff changeset
2107 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2108 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2109 Register lreg = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2110
a61af66fc99e Initial load
duke
parents:
diff changeset
2111 if (right->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2112 // cpu register - cpu register
a61af66fc99e Initial load
duke
parents:
diff changeset
2113 Register rreg = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2114 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2115 case lir_add: __ addl (lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2116 case lir_sub: __ subl (lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2117 case lir_mul: __ imull(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2118 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2120
a61af66fc99e Initial load
duke
parents:
diff changeset
2121 } else if (right->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2122 // cpu register - stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2123 Address raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2124 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2125 case lir_add: __ addl(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2126 case lir_sub: __ subl(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2127 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2129
a61af66fc99e Initial load
duke
parents:
diff changeset
2130 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2131 // cpu register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2132 jint c = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
2133 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2134 case lir_add: {
1790
7f9553bedfd5 6984056: C1: incorrect code for integer constant addition on x64
iveresov
parents: 1783
diff changeset
2135 __ incrementl(lreg, c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2136 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2138 case lir_sub: {
1790
7f9553bedfd5 6984056: C1: incorrect code for integer constant addition on x64
iveresov
parents: 1783
diff changeset
2139 __ decrementl(lreg, c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2140 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2142 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2144
a61af66fc99e Initial load
duke
parents:
diff changeset
2145 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2146 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2148
a61af66fc99e Initial load
duke
parents:
diff changeset
2149 } else if (left->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2150 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2151 Register lreg_lo = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2152 Register lreg_hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2153
a61af66fc99e Initial load
duke
parents:
diff changeset
2154 if (right->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2155 // cpu register - cpu register
a61af66fc99e Initial load
duke
parents:
diff changeset
2156 Register rreg_lo = right->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2157 Register rreg_hi = right->as_register_hi();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2158 NOT_LP64(assert_different_registers(lreg_lo, lreg_hi, rreg_lo, rreg_hi));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2159 LP64_ONLY(assert_different_registers(lreg_lo, rreg_lo));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2160 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2161 case lir_add:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2162 __ addptr(lreg_lo, rreg_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2163 NOT_LP64(__ adcl(lreg_hi, rreg_hi));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2164 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2165 case lir_sub:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2166 __ subptr(lreg_lo, rreg_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2167 NOT_LP64(__ sbbl(lreg_hi, rreg_hi));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2168 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2169 case lir_mul:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2170 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2171 __ imulq(lreg_lo, rreg_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2172 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2173 assert(lreg_lo == rax && lreg_hi == rdx, "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
2174 __ imull(lreg_hi, rreg_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2175 __ imull(rreg_hi, lreg_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2176 __ addl (rreg_hi, lreg_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2177 __ mull (rreg_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2178 __ addl (lreg_hi, rreg_hi);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2179 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2180 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2181 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
2182 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2184
a61af66fc99e Initial load
duke
parents:
diff changeset
2185 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2186 // cpu register - constant
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2187 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2188 jlong c = right->as_constant_ptr()->as_jlong_bits();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2189 __ movptr(r10, (intptr_t) c);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2190 switch (code) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2191 case lir_add:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2192 __ addptr(lreg_lo, r10);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2193 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2194 case lir_sub:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2195 __ subptr(lreg_lo, r10);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2196 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2197 default:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2198 ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2199 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2200 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2201 jint c_lo = right->as_constant_ptr()->as_jint_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2202 jint c_hi = right->as_constant_ptr()->as_jint_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2203 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2204 case lir_add:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2205 __ addptr(lreg_lo, c_lo);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2206 __ adcl(lreg_hi, c_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2207 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2208 case lir_sub:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2209 __ subptr(lreg_lo, c_lo);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2210 __ sbbl(lreg_hi, c_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2211 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2212 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
2213 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2214 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2215 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2216
a61af66fc99e Initial load
duke
parents:
diff changeset
2217 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2218 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2220
a61af66fc99e Initial load
duke
parents:
diff changeset
2221 } else if (left->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2222 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2223 XMMRegister lreg = left->as_xmm_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2224
a61af66fc99e Initial load
duke
parents:
diff changeset
2225 if (right->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2226 XMMRegister rreg = right->as_xmm_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2227 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2228 case lir_add: __ addss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2229 case lir_sub: __ subss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2230 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2231 case lir_mul: __ mulss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2232 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2233 case lir_div: __ divss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2234 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2236 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2237 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2238 if (right->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2239 raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2240 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2241 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
2242 raddr = __ as_Address(InternalAddress(float_constant(right->as_jfloat())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2243 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2244 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2246 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2247 case lir_add: __ addss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2248 case lir_sub: __ subss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2249 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2250 case lir_mul: __ mulss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2251 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2252 case lir_div: __ divss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2253 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2256
a61af66fc99e Initial load
duke
parents:
diff changeset
2257 } else if (left->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2258 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2259
a61af66fc99e Initial load
duke
parents:
diff changeset
2260 XMMRegister lreg = left->as_xmm_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2261 if (right->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2262 XMMRegister rreg = right->as_xmm_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2263 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2264 case lir_add: __ addsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2265 case lir_sub: __ subsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2266 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2267 case lir_mul: __ mulsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2268 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2269 case lir_div: __ divsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2270 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2272 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2273 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2274 if (right->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2275 raddr = frame_map()->address_for_slot(right->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2276 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2277 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
2278 raddr = __ as_Address(InternalAddress(double_constant(right->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2279 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2280 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2282 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2283 case lir_add: __ addsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2284 case lir_sub: __ subsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2285 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2286 case lir_mul: __ mulsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2287 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2288 case lir_div: __ divsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2289 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2292
a61af66fc99e Initial load
duke
parents:
diff changeset
2293 } else if (left->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2294 assert(dest->is_single_fpu(), "fpu stack allocation required");
a61af66fc99e Initial load
duke
parents:
diff changeset
2295
a61af66fc99e Initial load
duke
parents:
diff changeset
2296 if (right->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2297 arith_fpu_implementation(code, left->fpu_regnr(), right->fpu_regnr(), dest->fpu_regnr(), pop_fpu_stack);
a61af66fc99e Initial load
duke
parents:
diff changeset
2298
a61af66fc99e Initial load
duke
parents:
diff changeset
2299 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2300 assert(left->fpu_regnr() == 0, "left must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2301 assert(dest->fpu_regnr() == 0, "dest must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2302
a61af66fc99e Initial load
duke
parents:
diff changeset
2303 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2304 if (right->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2305 raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2306 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2307 address const_addr = float_constant(right->as_jfloat());
a61af66fc99e Initial load
duke
parents:
diff changeset
2308 assert(const_addr != NULL, "incorrect float/double constant maintainance");
a61af66fc99e Initial load
duke
parents:
diff changeset
2309 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
2310 raddr = __ as_Address(InternalAddress(const_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
2311 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2312 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2314
a61af66fc99e Initial load
duke
parents:
diff changeset
2315 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2316 case lir_add: __ fadd_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2317 case lir_sub: __ fsub_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2318 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2319 case lir_mul: __ fmul_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2320 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2321 case lir_div: __ fdiv_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2322 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2323 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2325
a61af66fc99e Initial load
duke
parents:
diff changeset
2326 } else if (left->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2327 assert(dest->is_double_fpu(), "fpu stack allocation required");
a61af66fc99e Initial load
duke
parents:
diff changeset
2328
a61af66fc99e Initial load
duke
parents:
diff changeset
2329 if (code == lir_mul_strictfp || code == lir_div_strictfp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2330 // Double values require special handling for strictfp mul/div on x86
a61af66fc99e Initial load
duke
parents:
diff changeset
2331 __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias1()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2332 __ fmulp(left->fpu_regnrLo() + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2334
a61af66fc99e Initial load
duke
parents:
diff changeset
2335 if (right->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2336 arith_fpu_implementation(code, left->fpu_regnrLo(), right->fpu_regnrLo(), dest->fpu_regnrLo(), pop_fpu_stack);
a61af66fc99e Initial load
duke
parents:
diff changeset
2337
a61af66fc99e Initial load
duke
parents:
diff changeset
2338 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2339 assert(left->fpu_regnrLo() == 0, "left must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2340 assert(dest->fpu_regnrLo() == 0, "dest must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2341
a61af66fc99e Initial load
duke
parents:
diff changeset
2342 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2343 if (right->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2344 raddr = frame_map()->address_for_slot(right->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2345 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2346 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
2347 raddr = __ as_Address(InternalAddress(double_constant(right->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2348 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2349 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2351
a61af66fc99e Initial load
duke
parents:
diff changeset
2352 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2353 case lir_add: __ fadd_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2354 case lir_sub: __ fsub_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2355 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2356 case lir_mul: __ fmul_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2357 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2358 case lir_div: __ fdiv_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2359 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2362
a61af66fc99e Initial load
duke
parents:
diff changeset
2363 if (code == lir_mul_strictfp || code == lir_div_strictfp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2364 // Double values require special handling for strictfp mul/div on x86
a61af66fc99e Initial load
duke
parents:
diff changeset
2365 __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias2()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2366 __ fmulp(dest->fpu_regnrLo() + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2368
a61af66fc99e Initial load
duke
parents:
diff changeset
2369 } else if (left->is_single_stack() || left->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2370 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2371
a61af66fc99e Initial load
duke
parents:
diff changeset
2372 Address laddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2373 if (left->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2374 laddr = frame_map()->address_for_slot(left->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2375 } else if (left->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2376 laddr = as_Address(left->as_address_ptr());
a61af66fc99e Initial load
duke
parents:
diff changeset
2377 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2378 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2379 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2380
a61af66fc99e Initial load
duke
parents:
diff changeset
2381 if (right->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2382 Register rreg = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2383 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2384 case lir_add: __ addl(laddr, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2385 case lir_sub: __ subl(laddr, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2386 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2388 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2389 jint c = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
2390 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2391 case lir_add: {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2392 __ incrementl(laddr, c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2393 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2395 case lir_sub: {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2396 __ decrementl(laddr, c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2397 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2398 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2399 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2401 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2402 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2404
a61af66fc99e Initial load
duke
parents:
diff changeset
2405 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2406 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2408 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2409
a61af66fc99e Initial load
duke
parents:
diff changeset
2410 void LIR_Assembler::arith_fpu_implementation(LIR_Code code, int left_index, int right_index, int dest_index, bool pop_fpu_stack) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2411 assert(pop_fpu_stack || (left_index == dest_index || right_index == dest_index), "invalid LIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
2412 assert(!pop_fpu_stack || (left_index - 1 == dest_index || right_index - 1 == dest_index), "invalid LIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
2413 assert(left_index == 0 || right_index == 0, "either must be on top of stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
2414
a61af66fc99e Initial load
duke
parents:
diff changeset
2415 bool left_is_tos = (left_index == 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2416 bool dest_is_tos = (dest_index == 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2417 int non_tos_index = (left_is_tos ? right_index : left_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2418
a61af66fc99e Initial load
duke
parents:
diff changeset
2419 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2420 case lir_add:
a61af66fc99e Initial load
duke
parents:
diff changeset
2421 if (pop_fpu_stack) __ faddp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2422 else if (dest_is_tos) __ fadd (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2423 else __ fadda(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2424 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2425
a61af66fc99e Initial load
duke
parents:
diff changeset
2426 case lir_sub:
a61af66fc99e Initial load
duke
parents:
diff changeset
2427 if (left_is_tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2428 if (pop_fpu_stack) __ fsubrp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2429 else if (dest_is_tos) __ fsub (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2430 else __ fsubra(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2431 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2432 if (pop_fpu_stack) __ fsubp (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2433 else if (dest_is_tos) __ fsubr (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2434 else __ fsuba (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2436 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2437
a61af66fc99e Initial load
duke
parents:
diff changeset
2438 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2439 case lir_mul:
a61af66fc99e Initial load
duke
parents:
diff changeset
2440 if (pop_fpu_stack) __ fmulp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2441 else if (dest_is_tos) __ fmul (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2442 else __ fmula(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2443 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2444
a61af66fc99e Initial load
duke
parents:
diff changeset
2445 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2446 case lir_div:
a61af66fc99e Initial load
duke
parents:
diff changeset
2447 if (left_is_tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2448 if (pop_fpu_stack) __ fdivrp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2449 else if (dest_is_tos) __ fdiv (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2450 else __ fdivra(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2451 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2452 if (pop_fpu_stack) __ fdivp (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2453 else if (dest_is_tos) __ fdivr (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2454 else __ fdiva (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2456 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2457
a61af66fc99e Initial load
duke
parents:
diff changeset
2458 case lir_rem:
a61af66fc99e Initial load
duke
parents:
diff changeset
2459 assert(left_is_tos && dest_is_tos && right_index == 1, "must be guaranteed by FPU stack allocation");
a61af66fc99e Initial load
duke
parents:
diff changeset
2460 __ fremr(noreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2461 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2462
a61af66fc99e Initial load
duke
parents:
diff changeset
2463 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
2464 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2465 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2466 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2467
a61af66fc99e Initial load
duke
parents:
diff changeset
2468
a61af66fc99e Initial load
duke
parents:
diff changeset
2469 void LIR_Assembler::intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr unused, LIR_Opr dest, LIR_Op* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2470 if (value->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2471 switch(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2472 case lir_abs :
a61af66fc99e Initial load
duke
parents:
diff changeset
2473 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2474 if (dest->as_xmm_double_reg() != value->as_xmm_double_reg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2475 __ movdbl(dest->as_xmm_double_reg(), value->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
2476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2477 __ andpd(dest->as_xmm_double_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2478 ExternalAddress((address)double_signmask_pool));
a61af66fc99e Initial load
duke
parents:
diff changeset
2479 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2480 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2481
a61af66fc99e Initial load
duke
parents:
diff changeset
2482 case lir_sqrt: __ sqrtsd(dest->as_xmm_double_reg(), value->as_xmm_double_reg()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2483 // all other intrinsics are not available in the SSE instruction set, so FPU is used
a61af66fc99e Initial load
duke
parents:
diff changeset
2484 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2485 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2486
a61af66fc99e Initial load
duke
parents:
diff changeset
2487 } else if (value->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2488 assert(value->fpu_regnrLo() == 0 && dest->fpu_regnrLo() == 0, "both must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2489 switch(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2490 case lir_log : __ flog() ; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2491 case lir_log10 : __ flog10() ; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2492 case lir_abs : __ fabs() ; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2493 case lir_sqrt : __ fsqrt(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2494 case lir_sin :
a61af66fc99e Initial load
duke
parents:
diff changeset
2495 // Should consider not saving rbx, if not necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
2496 __ trigfunc('s', op->as_Op2()->fpu_stack_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
2497 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2498 case lir_cos :
a61af66fc99e Initial load
duke
parents:
diff changeset
2499 // Should consider not saving rbx, if not necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
2500 assert(op->as_Op2()->fpu_stack_size() <= 6, "sin and cos need two free stack slots");
a61af66fc99e Initial load
duke
parents:
diff changeset
2501 __ trigfunc('c', op->as_Op2()->fpu_stack_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
2502 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2503 case lir_tan :
a61af66fc99e Initial load
duke
parents:
diff changeset
2504 // Should consider not saving rbx, if not necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
2505 __ trigfunc('t', op->as_Op2()->fpu_stack_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
2506 break;
6084
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6057
diff changeset
2507 case lir_exp :
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6057
diff changeset
2508 __ exp_with_fallback(op->as_Op2()->fpu_stack_size());
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6057
diff changeset
2509 break;
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6057
diff changeset
2510 case lir_pow :
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6057
diff changeset
2511 __ pow_with_fallback(op->as_Op2()->fpu_stack_size());
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6057
diff changeset
2512 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2513 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2514 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2515 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2516 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2517 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2518 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2519
a61af66fc99e Initial load
duke
parents:
diff changeset
2520 void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2521 // assert(left->destroys_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
2522 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2523 Register reg = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2524 if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2525 int val = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
2526 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2527 case lir_logic_and: __ andl (reg, val); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2528 case lir_logic_or: __ orl (reg, val); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2529 case lir_logic_xor: __ xorl (reg, val); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2530 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2531 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2532 } else if (right->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2533 // added support for stack operands
a61af66fc99e Initial load
duke
parents:
diff changeset
2534 Address raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2535 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2536 case lir_logic_and: __ andl (reg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2537 case lir_logic_or: __ orl (reg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2538 case lir_logic_xor: __ xorl (reg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2539 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2541 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2542 Register rright = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2543 switch (code) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2544 case lir_logic_and: __ andptr (reg, rright); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2545 case lir_logic_or : __ orptr (reg, rright); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2546 case lir_logic_xor: __ xorptr (reg, rright); break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2547 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2548 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2549 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2550 move_regs(reg, dst->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
2551 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2552 Register l_lo = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2553 Register l_hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2554 if (right->is_constant()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2555 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2556 __ mov64(rscratch1, right->as_constant_ptr()->as_jlong());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2557 switch (code) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2558 case lir_logic_and:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2559 __ andq(l_lo, rscratch1);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2560 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2561 case lir_logic_or:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2562 __ orq(l_lo, rscratch1);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2563 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2564 case lir_logic_xor:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2565 __ xorq(l_lo, rscratch1);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2566 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2567 default: ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2568 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2569 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2570 int r_lo = right->as_constant_ptr()->as_jint_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2571 int r_hi = right->as_constant_ptr()->as_jint_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2572 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2573 case lir_logic_and:
a61af66fc99e Initial load
duke
parents:
diff changeset
2574 __ andl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2575 __ andl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2576 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2577 case lir_logic_or:
a61af66fc99e Initial load
duke
parents:
diff changeset
2578 __ orl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2579 __ orl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2580 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2581 case lir_logic_xor:
a61af66fc99e Initial load
duke
parents:
diff changeset
2582 __ xorl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2583 __ xorl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2584 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2585 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2586 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2587 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2588 } else {
1572
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2589 #ifdef _LP64
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2590 Register r_lo;
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2591 if (right->type() == T_OBJECT || right->type() == T_ARRAY) {
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2592 r_lo = right->as_register();
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2593 } else {
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2594 r_lo = right->as_register_lo();
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2595 }
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2596 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2597 Register r_lo = right->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2598 Register r_hi = right->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2599 assert(l_lo != r_hi, "overwriting registers");
1572
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2600 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2601 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2602 case lir_logic_and:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2603 __ andptr(l_lo, r_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2604 NOT_LP64(__ andptr(l_hi, r_hi);)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2605 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2606 case lir_logic_or:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2607 __ orptr(l_lo, r_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2608 NOT_LP64(__ orptr(l_hi, r_hi);)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2609 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2610 case lir_logic_xor:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2611 __ xorptr(l_lo, r_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2612 NOT_LP64(__ xorptr(l_hi, r_hi);)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2613 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2614 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2615 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2616 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2617
a61af66fc99e Initial load
duke
parents:
diff changeset
2618 Register dst_lo = dst->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2619 Register dst_hi = dst->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2620
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2621 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2622 move_regs(l_lo, dst_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2623 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2624 if (dst_lo == l_hi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2625 assert(dst_hi != l_lo, "overwriting registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
2626 move_regs(l_hi, dst_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2627 move_regs(l_lo, dst_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2628 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2629 assert(dst_lo != l_hi, "overwriting registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
2630 move_regs(l_lo, dst_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2631 move_regs(l_hi, dst_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2632 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2633 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2634 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2635 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2636
a61af66fc99e Initial load
duke
parents:
diff changeset
2637
a61af66fc99e Initial load
duke
parents:
diff changeset
2638 // we assume that rax, and rdx can be overwritten
a61af66fc99e Initial load
duke
parents:
diff changeset
2639 void LIR_Assembler::arithmetic_idiv(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr temp, LIR_Opr result, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2640
a61af66fc99e Initial load
duke
parents:
diff changeset
2641 assert(left->is_single_cpu(), "left must be register");
a61af66fc99e Initial load
duke
parents:
diff changeset
2642 assert(right->is_single_cpu() || right->is_constant(), "right must be register or constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
2643 assert(result->is_single_cpu(), "result must be register");
a61af66fc99e Initial load
duke
parents:
diff changeset
2644
a61af66fc99e Initial load
duke
parents:
diff changeset
2645 // assert(left->destroys_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
2646 // assert(right->destroys_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
2647
a61af66fc99e Initial load
duke
parents:
diff changeset
2648 Register lreg = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2649 Register dreg = result->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2650
a61af66fc99e Initial load
duke
parents:
diff changeset
2651 if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2652 int divisor = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
2653 assert(divisor > 0 && is_power_of_2(divisor), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
2654 if (code == lir_idiv) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2655 assert(lreg == rax, "must be rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
2656 assert(temp->as_register() == rdx, "tmp register must be rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
2657 __ cdql(); // sign extend into rdx:rax
a61af66fc99e Initial load
duke
parents:
diff changeset
2658 if (divisor == 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2659 __ subl(lreg, rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2660 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2661 __ andl(rdx, divisor - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2662 __ addl(lreg, rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2663 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2664 __ sarl(lreg, log2_intptr(divisor));
a61af66fc99e Initial load
duke
parents:
diff changeset
2665 move_regs(lreg, dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2666 } else if (code == lir_irem) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2667 Label done;
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2668 __ mov(dreg, lreg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2669 __ andl(dreg, 0x80000000 | (divisor - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2670 __ jcc(Assembler::positive, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2671 __ decrement(dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2672 __ orl(dreg, ~(divisor - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2673 __ increment(dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2674 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2675 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2676 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2677 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2678 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2679 Register rreg = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2680 assert(lreg == rax, "left register must be rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
2681 assert(rreg != rdx, "right register must not be rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
2682 assert(temp->as_register() == rdx, "tmp register must be rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
2683
a61af66fc99e Initial load
duke
parents:
diff changeset
2684 move_regs(lreg, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2685
a61af66fc99e Initial load
duke
parents:
diff changeset
2686 int idivl_offset = __ corrected_idivl(rreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2687 add_debug_info_for_div0(idivl_offset, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2688 if (code == lir_irem) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2689 move_regs(rdx, dreg); // result is in rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
2690 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2691 move_regs(rax, dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2692 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2693 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2694 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2695
a61af66fc99e Initial load
duke
parents:
diff changeset
2696
a61af66fc99e Initial load
duke
parents:
diff changeset
2697 void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2698 if (opr1->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2699 Register reg1 = opr1->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2700 if (opr2->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2701 // cpu register - cpu register
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2702 if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2703 __ cmpptr(reg1, opr2->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2704 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2705 assert(opr2->type() != T_OBJECT && opr2->type() != T_ARRAY, "cmp int, oop?");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2706 __ cmpl(reg1, opr2->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2707 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2708 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2709 // cpu register - stack
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2710 if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2711 __ cmpptr(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2712 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2713 __ cmpl(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2714 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2715 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2716 // cpu register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2717 LIR_Const* c = opr2->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2718 if (c->type() == T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2719 __ cmpl(reg1, c->as_jint());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2720 } else if (c->type() == T_OBJECT || c->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2721 // In 64bit oops are single register
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2722 jobject o = c->as_jobject();
a61af66fc99e Initial load
duke
parents:
diff changeset
2723 if (o == NULL) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2724 __ cmpptr(reg1, (int32_t)NULL_WORD);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2725 } else {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2726 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2727 __ movoop(rscratch1, o);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2728 __ cmpptr(reg1, rscratch1);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2729 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2730 __ cmpoop(reg1, c->as_jobject());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2731 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2732 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2733 } else {
6145
e2fe93124108 7174928: JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
twisti
parents: 6084
diff changeset
2734 fatal(err_msg("unexpected type: %s", basictype_to_str(c->type())));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2735 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2736 // cpu register - address
a61af66fc99e Initial load
duke
parents:
diff changeset
2737 } else if (opr2->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2738 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2739 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2740 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2741 __ cmpl(reg1, as_Address(opr2->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2742 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2743 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2744 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2745
a61af66fc99e Initial load
duke
parents:
diff changeset
2746 } else if(opr1->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2747 Register xlo = opr1->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2748 Register xhi = opr1->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2749 if (opr2->is_double_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2750 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2751 __ cmpptr(xlo, opr2->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2752 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2753 // cpu register - cpu register
a61af66fc99e Initial load
duke
parents:
diff changeset
2754 Register ylo = opr2->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2755 Register yhi = opr2->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2756 __ subl(xlo, ylo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2757 __ sbbl(xhi, yhi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2758 if (condition == lir_cond_equal || condition == lir_cond_notEqual) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2759 __ orl(xhi, xlo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2760 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2761 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2762 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2763 // cpu register - constant 0
a61af66fc99e Initial load
duke
parents:
diff changeset
2764 assert(opr2->as_jlong() == (jlong)0, "only handles zero");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2765 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2766 __ cmpptr(xlo, (int32_t)opr2->as_jlong());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2767 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2768 assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "only handles equals case");
a61af66fc99e Initial load
duke
parents:
diff changeset
2769 __ orl(xhi, xlo);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2770 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2771 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2772 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2773 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2774
a61af66fc99e Initial load
duke
parents:
diff changeset
2775 } else if (opr1->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2776 XMMRegister reg1 = opr1->as_xmm_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2777 if (opr2->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2778 // xmm register - xmm register
a61af66fc99e Initial load
duke
parents:
diff changeset
2779 __ ucomiss(reg1, opr2->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
2780 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2781 // xmm register - stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2782 __ ucomiss(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2783 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2784 // xmm register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2785 __ ucomiss(reg1, InternalAddress(float_constant(opr2->as_jfloat())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2786 } else if (opr2->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2787 // xmm register - address
a61af66fc99e Initial load
duke
parents:
diff changeset
2788 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2789 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2790 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2791 __ ucomiss(reg1, as_Address(opr2->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2792 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2793 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2794 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2795
a61af66fc99e Initial load
duke
parents:
diff changeset
2796 } else if (opr1->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2797 XMMRegister reg1 = opr1->as_xmm_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2798 if (opr2->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2799 // xmm register - xmm register
a61af66fc99e Initial load
duke
parents:
diff changeset
2800 __ ucomisd(reg1, opr2->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
2801 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2802 // xmm register - stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2803 __ ucomisd(reg1, frame_map()->address_for_slot(opr2->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2804 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2805 // xmm register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2806 __ ucomisd(reg1, InternalAddress(double_constant(opr2->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2807 } else if (opr2->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2808 // xmm register - address
a61af66fc99e Initial load
duke
parents:
diff changeset
2809 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2810 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2811 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2812 __ ucomisd(reg1, as_Address(opr2->pointer()->as_address()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2813 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2814 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2815 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2816
a61af66fc99e Initial load
duke
parents:
diff changeset
2817 } else if(opr1->is_single_fpu() || opr1->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2818 assert(opr1->is_fpu_register() && opr1->fpu() == 0, "currently left-hand side must be on TOS (relax this restriction)");
a61af66fc99e Initial load
duke
parents:
diff changeset
2819 assert(opr2->is_fpu_register(), "both must be registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
2820 __ fcmp(noreg, opr2->fpu(), op->fpu_pop_count() > 0, op->fpu_pop_count() > 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2821
a61af66fc99e Initial load
duke
parents:
diff changeset
2822 } else if (opr1->is_address() && opr2->is_constant()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2823 LIR_Const* c = opr2->as_constant_ptr();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2824 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2825 if (c->type() == T_OBJECT || c->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2826 assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "need to reverse");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2827 __ movoop(rscratch1, c->as_jobject());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2828 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2829 #endif // LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2830 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2831 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2832 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2833 // special case: address - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2834 LIR_Address* addr = opr1->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2835 if (c->type() == T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2836 __ cmpl(as_Address(addr), c->as_jint());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2837 } else if (c->type() == T_OBJECT || c->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2838 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2839 // %%% Make this explode if addr isn't reachable until we figure out a
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2840 // better strategy by giving noreg as the temp for as_Address
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2841 __ cmpptr(rscratch1, as_Address(addr, noreg));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2842 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2843 __ cmpoop(as_Address(addr), c->as_jobject());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2844 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2845 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2846 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2847 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2848
a61af66fc99e Initial load
duke
parents:
diff changeset
2849 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2850 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2851 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2852 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2853
a61af66fc99e Initial load
duke
parents:
diff changeset
2854 void LIR_Assembler::comp_fl2i(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst, LIR_Op2* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2855 if (code == lir_cmp_fd2i || code == lir_ucmp_fd2i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2856 if (left->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2857 assert(right->is_single_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2858 __ cmpss2int(left->as_xmm_float_reg(), right->as_xmm_float_reg(), dst->as_register(), code == lir_ucmp_fd2i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2859 } else if (left->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2860 assert(right->is_double_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2861 __ cmpsd2int(left->as_xmm_double_reg(), right->as_xmm_double_reg(), dst->as_register(), code == lir_ucmp_fd2i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2862
a61af66fc99e Initial load
duke
parents:
diff changeset
2863 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2864 assert(left->is_single_fpu() || left->is_double_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
2865 assert(right->is_single_fpu() || right->is_double_fpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2866
a61af66fc99e Initial load
duke
parents:
diff changeset
2867 assert(left->fpu() == 0, "left must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2868 __ fcmp2int(dst->as_register(), code == lir_ucmp_fd2i, right->fpu(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2869 op->fpu_pop_count() > 0, op->fpu_pop_count() > 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2870 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2871 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2872 assert(code == lir_cmp_l2i, "check");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2873 #ifdef _LP64
1369
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2874 Label done;
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2875 Register dest = dst->as_register();
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2876 __ cmpptr(left->as_register_lo(), right->as_register_lo());
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2877 __ movl(dest, -1);
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2878 __ jccb(Assembler::less, done);
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2879 __ set_byte_if_not_zero(dest);
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2880 __ movzbl(dest, dest);
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2881 __ bind(done);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2882 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2883 __ lcmp2int(left->as_register_hi(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2884 left->as_register_lo(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2885 right->as_register_hi(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2886 right->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
2887 move_regs(left->as_register_hi(), dst->as_register());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2888 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2889 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2890 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2891
a61af66fc99e Initial load
duke
parents:
diff changeset
2892
a61af66fc99e Initial load
duke
parents:
diff changeset
2893 void LIR_Assembler::align_call(LIR_Code code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2894 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2895 // make sure that the displacement word of the call ends up word aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
2896 int offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2897 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2898 case lir_static_call:
a61af66fc99e Initial load
duke
parents:
diff changeset
2899 case lir_optvirtual_call:
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2900 case lir_dynamic_call:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2901 offset += NativeCall::displacement_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
2902 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2903 case lir_icvirtual_call:
a61af66fc99e Initial load
duke
parents:
diff changeset
2904 offset += NativeCall::displacement_offset + NativeMovConstReg::instruction_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
2905 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2906 case lir_virtual_call: // currently, sparc-specific for niagara
a61af66fc99e Initial load
duke
parents:
diff changeset
2907 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2908 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2909 while (offset++ % BytesPerWord != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2910 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2911 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2912 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2913 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2914
a61af66fc99e Initial load
duke
parents:
diff changeset
2915
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2916 void LIR_Assembler::call(LIR_OpJavaCall* op, relocInfo::relocType rtype) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2917 assert(!os::is_MP() || (__ offset() + NativeCall::displacement_offset) % BytesPerWord == 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
2918 "must be aligned");
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2919 __ call(AddressLiteral(op->addr(), rtype));
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1491
diff changeset
2920 add_call_info(code_offset(), op->info());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2921 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2922
a61af66fc99e Initial load
duke
parents:
diff changeset
2923
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2924 void LIR_Assembler::ic_call(LIR_OpJavaCall* op) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
2925 __ ic_call(op->addr());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
2926 add_call_info(code_offset(), op->info());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2927 assert(!os::is_MP() ||
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
2928 (__ offset() - NativeCall::instruction_size + NativeCall::displacement_offset) % BytesPerWord == 0,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2929 "must be aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
2930 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2931
a61af66fc99e Initial load
duke
parents:
diff changeset
2932
a61af66fc99e Initial load
duke
parents:
diff changeset
2933 /* Currently, vtable-dispatch is only enabled for sparc platforms */
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2934 void LIR_Assembler::vtable_call(LIR_OpJavaCall* op) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2935 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2936 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2937
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2938
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2939 void LIR_Assembler::emit_static_call_stub() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2940 address call_pc = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
2941 address stub = __ start_a_stub(call_stub_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
2942 if (stub == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2943 bailout("static call stub overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
2944 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2945 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2946
a61af66fc99e Initial load
duke
parents:
diff changeset
2947 int start = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2948 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2949 // make sure that the displacement word of the call ends up word aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
2950 int offset = __ offset() + NativeMovConstReg::instruction_size + NativeCall::displacement_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
2951 while (offset++ % BytesPerWord != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2952 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2953 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2954 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2955 __ relocate(static_stub_Relocation::spec(call_pc));
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
2956 __ mov_metadata(rbx, (Metadata*)NULL);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2957 // must be set to -1 at code generation time
a61af66fc99e Initial load
duke
parents:
diff changeset
2958 assert(!os::is_MP() || ((__ offset() + 1) % BytesPerWord) == 0, "must be aligned on MP");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2959 // On 64bit this will die since it will take a movq & jmp, must be only a jmp
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2960 __ jump(RuntimeAddress(__ pc()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2961
1489
cff162798819 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 1378
diff changeset
2962 assert(__ offset() - start <= call_stub_size, "stub too big");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2963 __ end_a_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
2964 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2965
a61af66fc99e Initial load
duke
parents:
diff changeset
2966
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2967 void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2968 assert(exceptionOop->as_register() == rax, "must match");
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2969 assert(exceptionPC->as_register() == rdx, "must match");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2970
a61af66fc99e Initial load
duke
parents:
diff changeset
2971 // exception object is not added to oop map by LinearScan
a61af66fc99e Initial load
duke
parents:
diff changeset
2972 // (LinearScan assumes that no oops are in fixed registers)
a61af66fc99e Initial load
duke
parents:
diff changeset
2973 info->add_register_oop(exceptionOop);
a61af66fc99e Initial load
duke
parents:
diff changeset
2974 Runtime1::StubID unwind_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
2975
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2976 // get current pc information
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2977 // pc is only needed if the method has an exception handler, the unwind code does not need it.
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2978 int pc_for_athrow_offset = __ offset();
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2979 InternalAddress pc_for_athrow(__ pc());
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2980 __ lea(exceptionPC->as_register(), pc_for_athrow);
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2981 add_call_info(pc_for_athrow_offset, info); // for exception handler
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2982
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2983 __ verify_not_null_oop(rax);
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2984 // search an exception handler (rax: exception oop, rdx: throwing pc)
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2985 if (compilation()->has_fpu_code()) {
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2986 unwind_id = Runtime1::handle_exception_id;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2987 } else {
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2988 unwind_id = Runtime1::handle_exception_nofpu_id;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2989 }
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2990 __ call(RuntimeAddress(Runtime1::entry_for(unwind_id)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2991
a61af66fc99e Initial load
duke
parents:
diff changeset
2992 // enough room for two byte trap
a61af66fc99e Initial load
duke
parents:
diff changeset
2993 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2994 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2995
a61af66fc99e Initial load
duke
parents:
diff changeset
2996
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2997 void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2998 assert(exceptionOop->as_register() == rax, "must match");
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2999
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
3000 __ jmp(_unwind_handler_entry);
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
3001 }
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
3002
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
3003
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3004 void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, LIR_Opr count, LIR_Opr dest, LIR_Opr tmp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3005
a61af66fc99e Initial load
duke
parents:
diff changeset
3006 // optimized version for linear scan:
a61af66fc99e Initial load
duke
parents:
diff changeset
3007 // * count must be already in ECX (guaranteed by LinearScan)
a61af66fc99e Initial load
duke
parents:
diff changeset
3008 // * left and dest must be equal
a61af66fc99e Initial load
duke
parents:
diff changeset
3009 // * tmp must be unused
a61af66fc99e Initial load
duke
parents:
diff changeset
3010 assert(count->as_register() == SHIFT_count, "count must be in ECX");
a61af66fc99e Initial load
duke
parents:
diff changeset
3011 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
3012 assert(tmp->is_illegal(), "wasting a register if tmp is allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
3013
a61af66fc99e Initial load
duke
parents:
diff changeset
3014 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3015 Register value = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3016 assert(value != SHIFT_count, "left cannot be ECX");
a61af66fc99e Initial load
duke
parents:
diff changeset
3017
a61af66fc99e Initial load
duke
parents:
diff changeset
3018 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3019 case lir_shl: __ shll(value); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3020 case lir_shr: __ sarl(value); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3021 case lir_ushr: __ shrl(value); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3022 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3023 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3024 } else if (left->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3025 Register lo = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
3026 Register hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
3027 assert(lo != SHIFT_count && hi != SHIFT_count, "left cannot be ECX");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3028 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3029 switch (code) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3030 case lir_shl: __ shlptr(lo); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3031 case lir_shr: __ sarptr(lo); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3032 case lir_ushr: __ shrptr(lo); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3033 default: ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3034 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3035 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3036
a61af66fc99e Initial load
duke
parents:
diff changeset
3037 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3038 case lir_shl: __ lshl(hi, lo); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3039 case lir_shr: __ lshr(hi, lo, true); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3040 case lir_ushr: __ lshr(hi, lo, false); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3041 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3042 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3043 #endif // LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3044 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3045 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3046 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3047 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3048
a61af66fc99e Initial load
duke
parents:
diff changeset
3049
a61af66fc99e Initial load
duke
parents:
diff changeset
3050 void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3051 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3052 // first move left into dest so that left is not destroyed by the shift
a61af66fc99e Initial load
duke
parents:
diff changeset
3053 Register value = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3054 count = count & 0x1F; // Java spec
a61af66fc99e Initial load
duke
parents:
diff changeset
3055
a61af66fc99e Initial load
duke
parents:
diff changeset
3056 move_regs(left->as_register(), value);
a61af66fc99e Initial load
duke
parents:
diff changeset
3057 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3058 case lir_shl: __ shll(value, count); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3059 case lir_shr: __ sarl(value, count); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3060 case lir_ushr: __ shrl(value, count); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3061 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3062 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3063 } else if (dest->is_double_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3064 #ifndef _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3065 Unimplemented();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3066 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3067 // first move left into dest so that left is not destroyed by the shift
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3068 Register value = dest->as_register_lo();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3069 count = count & 0x1F; // Java spec
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3070
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3071 move_regs(left->as_register_lo(), value);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3072 switch (code) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3073 case lir_shl: __ shlptr(value, count); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3074 case lir_shr: __ sarptr(value, count); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3075 case lir_ushr: __ shrptr(value, count); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3076 default: ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3077 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3078 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3079 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3080 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3081 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3082 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3083
a61af66fc99e Initial load
duke
parents:
diff changeset
3084
a61af66fc99e Initial load
duke
parents:
diff changeset
3085 void LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3086 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
a61af66fc99e Initial load
duke
parents:
diff changeset
3087 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
3088 assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3089 __ movptr (Address(rsp, offset_from_rsp_in_bytes), r);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3090 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3091
a61af66fc99e Initial load
duke
parents:
diff changeset
3092
a61af66fc99e Initial load
duke
parents:
diff changeset
3093 void LIR_Assembler::store_parameter(jint c, int offset_from_rsp_in_words) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3094 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
a61af66fc99e Initial load
duke
parents:
diff changeset
3095 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
3096 assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3097 __ movptr (Address(rsp, offset_from_rsp_in_bytes), c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3098 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3099
a61af66fc99e Initial load
duke
parents:
diff changeset
3100
a61af66fc99e Initial load
duke
parents:
diff changeset
3101 void LIR_Assembler::store_parameter(jobject o, int offset_from_rsp_in_words) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3102 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
a61af66fc99e Initial load
duke
parents:
diff changeset
3103 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
3104 assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
3105 __ movoop (Address(rsp, offset_from_rsp_in_bytes), o);
a61af66fc99e Initial load
duke
parents:
diff changeset
3106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3107
a61af66fc99e Initial load
duke
parents:
diff changeset
3108
a61af66fc99e Initial load
duke
parents:
diff changeset
3109 // This code replaces a call to arraycopy; no exception may
a61af66fc99e Initial load
duke
parents:
diff changeset
3110 // be thrown in this code, they must be thrown in the System.arraycopy
a61af66fc99e Initial load
duke
parents:
diff changeset
3111 // activation frame; we could save some checks if this would not be the case
a61af66fc99e Initial load
duke
parents:
diff changeset
3112 void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3113 ciArrayKlass* default_type = op->expected_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
3114 Register src = op->src()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3115 Register dst = op->dst()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3116 Register src_pos = op->src_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3117 Register dst_pos = op->dst_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3118 Register length = op->length()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3119 Register tmp = op->tmp()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3120
a61af66fc99e Initial load
duke
parents:
diff changeset
3121 CodeStub* stub = op->stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
3122 int flags = op->flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
3123 BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
3124 if (basic_type == T_ARRAY) basic_type = T_OBJECT;
a61af66fc99e Initial load
duke
parents:
diff changeset
3125
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3126 // if we don't know anything, just go through the generic arraycopy
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3127 if (default_type == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3128 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
3129 // save outgoing arguments on stack in case call to System.arraycopy is needed
a61af66fc99e Initial load
duke
parents:
diff changeset
3130 // HACK ALERT. This code used to push the parameters in a hardwired fashion
a61af66fc99e Initial load
duke
parents:
diff changeset
3131 // for interpreter calling conventions. Now we have to do it in new style conventions.
a61af66fc99e Initial load
duke
parents:
diff changeset
3132 // For the moment until C1 gets the new register allocator I just force all the
a61af66fc99e Initial load
duke
parents:
diff changeset
3133 // args to the right place (except the register args) and then on the back side
a61af66fc99e Initial load
duke
parents:
diff changeset
3134 // reload the register args properly if we go slow path. Yuck
a61af66fc99e Initial load
duke
parents:
diff changeset
3135
a61af66fc99e Initial load
duke
parents:
diff changeset
3136 // These are proper for the calling convention
a61af66fc99e Initial load
duke
parents:
diff changeset
3137 store_parameter(length, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3138 store_parameter(dst_pos, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3139 store_parameter(dst, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3140
a61af66fc99e Initial load
duke
parents:
diff changeset
3141 // these are just temporary placements until we need to reload
a61af66fc99e Initial load
duke
parents:
diff changeset
3142 store_parameter(src_pos, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
3143 store_parameter(src, 4);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3144 NOT_LP64(assert(src == rcx && src_pos == rdx, "mismatch in calling convention");)
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3145
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3146 address C_entry = CAST_FROM_FN_PTR(address, Runtime1::arraycopy);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3147
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3148 address copyfunc_addr = StubRoutines::generic_arraycopy();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3149
a61af66fc99e Initial load
duke
parents:
diff changeset
3150 // pass arguments: may push as this is not a safepoint; SP must be fix at each safepoint
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3151 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3152 // The arguments are in java calling convention so we can trivially shift them to C
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3153 // convention
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3154 assert_different_registers(c_rarg0, j_rarg1, j_rarg2, j_rarg3, j_rarg4);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3155 __ mov(c_rarg0, j_rarg0);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3156 assert_different_registers(c_rarg1, j_rarg2, j_rarg3, j_rarg4);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3157 __ mov(c_rarg1, j_rarg1);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3158 assert_different_registers(c_rarg2, j_rarg3, j_rarg4);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3159 __ mov(c_rarg2, j_rarg2);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3160 assert_different_registers(c_rarg3, j_rarg4);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3161 __ mov(c_rarg3, j_rarg3);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3162 #ifdef _WIN64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3163 // Allocate abi space for args but be sure to keep stack aligned
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3164 __ subptr(rsp, 6*wordSize);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3165 store_parameter(j_rarg4, 4);
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3166 if (copyfunc_addr == NULL) { // Use C version if stub was not generated
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3167 __ call(RuntimeAddress(C_entry));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3168 } else {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3169 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3170 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3171 __ incrementl(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3172 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3173 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3174 __ call(RuntimeAddress(copyfunc_addr));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3175 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3176 __ addptr(rsp, 6*wordSize);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3177 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3178 __ mov(c_rarg4, j_rarg4);
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3179 if (copyfunc_addr == NULL) { // Use C version if stub was not generated
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3180 __ call(RuntimeAddress(C_entry));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3181 } else {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3182 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3183 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3184 __ incrementl(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3185 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3186 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3187 __ call(RuntimeAddress(copyfunc_addr));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3188 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3189 #endif // _WIN64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3190 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3191 __ push(length);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3192 __ push(dst_pos);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3193 __ push(dst);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3194 __ push(src_pos);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3195 __ push(src);
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3196
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3197 if (copyfunc_addr == NULL) { // Use C version if stub was not generated
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3198 __ call_VM_leaf(C_entry, 5); // removes pushed parameter from the stack
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3199 } else {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3200 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3201 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3202 __ incrementl(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3203 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3204 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3205 __ call_VM_leaf(copyfunc_addr, 5); // removes pushed parameter from the stack
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3206 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3207
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3208 #endif // _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3209
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3210 __ cmpl(rax, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3211 __ jcc(Assembler::equal, *stub->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
3212
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3213 if (copyfunc_addr != NULL) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3214 __ mov(tmp, rax);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3215 __ xorl(tmp, -1);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3216 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3217
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3218 // Reload values from the stack so they are where the stub
a61af66fc99e Initial load
duke
parents:
diff changeset
3219 // expects them.
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3220 __ movptr (dst, Address(rsp, 0*BytesPerWord));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3221 __ movptr (dst_pos, Address(rsp, 1*BytesPerWord));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3222 __ movptr (length, Address(rsp, 2*BytesPerWord));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3223 __ movptr (src_pos, Address(rsp, 3*BytesPerWord));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3224 __ movptr (src, Address(rsp, 4*BytesPerWord));
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3225
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3226 if (copyfunc_addr != NULL) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3227 __ subl(length, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3228 __ addl(src_pos, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3229 __ addl(dst_pos, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3230 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3231 __ jmp(*stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3232
a61af66fc99e Initial load
duke
parents:
diff changeset
3233 __ bind(*stub->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
3234 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
3235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3236
a61af66fc99e Initial load
duke
parents:
diff changeset
3237 assert(default_type != NULL && default_type->is_array_klass() && default_type->is_loaded(), "must be true at this point");
a61af66fc99e Initial load
duke
parents:
diff changeset
3238
29
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
3239 int elem_size = type2aelembytes(basic_type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3240 int shift_amount;
a61af66fc99e Initial load
duke
parents:
diff changeset
3241 Address::ScaleFactor scale;
a61af66fc99e Initial load
duke
parents:
diff changeset
3242
a61af66fc99e Initial load
duke
parents:
diff changeset
3243 switch (elem_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3244 case 1 :
a61af66fc99e Initial load
duke
parents:
diff changeset
3245 shift_amount = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
3246 scale = Address::times_1;
a61af66fc99e Initial load
duke
parents:
diff changeset
3247 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3248 case 2 :
a61af66fc99e Initial load
duke
parents:
diff changeset
3249 shift_amount = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
3250 scale = Address::times_2;
a61af66fc99e Initial load
duke
parents:
diff changeset
3251 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3252 case 4 :
a61af66fc99e Initial load
duke
parents:
diff changeset
3253 shift_amount = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
3254 scale = Address::times_4;
a61af66fc99e Initial load
duke
parents:
diff changeset
3255 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3256 case 8 :
a61af66fc99e Initial load
duke
parents:
diff changeset
3257 shift_amount = 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
3258 scale = Address::times_8;
a61af66fc99e Initial load
duke
parents:
diff changeset
3259 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3260 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
3261 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3263
a61af66fc99e Initial load
duke
parents:
diff changeset
3264 Address src_length_addr = Address(src, arrayOopDesc::length_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
3265 Address dst_length_addr = Address(dst, arrayOopDesc::length_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
3266 Address src_klass_addr = Address(src, oopDesc::klass_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
3267 Address dst_klass_addr = Address(dst, oopDesc::klass_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
3268
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3269 // length and pos's are all sign extended at this point on 64bit
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3270
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3271 // test for NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
3272 if (flags & LIR_OpArrayCopy::src_null_check) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3273 __ testptr(src, src);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3274 __ jcc(Assembler::zero, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3276 if (flags & LIR_OpArrayCopy::dst_null_check) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3277 __ testptr(dst, dst);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3278 __ jcc(Assembler::zero, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3280
a61af66fc99e Initial load
duke
parents:
diff changeset
3281 // check if negative
a61af66fc99e Initial load
duke
parents:
diff changeset
3282 if (flags & LIR_OpArrayCopy::src_pos_positive_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3283 __ testl(src_pos, src_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
3284 __ jcc(Assembler::less, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3286 if (flags & LIR_OpArrayCopy::dst_pos_positive_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3287 __ testl(dst_pos, dst_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
3288 __ jcc(Assembler::less, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3290
a61af66fc99e Initial load
duke
parents:
diff changeset
3291 if (flags & LIR_OpArrayCopy::src_range_check) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3292 __ lea(tmp, Address(src_pos, length, Address::times_1, 0));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3293 __ cmpl(tmp, src_length_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
3294 __ jcc(Assembler::above, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3296 if (flags & LIR_OpArrayCopy::dst_range_check) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3297 __ lea(tmp, Address(dst_pos, length, Address::times_1, 0));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3298 __ cmpl(tmp, dst_length_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
3299 __ jcc(Assembler::above, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3301
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3302 if (flags & LIR_OpArrayCopy::length_positive_check) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3303 __ testl(length, length);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3304 __ jcc(Assembler::less, *stub->entry());
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3305 __ jcc(Assembler::zero, *stub->continuation());
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3306 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3307
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3308 #ifdef _LP64
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3309 __ movl2ptr(src_pos, src_pos); //higher 32bits must be null
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3310 __ movl2ptr(dst_pos, dst_pos); //higher 32bits must be null
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3311 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3312
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3313 if (flags & LIR_OpArrayCopy::type_check) {
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3314 // We don't know the array types are compatible
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3315 if (basic_type != T_OBJECT) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3316 // Simple test for basic type arrays
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
3317 if (UseCompressedClassPointers) {
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3318 __ movl(tmp, src_klass_addr);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3319 __ cmpl(tmp, dst_klass_addr);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3320 } else {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3321 __ movptr(tmp, src_klass_addr);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3322 __ cmpptr(tmp, dst_klass_addr);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3323 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3324 __ jcc(Assembler::notEqual, *stub->entry());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3325 } else {
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3326 // For object arrays, if src is a sub class of dst then we can
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3327 // safely do the copy.
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3328 Label cont, slow;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3329
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3330 __ push(src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3331 __ push(dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3332
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3333 __ load_klass(src, src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3334 __ load_klass(dst, dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3335
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3336 __ check_klass_subtype_fast_path(src, dst, tmp, &cont, &slow, NULL);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3337
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3338 __ push(src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3339 __ push(dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3340 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3341 __ pop(dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3342 __ pop(src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3343
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3344 __ cmpl(src, 0);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3345 __ jcc(Assembler::notEqual, cont);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3346
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3347 __ bind(slow);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3348 __ pop(dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3349 __ pop(src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3350
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3351 address copyfunc_addr = StubRoutines::checkcast_arraycopy();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3352 if (copyfunc_addr != NULL) { // use stub if available
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3353 // src is not a sub class of dst so we have to do a
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3354 // per-element check.
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3355
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3356 int mask = LIR_OpArrayCopy::src_objarray|LIR_OpArrayCopy::dst_objarray;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3357 if ((flags & mask) != mask) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3358 // Check that at least both of them object arrays.
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3359 assert(flags & mask, "one of the two should be known to be an object array");
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3360
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3361 if (!(flags & LIR_OpArrayCopy::src_objarray)) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3362 __ load_klass(tmp, src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3363 } else if (!(flags & LIR_OpArrayCopy::dst_objarray)) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3364 __ load_klass(tmp, dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3365 }
4762
069ab3f976d3 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 3960
diff changeset
3366 int lh_offset = in_bytes(Klass::layout_helper_offset());
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3367 Address klass_lh_addr(tmp, lh_offset);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3368 jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3369 __ cmpl(klass_lh_addr, objArray_lh);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3370 __ jcc(Assembler::notEqual, *stub->entry());
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3371 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3372
3739
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3373 // Spill because stubs can use any register they like and it's
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3374 // easier to restore just those that we care about.
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3375 store_parameter(dst, 0);
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3376 store_parameter(dst_pos, 1);
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3377 store_parameter(length, 2);
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3378 store_parameter(src_pos, 3);
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3379 store_parameter(src, 4);
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3380
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3381 #ifndef _LP64
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3382 __ movptr(tmp, dst_klass_addr);
6831
d8ce2825b193 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 6795
diff changeset
3383 __ movptr(tmp, Address(tmp, ObjArrayKlass::element_klass_offset()));
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3384 __ push(tmp);
4762
069ab3f976d3 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 3960
diff changeset
3385 __ movl(tmp, Address(tmp, Klass::super_check_offset_offset()));
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3386 __ push(tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3387 __ push(length);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3388 __ lea(tmp, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3389 __ push(tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3390 __ lea(tmp, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3391 __ push(tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3392
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3393 __ call_VM_leaf(copyfunc_addr, 5);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3394 #else
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3395 __ movl2ptr(length, length); //higher 32bits must be null
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3396
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3397 __ lea(c_rarg0, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3398 assert_different_registers(c_rarg0, dst, dst_pos, length);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3399 __ lea(c_rarg1, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3400 assert_different_registers(c_rarg1, dst, length);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3401
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3402 __ mov(c_rarg2, length);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3403 assert_different_registers(c_rarg2, dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3404
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3405 #ifdef _WIN64
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3406 // Allocate abi space for args but be sure to keep stack aligned
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3407 __ subptr(rsp, 6*wordSize);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3408 __ load_klass(c_rarg3, dst);
6831
d8ce2825b193 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 6795
diff changeset
3409 __ movptr(c_rarg3, Address(c_rarg3, ObjArrayKlass::element_klass_offset()));
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3410 store_parameter(c_rarg3, 4);
4762
069ab3f976d3 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 3960
diff changeset
3411 __ movl(c_rarg3, Address(c_rarg3, Klass::super_check_offset_offset()));
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3412 __ call(RuntimeAddress(copyfunc_addr));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3413 __ addptr(rsp, 6*wordSize);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3414 #else
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3415 __ load_klass(c_rarg4, dst);
6831
d8ce2825b193 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 6795
diff changeset
3416 __ movptr(c_rarg4, Address(c_rarg4, ObjArrayKlass::element_klass_offset()));
4762
069ab3f976d3 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 3960
diff changeset
3417 __ movl(c_rarg3, Address(c_rarg4, Klass::super_check_offset_offset()));
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3418 __ call(RuntimeAddress(copyfunc_addr));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3419 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3420
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3421 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3422
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3423 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3424 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3425 Label failed;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3426 __ testl(rax, rax);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3427 __ jcc(Assembler::notZero, failed);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3428 __ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_cnt));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3429 __ bind(failed);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3430 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3431 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3432
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3433 __ testl(rax, rax);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3434 __ jcc(Assembler::zero, *stub->continuation());
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3435
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3436 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3437 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3438 __ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_attempt_cnt));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3439 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3440 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3441
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3442 __ mov(tmp, rax);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3443
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3444 __ xorl(tmp, -1);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3445
3739
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3446 // Restore previously spilled arguments
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3447 __ movptr (dst, Address(rsp, 0*BytesPerWord));
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3448 __ movptr (dst_pos, Address(rsp, 1*BytesPerWord));
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3449 __ movptr (length, Address(rsp, 2*BytesPerWord));
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3450 __ movptr (src_pos, Address(rsp, 3*BytesPerWord));
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3451 __ movptr (src, Address(rsp, 4*BytesPerWord));
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3452
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3453
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3454 __ subl(length, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3455 __ addl(src_pos, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3456 __ addl(dst_pos, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3457 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3458
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3459 __ jmp(*stub->entry());
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3460
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3461 __ bind(cont);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3462 __ pop(dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3463 __ pop(src);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3464 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3465 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3466
a61af66fc99e Initial load
duke
parents:
diff changeset
3467 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
3468 if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3469 // Sanity check the known type with the incoming class. For the
a61af66fc99e Initial load
duke
parents:
diff changeset
3470 // primitive case the types must match exactly with src.klass and
a61af66fc99e Initial load
duke
parents:
diff changeset
3471 // dst.klass each exactly matching the default type. For the
a61af66fc99e Initial load
duke
parents:
diff changeset
3472 // object array case, if no type check is needed then either the
a61af66fc99e Initial load
duke
parents:
diff changeset
3473 // dst type is exactly the expected type and the src type is a
a61af66fc99e Initial load
duke
parents:
diff changeset
3474 // subtype which we can't check or src is the same array as dst
a61af66fc99e Initial load
duke
parents:
diff changeset
3475 // but not necessarily exactly of type default_type.
a61af66fc99e Initial load
duke
parents:
diff changeset
3476 Label known_ok, halt;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
3477 __ mov_metadata(tmp, default_type->constant_encoding());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3478 #ifdef _LP64
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
3479 if (UseCompressedClassPointers) {
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
3480 __ encode_klass_not_null(tmp);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3481 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3482 #endif
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3483
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3484 if (basic_type != T_OBJECT) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3485
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
3486 if (UseCompressedClassPointers) __ cmpl(tmp, dst_klass_addr);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3487 else __ cmpptr(tmp, dst_klass_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3488 __ jcc(Assembler::notEqual, halt);
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
3489 if (UseCompressedClassPointers) __ cmpl(tmp, src_klass_addr);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3490 else __ cmpptr(tmp, src_klass_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3491 __ jcc(Assembler::equal, known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
3492 } else {
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
3493 if (UseCompressedClassPointers) __ cmpl(tmp, dst_klass_addr);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3494 else __ cmpptr(tmp, dst_klass_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3495 __ jcc(Assembler::equal, known_ok);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3496 __ cmpptr(src, dst);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3497 __ jcc(Assembler::equal, known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
3498 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3499 __ bind(halt);
a61af66fc99e Initial load
duke
parents:
diff changeset
3500 __ stop("incorrect type information in arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
3501 __ bind(known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
3502 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3503 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
3504
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3505 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3506 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3507 __ incrementl(ExternalAddress(Runtime1::arraycopy_count_address(basic_type)));
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3508 }
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3509 #endif
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3510
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3511 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3512 assert_different_registers(c_rarg0, dst, dst_pos, length);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3513 __ lea(c_rarg0, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3514 assert_different_registers(c_rarg1, length);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3515 __ lea(c_rarg1, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3516 __ mov(c_rarg2, length);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3517
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3518 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3519 __ lea(tmp, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3520 store_parameter(tmp, 0);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3521 __ lea(tmp, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3522 store_parameter(tmp, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3523 store_parameter(length, 2);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3524 #endif // _LP64
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3525
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3526 bool disjoint = (flags & LIR_OpArrayCopy::overlapping) == 0;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3527 bool aligned = (flags & LIR_OpArrayCopy::unaligned) == 0;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3528 const char *name;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3529 address entry = StubRoutines::select_arraycopy_function(basic_type, aligned, disjoint, name, false);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3530 __ call_VM_leaf(entry, 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3531
a61af66fc99e Initial load
duke
parents:
diff changeset
3532 __ bind(*stub->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
3533 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3534
11080
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3535 void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) {
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3536 assert(op->crc()->is_single_cpu(), "crc must be register");
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3537 assert(op->val()->is_single_cpu(), "byte value must be register");
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3538 assert(op->result_opr()->is_single_cpu(), "result must be register");
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3539 Register crc = op->crc()->as_register();
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3540 Register val = op->val()->as_register();
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3541 Register res = op->result_opr()->as_register();
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3542
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3543 assert_different_registers(val, crc, res);
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3544
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3545 __ lea(res, ExternalAddress(StubRoutines::crc_table_addr()));
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3546 __ notl(crc); // ~crc
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3547 __ update_byte_crc32(crc, val, res);
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3548 __ notl(crc); // ~crc
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3549 __ mov(res, crc);
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3550 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3551
a61af66fc99e Initial load
duke
parents:
diff changeset
3552 void LIR_Assembler::emit_lock(LIR_OpLock* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3553 Register obj = op->obj_opr()->as_register(); // may not be an oop
a61af66fc99e Initial load
duke
parents:
diff changeset
3554 Register hdr = op->hdr_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3555 Register lock = op->lock_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3556 if (!UseFastLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3557 __ jmp(*op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3558 } else if (op->code() == lir_lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3559 Register scratch = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
3560 if (UseBiasedLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3561 scratch = op->scratch_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3562 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3563 assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
a61af66fc99e Initial load
duke
parents:
diff changeset
3564 // add debug info for NullPointerException only if one is possible
a61af66fc99e Initial load
duke
parents:
diff changeset
3565 int null_check_offset = __ lock_object(hdr, obj, lock, scratch, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3566 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3567 add_debug_info_for_null_check(null_check_offset, op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
3568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3569 // done
a61af66fc99e Initial load
duke
parents:
diff changeset
3570 } else if (op->code() == lir_unlock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3571 assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
a61af66fc99e Initial load
duke
parents:
diff changeset
3572 __ unlock_object(hdr, obj, lock, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3573 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3574 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
3575 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3576 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
3577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3578
a61af66fc99e Initial load
duke
parents:
diff changeset
3579
a61af66fc99e Initial load
duke
parents:
diff changeset
3580 void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3581 ciMethod* method = op->profiled_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
3582 int bci = op->profiled_bci();
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
3583 ciMethod* callee = op->profiled_callee();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3584
a61af66fc99e Initial load
duke
parents:
diff changeset
3585 // Update counter for all call types
2007
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
3586 ciMethodData* md = method->method_data_or_null();
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
3587 assert(md != NULL, "Sanity");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3588 ciProfileData* data = md->bci_to_data(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
3589 assert(data->is_CounterData(), "need CounterData for calls");
a61af66fc99e Initial load
duke
parents:
diff changeset
3590 assert(op->mdo()->is_single_cpu(), "mdo must be allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
3591 Register mdo = op->mdo()->as_register();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
3592 __ mov_metadata(mdo, md->constant_encoding());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3593 Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3594 Bytecodes::Code bc = method->java_code_at_bci(bci);
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
3595 const bool callee_is_static = callee->is_loaded() && callee->is_static();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3596 // Perform additional virtual call profiling for invokevirtual and
a61af66fc99e Initial load
duke
parents:
diff changeset
3597 // invokeinterface bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
3598 if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) &&
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
3599 !callee_is_static && // required for optimized MH invokes
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
3600 C1ProfileVirtualCalls) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3601 assert(op->recv()->is_single_cpu(), "recv must be allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
3602 Register recv = op->recv()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3603 assert_different_registers(mdo, recv);
a61af66fc99e Initial load
duke
parents:
diff changeset
3604 assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls");
a61af66fc99e Initial load
duke
parents:
diff changeset
3605 ciKlass* known_klass = op->known_holder();
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
3606 if (C1OptimizeVirtualCallProfiling && known_klass != NULL) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3607 // We know the type that will be seen at this call site; we can
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
3608 // statically update the MethodData* rather than needing to do
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3609 // dynamic tests on the receiver type
a61af66fc99e Initial load
duke
parents:
diff changeset
3610
a61af66fc99e Initial load
duke
parents:
diff changeset
3611 // NOTE: we should probably put a lock around this search to
a61af66fc99e Initial load
duke
parents:
diff changeset
3612 // avoid collisions by concurrent compilations
a61af66fc99e Initial load
duke
parents:
diff changeset
3613 ciVirtualCallData* vc_data = (ciVirtualCallData*) data;
a61af66fc99e Initial load
duke
parents:
diff changeset
3614 uint i;
a61af66fc99e Initial load
duke
parents:
diff changeset
3615 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3616 ciKlass* receiver = vc_data->receiver(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
3617 if (known_klass->equals(receiver)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3618 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
3619 __ addptr(data_addr, DataLayout::counter_increment);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3620 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
3621 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3622 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3623
a61af66fc99e Initial load
duke
parents:
diff changeset
3624 // Receiver type not found in profile data; select an empty slot
a61af66fc99e Initial load
duke
parents:
diff changeset
3625
a61af66fc99e Initial load
duke
parents:
diff changeset
3626 // Note that this is less efficient than it should be because it
a61af66fc99e Initial load
duke
parents:
diff changeset
3627 // always does a write to the receiver part of the
a61af66fc99e Initial load
duke
parents:
diff changeset
3628 // VirtualCallData rather than just the first time
a61af66fc99e Initial load
duke
parents:
diff changeset
3629 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3630 ciKlass* receiver = vc_data->receiver(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
3631 if (receiver == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3632 Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)));
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
3633 __ mov_metadata(recv_addr, known_klass->constant_encoding());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3634 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
3635 __ addptr(data_addr, DataLayout::counter_increment);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3636 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
3637 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3638 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3639 } else {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3640 __ load_klass(recv, recv);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3641 Label update_done;
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
3642 type_profile_helper(mdo, md, data, recv, &update_done);
1206
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1204
diff changeset
3643 // Receiver did not match any saved receiver and there is no empty row for it.
1251
576e77447e3c 6923002: assert(false,"this call site should not be polymorphic")
kvn
parents: 1206
diff changeset
3644 // Increment total counter to indicate polymorphic case.
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
3645 __ addptr(counter_addr, DataLayout::counter_increment);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3646
a61af66fc99e Initial load
duke
parents:
diff changeset
3647 __ bind(update_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
3648 }
1206
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1204
diff changeset
3649 } else {
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1204
diff changeset
3650 // Static call
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
3651 __ addptr(counter_addr, DataLayout::counter_increment);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3652 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3653 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3654
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3655 void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3656 Register obj = op->obj()->as_register();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3657 Register tmp = op->tmp()->as_pointer_register();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3658 Address mdo_addr = as_Address(op->mdp()->as_address_ptr());
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3659 ciKlass* exact_klass = op->exact_klass();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3660 intptr_t current_klass = op->current_klass();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3661 bool not_null = op->not_null();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3662 bool no_conflict = op->no_conflict();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3663
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3664 Label update, next, none;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3665
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3666 bool do_null = !not_null;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3667 bool exact_klass_set = exact_klass != NULL && ciTypeEntries::valid_ciklass(current_klass) == exact_klass;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3668 bool do_update = !TypeEntries::is_type_unknown(current_klass) && !exact_klass_set;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3669
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3670 assert(do_null || do_update, "why are we here?");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3671 assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3672
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3673 __ verify_oop(obj);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3674
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3675 if (tmp != obj) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3676 __ mov(tmp, obj);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3677 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3678 if (do_null) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3679 __ testptr(tmp, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3680 __ jccb(Assembler::notZero, update);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3681 if (!TypeEntries::was_null_seen(current_klass)) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3682 __ orptr(mdo_addr, TypeEntries::null_seen);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3683 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3684 if (do_update) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3685 #ifndef ASSERT
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3686 __ jmpb(next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3687 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3688 #else
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3689 __ jmp(next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3690 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3691 } else {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3692 __ testptr(tmp, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3693 __ jccb(Assembler::notZero, update);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3694 __ stop("unexpect null obj");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3695 #endif
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3696 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3697
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3698 __ bind(update);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3699
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3700 if (do_update) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3701 #ifdef ASSERT
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3702 if (exact_klass != NULL) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3703 Label ok;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3704 __ load_klass(tmp, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3705 __ push(tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3706 __ mov_metadata(tmp, exact_klass->constant_encoding());
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3707 __ cmpptr(tmp, Address(rsp, 0));
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3708 __ jccb(Assembler::equal, ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3709 __ stop("exact klass and actual klass differ");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3710 __ bind(ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3711 __ pop(tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3712 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3713 #endif
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3714 if (!no_conflict) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3715 if (exact_klass == NULL || TypeEntries::is_type_none(current_klass)) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3716 if (exact_klass != NULL) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3717 __ mov_metadata(tmp, exact_klass->constant_encoding());
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3718 } else {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3719 __ load_klass(tmp, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3720 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3721
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3722 __ xorptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3723 __ testptr(tmp, TypeEntries::type_klass_mask);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3724 // klass seen before, nothing to do. The unknown bit may have been
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3725 // set already but no need to check.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3726 __ jccb(Assembler::zero, next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3727
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3728 __ testptr(tmp, TypeEntries::type_unknown);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3729 __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3730
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3731 if (TypeEntries::is_type_none(current_klass)) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3732 __ cmpptr(mdo_addr, 0);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3733 __ jccb(Assembler::equal, none);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3734 __ cmpptr(mdo_addr, TypeEntries::null_seen);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3735 __ jccb(Assembler::equal, none);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3736 // There is a chance that the checks above (re-reading profiling
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3737 // data from memory) fail if another thread has just set the
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3738 // profiling to this obj's klass
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3739 __ xorptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3740 __ testptr(tmp, TypeEntries::type_klass_mask);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3741 __ jccb(Assembler::zero, next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3742 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3743 } else {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3744 assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3745 ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "conflict only");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3746
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3747 __ movptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3748 __ testptr(tmp, TypeEntries::type_unknown);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3749 __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3750 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3751
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3752 // different than before. Cannot keep accurate profile.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3753 __ orptr(mdo_addr, TypeEntries::type_unknown);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3754
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3755 if (TypeEntries::is_type_none(current_klass)) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3756 __ jmpb(next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3757
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3758 __ bind(none);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3759 // first time here. Set profile type.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3760 __ movptr(mdo_addr, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3761 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3762 } else {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3763 // There's a single possible klass at this profile point
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3764 assert(exact_klass != NULL, "should be");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3765 if (TypeEntries::is_type_none(current_klass)) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3766 __ mov_metadata(tmp, exact_klass->constant_encoding());
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3767 __ xorptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3768 __ testptr(tmp, TypeEntries::type_klass_mask);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3769 #ifdef ASSERT
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3770 __ jcc(Assembler::zero, next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3771
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3772 {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3773 Label ok;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3774 __ push(tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3775 __ cmpptr(mdo_addr, 0);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3776 __ jcc(Assembler::equal, ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3777 __ cmpptr(mdo_addr, TypeEntries::null_seen);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3778 __ jcc(Assembler::equal, ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3779 // may have been set by another thread
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3780 __ mov_metadata(tmp, exact_klass->constant_encoding());
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3781 __ xorptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3782 __ testptr(tmp, TypeEntries::type_mask);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3783 __ jcc(Assembler::zero, ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3784
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3785 __ stop("unexpected profiling mismatch");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3786 __ bind(ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3787 __ pop(tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3788 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3789 #else
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3790 __ jccb(Assembler::zero, next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3791 #endif
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3792 // first time here. Set profile type.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3793 __ movptr(mdo_addr, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3794 } else {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3795 assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3796 ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3797
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3798 __ movptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3799 __ testptr(tmp, TypeEntries::type_unknown);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3800 __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3801
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3802 __ orptr(mdo_addr, TypeEntries::type_unknown);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3803 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3804 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3805
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3806 __ bind(next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3807 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3808 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3809
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3810 void LIR_Assembler::emit_delay(LIR_OpDelay*) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3811 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
3812 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3813
a61af66fc99e Initial load
duke
parents:
diff changeset
3814
a61af66fc99e Initial load
duke
parents:
diff changeset
3815 void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3816 __ lea(dst->as_register(), frame_map()->address_for_monitor_lock(monitor_no));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3817 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3818
a61af66fc99e Initial load
duke
parents:
diff changeset
3819
a61af66fc99e Initial load
duke
parents:
diff changeset
3820 void LIR_Assembler::align_backward_branch_target() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3821 __ align(BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
3822 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3823
a61af66fc99e Initial load
duke
parents:
diff changeset
3824
a61af66fc99e Initial load
duke
parents:
diff changeset
3825 void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3826 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3827 __ negl(left->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
3828 move_regs(left->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
3829
a61af66fc99e Initial load
duke
parents:
diff changeset
3830 } else if (left->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3831 Register lo = left->as_register_lo();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3832 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3833 Register dst = dest->as_register_lo();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3834 __ movptr(dst, lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3835 __ negptr(dst);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3836 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3837 Register hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
3838 __ lneg(hi, lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
3839 if (dest->as_register_lo() == hi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3840 assert(dest->as_register_hi() != lo, "destroying register");
a61af66fc99e Initial load
duke
parents:
diff changeset
3841 move_regs(hi, dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
3842 move_regs(lo, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
3843 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3844 move_regs(lo, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
3845 move_regs(hi, dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
3846 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3847 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3848
a61af66fc99e Initial load
duke
parents:
diff changeset
3849 } else if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3850 if (left->as_xmm_float_reg() != dest->as_xmm_float_reg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3851 __ movflt(dest->as_xmm_float_reg(), left->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3852 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3853 __ xorps(dest->as_xmm_float_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
3854 ExternalAddress((address)float_signflip_pool));
a61af66fc99e Initial load
duke
parents:
diff changeset
3855
a61af66fc99e Initial load
duke
parents:
diff changeset
3856 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3857 if (left->as_xmm_double_reg() != dest->as_xmm_double_reg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3858 __ movdbl(dest->as_xmm_double_reg(), left->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3859 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3860 __ xorpd(dest->as_xmm_double_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
3861 ExternalAddress((address)double_signflip_pool));
a61af66fc99e Initial load
duke
parents:
diff changeset
3862
a61af66fc99e Initial load
duke
parents:
diff changeset
3863 } else if (left->is_single_fpu() || left->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3864 assert(left->fpu() == 0, "arg must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3865 assert(dest->fpu() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3866 __ fchs();
a61af66fc99e Initial load
duke
parents:
diff changeset
3867
a61af66fc99e Initial load
duke
parents:
diff changeset
3868 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3869 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3870 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3871 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3872
a61af66fc99e Initial load
duke
parents:
diff changeset
3873
a61af66fc99e Initial load
duke
parents:
diff changeset
3874 void LIR_Assembler::leal(LIR_Opr addr, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3875 assert(addr->is_address() && dest->is_register(), "check");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3876 Register reg;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3877 reg = dest->as_pointer_register();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3878 __ lea(reg, as_Address(addr->as_address_ptr()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3879 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3880
a61af66fc99e Initial load
duke
parents:
diff changeset
3881
a61af66fc99e Initial load
duke
parents:
diff changeset
3882
a61af66fc99e Initial load
duke
parents:
diff changeset
3883 void LIR_Assembler::rt_call(LIR_Opr result, address dest, const LIR_OprList* args, LIR_Opr tmp, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3884 assert(!tmp->is_valid(), "don't need temporary");
a61af66fc99e Initial load
duke
parents:
diff changeset
3885 __ call(RuntimeAddress(dest));
a61af66fc99e Initial load
duke
parents:
diff changeset
3886 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3887 add_call_info_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
3888 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3889 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3890
a61af66fc99e Initial load
duke
parents:
diff changeset
3891
a61af66fc99e Initial load
duke
parents:
diff changeset
3892 void LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3893 assert(type == T_LONG, "only for volatile long fields");
a61af66fc99e Initial load
duke
parents:
diff changeset
3894
a61af66fc99e Initial load
duke
parents:
diff changeset
3895 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3896 add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
3897 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3898
a61af66fc99e Initial load
duke
parents:
diff changeset
3899 if (src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3900 if (dest->is_double_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3901 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3902 __ movdq(dest->as_register_lo(), src->as_xmm_double_reg());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3903 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3904 __ movdl(dest->as_register_lo(), src->as_xmm_double_reg());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3905 __ psrlq(src->as_xmm_double_reg(), 32);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3906 __ movdl(dest->as_register_hi(), src->as_xmm_double_reg());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3907 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3908 } else if (dest->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3909 __ movdbl(frame_map()->address_for_slot(dest->double_stack_ix()), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3910 } else if (dest->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3911 __ movdbl(as_Address(dest->as_address_ptr()), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3912 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3913 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3914 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3915
a61af66fc99e Initial load
duke
parents:
diff changeset
3916 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3917 if (src->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3918 __ movdbl(dest->as_xmm_double_reg(), frame_map()->address_for_slot(src->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3919 } else if (src->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3920 __ movdbl(dest->as_xmm_double_reg(), as_Address(src->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3921 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3922 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3923 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3924
a61af66fc99e Initial load
duke
parents:
diff changeset
3925 } else if (src->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3926 assert(src->fpu_regnrLo() == 0, "must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3927 if (dest->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3928 __ fistp_d(frame_map()->address_for_slot(dest->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3929 } else if (dest->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3930 __ fistp_d(as_Address(dest->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3931 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3932 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3933 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3934
a61af66fc99e Initial load
duke
parents:
diff changeset
3935 } else if (dest->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3936 assert(dest->fpu_regnrLo() == 0, "must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3937 if (src->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3938 __ fild_d(frame_map()->address_for_slot(src->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3939 } else if (src->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3940 __ fild_d(as_Address(src->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3941 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3942 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3943 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3944 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3945 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3946 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3947 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3948
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3949 #ifdef ASSERT
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3950 // emit run-time assertion
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3951 void LIR_Assembler::emit_assert(LIR_OpAssert* op) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3952 assert(op->code() == lir_assert, "must be");
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3953
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3954 if (op->in_opr1()->is_valid()) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3955 assert(op->in_opr2()->is_valid(), "both operands must be valid");
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3956 comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3957 } else {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3958 assert(op->in_opr2()->is_illegal(), "both operands must be illegal");
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3959 assert(op->condition() == lir_cond_always, "no other conditions allowed");
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3960 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3961
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3962 Label ok;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3963 if (op->condition() != lir_cond_always) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3964 Assembler::Condition acond = Assembler::zero;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3965 switch (op->condition()) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3966 case lir_cond_equal: acond = Assembler::equal; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3967 case lir_cond_notEqual: acond = Assembler::notEqual; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3968 case lir_cond_less: acond = Assembler::less; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3969 case lir_cond_lessEqual: acond = Assembler::lessEqual; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3970 case lir_cond_greaterEqual: acond = Assembler::greaterEqual;break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3971 case lir_cond_greater: acond = Assembler::greater; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3972 case lir_cond_belowEqual: acond = Assembler::belowEqual; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3973 case lir_cond_aboveEqual: acond = Assembler::aboveEqual; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3974 default: ShouldNotReachHere();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3975 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3976 __ jcc(acond, ok);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3977 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3978 if (op->halt()) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3979 const char* str = __ code_string(op->msg());
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3980 __ stop(str);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3981 } else {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3982 breakpoint();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3983 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3984 __ bind(ok);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3985 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3986 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3987
a61af66fc99e Initial load
duke
parents:
diff changeset
3988 void LIR_Assembler::membar() {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3989 // QQQ sparc TSO uses this,
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3990 __ membar( Assembler::Membar_mask_bits(Assembler::StoreLoad));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3991 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3992
a61af66fc99e Initial load
duke
parents:
diff changeset
3993 void LIR_Assembler::membar_acquire() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3994 // No x86 machines currently require load fences
a61af66fc99e Initial load
duke
parents:
diff changeset
3995 // __ load_fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
3996 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3997
a61af66fc99e Initial load
duke
parents:
diff changeset
3998 void LIR_Assembler::membar_release() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3999 // No x86 machines currently require store fences
a61af66fc99e Initial load
duke
parents:
diff changeset
4000 // __ store_fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
4001 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4002
4966
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4003 void LIR_Assembler::membar_loadload() {
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4004 // no-op
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4005 //__ membar(Assembler::Membar_mask_bits(Assembler::loadload));
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4006 }
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4007
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4008 void LIR_Assembler::membar_storestore() {
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4009 // no-op
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4010 //__ membar(Assembler::Membar_mask_bits(Assembler::storestore));
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4011 }
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4012
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4013 void LIR_Assembler::membar_loadstore() {
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4014 // no-op
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4015 //__ membar(Assembler::Membar_mask_bits(Assembler::loadstore));
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4016 }
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4017
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4018 void LIR_Assembler::membar_storeload() {
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4019 __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4020 }
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4021
0
a61af66fc99e Initial load
duke
parents:
diff changeset
4022 void LIR_Assembler::get_thread(LIR_Opr result_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4023 assert(result_reg->is_register(), "check");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
4024 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
4025 // __ get_thread(result_reg->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
4026 __ mov(result_reg->as_register(), r15_thread);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
4027 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
4028 __ get_thread(result_reg->as_register());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
4029 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
4030 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4031
a61af66fc99e Initial load
duke
parents:
diff changeset
4032
a61af66fc99e Initial load
duke
parents:
diff changeset
4033 void LIR_Assembler::peephole(LIR_List*) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4034 // do nothing for now
a61af66fc99e Initial load
duke
parents:
diff changeset
4035 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4036
6795
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4037 void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr dest, LIR_Opr tmp) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4038 assert(data == dest, "xchg/xadd uses only 2 operands");
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4039
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4040 if (data->type() == T_INT) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4041 if (code == lir_xadd) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4042 if (os::is_MP()) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4043 __ lock();
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4044 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4045 __ xaddl(as_Address(src->as_address_ptr()), data->as_register());
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4046 } else {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4047 __ xchgl(data->as_register(), as_Address(src->as_address_ptr()));
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4048 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4049 } else if (data->is_oop()) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4050 assert (code == lir_xchg, "xadd for oops");
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4051 Register obj = data->as_register();
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4052 #ifdef _LP64
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4053 if (UseCompressedOops) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4054 __ encode_heap_oop(obj);
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4055 __ xchgl(obj, as_Address(src->as_address_ptr()));
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4056 __ decode_heap_oop(obj);
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4057 } else {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4058 __ xchgptr(obj, as_Address(src->as_address_ptr()));
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4059 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4060 #else
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4061 __ xchgl(obj, as_Address(src->as_address_ptr()));
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4062 #endif
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4063 } else if (data->type() == T_LONG) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4064 #ifdef _LP64
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4065 assert(data->as_register_lo() == data->as_register_hi(), "should be a single register");
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4066 if (code == lir_xadd) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4067 if (os::is_MP()) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4068 __ lock();
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4069 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4070 __ xaddq(as_Address(src->as_address_ptr()), data->as_register_lo());
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4071 } else {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4072 __ xchgq(data->as_register_lo(), as_Address(src->as_address_ptr()));
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4073 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4074 #else
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4075 ShouldNotReachHere();
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4076 #endif
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4077 } else {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4078 ShouldNotReachHere();
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4079 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4080 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
4081
a61af66fc99e Initial load
duke
parents:
diff changeset
4082 #undef __