annotate src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @ 12969:9acbfe04b5c3

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