annotate src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @ 14258:9bcf7b329013

8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a Summary: C1 generates code to encode compressed oop into tmp register before runtime call for patching where GC may happen Reviewed-by: iveresov, twisti, kvn Contributed-by: mgerdin <mikael.gerdin@oracle.com>
author roland
date Tue, 14 Jan 2014 09:44:45 +0100
parents 9acbfe04b5c3
children 4ca6dc0799b6 876390ee9b6f
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"
14258
9bcf7b329013 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();
a61af66fc99e Initial load
duke
parents:
diff changeset
291 __ build_frame(initial_frame_size_in_bytes());
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
a61af66fc99e Initial load
duke
parents:
diff changeset
379 int LIR_Assembler::initial_frame_size_in_bytes() {
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 {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
804 __ movptr(as_Address(addr), NULL_WORD);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
805 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
806 } else {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
807 if (is_literal_address(addr)) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
808 ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
809 __ movoop(as_Address(addr, noreg), c->as_jobject());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
810 } else {
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
811 #ifdef _LP64
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
812 __ movoop(rscratch1, c->as_jobject());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
813 if (UseCompressedOops && !wide) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
814 __ encode_heap_oop(rscratch1);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
815 null_check_here = code_offset();
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
816 __ movl(as_Address_lo(addr), rscratch1);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
817 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
818 null_check_here = code_offset();
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
819 __ movptr(as_Address_lo(addr), rscratch1);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
820 }
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
821 #else
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
822 __ movoop(as_Address(addr), c->as_jobject());
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
823 #endif
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
824 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
825 }
a61af66fc99e Initial load
duke
parents:
diff changeset
826 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
827
a61af66fc99e Initial load
duke
parents:
diff changeset
828 case T_LONG: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
829 case T_DOUBLE:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
830 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
831 if (is_literal_address(addr)) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
832 ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
833 __ 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
834 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
835 __ movptr(r10, (intptr_t)c->as_jlong_bits());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
836 null_check_here = code_offset();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
837 __ movptr(as_Address_lo(addr), r10);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
838 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
839 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
840 // 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
841 __ movptr(as_Address_hi(addr), c->as_jint_hi_bits());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
842 __ movptr(as_Address_lo(addr), c->as_jint_lo_bits());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
843 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
844 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
845
a61af66fc99e Initial load
duke
parents:
diff changeset
846 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
847 case T_BYTE:
a61af66fc99e Initial load
duke
parents:
diff changeset
848 __ movb(as_Address(addr), c->as_jint() & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
849 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
850
a61af66fc99e Initial load
duke
parents:
diff changeset
851 case T_CHAR: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
852 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
853 __ movw(as_Address(addr), c->as_jint() & 0xFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
854 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
855
a61af66fc99e Initial load
duke
parents:
diff changeset
856 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
857 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
858 };
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
859
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
860 if (info != NULL) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
861 add_debug_info_for_null_check(null_check_here, info);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
862 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
863 }
a61af66fc99e Initial load
duke
parents:
diff changeset
864
a61af66fc99e Initial load
duke
parents:
diff changeset
865
a61af66fc99e Initial load
duke
parents:
diff changeset
866 void LIR_Assembler::reg2reg(LIR_Opr src, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
867 assert(src->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
868 assert(dest->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
869
a61af66fc99e Initial load
duke
parents:
diff changeset
870 // move between cpu-registers
a61af66fc99e Initial load
duke
parents:
diff changeset
871 if (dest->is_single_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
872 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
873 if (src->type() == T_LONG) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
874 // Can do LONG -> OBJECT
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
875 move_regs(src->as_register_lo(), dest->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
876 return;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
877 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
878 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
879 assert(src->is_single_cpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
880 if (src->type() == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
881 __ verify_oop(src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
882 }
a61af66fc99e Initial load
duke
parents:
diff changeset
883 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
884
a61af66fc99e Initial load
duke
parents:
diff changeset
885 } else if (dest->is_double_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
886 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
887 if (src->type() == T_OBJECT || src->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
888 // 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
889 __ verify_oop(src->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
890 move_regs(src->as_register(), dest->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
891 return;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
892 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
893 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
894 assert(src->is_double_cpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
895 Register f_lo = src->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
896 Register f_hi = src->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
897 Register t_lo = dest->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
898 Register t_hi = dest->as_register_hi();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
899 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
900 assert(f_hi == f_lo, "must be same");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
901 assert(t_hi == t_lo, "must be same");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
902 move_regs(f_lo, t_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
903 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
904 assert(f_lo != f_hi && t_lo != t_hi, "invalid register allocation");
a61af66fc99e Initial load
duke
parents:
diff changeset
905
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
906
0
a61af66fc99e Initial load
duke
parents:
diff changeset
907 if (f_lo == t_hi && f_hi == t_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
908 swap_reg(f_lo, f_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
909 } else if (f_hi == t_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
910 assert(f_lo != t_hi, "overwriting register");
a61af66fc99e Initial load
duke
parents:
diff changeset
911 move_regs(f_hi, t_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
912 move_regs(f_lo, t_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
913 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
914 assert(f_hi != t_lo, "overwriting register");
a61af66fc99e Initial load
duke
parents:
diff changeset
915 move_regs(f_lo, t_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
916 move_regs(f_hi, t_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
917 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
918 #endif // LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
919
a61af66fc99e Initial load
duke
parents:
diff changeset
920 // special moves from fpu-register to xmm-register
a61af66fc99e Initial load
duke
parents:
diff changeset
921 // necessary for method results
a61af66fc99e Initial load
duke
parents:
diff changeset
922 } else if (src->is_single_xmm() && !dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
923 __ movflt(Address(rsp, 0), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
924 __ fld_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
925 } else if (src->is_double_xmm() && !dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
926 __ movdbl(Address(rsp, 0), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
927 __ fld_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
928 } else if (dest->is_single_xmm() && !src->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
929 __ fstp_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
930 __ movflt(dest->as_xmm_float_reg(), Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
931 } else if (dest->is_double_xmm() && !src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
932 __ fstp_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
933 __ movdbl(dest->as_xmm_double_reg(), Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
934
a61af66fc99e Initial load
duke
parents:
diff changeset
935 // move between xmm-registers
a61af66fc99e Initial load
duke
parents:
diff changeset
936 } else if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
937 assert(src->is_single_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
938 __ movflt(dest->as_xmm_float_reg(), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
939 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
940 assert(src->is_double_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
941 __ movdbl(dest->as_xmm_double_reg(), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
942
a61af66fc99e Initial load
duke
parents:
diff changeset
943 // move between fpu-registers (no instruction necessary because of fpu-stack)
a61af66fc99e Initial load
duke
parents:
diff changeset
944 } else if (dest->is_single_fpu() || dest->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
945 assert(src->is_single_fpu() || src->is_double_fpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
946 assert(src->fpu() == dest->fpu(), "currently should be nothing to do");
a61af66fc99e Initial load
duke
parents:
diff changeset
947 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
948 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
949 }
a61af66fc99e Initial load
duke
parents:
diff changeset
950 }
a61af66fc99e Initial load
duke
parents:
diff changeset
951
a61af66fc99e Initial load
duke
parents:
diff changeset
952 void LIR_Assembler::reg2stack(LIR_Opr src, LIR_Opr dest, BasicType type, bool pop_fpu_stack) {
a61af66fc99e Initial load
duke
parents:
diff changeset
953 assert(src->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
954 assert(dest->is_stack(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
955
a61af66fc99e Initial load
duke
parents:
diff changeset
956 if (src->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
957 Address dst = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
958 if (type == T_OBJECT || type == T_ARRAY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
959 __ verify_oop(src->as_register());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
960 __ movptr (dst, src->as_register());
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
961 } else if (type == T_METADATA) {
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
962 __ movptr (dst, src->as_register());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
963 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
964 __ movl (dst, src->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
965 }
a61af66fc99e Initial load
duke
parents:
diff changeset
966
a61af66fc99e Initial load
duke
parents:
diff changeset
967 } else if (src->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
968 Address dstLO = frame_map()->address_for_slot(dest->double_stack_ix(), lo_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
969 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
970 __ movptr (dstLO, src->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
971 NOT_LP64(__ movptr (dstHI, src->as_register_hi()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
972
a61af66fc99e Initial load
duke
parents:
diff changeset
973 } else if (src->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
974 Address dst_addr = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
975 __ movflt(dst_addr, src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
976
a61af66fc99e Initial load
duke
parents:
diff changeset
977 } else if (src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
978 Address dst_addr = frame_map()->address_for_slot(dest->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
979 __ movdbl(dst_addr, src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
980
a61af66fc99e Initial load
duke
parents:
diff changeset
981 } else if (src->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
982 assert(src->fpu_regnr() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
983 Address dst_addr = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
984 if (pop_fpu_stack) __ fstp_s (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
985 else __ fst_s (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
986
a61af66fc99e Initial load
duke
parents:
diff changeset
987 } else if (src->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
988 assert(src->fpu_regnrLo() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
989 Address dst_addr = frame_map()->address_for_slot(dest->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
990 if (pop_fpu_stack) __ fstp_d (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
991 else __ fst_d (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
992
a61af66fc99e Initial load
duke
parents:
diff changeset
993 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
994 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
995 }
a61af66fc99e Initial load
duke
parents:
diff changeset
996 }
a61af66fc99e Initial load
duke
parents:
diff changeset
997
a61af66fc99e Initial load
duke
parents:
diff changeset
998
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
999 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
1000 LIR_Address* to_addr = dest->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 PatchingStub* patch = NULL;
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1002 Register compressed_src = rscratch1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1003
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 if (type == T_ARRAY || type == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 __ verify_oop(src->as_register());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1006 #ifdef _LP64
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1007 if (UseCompressedOops && !wide) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1008 __ movptr(compressed_src, src->as_register());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1009 __ encode_heap_oop(compressed_src);
14258
9bcf7b329013 8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a
roland
parents: 12969
diff changeset
1010 if (patch_code != lir_patch_none) {
9bcf7b329013 8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a
roland
parents: 12969
diff changeset
1011 info->oop_map()->set_narrowoop(compressed_src->as_VMReg());
9bcf7b329013 8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a
roland
parents: 12969
diff changeset
1012 }
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1013 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1014 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 }
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1016
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 if (patch_code != lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1019 Address toa = as_Address(to_addr);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1020 assert(toa.disp() != 0, "must have");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 }
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1022
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1023 int null_check_here = code_offset();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 case T_FLOAT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 if (src->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 __ movflt(as_Address(to_addr), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 assert(src->is_single_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 assert(src->fpu_regnr() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 if (pop_fpu_stack) __ fstp_s(as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 else __ fst_s (as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1036
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 case T_DOUBLE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 if (src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 __ movdbl(as_Address(to_addr), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 assert(src->is_double_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 assert(src->fpu_regnrLo() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 if (pop_fpu_stack) __ fstp_d(as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 else __ fst_d (as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1048
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 case T_ARRAY: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 case T_OBJECT: // fall through
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1051 if (UseCompressedOops && !wide) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1052 __ movl(as_Address(to_addr), compressed_src);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1053 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1054 __ movptr(as_Address(to_addr), src->as_register());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1055 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1056 break;
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1057 case T_METADATA:
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1058 // 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
1059 // 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
1060 // compressed klass ptrs: T_METADATA can be a compressed klass
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1061 // ptr or a 64 bit method pointer.
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1062 LP64_ONLY(ShouldNotReachHere());
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1063 __ movptr(as_Address(to_addr), src->as_register());
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1064 break;
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1065 case T_ADDRESS:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1066 __ movptr(as_Address(to_addr), src->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1067 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 __ movl(as_Address(to_addr), src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1071
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 case T_LONG: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 Register from_lo = src->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 Register from_hi = src->as_register_hi();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1075 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1076 __ movptr(as_Address_lo(to_addr), from_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1077 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 Register base = to_addr->base()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 Register index = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 if (to_addr->index()->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 index = to_addr->index()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 if (base == from_lo || index == from_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 assert(base != from_hi, "can't be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 assert(index == noreg || (index != base && index != from_hi), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 __ movl(as_Address_hi(to_addr), from_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 patching_epilog(patch, lir_patch_high, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 patch_code = lir_patch_low;
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 __ movl(as_Address_lo(to_addr), from_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 assert(index == noreg || (index != base && index != from_lo), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 __ movl(as_Address_lo(to_addr), from_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 patching_epilog(patch, lir_patch_low, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 patch_code = lir_patch_high;
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 __ movl(as_Address_hi(to_addr), from_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1103 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1106
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 case T_BYTE: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 case T_BOOLEAN: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 Register src_reg = src->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 Address dst_addr = as_Address(to_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 assert(VM_Version::is_P6() || src_reg->has_byte_register(), "must use byte registers if not P6");
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 __ movb(dst_addr, src_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1115
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 case T_CHAR: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 __ movw(as_Address(to_addr), src->as_register());
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 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 }
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1124 if (info != NULL) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1125 add_debug_info_for_null_check(null_check_here, info);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1126 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1127
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 if (patch_code != lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 patching_epilog(patch, patch_code, to_addr->base()->as_register(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1132
a61af66fc99e Initial load
duke
parents:
diff changeset
1133
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 assert(src->is_stack(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 assert(dest->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
1137
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 if (type == T_ARRAY || type == T_OBJECT) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1140 __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 __ verify_oop(dest->as_register());
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1142 } else if (type == T_METADATA) {
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6725
diff changeset
1143 __ 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
1144 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1145 __ movl(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1147
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 } else if (dest->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 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
1150 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
1151 __ movptr(dest->as_register_lo(), src_addr_LO);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1152 NOT_LP64(__ movptr(dest->as_register_hi(), src_addr_HI));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1153
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 } else if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 Address src_addr = frame_map()->address_for_slot(src->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 __ movflt(dest->as_xmm_float_reg(), src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1157
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 Address src_addr = frame_map()->address_for_slot(src->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 __ movdbl(dest->as_xmm_double_reg(), src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1161
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 } else if (dest->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 assert(dest->fpu_regnr() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 Address src_addr = frame_map()->address_for_slot(src->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 __ fld_s(src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1166
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 } else if (dest->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 assert(dest->fpu_regnrLo() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 Address src_addr = frame_map()->address_for_slot(src->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 __ fld_d(src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1171
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1176
a61af66fc99e Initial load
duke
parents:
diff changeset
1177
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 if (src->is_single_stack()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1180 if (type == T_OBJECT || type == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1181 __ pushptr(frame_map()->address_for_slot(src ->single_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1182 __ popptr (frame_map()->address_for_slot(dest->single_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1183 } else {
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1184 #ifndef _LP64
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1185 __ pushl(frame_map()->address_for_slot(src ->single_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1186 __ popl (frame_map()->address_for_slot(dest->single_stack_ix()));
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1187 #else
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1188 //no pushl on 64bits
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1189 __ movl(rscratch1, frame_map()->address_for_slot(src ->single_stack_ix()));
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1190 __ movl(frame_map()->address_for_slot(dest->single_stack_ix()), rscratch1);
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
1191 #endif
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1192 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1193
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 } else if (src->is_double_stack()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1195 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1196 __ pushptr(frame_map()->address_for_slot(src ->double_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1197 __ popptr (frame_map()->address_for_slot(dest->double_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1198 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 __ 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
1200 // 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
1201 __ 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
1202 __ popl (frame_map()->address_for_slot(dest->double_stack_ix(), 2 * wordSize));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 __ 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
1204 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1205
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1210
a61af66fc99e Initial load
duke
parents:
diff changeset
1211
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1212 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
1213 assert(src->is_address(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 assert(dest->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
1215
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 LIR_Address* addr = src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 Address from_addr = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1218
12955
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12875
diff changeset
1219 if (addr->base()->type() == T_OBJECT) {
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12875
diff changeset
1220 __ verify_oop(addr->base()->as_pointer_register());
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12875
diff changeset
1221 }
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12875
diff changeset
1222
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 case T_BYTE: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 case T_CHAR: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 if (!VM_Version::is_P6() && !from_addr.uses(dest->as_register())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 // on pre P6 processors we may get partial register stalls
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 // so blow away the value of to_rinfo before loading a
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 // partial word into it. Do it here so that it precedes
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 // the potential patch point below.
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1233 __ xorptr(dest->as_register(), dest->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1237
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 PatchingStub* patch = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 if (patch_code != lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1241 assert(from_addr.disp() != 0, "must have");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1246
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 case T_FLOAT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 __ movflt(dest->as_xmm_float_reg(), from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 assert(dest->is_single_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 assert(dest->fpu_regnr() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 __ fld_s(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1258
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 case T_DOUBLE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 __ movdbl(dest->as_xmm_double_reg(), from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 assert(dest->is_double_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 assert(dest->fpu_regnrLo() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 __ fld_d(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1269
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 case T_OBJECT: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 case T_ARRAY: // fall through
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1272 if (UseCompressedOops && !wide) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1273 __ movl(dest->as_register(), from_addr);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1274 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1275 __ movptr(dest->as_register(), from_addr);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1276 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1277 break;
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1278
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1279 case T_ADDRESS:
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
1280 if (UseCompressedClassPointers && addr->disp() == oopDesc::klass_offset_in_bytes()) {
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1281 __ movl(dest->as_register(), from_addr);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1282 } else {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1283 __ movptr(dest->as_register(), from_addr);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1284 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1285 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 case T_INT:
1398
314e17ca2c23 6946892: c1 shouldn't sign-extend to upper 32bits on x64
iveresov
parents: 1378
diff changeset
1287 __ movl(dest->as_register(), from_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1289
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 case T_LONG: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 Register to_lo = dest->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 Register to_hi = dest->as_register_hi();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1293 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1294 __ movptr(to_lo, as_Address_lo(addr));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1295 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 Register base = addr->base()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 Register index = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 if (addr->index()->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 index = addr->index()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 if ((base == to_lo && index == to_hi) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 (base == to_hi && index == to_lo)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 // addresses with 2 registers are only formed as a result of
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 // array access so this code will never have to deal with
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 // patches or null checks.
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 assert(info == NULL && patch == NULL, "must be");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1307 __ lea(to_hi, as_Address(addr));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 __ movl(to_lo, Address(to_hi, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 __ movl(to_hi, Address(to_hi, BytesPerWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 } else if (base == to_lo || index == to_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 assert(base != to_hi, "can't be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 assert(index == noreg || (index != base && index != to_hi), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 __ movl(to_hi, as_Address_hi(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 patching_epilog(patch, lir_patch_high, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 patch_code = lir_patch_low;
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 __ movl(to_lo, as_Address_lo(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 assert(index == noreg || (index != base && index != to_lo), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 __ movl(to_lo, as_Address_lo(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 patching_epilog(patch, lir_patch_low, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 patch_code = lir_patch_high;
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 __ movl(to_hi, as_Address_hi(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1330 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1333
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 case T_BYTE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 Register dest_reg = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6");
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1339 __ movsbl(dest_reg, from_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 __ movb(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1342 __ shll(dest_reg, 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 __ sarl(dest_reg, 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1347
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 case T_CHAR: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 Register dest_reg = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6");
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1352 __ movzwl(dest_reg, from_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 __ movw(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1358
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 case T_SHORT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 Register dest_reg = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1362 __ movswl(dest_reg, from_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 __ movw(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 __ shll(dest_reg, 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 __ sarl(dest_reg, 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1370
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1374
a61af66fc99e Initial load
duke
parents:
diff changeset
1375 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 patching_epilog(patch, patch_code, addr->base()->as_register(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1378
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 if (type == T_ARRAY || type == T_OBJECT) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1380 #ifdef _LP64
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1381 if (UseCompressedOops && !wide) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1382 __ decode_heap_oop(dest->as_register());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1383 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1384 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 __ verify_oop(dest->as_register());
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1386 } 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
1387 #ifdef _LP64
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
1388 if (UseCompressedClassPointers) {
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1389 __ decode_klass_not_null(dest->as_register());
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1390 }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
1391 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1394
a61af66fc99e Initial load
duke
parents:
diff changeset
1395
a61af66fc99e Initial load
duke
parents:
diff changeset
1396 void LIR_Assembler::prefetchr(LIR_Opr src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 LIR_Address* addr = src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 Address from_addr = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1399
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 if (VM_Version::supports_sse()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 switch (ReadPrefetchInstr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 case 0:
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 __ prefetchnta(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
1405 __ prefetcht0(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 __ prefetcht2(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 ShouldNotReachHere(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 }
2479
15c9a0e16269 7035713: 3DNow Prefetch Instruction Support
kvn
parents: 2446
diff changeset
1411 } else if (VM_Version::supports_3dnow_prefetch()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 __ prefetchr(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1415
a61af66fc99e Initial load
duke
parents:
diff changeset
1416
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 void LIR_Assembler::prefetchw(LIR_Opr src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 LIR_Address* addr = src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 Address from_addr = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1420
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 if (VM_Version::supports_sse()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 switch (AllocatePrefetchInstr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1423 case 0:
a61af66fc99e Initial load
duke
parents:
diff changeset
1424 __ prefetchnta(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1425 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
1426 __ prefetcht0(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 __ prefetcht2(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 case 3:
a61af66fc99e Initial load
duke
parents:
diff changeset
1430 __ prefetchw(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 ShouldNotReachHere(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 }
2479
15c9a0e16269 7035713: 3DNow Prefetch Instruction Support
kvn
parents: 2446
diff changeset
1434 } else if (VM_Version::supports_3dnow_prefetch()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 __ prefetchw(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1438
a61af66fc99e Initial load
duke
parents:
diff changeset
1439
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 NEEDS_CLEANUP; // This could be static?
a61af66fc99e Initial load
duke
parents:
diff changeset
1441 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
1442 int elem_size = type2aelembytes(type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 switch (elem_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1444 case 1: return Address::times_1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1445 case 2: return Address::times_2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 case 4: return Address::times_4;
a61af66fc99e Initial load
duke
parents:
diff changeset
1447 case 8: return Address::times_8;
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1450 return Address::no_scale;
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1452
a61af66fc99e Initial load
duke
parents:
diff changeset
1453
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 void LIR_Assembler::emit_op3(LIR_Op3* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1455 switch (op->code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 case lir_idiv:
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 case lir_irem:
a61af66fc99e Initial load
duke
parents:
diff changeset
1458 arithmetic_idiv(op->code(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1459 op->in_opr1(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1460 op->in_opr2(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 op->in_opr3(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1462 op->result_opr(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1463 op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1465 default: ShouldNotReachHere(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1466 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1468
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 void LIR_Assembler::emit_opBranch(LIR_OpBranch* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1470 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 assert(op->block() == NULL || op->block()->label() == op->label(), "wrong label");
a61af66fc99e Initial load
duke
parents:
diff changeset
1472 if (op->block() != NULL) _branch_target_blocks.append(op->block());
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 if (op->ublock() != NULL) _branch_target_blocks.append(op->ublock());
a61af66fc99e Initial load
duke
parents:
diff changeset
1474 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1475
a61af66fc99e Initial load
duke
parents:
diff changeset
1476 if (op->cond() == lir_cond_always) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 if (op->info() != NULL) add_debug_info_for_branch(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 __ jmp (*(op->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1479 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1480 Assembler::Condition acond = Assembler::zero;
a61af66fc99e Initial load
duke
parents:
diff changeset
1481 if (op->code() == lir_cond_float_branch) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 assert(op->ublock() != NULL, "must have unordered successor");
a61af66fc99e Initial load
duke
parents:
diff changeset
1483 __ jcc(Assembler::parity, *(op->ublock()->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1484 switch(op->cond()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1485 case lir_cond_equal: acond = Assembler::equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 case lir_cond_notEqual: acond = Assembler::notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1487 case lir_cond_less: acond = Assembler::below; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1488 case lir_cond_lessEqual: acond = Assembler::belowEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 case lir_cond_greaterEqual: acond = Assembler::aboveEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 case lir_cond_greater: acond = Assembler::above; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1491 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1494 switch (op->cond()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 case lir_cond_equal: acond = Assembler::equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1496 case lir_cond_notEqual: acond = Assembler::notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 case lir_cond_less: acond = Assembler::less; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1498 case lir_cond_lessEqual: acond = Assembler::lessEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1499 case lir_cond_greaterEqual: acond = Assembler::greaterEqual;break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1500 case lir_cond_greater: acond = Assembler::greater; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 case lir_cond_belowEqual: acond = Assembler::belowEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1502 case lir_cond_aboveEqual: acond = Assembler::aboveEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1504 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1506 __ jcc(acond,*(op->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1507 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1509
a61af66fc99e Initial load
duke
parents:
diff changeset
1510 void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1511 LIR_Opr src = op->in_opr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1512 LIR_Opr dest = op->result_opr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1513
a61af66fc99e Initial load
duke
parents:
diff changeset
1514 switch (op->bytecode()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1515 case Bytecodes::_i2l:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1516 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1517 __ movl2ptr(dest->as_register_lo(), src->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1518 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1519 move_regs(src->as_register(), dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1520 move_regs(src->as_register(), dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1521 __ sarl(dest->as_register_hi(), 31);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1522 #endif // LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1523 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1524
a61af66fc99e Initial load
duke
parents:
diff changeset
1525 case Bytecodes::_l2i:
6041
3576af4cb939 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 4966
diff changeset
1526 #ifdef _LP64
3576af4cb939 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 4966
diff changeset
1527 __ movl(dest->as_register(), src->as_register_lo());
3576af4cb939 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 4966
diff changeset
1528 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1529 move_regs(src->as_register_lo(), dest->as_register());
6041
3576af4cb939 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 4966
diff changeset
1530 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1531 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1532
a61af66fc99e Initial load
duke
parents:
diff changeset
1533 case Bytecodes::_i2b:
a61af66fc99e Initial load
duke
parents:
diff changeset
1534 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1535 __ sign_extend_byte(dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1536 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1537
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 case Bytecodes::_i2c:
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1540 __ andl(dest->as_register(), 0xFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1542
a61af66fc99e Initial load
duke
parents:
diff changeset
1543 case Bytecodes::_i2s:
a61af66fc99e Initial load
duke
parents:
diff changeset
1544 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1545 __ sign_extend_short(dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1546 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1547
a61af66fc99e Initial load
duke
parents:
diff changeset
1548
a61af66fc99e Initial load
duke
parents:
diff changeset
1549 case Bytecodes::_f2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
1550 case Bytecodes::_d2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1552 __ cvtsd2ss(dest->as_xmm_float_reg(), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1553 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1554 __ cvtss2sd(dest->as_xmm_double_reg(), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1555 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1556 assert(src->fpu() == dest->fpu(), "register must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
1557 // do nothing (float result is rounded later through spilling)
a61af66fc99e Initial load
duke
parents:
diff changeset
1558 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1559 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1560
a61af66fc99e Initial load
duke
parents:
diff changeset
1561 case Bytecodes::_i2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
1562 case Bytecodes::_i2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 if (dest->is_single_xmm()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1564 __ cvtsi2ssl(dest->as_xmm_float_reg(), src->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1565 } else if (dest->is_double_xmm()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1566 __ cvtsi2sdl(dest->as_xmm_double_reg(), src->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 assert(dest->fpu() == 0, "result must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1569 __ movl(Address(rsp, 0), src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 __ fild_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1572 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1573
a61af66fc99e Initial load
duke
parents:
diff changeset
1574 case Bytecodes::_f2i:
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 case Bytecodes::_d2i:
a61af66fc99e Initial load
duke
parents:
diff changeset
1576 if (src->is_single_xmm()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1577 __ cvttss2sil(dest->as_register(), src->as_xmm_float_reg());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1578 } else if (src->is_double_xmm()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1579 __ cvttsd2sil(dest->as_register(), src->as_xmm_double_reg());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1580 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1581 assert(src->fpu() == 0, "input must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1582 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_trunc()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1583 __ fist_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 __ movl(dest->as_register(), Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1585 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1587
a61af66fc99e Initial load
duke
parents:
diff changeset
1588 // IA32 conversion instructions do not match JLS for overflow, underflow and NaN -> fixup in stub
a61af66fc99e Initial load
duke
parents:
diff changeset
1589 assert(op->stub() != NULL, "stub required");
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 __ cmpl(dest->as_register(), 0x80000000);
a61af66fc99e Initial load
duke
parents:
diff changeset
1591 __ jcc(Assembler::equal, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1592 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
1593 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1594
a61af66fc99e Initial load
duke
parents:
diff changeset
1595 case Bytecodes::_l2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
1596 case Bytecodes::_l2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
1597 assert(!dest->is_xmm_register(), "result in xmm register not supported (no SSE instruction present)");
a61af66fc99e Initial load
duke
parents:
diff changeset
1598 assert(dest->fpu() == 0, "result must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1599
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1600 __ movptr(Address(rsp, 0), src->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1601 NOT_LP64(__ movl(Address(rsp, BytesPerWord), src->as_register_hi()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1602 __ fild_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1603 // float result is rounded later through spilling
a61af66fc99e Initial load
duke
parents:
diff changeset
1604 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1605
a61af66fc99e Initial load
duke
parents:
diff changeset
1606 case Bytecodes::_f2l:
a61af66fc99e Initial load
duke
parents:
diff changeset
1607 case Bytecodes::_d2l:
a61af66fc99e Initial load
duke
parents:
diff changeset
1608 assert(!src->is_xmm_register(), "input in xmm register not supported (no SSE instruction present)");
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 assert(src->fpu() == 0, "input must be on TOS");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1610 assert(dest == FrameMap::long0_opr, "runtime stub places result in these registers");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1611
a61af66fc99e Initial load
duke
parents:
diff changeset
1612 // instruction sequence too long to inline it here
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::fpu2long_stub_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1616 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1617
a61af66fc99e Initial load
duke
parents:
diff changeset
1618 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1619 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1621
a61af66fc99e Initial load
duke
parents:
diff changeset
1622 void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1623 if (op->init_check()) {
4739
52b5d32fbfaf 7117052: instanceKlass::_init_state can be u1 type
coleenp
parents: 3960
diff changeset
1624 __ cmpb(Address(op->klass()->as_register(),
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1625 InstanceKlass::init_state_offset()),
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1626 InstanceKlass::fully_initialized);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1627 add_debug_info_for_null_check_here(op->stub()->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 __ jcc(Assembler::notEqual, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1629 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1630 __ allocate_object(op->obj()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 op->tmp1()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1632 op->tmp2()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1633 op->header_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1634 op->object_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 op->klass()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1639
a61af66fc99e Initial load
duke
parents:
diff changeset
1640 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
1641 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
1642 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
1643
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 if (UseSlowPath ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 (!UseFastNewObjectArray && (op->type() == T_OBJECT || op->type() == T_ARRAY)) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 (!UseFastNewTypeArray && (op->type() != T_OBJECT && op->type() != T_ARRAY))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1647 __ jmp(*op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1648 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1649 Register tmp1 = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1650 Register tmp2 = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1651 Register tmp3 = op->tmp3()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1652 if (len == tmp1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 tmp1 = tmp3;
a61af66fc99e Initial load
duke
parents:
diff changeset
1654 } else if (len == tmp2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 tmp2 = tmp3;
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 } else if (len == tmp3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1657 // everything is ok
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 } else {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1659 __ mov(tmp3, len);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 __ allocate_array(op->obj()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 len,
a61af66fc99e Initial load
duke
parents:
diff changeset
1663 tmp1,
a61af66fc99e Initial load
duke
parents:
diff changeset
1664 tmp2,
a61af66fc99e Initial load
duke
parents:
diff changeset
1665 arrayOopDesc::header_size(op->type()),
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 array_element_size(op->type()),
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 op->klass()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1670 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
1671 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1672
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1673 void LIR_Assembler::type_profile_helper(Register mdo,
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1674 ciMethodData *md, ciProfileData *data,
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1675 Register recv, Label* update_done) {
1808
5511edd5d719 6988779: c1_LIRAssembler_x86.cpp crashes VS2010 compiler
iveresov
parents: 1791
diff changeset
1676 for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1677 Label next_test;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1678 // See if the receiver is receiver[n].
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1679 __ cmpptr(recv, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1680 __ jccb(Assembler::notEqual, next_test);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1681 Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1682 __ 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
1683 __ jmp(*update_done);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1684 __ bind(next_test);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1685 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1686
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1687 // 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
1688 for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1689 Label next_test;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1690 Address recv_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1691 __ cmpptr(recv_addr, (intptr_t)NULL_WORD);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1692 __ jccb(Assembler::notEqual, next_test);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1693 __ movptr(recv_addr, recv);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1694 __ 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
1695 __ jmp(*update_done);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1696 __ bind(next_test);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1697 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1698 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1699
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1700 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
1701 // we always need a stub for the failure case.
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1702 CodeStub* stub = op->stub();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1703 Register obj = op->object()->as_register();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1704 Register k_RInfo = op->tmp1()->as_register();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1705 Register klass_RInfo = op->tmp2()->as_register();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1706 Register dst = op->result_opr()->as_register();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1707 ciKlass* k = op->klass();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1708 Register Rtmp1 = noreg;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1709
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1710 // check if it needs to be profiled
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1711 ciMethodData* md;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1712 ciProfileData* data;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1713
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1714 if (op->should_profile()) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1715 ciMethod* method = op->profiled_method();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1716 assert(method != NULL, "Should have method");
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1717 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
1718 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
1719 assert(md != NULL, "Sanity");
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1720 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
1721 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
1722 assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check");
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1723 }
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1724 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
1725 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
1726 Label *failure_target = op->should_profile() ? &profile_cast_failure : failure;
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1727
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1728 if (obj == k_RInfo) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1729 k_RInfo = dst;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1730 } else if (obj == klass_RInfo) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1731 klass_RInfo = dst;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1732 }
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
1733 if (k->is_loaded() && !UseCompressedClassPointers) {
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1734 select_different_registers(obj, dst, k_RInfo, klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1735 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1736 Rtmp1 = op->tmp3()->as_register();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1737 select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1738 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1739
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1740 assert_different_registers(obj, k_RInfo, klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1741
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1742 __ cmpptr(obj, (int32_t)NULL_WORD);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1743 if (op->should_profile()) {
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1744 Label not_null;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1745 __ jccb(Assembler::notEqual, not_null);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1746 // Object is null; update MDO and exit
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1747 Register mdo = klass_RInfo;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1748 __ mov_metadata(mdo, md->constant_encoding());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1749 Address data_addr(mdo, md->byte_offset_of_slot(data, DataLayout::header_offset()));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1750 int header_bits = DataLayout::flag_mask_to_header_mask(BitData::null_seen_byte_constant());
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1751 __ orl(data_addr, header_bits);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1752 __ jmp(*obj_is_null);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1753 __ bind(not_null);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1754 } else {
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1755 __ jcc(Assembler::equal, *obj_is_null);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1756 }
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
1757
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
1758 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
1759 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
1760 } 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
1761 #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
1762 __ 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
1763 #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
1764 }
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1765 __ verify_oop(obj);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1766
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1767 if (op->fast_check()) {
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1768 // get object class
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1769 // not a safepoint as obj null check happens earlier
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1770 #ifdef _LP64
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
1771 if (UseCompressedClassPointers) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1772 __ load_klass(Rtmp1, obj);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1773 __ cmpptr(k_RInfo, Rtmp1);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1774 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1775 __ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1776 }
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1777 #else
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1778 if (k->is_loaded()) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1779 __ 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
1780 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1781 __ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1782 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1783 #endif
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1784 __ jcc(Assembler::notEqual, *failure_target);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1785 // successful cast, fall through to profile or jump
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1786 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1787 // get object class
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1788 // not a safepoint as obj null check happens earlier
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1789 __ load_klass(klass_RInfo, obj);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1790 if (k->is_loaded()) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1791 // See if we get an immediate positive hit
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1792 #ifdef _LP64
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1793 __ cmpptr(k_RInfo, Address(klass_RInfo, k->super_check_offset()));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1794 #else
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1795 __ cmpklass(Address(klass_RInfo, k->super_check_offset()), k->constant_encoding());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1796 #endif // _LP64
4762
069ab3f976d3 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 3960
diff changeset
1797 if ((juint)in_bytes(Klass::secondary_super_cache_offset()) != k->super_check_offset()) {
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1798 __ jcc(Assembler::notEqual, *failure_target);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1799 // successful cast, fall through to profile or jump
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1800 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1801 // 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
1802 __ jcc(Assembler::equal, *success_target);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1803 // check for self
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1804 #ifdef _LP64
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1805 __ cmpptr(klass_RInfo, k_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1806 #else
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1807 __ cmpklass(klass_RInfo, k->constant_encoding());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1808 #endif // _LP64
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1809 __ jcc(Assembler::equal, *success_target);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1810
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1811 __ push(klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1812 #ifdef _LP64
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1813 __ push(k_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1814 #else
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1815 __ pushklass(k->constant_encoding());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1816 #endif // _LP64
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1817 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1818 __ pop(klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1819 __ pop(klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1820 // result is a boolean
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1821 __ cmpl(klass_RInfo, 0);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1822 __ jcc(Assembler::equal, *failure_target);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1823 // successful cast, fall through to profile or jump
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1824 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1825 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1826 // 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
1827 __ 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
1828 // call out-of-line instance of __ check_klass_subtype_slow_path(...):
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1829 __ push(klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1830 __ push(k_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1831 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1832 __ pop(klass_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1833 __ pop(k_RInfo);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1834 // result is a boolean
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1835 __ cmpl(k_RInfo, 0);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1836 __ jcc(Assembler::equal, *failure_target);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1837 // successful cast, fall through to profile or jump
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1838 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1839 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1840 if (op->should_profile()) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1841 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
1842 __ bind(profile_cast_success);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1843 __ mov_metadata(mdo, md->constant_encoding());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1844 __ load_klass(recv, obj);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1845 Label update_done;
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1846 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
1847 __ jmp(*success);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1848
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1849 __ bind(profile_cast_failure);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1850 __ mov_metadata(mdo, md->constant_encoding());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1851 Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1852 __ 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
1853 __ jmp(*failure);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1854 }
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1855 __ jmp(*success);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
1856 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1857
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1858
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1859 void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1860 LIR_Code code = op->code();
a61af66fc99e Initial load
duke
parents:
diff changeset
1861 if (code == lir_store_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1862 Register value = op->object()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1863 Register array = op->array()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1864 Register k_RInfo = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1865 Register klass_RInfo = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1866 Register Rtmp1 = op->tmp3()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1867
a61af66fc99e Initial load
duke
parents:
diff changeset
1868 CodeStub* stub = op->stub();
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1869
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1870 // 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
1871 ciMethodData* md;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1872 ciProfileData* data;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1873
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1874 if (op->should_profile()) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1875 ciMethod* method = op->profiled_method();
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1876 assert(method != NULL, "Should have method");
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1877 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
1878 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
1879 assert(md != NULL, "Sanity");
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1880 data = md->bci_to_data(bci);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1881 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
1882 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
1883 }
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1884 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
1885 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
1886 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
1887
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1888 __ 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
1889 if (op->should_profile()) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1890 Label not_null;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1891 __ jccb(Assembler::notEqual, not_null);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1892 // 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
1893 Register mdo = klass_RInfo;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1894 __ 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
1895 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
1896 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
1897 __ orl(data_addr, header_bits);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1898 __ jmp(done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1899 __ bind(not_null);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1900 } else {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1901 __ jcc(Assembler::equal, done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1902 }
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1903
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1904 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
1905 __ load_klass(k_RInfo, array);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1906 __ load_klass(klass_RInfo, value);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1907
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1908 // get instance klass (it's already uncompressed)
6831
d8ce2825b193 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 6795
diff changeset
1909 __ 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
1910 // 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
1911 __ 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
1912 // 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
1913 __ push(klass_RInfo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1914 __ push(k_RInfo);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1915 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1916 __ pop(klass_RInfo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1917 __ pop(k_RInfo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1918 // result is a boolean
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1919 __ cmpl(k_RInfo, 0);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1920 __ jcc(Assembler::equal, *failure_target);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1921 // fall through to the success case
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1922
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1923 if (op->should_profile()) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1924 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
1925 __ bind(profile_cast_success);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1926 __ mov_metadata(mdo, md->constant_encoding());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1927 __ load_klass(recv, value);
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1928 Label update_done;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1929 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
1930 __ jmpb(done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1931
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1932 __ bind(profile_cast_failure);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1933 __ 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
1934 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
1935 __ subptr(counter_addr, DataLayout::counter_increment);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1936 __ jmp(*stub->entry());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1937 }
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1938
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1939 __ bind(done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1940 } else
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1941 if (code == lir_checkcast) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1942 Register obj = op->object()->as_register();
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1943 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
1944 Label success;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1945 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
1946 __ bind(success);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1947 if (dst != obj) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1948 __ mov(dst, obj);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1949 }
1791
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1950 } else
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1951 if (code == lir_instanceof) {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1952 Register obj = op->object()->as_register();
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1953 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
1954 Label success, failure, done;
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1955 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
1956 __ bind(failure);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1957 __ xorptr(dst, dst);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1958 __ jmpb(done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1959 __ bind(success);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1960 __ movptr(dst, 1);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1961 __ bind(done);
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1962 } else {
3a294e483abc 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 1790
diff changeset
1963 ShouldNotReachHere();
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 622
diff changeset
1964 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1965
a61af66fc99e Initial load
duke
parents:
diff changeset
1966 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1967
a61af66fc99e Initial load
duke
parents:
diff changeset
1968
a61af66fc99e Initial load
duke
parents:
diff changeset
1969 void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1970 if (LP64_ONLY(false &&) op->code() == lir_cas_long && VM_Version::supports_cx8()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1971 assert(op->cmp_value()->as_register_lo() == rax, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1972 assert(op->cmp_value()->as_register_hi() == rdx, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1973 assert(op->new_value()->as_register_lo() == rbx, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1974 assert(op->new_value()->as_register_hi() == rcx, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1975 Register addr = op->addr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1976 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1977 __ lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
1978 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1979 NOT_LP64(__ cmpxchg8(Address(addr, 0)));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1980
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1981 } 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
1982 NOT_LP64(assert(op->addr()->is_single_cpu(), "must be single");)
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1983 Register addr = (op->addr()->is_single_cpu() ? op->addr()->as_register() : op->addr()->as_register_lo());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1984 Register newval = op->new_value()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1985 Register cmpval = op->cmp_value()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1986 assert(cmpval == rax, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1987 assert(newval != NULL, "new val must be register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1988 assert(cmpval != newval, "cmp and new values must be in different registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1989 assert(cmpval != addr, "cmp and addr must be in different registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1990 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
1991
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
1992 if ( op->code() == lir_cas_obj) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1993 #ifdef _LP64
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1994 if (UseCompressedOops) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1995 __ encode_heap_oop(cmpval);
2013
ec8c74742417 7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops
iveresov
parents: 2007
diff changeset
1996 __ mov(rscratch1, newval);
ec8c74742417 7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops
iveresov
parents: 2007
diff changeset
1997 __ encode_heap_oop(rscratch1);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1998 if (os::is_MP()) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1999 __ lock();
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2000 }
2013
ec8c74742417 7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops
iveresov
parents: 2007
diff changeset
2001 // 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
2002 __ cmpxchgl(rscratch1, Address(addr, 0));
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2003 } else
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2004 #endif
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2005 {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2006 if (os::is_MP()) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2007 __ lock();
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2008 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2009 __ cmpxchgptr(newval, Address(addr, 0));
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2010 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2011 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2012 assert(op->code() == lir_cas_int, "lir_cas_int expected");
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2013 if (os::is_MP()) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2014 __ lock();
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2015 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2016 __ cmpxchgl(newval, Address(addr, 0));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2017 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2018 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2019 } else if (op->code() == lir_cas_long) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2020 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
2021 Register newval = op->new_value()->as_register_lo();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2022 Register cmpval = op->cmp_value()->as_register_lo();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2023 assert(cmpval == rax, "wrong register");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2024 assert(newval != NULL, "new val must be register");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2025 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
2026 assert(cmpval != addr, "cmp and addr must be in different registers");
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2027 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
2028 if (os::is_MP()) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2029 __ lock();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2030 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2031 __ cmpxchgq(newval, Address(addr, 0));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2032 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2033 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2034 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2035 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2036 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2037
2089
037c727f35fb 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 2013
diff changeset
2038 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
2039 Assembler::Condition acond, ncond;
a61af66fc99e Initial load
duke
parents:
diff changeset
2040 switch (condition) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2041 case lir_cond_equal: acond = Assembler::equal; ncond = Assembler::notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2042 case lir_cond_notEqual: acond = Assembler::notEqual; ncond = Assembler::equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2043 case lir_cond_less: acond = Assembler::less; ncond = Assembler::greaterEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2044 case lir_cond_lessEqual: acond = Assembler::lessEqual; ncond = Assembler::greater; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2045 case lir_cond_greaterEqual: acond = Assembler::greaterEqual; ncond = Assembler::less; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2046 case lir_cond_greater: acond = Assembler::greater; ncond = Assembler::lessEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2047 case lir_cond_belowEqual: acond = Assembler::belowEqual; ncond = Assembler::above; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2048 case lir_cond_aboveEqual: acond = Assembler::aboveEqual; ncond = Assembler::below; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2049 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2050 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2051
a61af66fc99e Initial load
duke
parents:
diff changeset
2052 if (opr1->is_cpu_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2053 reg2reg(opr1, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
2054 } else if (opr1->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2055 stack2reg(opr1, result, result->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
2056 } else if (opr1->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2057 const2reg(opr1, result, lir_patch_none, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2058 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2059 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2060 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2061
a61af66fc99e Initial load
duke
parents:
diff changeset
2062 if (VM_Version::supports_cmov() && !opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2063 // optimized version that does not require a branch
a61af66fc99e Initial load
duke
parents:
diff changeset
2064 if (opr2->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2065 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
2066 __ cmov(ncond, result->as_register(), opr2->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2067 } else if (opr2->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2068 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
2069 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
2070 __ cmovptr(ncond, result->as_register_lo(), opr2->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2071 NOT_LP64(__ cmovptr(ncond, result->as_register_hi(), opr2->as_register_hi());)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2072 } else if (opr2->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2073 __ cmovl(ncond, result->as_register(), frame_map()->address_for_slot(opr2->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2074 } else if (opr2->is_double_stack()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2075 __ 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
2076 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
2077 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2078 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2079 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2080
a61af66fc99e Initial load
duke
parents:
diff changeset
2081 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2082 Label skip;
a61af66fc99e Initial load
duke
parents:
diff changeset
2083 __ jcc (acond, skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
2084 if (opr2->is_cpu_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2085 reg2reg(opr2, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
2086 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2087 stack2reg(opr2, result, result->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
2088 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2089 const2reg(opr2, result, lir_patch_none, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2090 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2091 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2092 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2093 __ bind(skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
2094 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2095 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2096
a61af66fc99e Initial load
duke
parents:
diff changeset
2097
a61af66fc99e Initial load
duke
parents:
diff changeset
2098 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
2099 assert(info == NULL, "should never be used, idiv/irem and ldiv/lrem not handled by this method");
a61af66fc99e Initial load
duke
parents:
diff changeset
2100
a61af66fc99e Initial load
duke
parents:
diff changeset
2101 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2102 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2103 Register lreg = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2104
a61af66fc99e Initial load
duke
parents:
diff changeset
2105 if (right->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2106 // cpu register - cpu register
a61af66fc99e Initial load
duke
parents:
diff changeset
2107 Register rreg = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2108 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2109 case lir_add: __ addl (lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2110 case lir_sub: __ subl (lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2111 case lir_mul: __ imull(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2112 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2114
a61af66fc99e Initial load
duke
parents:
diff changeset
2115 } else if (right->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2116 // cpu register - stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2117 Address raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2118 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2119 case lir_add: __ addl(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2120 case lir_sub: __ subl(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2121 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2123
a61af66fc99e Initial load
duke
parents:
diff changeset
2124 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2125 // cpu register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2126 jint c = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
2127 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2128 case lir_add: {
1790
7f9553bedfd5 6984056: C1: incorrect code for integer constant addition on x64
iveresov
parents: 1783
diff changeset
2129 __ incrementl(lreg, c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2130 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2132 case lir_sub: {
1790
7f9553bedfd5 6984056: C1: incorrect code for integer constant addition on x64
iveresov
parents: 1783
diff changeset
2133 __ decrementl(lreg, c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2134 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2136 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2138
a61af66fc99e Initial load
duke
parents:
diff changeset
2139 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2140 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2142
a61af66fc99e Initial load
duke
parents:
diff changeset
2143 } else if (left->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2144 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2145 Register lreg_lo = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2146 Register lreg_hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2147
a61af66fc99e Initial load
duke
parents:
diff changeset
2148 if (right->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2149 // cpu register - cpu register
a61af66fc99e Initial load
duke
parents:
diff changeset
2150 Register rreg_lo = right->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2151 Register rreg_hi = right->as_register_hi();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2152 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
2153 LP64_ONLY(assert_different_registers(lreg_lo, rreg_lo));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2154 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2155 case lir_add:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2156 __ addptr(lreg_lo, rreg_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2157 NOT_LP64(__ adcl(lreg_hi, rreg_hi));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2158 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2159 case lir_sub:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2160 __ subptr(lreg_lo, rreg_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2161 NOT_LP64(__ sbbl(lreg_hi, rreg_hi));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2162 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2163 case lir_mul:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2164 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2165 __ imulq(lreg_lo, rreg_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2166 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2167 assert(lreg_lo == rax && lreg_hi == rdx, "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
2168 __ imull(lreg_hi, rreg_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2169 __ imull(rreg_hi, lreg_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2170 __ addl (rreg_hi, lreg_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2171 __ mull (rreg_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2172 __ addl (lreg_hi, rreg_hi);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2173 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2174 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2175 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
2176 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2178
a61af66fc99e Initial load
duke
parents:
diff changeset
2179 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2180 // cpu register - constant
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2181 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2182 jlong c = right->as_constant_ptr()->as_jlong_bits();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2183 __ movptr(r10, (intptr_t) c);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2184 switch (code) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2185 case lir_add:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2186 __ addptr(lreg_lo, r10);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2187 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2188 case lir_sub:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2189 __ subptr(lreg_lo, r10);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2190 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2191 default:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2192 ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2193 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2194 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2195 jint c_lo = right->as_constant_ptr()->as_jint_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2196 jint c_hi = right->as_constant_ptr()->as_jint_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2197 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2198 case lir_add:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2199 __ addptr(lreg_lo, c_lo);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2200 __ adcl(lreg_hi, c_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2201 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2202 case lir_sub:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2203 __ subptr(lreg_lo, c_lo);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2204 __ sbbl(lreg_hi, c_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2205 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2206 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
2207 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2208 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2209 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2210
a61af66fc99e Initial load
duke
parents:
diff changeset
2211 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2212 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2214
a61af66fc99e Initial load
duke
parents:
diff changeset
2215 } else if (left->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2216 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2217 XMMRegister lreg = left->as_xmm_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2218
a61af66fc99e Initial load
duke
parents:
diff changeset
2219 if (right->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2220 XMMRegister rreg = right->as_xmm_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2221 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2222 case lir_add: __ addss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2223 case lir_sub: __ subss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2224 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2225 case lir_mul: __ mulss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2226 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2227 case lir_div: __ divss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2228 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2229 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2230 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2231 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2232 if (right->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2233 raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2234 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2235 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
2236 raddr = __ as_Address(InternalAddress(float_constant(right->as_jfloat())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2237 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2238 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2240 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2241 case lir_add: __ addss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2242 case lir_sub: __ subss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2243 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2244 case lir_mul: __ mulss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2245 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2246 case lir_div: __ divss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2247 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2250
a61af66fc99e Initial load
duke
parents:
diff changeset
2251 } else if (left->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2252 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2253
a61af66fc99e Initial load
duke
parents:
diff changeset
2254 XMMRegister lreg = left->as_xmm_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2255 if (right->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2256 XMMRegister rreg = right->as_xmm_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2257 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2258 case lir_add: __ addsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2259 case lir_sub: __ subsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2260 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2261 case lir_mul: __ mulsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2262 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2263 case lir_div: __ divsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2264 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2266 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2267 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2268 if (right->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2269 raddr = frame_map()->address_for_slot(right->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2270 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2271 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
2272 raddr = __ as_Address(InternalAddress(double_constant(right->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2273 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2274 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2276 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2277 case lir_add: __ addsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2278 case lir_sub: __ subsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2279 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2280 case lir_mul: __ mulsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2281 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2282 case lir_div: __ divsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2283 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2286
a61af66fc99e Initial load
duke
parents:
diff changeset
2287 } else if (left->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2288 assert(dest->is_single_fpu(), "fpu stack allocation required");
a61af66fc99e Initial load
duke
parents:
diff changeset
2289
a61af66fc99e Initial load
duke
parents:
diff changeset
2290 if (right->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2291 arith_fpu_implementation(code, left->fpu_regnr(), right->fpu_regnr(), dest->fpu_regnr(), pop_fpu_stack);
a61af66fc99e Initial load
duke
parents:
diff changeset
2292
a61af66fc99e Initial load
duke
parents:
diff changeset
2293 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2294 assert(left->fpu_regnr() == 0, "left must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2295 assert(dest->fpu_regnr() == 0, "dest must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2296
a61af66fc99e Initial load
duke
parents:
diff changeset
2297 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2298 if (right->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2299 raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2300 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2301 address const_addr = float_constant(right->as_jfloat());
a61af66fc99e Initial load
duke
parents:
diff changeset
2302 assert(const_addr != NULL, "incorrect float/double constant maintainance");
a61af66fc99e Initial load
duke
parents:
diff changeset
2303 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
2304 raddr = __ as_Address(InternalAddress(const_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
2305 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2306 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2308
a61af66fc99e Initial load
duke
parents:
diff changeset
2309 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2310 case lir_add: __ fadd_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2311 case lir_sub: __ fsub_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2312 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2313 case lir_mul: __ fmul_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2314 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2315 case lir_div: __ fdiv_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2316 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2319
a61af66fc99e Initial load
duke
parents:
diff changeset
2320 } else if (left->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2321 assert(dest->is_double_fpu(), "fpu stack allocation required");
a61af66fc99e Initial load
duke
parents:
diff changeset
2322
a61af66fc99e Initial load
duke
parents:
diff changeset
2323 if (code == lir_mul_strictfp || code == lir_div_strictfp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2324 // Double values require special handling for strictfp mul/div on x86
a61af66fc99e Initial load
duke
parents:
diff changeset
2325 __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias1()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2326 __ fmulp(left->fpu_regnrLo() + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2328
a61af66fc99e Initial load
duke
parents:
diff changeset
2329 if (right->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2330 arith_fpu_implementation(code, left->fpu_regnrLo(), right->fpu_regnrLo(), dest->fpu_regnrLo(), pop_fpu_stack);
a61af66fc99e Initial load
duke
parents:
diff changeset
2331
a61af66fc99e Initial load
duke
parents:
diff changeset
2332 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2333 assert(left->fpu_regnrLo() == 0, "left must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2334 assert(dest->fpu_regnrLo() == 0, "dest must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2335
a61af66fc99e Initial load
duke
parents:
diff changeset
2336 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2337 if (right->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2338 raddr = frame_map()->address_for_slot(right->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2339 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2340 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
2341 raddr = __ as_Address(InternalAddress(double_constant(right->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2342 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2343 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2344 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2345
a61af66fc99e Initial load
duke
parents:
diff changeset
2346 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2347 case lir_add: __ fadd_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2348 case lir_sub: __ fsub_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2349 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2350 case lir_mul: __ fmul_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2351 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2352 case lir_div: __ fdiv_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2353 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2356
a61af66fc99e Initial load
duke
parents:
diff changeset
2357 if (code == lir_mul_strictfp || code == lir_div_strictfp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2358 // Double values require special handling for strictfp mul/div on x86
a61af66fc99e Initial load
duke
parents:
diff changeset
2359 __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias2()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2360 __ fmulp(dest->fpu_regnrLo() + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2362
a61af66fc99e Initial load
duke
parents:
diff changeset
2363 } else if (left->is_single_stack() || left->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2364 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2365
a61af66fc99e Initial load
duke
parents:
diff changeset
2366 Address laddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2367 if (left->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2368 laddr = frame_map()->address_for_slot(left->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2369 } else if (left->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2370 laddr = as_Address(left->as_address_ptr());
a61af66fc99e Initial load
duke
parents:
diff changeset
2371 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2372 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2374
a61af66fc99e Initial load
duke
parents:
diff changeset
2375 if (right->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2376 Register rreg = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2377 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2378 case lir_add: __ addl(laddr, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2379 case lir_sub: __ subl(laddr, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2380 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2382 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2383 jint c = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
2384 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2385 case lir_add: {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2386 __ incrementl(laddr, c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2387 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2388 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2389 case lir_sub: {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2390 __ decrementl(laddr, c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2391 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2392 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2393 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2395 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2396 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2397 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2398
a61af66fc99e Initial load
duke
parents:
diff changeset
2399 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2400 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2403
a61af66fc99e Initial load
duke
parents:
diff changeset
2404 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
2405 assert(pop_fpu_stack || (left_index == dest_index || right_index == dest_index), "invalid LIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
2406 assert(!pop_fpu_stack || (left_index - 1 == dest_index || right_index - 1 == dest_index), "invalid LIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
2407 assert(left_index == 0 || right_index == 0, "either must be on top of stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
2408
a61af66fc99e Initial load
duke
parents:
diff changeset
2409 bool left_is_tos = (left_index == 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2410 bool dest_is_tos = (dest_index == 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2411 int non_tos_index = (left_is_tos ? right_index : left_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2412
a61af66fc99e Initial load
duke
parents:
diff changeset
2413 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2414 case lir_add:
a61af66fc99e Initial load
duke
parents:
diff changeset
2415 if (pop_fpu_stack) __ faddp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2416 else if (dest_is_tos) __ fadd (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2417 else __ fadda(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2418 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2419
a61af66fc99e Initial load
duke
parents:
diff changeset
2420 case lir_sub:
a61af66fc99e Initial load
duke
parents:
diff changeset
2421 if (left_is_tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2422 if (pop_fpu_stack) __ fsubrp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2423 else if (dest_is_tos) __ fsub (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2424 else __ fsubra(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2425 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2426 if (pop_fpu_stack) __ fsubp (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2427 else if (dest_is_tos) __ fsubr (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2428 else __ fsuba (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2429 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2430 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2431
a61af66fc99e Initial load
duke
parents:
diff changeset
2432 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2433 case lir_mul:
a61af66fc99e Initial load
duke
parents:
diff changeset
2434 if (pop_fpu_stack) __ fmulp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2435 else if (dest_is_tos) __ fmul (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2436 else __ fmula(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2437 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2438
a61af66fc99e Initial load
duke
parents:
diff changeset
2439 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2440 case lir_div:
a61af66fc99e Initial load
duke
parents:
diff changeset
2441 if (left_is_tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2442 if (pop_fpu_stack) __ fdivrp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2443 else if (dest_is_tos) __ fdiv (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2444 else __ fdivra(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2445 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2446 if (pop_fpu_stack) __ fdivp (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2447 else if (dest_is_tos) __ fdivr (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2448 else __ fdiva (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2449 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2450 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2451
a61af66fc99e Initial load
duke
parents:
diff changeset
2452 case lir_rem:
a61af66fc99e Initial load
duke
parents:
diff changeset
2453 assert(left_is_tos && dest_is_tos && right_index == 1, "must be guaranteed by FPU stack allocation");
a61af66fc99e Initial load
duke
parents:
diff changeset
2454 __ fremr(noreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2455 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2456
a61af66fc99e Initial load
duke
parents:
diff changeset
2457 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
2458 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2461
a61af66fc99e Initial load
duke
parents:
diff changeset
2462
a61af66fc99e Initial load
duke
parents:
diff changeset
2463 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
2464 if (value->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2465 switch(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2466 case lir_abs :
a61af66fc99e Initial load
duke
parents:
diff changeset
2467 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2468 if (dest->as_xmm_double_reg() != value->as_xmm_double_reg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2469 __ movdbl(dest->as_xmm_double_reg(), value->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
2470 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2471 __ andpd(dest->as_xmm_double_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2472 ExternalAddress((address)double_signmask_pool));
a61af66fc99e Initial load
duke
parents:
diff changeset
2473 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2474 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2475
a61af66fc99e Initial load
duke
parents:
diff changeset
2476 case lir_sqrt: __ sqrtsd(dest->as_xmm_double_reg(), value->as_xmm_double_reg()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2477 // all other intrinsics are not available in the SSE instruction set, so FPU is used
a61af66fc99e Initial load
duke
parents:
diff changeset
2478 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2479 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2480
a61af66fc99e Initial load
duke
parents:
diff changeset
2481 } else if (value->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2482 assert(value->fpu_regnrLo() == 0 && dest->fpu_regnrLo() == 0, "both must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2483 switch(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2484 case lir_log : __ flog() ; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2485 case lir_log10 : __ flog10() ; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2486 case lir_abs : __ fabs() ; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2487 case lir_sqrt : __ fsqrt(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2488 case lir_sin :
a61af66fc99e Initial load
duke
parents:
diff changeset
2489 // Should consider not saving rbx, if not necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
2490 __ trigfunc('s', op->as_Op2()->fpu_stack_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
2491 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2492 case lir_cos :
a61af66fc99e Initial load
duke
parents:
diff changeset
2493 // Should consider not saving rbx, if not necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
2494 assert(op->as_Op2()->fpu_stack_size() <= 6, "sin and cos need two free stack slots");
a61af66fc99e Initial load
duke
parents:
diff changeset
2495 __ trigfunc('c', op->as_Op2()->fpu_stack_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
2496 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2497 case lir_tan :
a61af66fc99e Initial load
duke
parents:
diff changeset
2498 // Should consider not saving rbx, if not necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
2499 __ trigfunc('t', op->as_Op2()->fpu_stack_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
2500 break;
6084
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6057
diff changeset
2501 case lir_exp :
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6057
diff changeset
2502 __ 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
2503 break;
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6057
diff changeset
2504 case lir_pow :
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6057
diff changeset
2505 __ 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
2506 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2507 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2508 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2509 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2510 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2512 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2513
a61af66fc99e Initial load
duke
parents:
diff changeset
2514 void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2515 // assert(left->destroys_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
2516 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2517 Register reg = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2518 if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2519 int val = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
2520 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2521 case lir_logic_and: __ andl (reg, val); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2522 case lir_logic_or: __ orl (reg, val); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2523 case lir_logic_xor: __ xorl (reg, val); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2524 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2525 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2526 } else if (right->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2527 // added support for stack operands
a61af66fc99e Initial load
duke
parents:
diff changeset
2528 Address raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2529 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2530 case lir_logic_and: __ andl (reg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2531 case lir_logic_or: __ orl (reg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2532 case lir_logic_xor: __ xorl (reg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2533 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2534 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2535 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2536 Register rright = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2537 switch (code) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2538 case lir_logic_and: __ andptr (reg, rright); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2539 case lir_logic_or : __ orptr (reg, rright); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2540 case lir_logic_xor: __ xorptr (reg, rright); break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2541 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2542 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2543 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2544 move_regs(reg, dst->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
2545 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2546 Register l_lo = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2547 Register l_hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2548 if (right->is_constant()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2549 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2550 __ mov64(rscratch1, right->as_constant_ptr()->as_jlong());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2551 switch (code) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2552 case lir_logic_and:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2553 __ andq(l_lo, rscratch1);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2554 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2555 case lir_logic_or:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2556 __ orq(l_lo, rscratch1);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2557 break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2558 case lir_logic_xor:
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2559 __ xorq(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 default: ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2562 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2563 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2564 int r_lo = right->as_constant_ptr()->as_jint_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2565 int r_hi = right->as_constant_ptr()->as_jint_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2566 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2567 case lir_logic_and:
a61af66fc99e Initial load
duke
parents:
diff changeset
2568 __ andl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2569 __ andl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2570 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2571 case lir_logic_or:
a61af66fc99e Initial load
duke
parents:
diff changeset
2572 __ orl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2573 __ orl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2574 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2575 case lir_logic_xor:
a61af66fc99e Initial load
duke
parents:
diff changeset
2576 __ xorl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2577 __ xorl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2578 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2579 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2580 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2581 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2582 } else {
1572
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2583 #ifdef _LP64
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2584 Register r_lo;
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2585 if (right->type() == T_OBJECT || right->type() == T_ARRAY) {
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2586 r_lo = right->as_register();
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2587 } else {
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2588 r_lo = right->as_register_lo();
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2589 }
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2590 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2591 Register r_lo = right->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2592 Register r_hi = right->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2593 assert(l_lo != r_hi, "overwriting registers");
1572
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
2594 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2595 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2596 case lir_logic_and:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2597 __ andptr(l_lo, r_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2598 NOT_LP64(__ andptr(l_hi, r_hi);)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2599 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2600 case lir_logic_or:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2601 __ orptr(l_lo, r_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2602 NOT_LP64(__ orptr(l_hi, r_hi);)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2603 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2604 case lir_logic_xor:
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2605 __ xorptr(l_lo, r_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2606 NOT_LP64(__ xorptr(l_hi, r_hi);)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2607 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2608 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2610 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2611
a61af66fc99e Initial load
duke
parents:
diff changeset
2612 Register dst_lo = dst->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2613 Register dst_hi = dst->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2614
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2615 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2616 move_regs(l_lo, dst_lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2617 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2618 if (dst_lo == l_hi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2619 assert(dst_hi != l_lo, "overwriting registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
2620 move_regs(l_hi, dst_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2621 move_regs(l_lo, dst_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2622 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2623 assert(dst_lo != l_hi, "overwriting registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
2624 move_regs(l_lo, dst_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2625 move_regs(l_hi, dst_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2626 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2627 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2628 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2629 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2630
a61af66fc99e Initial load
duke
parents:
diff changeset
2631
a61af66fc99e Initial load
duke
parents:
diff changeset
2632 // we assume that rax, and rdx can be overwritten
a61af66fc99e Initial load
duke
parents:
diff changeset
2633 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
2634
a61af66fc99e Initial load
duke
parents:
diff changeset
2635 assert(left->is_single_cpu(), "left must be register");
a61af66fc99e Initial load
duke
parents:
diff changeset
2636 assert(right->is_single_cpu() || right->is_constant(), "right must be register or constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
2637 assert(result->is_single_cpu(), "result must be register");
a61af66fc99e Initial load
duke
parents:
diff changeset
2638
a61af66fc99e Initial load
duke
parents:
diff changeset
2639 // assert(left->destroys_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
2640 // assert(right->destroys_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
2641
a61af66fc99e Initial load
duke
parents:
diff changeset
2642 Register lreg = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2643 Register dreg = result->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2644
a61af66fc99e Initial load
duke
parents:
diff changeset
2645 if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2646 int divisor = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
2647 assert(divisor > 0 && is_power_of_2(divisor), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
2648 if (code == lir_idiv) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2649 assert(lreg == rax, "must be rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
2650 assert(temp->as_register() == rdx, "tmp register must be rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
2651 __ cdql(); // sign extend into rdx:rax
a61af66fc99e Initial load
duke
parents:
diff changeset
2652 if (divisor == 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2653 __ subl(lreg, rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2654 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2655 __ andl(rdx, divisor - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2656 __ addl(lreg, rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2657 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2658 __ sarl(lreg, log2_intptr(divisor));
a61af66fc99e Initial load
duke
parents:
diff changeset
2659 move_regs(lreg, dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2660 } else if (code == lir_irem) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2661 Label done;
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2662 __ mov(dreg, lreg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2663 __ andl(dreg, 0x80000000 | (divisor - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2664 __ jcc(Assembler::positive, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2665 __ decrement(dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2666 __ orl(dreg, ~(divisor - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2667 __ increment(dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2668 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2669 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2670 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2671 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2672 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2673 Register rreg = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2674 assert(lreg == rax, "left register must be rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
2675 assert(rreg != rdx, "right register must not be rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
2676 assert(temp->as_register() == rdx, "tmp register must be rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
2677
a61af66fc99e Initial load
duke
parents:
diff changeset
2678 move_regs(lreg, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2679
a61af66fc99e Initial load
duke
parents:
diff changeset
2680 int idivl_offset = __ corrected_idivl(rreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2681 add_debug_info_for_div0(idivl_offset, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2682 if (code == lir_irem) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2683 move_regs(rdx, dreg); // result is in rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
2684 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2685 move_regs(rax, dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2686 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2687 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2688 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2689
a61af66fc99e Initial load
duke
parents:
diff changeset
2690
a61af66fc99e Initial load
duke
parents:
diff changeset
2691 void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2692 if (opr1->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2693 Register reg1 = opr1->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2694 if (opr2->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2695 // cpu register - cpu register
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2696 if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2697 __ cmpptr(reg1, opr2->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2698 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2699 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
2700 __ cmpl(reg1, opr2->as_register());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2701 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2702 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2703 // cpu register - stack
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2704 if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2705 __ cmpptr(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2706 } else {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2707 __ cmpl(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2708 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2709 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2710 // cpu register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2711 LIR_Const* c = opr2->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2712 if (c->type() == T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2713 __ cmpl(reg1, c->as_jint());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2714 } else if (c->type() == T_OBJECT || c->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2715 // In 64bit oops are single register
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2716 jobject o = c->as_jobject();
a61af66fc99e Initial load
duke
parents:
diff changeset
2717 if (o == NULL) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2718 __ cmpptr(reg1, (int32_t)NULL_WORD);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2719 } else {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2720 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2721 __ movoop(rscratch1, o);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2722 __ cmpptr(reg1, rscratch1);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2723 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2724 __ cmpoop(reg1, c->as_jobject());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2725 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2726 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2727 } else {
6145
e2fe93124108 7174928: JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
twisti
parents: 6084
diff changeset
2728 fatal(err_msg("unexpected type: %s", basictype_to_str(c->type())));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2729 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2730 // cpu register - address
a61af66fc99e Initial load
duke
parents:
diff changeset
2731 } else if (opr2->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2732 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2733 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2734 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2735 __ cmpl(reg1, as_Address(opr2->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2736 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2737 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2738 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2739
a61af66fc99e Initial load
duke
parents:
diff changeset
2740 } else if(opr1->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2741 Register xlo = opr1->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2742 Register xhi = opr1->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2743 if (opr2->is_double_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2744 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2745 __ cmpptr(xlo, opr2->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2746 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2747 // cpu register - cpu register
a61af66fc99e Initial load
duke
parents:
diff changeset
2748 Register ylo = opr2->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2749 Register yhi = opr2->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2750 __ subl(xlo, ylo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2751 __ sbbl(xhi, yhi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2752 if (condition == lir_cond_equal || condition == lir_cond_notEqual) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2753 __ orl(xhi, xlo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2754 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2755 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2756 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2757 // cpu register - constant 0
a61af66fc99e Initial load
duke
parents:
diff changeset
2758 assert(opr2->as_jlong() == (jlong)0, "only handles zero");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2759 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2760 __ cmpptr(xlo, (int32_t)opr2->as_jlong());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2761 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2762 assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "only handles equals case");
a61af66fc99e Initial load
duke
parents:
diff changeset
2763 __ orl(xhi, xlo);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2764 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2765 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2766 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2767 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2768
a61af66fc99e Initial load
duke
parents:
diff changeset
2769 } else if (opr1->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2770 XMMRegister reg1 = opr1->as_xmm_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2771 if (opr2->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2772 // xmm register - xmm register
a61af66fc99e Initial load
duke
parents:
diff changeset
2773 __ ucomiss(reg1, opr2->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
2774 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2775 // xmm register - stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2776 __ ucomiss(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2777 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2778 // xmm register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2779 __ ucomiss(reg1, InternalAddress(float_constant(opr2->as_jfloat())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2780 } else if (opr2->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2781 // xmm register - address
a61af66fc99e Initial load
duke
parents:
diff changeset
2782 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2783 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2784 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2785 __ ucomiss(reg1, as_Address(opr2->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2786 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2787 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2788 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2789
a61af66fc99e Initial load
duke
parents:
diff changeset
2790 } else if (opr1->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2791 XMMRegister reg1 = opr1->as_xmm_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2792 if (opr2->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2793 // xmm register - xmm register
a61af66fc99e Initial load
duke
parents:
diff changeset
2794 __ ucomisd(reg1, opr2->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
2795 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2796 // xmm register - stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2797 __ ucomisd(reg1, frame_map()->address_for_slot(opr2->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2798 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2799 // xmm register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2800 __ ucomisd(reg1, InternalAddress(double_constant(opr2->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2801 } else if (opr2->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2802 // xmm register - address
a61af66fc99e Initial load
duke
parents:
diff changeset
2803 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2804 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2805 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2806 __ ucomisd(reg1, as_Address(opr2->pointer()->as_address()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2807 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2808 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2809 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2810
a61af66fc99e Initial load
duke
parents:
diff changeset
2811 } else if(opr1->is_single_fpu() || opr1->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2812 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
2813 assert(opr2->is_fpu_register(), "both must be registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
2814 __ fcmp(noreg, opr2->fpu(), op->fpu_pop_count() > 0, op->fpu_pop_count() > 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2815
a61af66fc99e Initial load
duke
parents:
diff changeset
2816 } else if (opr1->is_address() && opr2->is_constant()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2817 LIR_Const* c = opr2->as_constant_ptr();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2818 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2819 if (c->type() == T_OBJECT || c->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2820 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
2821 __ movoop(rscratch1, c->as_jobject());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2822 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2823 #endif // LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2824 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2825 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2826 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2827 // special case: address - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2828 LIR_Address* addr = opr1->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2829 if (c->type() == T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2830 __ cmpl(as_Address(addr), c->as_jint());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2831 } else if (c->type() == T_OBJECT || c->type() == T_ARRAY) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2832 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2833 // %%% 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
2834 // better strategy by giving noreg as the temp for as_Address
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2835 __ cmpptr(rscratch1, as_Address(addr, noreg));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2836 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2837 __ cmpoop(as_Address(addr), c->as_jobject());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2838 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2839 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2840 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2841 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2842
a61af66fc99e Initial load
duke
parents:
diff changeset
2843 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2844 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2845 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2846 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2847
a61af66fc99e Initial load
duke
parents:
diff changeset
2848 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
2849 if (code == lir_cmp_fd2i || code == lir_ucmp_fd2i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2850 if (left->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2851 assert(right->is_single_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2852 __ 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
2853 } else if (left->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2854 assert(right->is_double_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2855 __ 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
2856
a61af66fc99e Initial load
duke
parents:
diff changeset
2857 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2858 assert(left->is_single_fpu() || left->is_double_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
2859 assert(right->is_single_fpu() || right->is_double_fpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2860
a61af66fc99e Initial load
duke
parents:
diff changeset
2861 assert(left->fpu() == 0, "left must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2862 __ fcmp2int(dst->as_register(), code == lir_ucmp_fd2i, right->fpu(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2863 op->fpu_pop_count() > 0, op->fpu_pop_count() > 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2864 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2865 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2866 assert(code == lir_cmp_l2i, "check");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2867 #ifdef _LP64
1369
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2868 Label done;
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2869 Register dest = dst->as_register();
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2870 __ cmpptr(left->as_register_lo(), right->as_register_lo());
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2871 __ movl(dest, -1);
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2872 __ jccb(Assembler::less, done);
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2873 __ set_byte_if_not_zero(dest);
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2874 __ movzbl(dest, dest);
0a43776437b6 6942223: c1 64 bit fixes
iveresov
parents: 1301
diff changeset
2875 __ bind(done);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2876 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2877 __ lcmp2int(left->as_register_hi(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2878 left->as_register_lo(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2879 right->as_register_hi(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2880 right->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
2881 move_regs(left->as_register_hi(), dst->as_register());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
2882 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2883 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2884 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2885
a61af66fc99e Initial load
duke
parents:
diff changeset
2886
a61af66fc99e Initial load
duke
parents:
diff changeset
2887 void LIR_Assembler::align_call(LIR_Code code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2888 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2889 // make sure that the displacement word of the call ends up word aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
2890 int offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2891 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2892 case lir_static_call:
a61af66fc99e Initial load
duke
parents:
diff changeset
2893 case lir_optvirtual_call:
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2894 case lir_dynamic_call:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2895 offset += NativeCall::displacement_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
2896 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2897 case lir_icvirtual_call:
a61af66fc99e Initial load
duke
parents:
diff changeset
2898 offset += NativeCall::displacement_offset + NativeMovConstReg::instruction_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
2899 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2900 case lir_virtual_call: // currently, sparc-specific for niagara
a61af66fc99e Initial load
duke
parents:
diff changeset
2901 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2902 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2903 while (offset++ % BytesPerWord != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2904 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2905 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2906 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2907 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2908
a61af66fc99e Initial load
duke
parents:
diff changeset
2909
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2910 void LIR_Assembler::call(LIR_OpJavaCall* op, relocInfo::relocType rtype) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2911 assert(!os::is_MP() || (__ offset() + NativeCall::displacement_offset) % BytesPerWord == 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
2912 "must be aligned");
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2913 __ call(AddressLiteral(op->addr(), rtype));
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1491
diff changeset
2914 add_call_info(code_offset(), op->info());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2915 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2916
a61af66fc99e Initial load
duke
parents:
diff changeset
2917
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2918 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
2919 __ ic_call(op->addr());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
2920 add_call_info(code_offset(), op->info());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2921 assert(!os::is_MP() ||
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
2922 (__ offset() - NativeCall::instruction_size + NativeCall::displacement_offset) % BytesPerWord == 0,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2923 "must be aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
2924 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2925
a61af66fc99e Initial load
duke
parents:
diff changeset
2926
a61af66fc99e Initial load
duke
parents:
diff changeset
2927 /* Currently, vtable-dispatch is only enabled for sparc platforms */
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2928 void LIR_Assembler::vtable_call(LIR_OpJavaCall* op) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2929 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2930 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2931
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1257
diff changeset
2932
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2933 void LIR_Assembler::emit_static_call_stub() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2934 address call_pc = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
2935 address stub = __ start_a_stub(call_stub_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
2936 if (stub == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2937 bailout("static call stub overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
2938 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2939 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2940
a61af66fc99e Initial load
duke
parents:
diff changeset
2941 int start = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2942 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2943 // make sure that the displacement word of the call ends up word aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
2944 int offset = __ offset() + NativeMovConstReg::instruction_size + NativeCall::displacement_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
2945 while (offset++ % BytesPerWord != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2946 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2947 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2948 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2949 __ relocate(static_stub_Relocation::spec(call_pc));
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
2950 __ mov_metadata(rbx, (Metadata*)NULL);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2951 // must be set to -1 at code generation time
a61af66fc99e Initial load
duke
parents:
diff changeset
2952 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
2953 // 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
2954 __ jump(RuntimeAddress(__ pc()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2955
1489
cff162798819 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 1378
diff changeset
2956 assert(__ offset() - start <= call_stub_size, "stub too big");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2957 __ end_a_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
2958 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2959
a61af66fc99e Initial load
duke
parents:
diff changeset
2960
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2961 void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2962 assert(exceptionOop->as_register() == rax, "must match");
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2963 assert(exceptionPC->as_register() == rdx, "must match");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2964
a61af66fc99e Initial load
duke
parents:
diff changeset
2965 // exception object is not added to oop map by LinearScan
a61af66fc99e Initial load
duke
parents:
diff changeset
2966 // (LinearScan assumes that no oops are in fixed registers)
a61af66fc99e Initial load
duke
parents:
diff changeset
2967 info->add_register_oop(exceptionOop);
a61af66fc99e Initial load
duke
parents:
diff changeset
2968 Runtime1::StubID unwind_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
2969
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2970 // get current pc information
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2971 // 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
2972 int pc_for_athrow_offset = __ offset();
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2973 InternalAddress pc_for_athrow(__ pc());
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2974 __ lea(exceptionPC->as_register(), pc_for_athrow);
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2975 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
2976
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2977 __ verify_not_null_oop(rax);
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2978 // 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
2979 if (compilation()->has_fpu_code()) {
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2980 unwind_id = Runtime1::handle_exception_id;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2981 } else {
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2982 unwind_id = Runtime1::handle_exception_nofpu_id;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2983 }
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2984 __ call(RuntimeAddress(Runtime1::entry_for(unwind_id)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2985
a61af66fc99e Initial load
duke
parents:
diff changeset
2986 // enough room for two byte trap
a61af66fc99e Initial load
duke
parents:
diff changeset
2987 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2988 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2989
a61af66fc99e Initial load
duke
parents:
diff changeset
2990
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2991 void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2992 assert(exceptionOop->as_register() == rax, "must match");
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2993
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2994 __ jmp(_unwind_handler_entry);
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2995 }
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2996
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1369
diff changeset
2997
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2998 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
2999
a61af66fc99e Initial load
duke
parents:
diff changeset
3000 // optimized version for linear scan:
a61af66fc99e Initial load
duke
parents:
diff changeset
3001 // * count must be already in ECX (guaranteed by LinearScan)
a61af66fc99e Initial load
duke
parents:
diff changeset
3002 // * left and dest must be equal
a61af66fc99e Initial load
duke
parents:
diff changeset
3003 // * tmp must be unused
a61af66fc99e Initial load
duke
parents:
diff changeset
3004 assert(count->as_register() == SHIFT_count, "count must be in ECX");
a61af66fc99e Initial load
duke
parents:
diff changeset
3005 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
3006 assert(tmp->is_illegal(), "wasting a register if tmp is allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
3007
a61af66fc99e Initial load
duke
parents:
diff changeset
3008 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3009 Register value = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3010 assert(value != SHIFT_count, "left cannot be ECX");
a61af66fc99e Initial load
duke
parents:
diff changeset
3011
a61af66fc99e Initial load
duke
parents:
diff changeset
3012 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3013 case lir_shl: __ shll(value); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3014 case lir_shr: __ sarl(value); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3015 case lir_ushr: __ shrl(value); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3016 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3017 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3018 } else if (left->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3019 Register lo = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
3020 Register hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
3021 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
3022 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3023 switch (code) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3024 case lir_shl: __ shlptr(lo); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3025 case lir_shr: __ sarptr(lo); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3026 case lir_ushr: __ shrptr(lo); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3027 default: ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3028 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3029 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3030
a61af66fc99e Initial load
duke
parents:
diff changeset
3031 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3032 case lir_shl: __ lshl(hi, lo); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3033 case lir_shr: __ lshr(hi, lo, true); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3034 case lir_ushr: __ lshr(hi, lo, false); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3035 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3036 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3037 #endif // LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3038 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3039 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3040 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3041 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3042
a61af66fc99e Initial load
duke
parents:
diff changeset
3043
a61af66fc99e Initial load
duke
parents:
diff changeset
3044 void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3045 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3046 // first move left into dest so that left is not destroyed by the shift
a61af66fc99e Initial load
duke
parents:
diff changeset
3047 Register value = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3048 count = count & 0x1F; // Java spec
a61af66fc99e Initial load
duke
parents:
diff changeset
3049
a61af66fc99e Initial load
duke
parents:
diff changeset
3050 move_regs(left->as_register(), value);
a61af66fc99e Initial load
duke
parents:
diff changeset
3051 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3052 case lir_shl: __ shll(value, count); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3053 case lir_shr: __ sarl(value, count); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3054 case lir_ushr: __ shrl(value, count); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3055 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3056 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3057 } else if (dest->is_double_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3058 #ifndef _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3059 Unimplemented();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3060 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3061 // 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
3062 Register value = dest->as_register_lo();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3063 count = count & 0x1F; // Java spec
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3064
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3065 move_regs(left->as_register_lo(), value);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3066 switch (code) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3067 case lir_shl: __ shlptr(value, count); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3068 case lir_shr: __ sarptr(value, count); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3069 case lir_ushr: __ shrptr(value, count); break;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3070 default: ShouldNotReachHere();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3071 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3072 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3073 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3074 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3075 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3076 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3077
a61af66fc99e Initial load
duke
parents:
diff changeset
3078
a61af66fc99e Initial load
duke
parents:
diff changeset
3079 void LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3080 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
a61af66fc99e Initial load
duke
parents:
diff changeset
3081 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
3082 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
3083 __ movptr (Address(rsp, offset_from_rsp_in_bytes), r);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3084 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3085
a61af66fc99e Initial load
duke
parents:
diff changeset
3086
a61af66fc99e Initial load
duke
parents:
diff changeset
3087 void LIR_Assembler::store_parameter(jint c, int offset_from_rsp_in_words) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3088 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
a61af66fc99e Initial load
duke
parents:
diff changeset
3089 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
3090 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
3091 __ movptr (Address(rsp, offset_from_rsp_in_bytes), c);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3092 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3093
a61af66fc99e Initial load
duke
parents:
diff changeset
3094
a61af66fc99e Initial load
duke
parents:
diff changeset
3095 void LIR_Assembler::store_parameter(jobject o, int offset_from_rsp_in_words) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3096 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
a61af66fc99e Initial load
duke
parents:
diff changeset
3097 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
3098 assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
3099 __ movoop (Address(rsp, offset_from_rsp_in_bytes), o);
a61af66fc99e Initial load
duke
parents:
diff changeset
3100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3101
a61af66fc99e Initial load
duke
parents:
diff changeset
3102
a61af66fc99e Initial load
duke
parents:
diff changeset
3103 // This code replaces a call to arraycopy; no exception may
a61af66fc99e Initial load
duke
parents:
diff changeset
3104 // be thrown in this code, they must be thrown in the System.arraycopy
a61af66fc99e Initial load
duke
parents:
diff changeset
3105 // activation frame; we could save some checks if this would not be the case
a61af66fc99e Initial load
duke
parents:
diff changeset
3106 void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3107 ciArrayKlass* default_type = op->expected_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
3108 Register src = op->src()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3109 Register dst = op->dst()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3110 Register src_pos = op->src_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3111 Register dst_pos = op->dst_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3112 Register length = op->length()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3113 Register tmp = op->tmp()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3114
a61af66fc99e Initial load
duke
parents:
diff changeset
3115 CodeStub* stub = op->stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
3116 int flags = op->flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
3117 BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
3118 if (basic_type == T_ARRAY) basic_type = T_OBJECT;
a61af66fc99e Initial load
duke
parents:
diff changeset
3119
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3120 // if we don't know anything, just go through the generic arraycopy
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3121 if (default_type == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3122 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
3123 // save outgoing arguments on stack in case call to System.arraycopy is needed
a61af66fc99e Initial load
duke
parents:
diff changeset
3124 // HACK ALERT. This code used to push the parameters in a hardwired fashion
a61af66fc99e Initial load
duke
parents:
diff changeset
3125 // for interpreter calling conventions. Now we have to do it in new style conventions.
a61af66fc99e Initial load
duke
parents:
diff changeset
3126 // For the moment until C1 gets the new register allocator I just force all the
a61af66fc99e Initial load
duke
parents:
diff changeset
3127 // args to the right place (except the register args) and then on the back side
a61af66fc99e Initial load
duke
parents:
diff changeset
3128 // reload the register args properly if we go slow path. Yuck
a61af66fc99e Initial load
duke
parents:
diff changeset
3129
a61af66fc99e Initial load
duke
parents:
diff changeset
3130 // These are proper for the calling convention
a61af66fc99e Initial load
duke
parents:
diff changeset
3131 store_parameter(length, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3132 store_parameter(dst_pos, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3133 store_parameter(dst, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3134
a61af66fc99e Initial load
duke
parents:
diff changeset
3135 // these are just temporary placements until we need to reload
a61af66fc99e Initial load
duke
parents:
diff changeset
3136 store_parameter(src_pos, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
3137 store_parameter(src, 4);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3138 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
3139
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3140 address C_entry = CAST_FROM_FN_PTR(address, Runtime1::arraycopy);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3141
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3142 address copyfunc_addr = StubRoutines::generic_arraycopy();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3143
a61af66fc99e Initial load
duke
parents:
diff changeset
3144 // 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
3145 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3146 // 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
3147 // convention
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3148 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
3149 __ mov(c_rarg0, j_rarg0);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3150 assert_different_registers(c_rarg1, j_rarg2, j_rarg3, j_rarg4);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3151 __ mov(c_rarg1, j_rarg1);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3152 assert_different_registers(c_rarg2, j_rarg3, j_rarg4);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3153 __ mov(c_rarg2, j_rarg2);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3154 assert_different_registers(c_rarg3, j_rarg4);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3155 __ mov(c_rarg3, j_rarg3);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3156 #ifdef _WIN64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3157 // 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
3158 __ subptr(rsp, 6*wordSize);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3159 store_parameter(j_rarg4, 4);
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3160 if (copyfunc_addr == NULL) { // Use C version if stub was not generated
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3161 __ call(RuntimeAddress(C_entry));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3162 } else {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3163 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3164 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3165 __ incrementl(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3166 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3167 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3168 __ call(RuntimeAddress(copyfunc_addr));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3169 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3170 __ addptr(rsp, 6*wordSize);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3171 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3172 __ mov(c_rarg4, j_rarg4);
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3173 if (copyfunc_addr == NULL) { // Use C version if stub was not generated
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3174 __ call(RuntimeAddress(C_entry));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3175 } else {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3176 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3177 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3178 __ incrementl(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3179 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3180 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3181 __ call(RuntimeAddress(copyfunc_addr));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3182 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3183 #endif // _WIN64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3184 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3185 __ push(length);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3186 __ push(dst_pos);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3187 __ push(dst);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3188 __ push(src_pos);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3189 __ push(src);
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3190
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3191 if (copyfunc_addr == NULL) { // Use C version if stub was not generated
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3192 __ call_VM_leaf(C_entry, 5); // removes pushed parameter from the stack
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3193 } else {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3194 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3195 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3196 __ incrementl(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3197 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3198 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3199 __ call_VM_leaf(copyfunc_addr, 5); // removes pushed parameter from the stack
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3200 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3201
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3202 #endif // _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3203
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3204 __ cmpl(rax, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3205 __ jcc(Assembler::equal, *stub->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
3206
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3207 if (copyfunc_addr != NULL) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3208 __ mov(tmp, rax);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3209 __ xorl(tmp, -1);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3210 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3211
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3212 // Reload values from the stack so they are where the stub
a61af66fc99e Initial load
duke
parents:
diff changeset
3213 // expects them.
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3214 __ movptr (dst, Address(rsp, 0*BytesPerWord));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3215 __ movptr (dst_pos, Address(rsp, 1*BytesPerWord));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3216 __ movptr (length, Address(rsp, 2*BytesPerWord));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3217 __ movptr (src_pos, Address(rsp, 3*BytesPerWord));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3218 __ movptr (src, Address(rsp, 4*BytesPerWord));
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3219
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3220 if (copyfunc_addr != NULL) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3221 __ subl(length, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3222 __ addl(src_pos, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3223 __ addl(dst_pos, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3224 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3225 __ jmp(*stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3226
a61af66fc99e Initial load
duke
parents:
diff changeset
3227 __ bind(*stub->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
3228 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
3229 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3230
a61af66fc99e Initial load
duke
parents:
diff changeset
3231 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
3232
29
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
3233 int elem_size = type2aelembytes(basic_type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3234 int shift_amount;
a61af66fc99e Initial load
duke
parents:
diff changeset
3235 Address::ScaleFactor scale;
a61af66fc99e Initial load
duke
parents:
diff changeset
3236
a61af66fc99e Initial load
duke
parents:
diff changeset
3237 switch (elem_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3238 case 1 :
a61af66fc99e Initial load
duke
parents:
diff changeset
3239 shift_amount = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
3240 scale = Address::times_1;
a61af66fc99e Initial load
duke
parents:
diff changeset
3241 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3242 case 2 :
a61af66fc99e Initial load
duke
parents:
diff changeset
3243 shift_amount = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
3244 scale = Address::times_2;
a61af66fc99e Initial load
duke
parents:
diff changeset
3245 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3246 case 4 :
a61af66fc99e Initial load
duke
parents:
diff changeset
3247 shift_amount = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
3248 scale = Address::times_4;
a61af66fc99e Initial load
duke
parents:
diff changeset
3249 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3250 case 8 :
a61af66fc99e Initial load
duke
parents:
diff changeset
3251 shift_amount = 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
3252 scale = Address::times_8;
a61af66fc99e Initial load
duke
parents:
diff changeset
3253 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3254 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
3255 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3257
a61af66fc99e Initial load
duke
parents:
diff changeset
3258 Address src_length_addr = Address(src, arrayOopDesc::length_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
3259 Address dst_length_addr = Address(dst, arrayOopDesc::length_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
3260 Address src_klass_addr = Address(src, oopDesc::klass_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
3261 Address dst_klass_addr = Address(dst, oopDesc::klass_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
3262
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3263 // 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
3264
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3265 // test for NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
3266 if (flags & LIR_OpArrayCopy::src_null_check) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3267 __ testptr(src, src);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3268 __ jcc(Assembler::zero, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3270 if (flags & LIR_OpArrayCopy::dst_null_check) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3271 __ testptr(dst, dst);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3272 __ jcc(Assembler::zero, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3274
a61af66fc99e Initial load
duke
parents:
diff changeset
3275 // check if negative
a61af66fc99e Initial load
duke
parents:
diff changeset
3276 if (flags & LIR_OpArrayCopy::src_pos_positive_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3277 __ testl(src_pos, src_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
3278 __ jcc(Assembler::less, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3280 if (flags & LIR_OpArrayCopy::dst_pos_positive_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3281 __ testl(dst_pos, dst_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
3282 __ jcc(Assembler::less, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3284
a61af66fc99e Initial load
duke
parents:
diff changeset
3285 if (flags & LIR_OpArrayCopy::src_range_check) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3286 __ lea(tmp, Address(src_pos, length, Address::times_1, 0));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3287 __ cmpl(tmp, src_length_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
3288 __ jcc(Assembler::above, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3290 if (flags & LIR_OpArrayCopy::dst_range_check) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3291 __ lea(tmp, Address(dst_pos, length, Address::times_1, 0));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3292 __ cmpl(tmp, dst_length_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
3293 __ jcc(Assembler::above, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3295
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3296 if (flags & LIR_OpArrayCopy::length_positive_check) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3297 __ testl(length, length);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3298 __ jcc(Assembler::less, *stub->entry());
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3299 __ jcc(Assembler::zero, *stub->continuation());
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3300 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3301
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3302 #ifdef _LP64
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3303 __ movl2ptr(src_pos, src_pos); //higher 32bits must be null
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3304 __ movl2ptr(dst_pos, dst_pos); //higher 32bits must be null
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3305 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3306
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3307 if (flags & LIR_OpArrayCopy::type_check) {
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3308 // We don't know the array types are compatible
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3309 if (basic_type != T_OBJECT) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3310 // Simple test for basic type arrays
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
3311 if (UseCompressedClassPointers) {
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3312 __ movl(tmp, src_klass_addr);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3313 __ cmpl(tmp, dst_klass_addr);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3314 } else {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3315 __ movptr(tmp, src_klass_addr);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3316 __ cmpptr(tmp, dst_klass_addr);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3317 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3318 __ jcc(Assembler::notEqual, *stub->entry());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3319 } else {
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3320 // 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
3321 // safely do the copy.
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3322 Label cont, slow;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3323
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3324 __ push(src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3325 __ push(dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3326
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3327 __ load_klass(src, src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3328 __ load_klass(dst, dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3329
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3330 __ check_klass_subtype_fast_path(src, dst, tmp, &cont, &slow, NULL);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3331
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3332 __ push(src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3333 __ push(dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3334 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3335 __ pop(dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3336 __ pop(src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3337
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3338 __ cmpl(src, 0);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3339 __ jcc(Assembler::notEqual, cont);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3340
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3341 __ bind(slow);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3342 __ pop(dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3343 __ pop(src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3344
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3345 address copyfunc_addr = StubRoutines::checkcast_arraycopy();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3346 if (copyfunc_addr != NULL) { // use stub if available
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3347 // 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
3348 // per-element check.
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3349
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3350 int mask = LIR_OpArrayCopy::src_objarray|LIR_OpArrayCopy::dst_objarray;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3351 if ((flags & mask) != mask) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3352 // Check that at least both of them object arrays.
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3353 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
3354
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3355 if (!(flags & LIR_OpArrayCopy::src_objarray)) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3356 __ load_klass(tmp, src);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3357 } else if (!(flags & LIR_OpArrayCopy::dst_objarray)) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3358 __ load_klass(tmp, dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3359 }
4762
069ab3f976d3 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 3960
diff changeset
3360 int lh_offset = in_bytes(Klass::layout_helper_offset());
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3361 Address klass_lh_addr(tmp, lh_offset);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3362 jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3363 __ cmpl(klass_lh_addr, objArray_lh);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3364 __ jcc(Assembler::notEqual, *stub->entry());
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3365 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3366
3739
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3367 // 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
3368 // 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
3369 store_parameter(dst, 0);
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3370 store_parameter(dst_pos, 1);
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3371 store_parameter(length, 2);
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3372 store_parameter(src_pos, 3);
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3373 store_parameter(src, 4);
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3374
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3375 #ifndef _LP64
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3376 __ movptr(tmp, dst_klass_addr);
6831
d8ce2825b193 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 6795
diff changeset
3377 __ movptr(tmp, Address(tmp, ObjArrayKlass::element_klass_offset()));
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3378 __ push(tmp);
4762
069ab3f976d3 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 3960
diff changeset
3379 __ movl(tmp, Address(tmp, Klass::super_check_offset_offset()));
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3380 __ push(tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3381 __ push(length);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3382 __ 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
3383 __ push(tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3384 __ 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
3385 __ push(tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3386
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3387 __ call_VM_leaf(copyfunc_addr, 5);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3388 #else
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3389 __ movl2ptr(length, length); //higher 32bits must be null
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3390
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3391 __ 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
3392 assert_different_registers(c_rarg0, dst, dst_pos, length);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3393 __ 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
3394 assert_different_registers(c_rarg1, dst, length);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3395
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3396 __ mov(c_rarg2, length);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3397 assert_different_registers(c_rarg2, dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3398
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3399 #ifdef _WIN64
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3400 // Allocate abi space for args but be sure to keep stack aligned
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3401 __ subptr(rsp, 6*wordSize);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3402 __ load_klass(c_rarg3, dst);
6831
d8ce2825b193 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 6795
diff changeset
3403 __ movptr(c_rarg3, Address(c_rarg3, ObjArrayKlass::element_klass_offset()));
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3404 store_parameter(c_rarg3, 4);
4762
069ab3f976d3 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 3960
diff changeset
3405 __ movl(c_rarg3, Address(c_rarg3, Klass::super_check_offset_offset()));
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3406 __ call(RuntimeAddress(copyfunc_addr));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3407 __ addptr(rsp, 6*wordSize);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3408 #else
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3409 __ load_klass(c_rarg4, dst);
6831
d8ce2825b193 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 6795
diff changeset
3410 __ 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
3411 __ movl(c_rarg3, Address(c_rarg4, 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 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3414
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3415 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3416
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3417 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3418 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3419 Label failed;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3420 __ testl(rax, rax);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3421 __ jcc(Assembler::notZero, failed);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3422 __ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_cnt));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3423 __ bind(failed);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3424 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3425 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3426
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3427 __ testl(rax, rax);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3428 __ jcc(Assembler::zero, *stub->continuation());
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3429
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3430 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3431 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3432 __ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_attempt_cnt));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3433 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3434 #endif
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3435
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3436 __ mov(tmp, rax);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3437
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3438 __ xorl(tmp, -1);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3439
3739
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3440 // Restore previously spilled arguments
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3441 __ movptr (dst, Address(rsp, 0*BytesPerWord));
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3442 __ movptr (dst_pos, Address(rsp, 1*BytesPerWord));
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3443 __ movptr (length, Address(rsp, 2*BytesPerWord));
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3444 __ movptr (src_pos, Address(rsp, 3*BytesPerWord));
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3445 __ movptr (src, Address(rsp, 4*BytesPerWord));
28263a73ebfb 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 3401
diff changeset
3446
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3447
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3448 __ subl(length, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3449 __ addl(src_pos, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3450 __ addl(dst_pos, tmp);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3451 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3452
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3453 __ jmp(*stub->entry());
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3454
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3455 __ bind(cont);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3456 __ pop(dst);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3457 __ pop(src);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3458 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3460
a61af66fc99e Initial load
duke
parents:
diff changeset
3461 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
3462 if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3463 // Sanity check the known type with the incoming class. For the
a61af66fc99e Initial load
duke
parents:
diff changeset
3464 // primitive case the types must match exactly with src.klass and
a61af66fc99e Initial load
duke
parents:
diff changeset
3465 // dst.klass each exactly matching the default type. For the
a61af66fc99e Initial load
duke
parents:
diff changeset
3466 // object array case, if no type check is needed then either the
a61af66fc99e Initial load
duke
parents:
diff changeset
3467 // dst type is exactly the expected type and the src type is a
a61af66fc99e Initial load
duke
parents:
diff changeset
3468 // subtype which we can't check or src is the same array as dst
a61af66fc99e Initial load
duke
parents:
diff changeset
3469 // but not necessarily exactly of type default_type.
a61af66fc99e Initial load
duke
parents:
diff changeset
3470 Label known_ok, halt;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
3471 __ mov_metadata(tmp, default_type->constant_encoding());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3472 #ifdef _LP64
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
3473 if (UseCompressedClassPointers) {
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6795
diff changeset
3474 __ encode_klass_not_null(tmp);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3475 }
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3476 #endif
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3477
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3478 if (basic_type != T_OBJECT) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3479
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
3480 if (UseCompressedClassPointers) __ cmpl(tmp, dst_klass_addr);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3481 else __ cmpptr(tmp, dst_klass_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3482 __ jcc(Assembler::notEqual, halt);
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
3483 if (UseCompressedClassPointers) __ cmpl(tmp, src_klass_addr);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3484 else __ cmpptr(tmp, src_klass_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3485 __ jcc(Assembler::equal, known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
3486 } else {
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 12160
diff changeset
3487 if (UseCompressedClassPointers) __ cmpl(tmp, dst_klass_addr);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3488 else __ cmpptr(tmp, dst_klass_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3489 __ jcc(Assembler::equal, known_ok);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3490 __ cmpptr(src, dst);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3491 __ jcc(Assembler::equal, known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
3492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3493 __ bind(halt);
a61af66fc99e Initial load
duke
parents:
diff changeset
3494 __ stop("incorrect type information in arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
3495 __ bind(known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
3496 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3497 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
3498
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3499 #ifndef PRODUCT
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3500 if (PrintC1Statistics) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3501 __ incrementl(ExternalAddress(Runtime1::arraycopy_count_address(basic_type)));
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3502 }
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3503 #endif
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3504
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3505 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3506 assert_different_registers(c_rarg0, dst, dst_pos, length);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3507 __ 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
3508 assert_different_registers(c_rarg1, length);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3509 __ 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
3510 __ mov(c_rarg2, length);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3511
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3512 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3513 __ lea(tmp, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3514 store_parameter(tmp, 0);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3515 __ lea(tmp, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3516 store_parameter(tmp, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3517 store_parameter(length, 2);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3518 #endif // _LP64
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3519
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3520 bool disjoint = (flags & LIR_OpArrayCopy::overlapping) == 0;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3521 bool aligned = (flags & LIR_OpArrayCopy::unaligned) == 0;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3522 const char *name;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3523 address entry = StubRoutines::select_arraycopy_function(basic_type, aligned, disjoint, name, false);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2415
diff changeset
3524 __ call_VM_leaf(entry, 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3525
a61af66fc99e Initial load
duke
parents:
diff changeset
3526 __ bind(*stub->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
3527 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3528
11080
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3529 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
3530 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
3531 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
3532 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
3533 Register crc = op->crc()->as_register();
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3534 Register val = op->val()->as_register();
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3535 Register res = op->result_opr()->as_register();
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3536
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3537 assert_different_registers(val, crc, res);
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3538
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3539 __ lea(res, ExternalAddress(StubRoutines::crc_table_addr()));
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3540 __ notl(crc); // ~crc
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3541 __ update_byte_crc32(crc, val, res);
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3542 __ notl(crc); // ~crc
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3543 __ mov(res, crc);
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 8860
diff changeset
3544 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3545
a61af66fc99e Initial load
duke
parents:
diff changeset
3546 void LIR_Assembler::emit_lock(LIR_OpLock* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3547 Register obj = op->obj_opr()->as_register(); // may not be an oop
a61af66fc99e Initial load
duke
parents:
diff changeset
3548 Register hdr = op->hdr_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3549 Register lock = op->lock_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3550 if (!UseFastLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3551 __ jmp(*op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3552 } else if (op->code() == lir_lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3553 Register scratch = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
3554 if (UseBiasedLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3555 scratch = op->scratch_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3557 assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
a61af66fc99e Initial load
duke
parents:
diff changeset
3558 // add debug info for NullPointerException only if one is possible
a61af66fc99e Initial load
duke
parents:
diff changeset
3559 int null_check_offset = __ lock_object(hdr, obj, lock, scratch, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3560 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3561 add_debug_info_for_null_check(null_check_offset, op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
3562 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3563 // done
a61af66fc99e Initial load
duke
parents:
diff changeset
3564 } else if (op->code() == lir_unlock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3565 assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
a61af66fc99e Initial load
duke
parents:
diff changeset
3566 __ unlock_object(hdr, obj, lock, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
3567 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3568 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
3569 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3570 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
3571 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3572
a61af66fc99e Initial load
duke
parents:
diff changeset
3573
a61af66fc99e Initial load
duke
parents:
diff changeset
3574 void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3575 ciMethod* method = op->profiled_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
3576 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
3577 ciMethod* callee = op->profiled_callee();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3578
a61af66fc99e Initial load
duke
parents:
diff changeset
3579 // 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
3580 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
3581 assert(md != NULL, "Sanity");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3582 ciProfileData* data = md->bci_to_data(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
3583 assert(data->is_CounterData(), "need CounterData for calls");
a61af66fc99e Initial load
duke
parents:
diff changeset
3584 assert(op->mdo()->is_single_cpu(), "mdo must be allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
3585 Register mdo = op->mdo()->as_register();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
3586 __ mov_metadata(mdo, md->constant_encoding());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3587 Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3588 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
3589 const bool callee_is_static = callee->is_loaded() && callee->is_static();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3590 // Perform additional virtual call profiling for invokevirtual and
a61af66fc99e Initial load
duke
parents:
diff changeset
3591 // invokeinterface bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
3592 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
3593 !callee_is_static && // required for optimized MH invokes
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
3594 C1ProfileVirtualCalls) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3595 assert(op->recv()->is_single_cpu(), "recv must be allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
3596 Register recv = op->recv()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3597 assert_different_registers(mdo, recv);
a61af66fc99e Initial load
duke
parents:
diff changeset
3598 assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls");
a61af66fc99e Initial load
duke
parents:
diff changeset
3599 ciKlass* known_klass = op->known_holder();
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
3600 if (C1OptimizeVirtualCallProfiling && known_klass != NULL) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3601 // 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
3602 // statically update the MethodData* rather than needing to do
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3603 // dynamic tests on the receiver type
a61af66fc99e Initial load
duke
parents:
diff changeset
3604
a61af66fc99e Initial load
duke
parents:
diff changeset
3605 // NOTE: we should probably put a lock around this search to
a61af66fc99e Initial load
duke
parents:
diff changeset
3606 // avoid collisions by concurrent compilations
a61af66fc99e Initial load
duke
parents:
diff changeset
3607 ciVirtualCallData* vc_data = (ciVirtualCallData*) data;
a61af66fc99e Initial load
duke
parents:
diff changeset
3608 uint i;
a61af66fc99e Initial load
duke
parents:
diff changeset
3609 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3610 ciKlass* receiver = vc_data->receiver(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
3611 if (known_klass->equals(receiver)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3612 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
3613 __ addptr(data_addr, DataLayout::counter_increment);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3614 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
3615 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3616 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3617
a61af66fc99e Initial load
duke
parents:
diff changeset
3618 // Receiver type not found in profile data; select an empty slot
a61af66fc99e Initial load
duke
parents:
diff changeset
3619
a61af66fc99e Initial load
duke
parents:
diff changeset
3620 // Note that this is less efficient than it should be because it
a61af66fc99e Initial load
duke
parents:
diff changeset
3621 // always does a write to the receiver part of the
a61af66fc99e Initial load
duke
parents:
diff changeset
3622 // VirtualCallData rather than just the first time
a61af66fc99e Initial load
duke
parents:
diff changeset
3623 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3624 ciKlass* receiver = vc_data->receiver(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
3625 if (receiver == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3626 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
3627 __ mov_metadata(recv_addr, known_klass->constant_encoding());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3628 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
3629 __ addptr(data_addr, DataLayout::counter_increment);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3630 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
3631 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3632 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3633 } else {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
3634 __ load_klass(recv, recv);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3635 Label update_done;
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
3636 type_profile_helper(mdo, md, data, recv, &update_done);
1206
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1204
diff changeset
3637 // 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
3638 // Increment total counter to indicate polymorphic case.
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1579
diff changeset
3639 __ addptr(counter_addr, DataLayout::counter_increment);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3640
a61af66fc99e Initial load
duke
parents:
diff changeset
3641 __ bind(update_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
3642 }
1206
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1204
diff changeset
3643 } else {
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1204
diff changeset
3644 // Static call
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 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3648
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3649 void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3650 Register obj = op->obj()->as_register();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3651 Register tmp = op->tmp()->as_pointer_register();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3652 Address mdo_addr = as_Address(op->mdp()->as_address_ptr());
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3653 ciKlass* exact_klass = op->exact_klass();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3654 intptr_t current_klass = op->current_klass();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3655 bool not_null = op->not_null();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3656 bool no_conflict = op->no_conflict();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3657
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3658 Label update, next, none;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3659
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3660 bool do_null = !not_null;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3661 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
3662 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
3663
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3664 assert(do_null || do_update, "why are we here?");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3665 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
3666
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3667 __ verify_oop(obj);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3668
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3669 if (tmp != obj) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3670 __ mov(tmp, obj);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3671 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3672 if (do_null) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3673 __ testptr(tmp, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3674 __ jccb(Assembler::notZero, update);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3675 if (!TypeEntries::was_null_seen(current_klass)) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3676 __ orptr(mdo_addr, TypeEntries::null_seen);
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_update) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3679 #ifndef ASSERT
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3680 __ jmpb(next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3681 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3682 #else
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3683 __ jmp(next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3684 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3685 } else {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3686 __ testptr(tmp, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3687 __ jccb(Assembler::notZero, update);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3688 __ stop("unexpect null obj");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3689 #endif
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
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3692 __ bind(update);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3693
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3694 if (do_update) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3695 #ifdef ASSERT
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3696 if (exact_klass != NULL) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3697 Label ok;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3698 __ load_klass(tmp, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3699 __ push(tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3700 __ mov_metadata(tmp, exact_klass->constant_encoding());
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3701 __ cmpptr(tmp, Address(rsp, 0));
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3702 __ jccb(Assembler::equal, ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3703 __ stop("exact klass and actual klass differ");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3704 __ bind(ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3705 __ pop(tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3706 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3707 #endif
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3708 if (!no_conflict) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3709 if (exact_klass == NULL || TypeEntries::is_type_none(current_klass)) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3710 if (exact_klass != NULL) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3711 __ mov_metadata(tmp, exact_klass->constant_encoding());
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3712 } else {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3713 __ load_klass(tmp, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3714 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3715
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3716 __ xorptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3717 __ testptr(tmp, TypeEntries::type_klass_mask);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3718 // 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
3719 // set already but no need to check.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3720 __ jccb(Assembler::zero, next);
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 __ testptr(tmp, TypeEntries::type_unknown);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3723 __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3724
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3725 if (TypeEntries::is_type_none(current_klass)) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3726 __ cmpptr(mdo_addr, 0);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3727 __ jccb(Assembler::equal, none);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3728 __ cmpptr(mdo_addr, TypeEntries::null_seen);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3729 __ jccb(Assembler::equal, none);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3730 // 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
3731 // 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
3732 // profiling to this obj's klass
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3733 __ xorptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3734 __ testptr(tmp, TypeEntries::type_klass_mask);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3735 __ jccb(Assembler::zero, next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3736 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3737 } else {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3738 assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3739 ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "conflict only");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3740
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3741 __ movptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3742 __ testptr(tmp, TypeEntries::type_unknown);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3743 __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3744 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3745
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3746 // different than before. Cannot keep accurate profile.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3747 __ orptr(mdo_addr, TypeEntries::type_unknown);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3748
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3749 if (TypeEntries::is_type_none(current_klass)) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3750 __ jmpb(next);
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 __ bind(none);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3753 // first time here. Set profile type.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3754 __ movptr(mdo_addr, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3755 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3756 } else {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3757 // There's a single possible klass at this profile point
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3758 assert(exact_klass != NULL, "should be");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3759 if (TypeEntries::is_type_none(current_klass)) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3760 __ mov_metadata(tmp, exact_klass->constant_encoding());
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3761 __ xorptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3762 __ testptr(tmp, TypeEntries::type_klass_mask);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3763 #ifdef ASSERT
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3764 __ jcc(Assembler::zero, next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3765
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3766 {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3767 Label ok;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3768 __ push(tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3769 __ cmpptr(mdo_addr, 0);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3770 __ jcc(Assembler::equal, ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3771 __ cmpptr(mdo_addr, TypeEntries::null_seen);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3772 __ jcc(Assembler::equal, ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3773 // may have been set by another thread
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3774 __ mov_metadata(tmp, exact_klass->constant_encoding());
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3775 __ xorptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3776 __ testptr(tmp, TypeEntries::type_mask);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3777 __ jcc(Assembler::zero, ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3778
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3779 __ stop("unexpected profiling mismatch");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3780 __ bind(ok);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3781 __ pop(tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3782 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3783 #else
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3784 __ jccb(Assembler::zero, next);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3785 #endif
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3786 // first time here. Set profile type.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3787 __ movptr(mdo_addr, tmp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3788 } else {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3789 assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3790 ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3791
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3792 __ movptr(tmp, mdo_addr);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3793 __ testptr(tmp, TypeEntries::type_unknown);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3794 __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3795
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3796 __ orptr(mdo_addr, TypeEntries::type_unknown);
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 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3799
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3800 __ bind(next);
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 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12269
diff changeset
3803
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3804 void LIR_Assembler::emit_delay(LIR_OpDelay*) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3805 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
3806 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3807
a61af66fc99e Initial load
duke
parents:
diff changeset
3808
a61af66fc99e Initial load
duke
parents:
diff changeset
3809 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
3810 __ lea(dst->as_register(), frame_map()->address_for_monitor_lock(monitor_no));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3811 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3812
a61af66fc99e Initial load
duke
parents:
diff changeset
3813
a61af66fc99e Initial load
duke
parents:
diff changeset
3814 void LIR_Assembler::align_backward_branch_target() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3815 __ align(BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
3816 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3817
a61af66fc99e Initial load
duke
parents:
diff changeset
3818
a61af66fc99e Initial load
duke
parents:
diff changeset
3819 void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3820 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3821 __ negl(left->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
3822 move_regs(left->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
3823
a61af66fc99e Initial load
duke
parents:
diff changeset
3824 } else if (left->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3825 Register lo = left->as_register_lo();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3826 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3827 Register dst = dest->as_register_lo();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3828 __ movptr(dst, lo);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3829 __ negptr(dst);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3830 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3831 Register hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
3832 __ lneg(hi, lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
3833 if (dest->as_register_lo() == hi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3834 assert(dest->as_register_hi() != lo, "destroying register");
a61af66fc99e Initial load
duke
parents:
diff changeset
3835 move_regs(hi, dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
3836 move_regs(lo, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
3837 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3838 move_regs(lo, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
3839 move_regs(hi, dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
3840 }
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3841 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3842
a61af66fc99e Initial load
duke
parents:
diff changeset
3843 } else if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3844 if (left->as_xmm_float_reg() != dest->as_xmm_float_reg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3845 __ movflt(dest->as_xmm_float_reg(), left->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3846 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3847 __ xorps(dest->as_xmm_float_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
3848 ExternalAddress((address)float_signflip_pool));
a61af66fc99e Initial load
duke
parents:
diff changeset
3849
a61af66fc99e Initial load
duke
parents:
diff changeset
3850 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3851 if (left->as_xmm_double_reg() != dest->as_xmm_double_reg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3852 __ movdbl(dest->as_xmm_double_reg(), left->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3853 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3854 __ xorpd(dest->as_xmm_double_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
3855 ExternalAddress((address)double_signflip_pool));
a61af66fc99e Initial load
duke
parents:
diff changeset
3856
a61af66fc99e Initial load
duke
parents:
diff changeset
3857 } else if (left->is_single_fpu() || left->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3858 assert(left->fpu() == 0, "arg must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3859 assert(dest->fpu() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3860 __ fchs();
a61af66fc99e Initial load
duke
parents:
diff changeset
3861
a61af66fc99e Initial load
duke
parents:
diff changeset
3862 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3863 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3864 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3865 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3866
a61af66fc99e Initial load
duke
parents:
diff changeset
3867
a61af66fc99e Initial load
duke
parents:
diff changeset
3868 void LIR_Assembler::leal(LIR_Opr addr, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3869 assert(addr->is_address() && dest->is_register(), "check");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3870 Register reg;
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3871 reg = dest->as_pointer_register();
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3872 __ lea(reg, as_Address(addr->as_address_ptr()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3873 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3874
a61af66fc99e Initial load
duke
parents:
diff changeset
3875
a61af66fc99e Initial load
duke
parents:
diff changeset
3876
a61af66fc99e Initial load
duke
parents:
diff changeset
3877 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
3878 assert(!tmp->is_valid(), "don't need temporary");
a61af66fc99e Initial load
duke
parents:
diff changeset
3879 __ call(RuntimeAddress(dest));
a61af66fc99e Initial load
duke
parents:
diff changeset
3880 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3881 add_call_info_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
3882 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3883 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3884
a61af66fc99e Initial load
duke
parents:
diff changeset
3885
a61af66fc99e Initial load
duke
parents:
diff changeset
3886 void LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3887 assert(type == T_LONG, "only for volatile long fields");
a61af66fc99e Initial load
duke
parents:
diff changeset
3888
a61af66fc99e Initial load
duke
parents:
diff changeset
3889 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3890 add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
3891 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3892
a61af66fc99e Initial load
duke
parents:
diff changeset
3893 if (src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3894 if (dest->is_double_cpu()) {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3895 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3896 __ movdq(dest->as_register_lo(), src->as_xmm_double_reg());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3897 #else
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3898 __ movdl(dest->as_register_lo(), src->as_xmm_double_reg());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3899 __ psrlq(src->as_xmm_double_reg(), 32);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3900 __ movdl(dest->as_register_hi(), src->as_xmm_double_reg());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3901 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3902 } else if (dest->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3903 __ movdbl(frame_map()->address_for_slot(dest->double_stack_ix()), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3904 } else if (dest->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3905 __ movdbl(as_Address(dest->as_address_ptr()), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3906 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3907 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3908 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3909
a61af66fc99e Initial load
duke
parents:
diff changeset
3910 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3911 if (src->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3912 __ movdbl(dest->as_xmm_double_reg(), frame_map()->address_for_slot(src->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3913 } else if (src->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3914 __ movdbl(dest->as_xmm_double_reg(), as_Address(src->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3915 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3916 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3917 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3918
a61af66fc99e Initial load
duke
parents:
diff changeset
3919 } else if (src->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3920 assert(src->fpu_regnrLo() == 0, "must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3921 if (dest->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3922 __ fistp_d(frame_map()->address_for_slot(dest->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3923 } else if (dest->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3924 __ fistp_d(as_Address(dest->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3925 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3926 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3927 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3928
a61af66fc99e Initial load
duke
parents:
diff changeset
3929 } else if (dest->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3930 assert(dest->fpu_regnrLo() == 0, "must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3931 if (src->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3932 __ fild_d(frame_map()->address_for_slot(src->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3933 } else if (src->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3934 __ fild_d(as_Address(src->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3935 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3936 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3937 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3938 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3939 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3940 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3941 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3942
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3943 #ifdef ASSERT
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3944 // emit run-time assertion
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3945 void LIR_Assembler::emit_assert(LIR_OpAssert* op) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3946 assert(op->code() == lir_assert, "must be");
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3947
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3948 if (op->in_opr1()->is_valid()) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3949 assert(op->in_opr2()->is_valid(), "both operands must be valid");
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3950 comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3951 } else {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3952 assert(op->in_opr2()->is_illegal(), "both operands must be illegal");
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3953 assert(op->condition() == lir_cond_always, "no other conditions allowed");
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3954 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3955
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3956 Label ok;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3957 if (op->condition() != lir_cond_always) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3958 Assembler::Condition acond = Assembler::zero;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3959 switch (op->condition()) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3960 case lir_cond_equal: acond = Assembler::equal; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3961 case lir_cond_notEqual: acond = Assembler::notEqual; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3962 case lir_cond_less: acond = Assembler::less; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3963 case lir_cond_lessEqual: acond = Assembler::lessEqual; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3964 case lir_cond_greaterEqual: acond = Assembler::greaterEqual;break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3965 case lir_cond_greater: acond = Assembler::greater; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3966 case lir_cond_belowEqual: acond = Assembler::belowEqual; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3967 case lir_cond_aboveEqual: acond = Assembler::aboveEqual; break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3968 default: ShouldNotReachHere();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3969 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3970 __ jcc(acond, ok);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3971 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3972 if (op->halt()) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3973 const char* str = __ code_string(op->msg());
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3974 __ stop(str);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3975 } else {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3976 breakpoint();
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 __ bind(ok);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3979 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 7199
diff changeset
3980 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3981
a61af66fc99e Initial load
duke
parents:
diff changeset
3982 void LIR_Assembler::membar() {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3983 // QQQ sparc TSO uses this,
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
3984 __ membar( Assembler::Membar_mask_bits(Assembler::StoreLoad));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3985 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3986
a61af66fc99e Initial load
duke
parents:
diff changeset
3987 void LIR_Assembler::membar_acquire() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3988 // No x86 machines currently require load fences
a61af66fc99e Initial load
duke
parents:
diff changeset
3989 // __ load_fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
3990 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3991
a61af66fc99e Initial load
duke
parents:
diff changeset
3992 void LIR_Assembler::membar_release() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3993 // No x86 machines currently require store fences
a61af66fc99e Initial load
duke
parents:
diff changeset
3994 // __ store_fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
3995 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3996
4966
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
3997 void LIR_Assembler::membar_loadload() {
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
3998 // no-op
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
3999 //__ membar(Assembler::Membar_mask_bits(Assembler::loadload));
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4000 }
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4001
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4002 void LIR_Assembler::membar_storestore() {
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4003 // no-op
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4004 //__ membar(Assembler::Membar_mask_bits(Assembler::storestore));
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4005 }
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 void LIR_Assembler::membar_loadstore() {
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4008 // no-op
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4009 //__ membar(Assembler::Membar_mask_bits(Assembler::loadstore));
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4010 }
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 void LIR_Assembler::membar_storeload() {
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4013 __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4014 }
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4808
diff changeset
4015
0
a61af66fc99e Initial load
duke
parents:
diff changeset
4016 void LIR_Assembler::get_thread(LIR_Opr result_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4017 assert(result_reg->is_register(), "check");
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
4018 #ifdef _LP64
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
4019 // __ get_thread(result_reg->as_register_lo());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
4020 __ mov(result_reg->as_register(), r15_thread);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
4021 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
4022 __ get_thread(result_reg->as_register());
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
4023 #endif // _LP64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
4024 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4025
a61af66fc99e Initial load
duke
parents:
diff changeset
4026
a61af66fc99e Initial load
duke
parents:
diff changeset
4027 void LIR_Assembler::peephole(LIR_List*) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4028 // do nothing for now
a61af66fc99e Initial load
duke
parents:
diff changeset
4029 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4030
6795
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4031 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
4032 assert(data == dest, "xchg/xadd uses only 2 operands");
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4033
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4034 if (data->type() == T_INT) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4035 if (code == lir_xadd) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4036 if (os::is_MP()) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4037 __ lock();
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4038 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4039 __ xaddl(as_Address(src->as_address_ptr()), data->as_register());
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4040 } else {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4041 __ xchgl(data->as_register(), as_Address(src->as_address_ptr()));
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4042 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4043 } else if (data->is_oop()) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4044 assert (code == lir_xchg, "xadd for oops");
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4045 Register obj = data->as_register();
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4046 #ifdef _LP64
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4047 if (UseCompressedOops) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4048 __ encode_heap_oop(obj);
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4049 __ xchgl(obj, as_Address(src->as_address_ptr()));
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4050 __ decode_heap_oop(obj);
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4051 } else {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4052 __ xchgptr(obj, as_Address(src->as_address_ptr()));
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4053 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4054 #else
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 #endif
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4057 } else if (data->type() == T_LONG) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4058 #ifdef _LP64
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4059 assert(data->as_register_lo() == data->as_register_hi(), "should be a single register");
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4060 if (code == lir_xadd) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4061 if (os::is_MP()) {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4062 __ lock();
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4063 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4064 __ xaddq(as_Address(src->as_address_ptr()), data->as_register_lo());
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4065 } else {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4066 __ xchgq(data->as_register_lo(), as_Address(src->as_address_ptr()));
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4067 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4068 #else
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4069 ShouldNotReachHere();
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4070 #endif
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4071 } else {
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4072 ShouldNotReachHere();
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4073 }
7eca5de9e0b6 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 6739
diff changeset
4074 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
4075
a61af66fc99e Initial load
duke
parents:
diff changeset
4076 #undef __