annotate src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @ 196:d1605aabd0a1 jdk7-b30

6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
author xdono
date Wed, 02 Jul 2008 12:55:16 -0700
parents d5fc211aea19
children dc7f315e41f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 29
diff changeset
2 * Copyright 2000-2008 Sun Microsystems, Inc. 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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_c1_LIRAssembler_x86.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // These masks are used to provide 128-bit aligned bitmasks to the XMM
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // instructions, to allow sign-masking or sign-bit flipping. They allow
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // fast versions of NegF/NegD and AbsF/AbsD.
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Note: 'double' and 'long long' have 32-bits alignment on x86.
a61af66fc99e Initial load
duke
parents:
diff changeset
34 static jlong* double_quadword(jlong *adr, jlong lo, jlong hi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // Use the expression (adr)&(~0xF) to provide 128-bits aligned address
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // of 128-bits operands for SSE instructions.
a61af66fc99e Initial load
duke
parents:
diff changeset
37 jlong *operand = (jlong*)(((long)adr)&((long)(~0xF)));
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // Store the value to a 128-bits operand.
a61af66fc99e Initial load
duke
parents:
diff changeset
39 operand[0] = lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 operand[1] = hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 return operand;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // Buffer for 128-bits masks used by SSE instructions.
a61af66fc99e Initial load
duke
parents:
diff changeset
45 static jlong fp_signmask_pool[(4+1)*2]; // 4*128bits(data) + 128bits(alignment)
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // Static initialization during VM startup.
a61af66fc99e Initial load
duke
parents:
diff changeset
48 static jlong *float_signmask_pool = double_quadword(&fp_signmask_pool[1*2], CONST64(0x7FFFFFFF7FFFFFFF), CONST64(0x7FFFFFFF7FFFFFFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
49 static jlong *double_signmask_pool = double_quadword(&fp_signmask_pool[2*2], CONST64(0x7FFFFFFFFFFFFFFF), CONST64(0x7FFFFFFFFFFFFFFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
50 static jlong *float_signflip_pool = double_quadword(&fp_signmask_pool[3*2], CONST64(0x8000000080000000), CONST64(0x8000000080000000));
a61af66fc99e Initial load
duke
parents:
diff changeset
51 static jlong *double_signflip_pool = double_quadword(&fp_signmask_pool[4*2], CONST64(0x8000000000000000), CONST64(0x8000000000000000));
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 NEEDS_CLEANUP // remove this definitions ?
a61af66fc99e Initial load
duke
parents:
diff changeset
56 const Register IC_Klass = rax; // where the IC klass is cached
a61af66fc99e Initial load
duke
parents:
diff changeset
57 const Register SYNC_header = rax; // synchronization header
a61af66fc99e Initial load
duke
parents:
diff changeset
58 const Register SHIFT_count = rcx; // where count for shift operations must be
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 #define __ _masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 static void select_different_registers(Register preserve,
a61af66fc99e Initial load
duke
parents:
diff changeset
64 Register extra,
a61af66fc99e Initial load
duke
parents:
diff changeset
65 Register &tmp1,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 Register &tmp2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 if (tmp1 == preserve) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 assert_different_registers(tmp1, tmp2, extra);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 tmp1 = extra;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 } else if (tmp2 == preserve) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 assert_different_registers(tmp1, tmp2, extra);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 tmp2 = extra;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 assert_different_registers(preserve, tmp1, tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 static void select_different_registers(Register preserve,
a61af66fc99e Initial load
duke
parents:
diff changeset
80 Register extra,
a61af66fc99e Initial load
duke
parents:
diff changeset
81 Register &tmp1,
a61af66fc99e Initial load
duke
parents:
diff changeset
82 Register &tmp2,
a61af66fc99e Initial load
duke
parents:
diff changeset
83 Register &tmp3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 if (tmp1 == preserve) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 assert_different_registers(tmp1, tmp2, tmp3, extra);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 tmp1 = extra;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 } else if (tmp2 == preserve) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 assert_different_registers(tmp1, tmp2, tmp3, extra);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 tmp2 = extra;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 } else if (tmp3 == preserve) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 assert_different_registers(tmp1, tmp2, tmp3, extra);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 tmp3 = extra;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 assert_different_registers(preserve, tmp1, tmp2, tmp3);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 bool LIR_Assembler::is_small_constant(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 if (opr->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 LIR_Const* constant = opr->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
102 switch (constant->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 case T_INT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
108 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 LIR_Opr LIR_Assembler::receiverOpr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 return FrameMap::rcx_oop_opr;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 LIR_Opr LIR_Assembler::incomingReceiverOpr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 return receiverOpr();
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 LIR_Opr LIR_Assembler::osrBufferPointer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 return FrameMap::rcx_opr;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 //--------------fpu register translations-----------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 address LIR_Assembler::float_constant(float f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 address const_addr = __ float_constant(f);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 if (const_addr == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 bailout("const section overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
134 return __ code()->consts()->start();
a61af66fc99e Initial load
duke
parents:
diff changeset
135 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 return const_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 address LIR_Assembler::double_constant(double d) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 address const_addr = __ double_constant(d);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if (const_addr == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 bailout("const section overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return __ code()->consts()->start();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 return const_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 void LIR_Assembler::set_24bit_FPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 void LIR_Assembler::reset_FPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 void LIR_Assembler::fpop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 __ fpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 void LIR_Assembler::fxch(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 __ fxch(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 void LIR_Assembler::fld(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 __ fld_s(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 void LIR_Assembler::ffree(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 __ ffree(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 void LIR_Assembler::breakpoint() {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 __ int3();
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 void LIR_Assembler::push(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 if (opr->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 __ push_reg(opr->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
183 } else if (opr->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 __ push_reg(opr->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
185 __ push_reg(opr->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
186 } else if (opr->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 __ push_addr(frame_map()->address_for_slot(opr->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
188 } else if (opr->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 LIR_Const* const_opr = opr->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
190 if (const_opr->type() == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 __ push_oop(const_opr->as_jobject());
a61af66fc99e Initial load
duke
parents:
diff changeset
192 } else if (const_opr->type() == T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 __ push_jint(const_opr->as_jint());
a61af66fc99e Initial load
duke
parents:
diff changeset
194 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 void LIR_Assembler::pop(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 if (opr->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 __ pop(opr->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
206 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 //-------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
212 Address LIR_Assembler::as_Address(LIR_Address* addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 if (addr->base()->is_illegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 assert(addr->index()->is_illegal(), "must be illegal too");
a61af66fc99e Initial load
duke
parents:
diff changeset
215 //return Address(addr->disp(), relocInfo::none);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // hack for now since this should really return an AddressLiteral
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // which will have to await 64bit c1 changes.
a61af66fc99e Initial load
duke
parents:
diff changeset
218 return Address(noreg, addr->disp());
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 Register base = addr->base()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 if (addr->index()->is_illegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 return Address( base, addr->disp());
a61af66fc99e Initial load
duke
parents:
diff changeset
225 } else if (addr->index()->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 Register index = addr->index()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
227 return Address(base, index, (Address::ScaleFactor) addr->scale(), addr->disp());
a61af66fc99e Initial load
duke
parents:
diff changeset
228 } else if (addr->index()->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 int addr_offset = (addr->index()->as_constant_ptr()->as_jint() << addr->scale()) + addr->disp();
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 return Address(base, addr_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
234 return Address();
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 Address LIR_Assembler::as_Address_hi(LIR_Address* addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 Address base = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 return Address(base._base, base._index, base._scale, base._disp + BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245 Address LIR_Assembler::as_Address_lo(LIR_Address* addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 return as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 void LIR_Assembler::osr_entry() {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 offsets()->set_value(CodeOffsets::OSR_Entry, code_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
252 BlockBegin* osr_entry = compilation()->hir()->osr_entry();
a61af66fc99e Initial load
duke
parents:
diff changeset
253 ValueStack* entry_state = osr_entry->state();
a61af66fc99e Initial load
duke
parents:
diff changeset
254 int number_of_locks = entry_state->locks_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // we jump here if osr happens with the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // state set up to continue at the beginning of the
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // loop that triggered osr - in particular, we have
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // the following registers setup:
a61af66fc99e Initial load
duke
parents:
diff changeset
260 //
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // rcx: osr buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
262 //
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // build frame
a61af66fc99e Initial load
duke
parents:
diff changeset
265 ciMethod* m = compilation()->method();
a61af66fc99e Initial load
duke
parents:
diff changeset
266 __ build_frame(initial_frame_size_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // OSR buffer is
a61af66fc99e Initial load
duke
parents:
diff changeset
269 //
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // locals[nlocals-1..0]
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // monitors[0..number_of_locks]
a61af66fc99e Initial load
duke
parents:
diff changeset
272 //
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // locals is a direct copy of the interpreter frame so in the osr buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // so first slot in the local array is the last local from the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // and last slot is local[0] (receiver) from the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
276 //
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // Similarly with locks. The first lock slot in the osr buffer is the nth lock
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // from the interpreter frame, the nth lock slot in the osr buffer is 0th lock
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // in the interpreter frame (the method lock if a sync method)
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // Initialize monitors in the compiled activation.
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // rcx: pointer to osr buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
283 //
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // All other registers are dead at this point and the locals will be
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // copied into place by code emitted in the IR.
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 Register OSR_buf = osrBufferPointer()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
288 { assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below");
a61af66fc99e Initial load
duke
parents:
diff changeset
289 int monitor_offset = BytesPerWord * method()->max_locals() +
a61af66fc99e Initial load
duke
parents:
diff changeset
290 (BasicObjectLock::size() * BytesPerWord) * (number_of_locks - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
291 for (int i = 0; i < number_of_locks; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 int slot_offset = monitor_offset - ((i * BasicObjectLock::size()) * BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // verify the interpreter's monitor has a non-null object
a61af66fc99e Initial load
duke
parents:
diff changeset
295 {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
297 __ cmpl(Address(OSR_buf, slot_offset + BasicObjectLock::obj_offset_in_bytes()), NULL_WORD);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 __ jcc(Assembler::notZero, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
299 __ stop("locked object is NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
300 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
303 __ movl(rbx, Address(OSR_buf, slot_offset + BasicObjectLock::lock_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
304 __ movl(frame_map()->address_for_monitor_lock(i), rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 __ movl(rbx, Address(OSR_buf, slot_offset + BasicObjectLock::obj_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
306 __ movl(frame_map()->address_for_monitor_object(i), rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 // inline cache check; done before the frame is built.
a61af66fc99e Initial load
duke
parents:
diff changeset
313 int LIR_Assembler::check_icache() {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 Register receiver = FrameMap::receiver_opr->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
315 Register ic_klass = IC_Klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 if (!VerifyOops) {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // insert some nops so that the verified entry point is aligned on CodeEntryAlignment
a61af66fc99e Initial load
duke
parents:
diff changeset
319 while ((__ offset() + 9) % CodeEntryAlignment != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
320 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323 int offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
324 __ inline_cache_check(receiver, IC_Klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
325 assert(__ offset() % CodeEntryAlignment == 0 || VerifyOops, "alignment must be correct");
a61af66fc99e Initial load
duke
parents:
diff changeset
326 if (VerifyOops) {
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // force alignment after the cache check.
a61af66fc99e Initial load
duke
parents:
diff changeset
328 // It's been verified to be aligned if !VerifyOops
a61af66fc99e Initial load
duke
parents:
diff changeset
329 __ align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331 return offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 void LIR_Assembler::jobject2reg_with_patching(Register reg, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 jobject o = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
337 PatchingStub* patch = new PatchingStub(_masm, PatchingStub::load_klass_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
338 __ movoop(reg, o);
a61af66fc99e Initial load
duke
parents:
diff changeset
339 patching_epilog(patch, lir_patch_normal, reg, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
340 }
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 void LIR_Assembler::monitorexit(LIR_Opr obj_opr, LIR_Opr lock_opr, Register new_hdr, int monitor_no, Register exception) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 if (exception->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // preserve exception
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // note: the monitor_exit runtime call is a leaf routine
a61af66fc99e Initial load
duke
parents:
diff changeset
347 // and cannot block => no GC can happen
a61af66fc99e Initial load
duke
parents:
diff changeset
348 // The slow case (MonitorAccessStub) uses the first two stack slots
a61af66fc99e Initial load
duke
parents:
diff changeset
349 // ([esp+0] and [esp+4]), therefore we store the exception at [esp+8]
a61af66fc99e Initial load
duke
parents:
diff changeset
350 __ movl (Address(rsp, 2*wordSize), exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353 Register obj_reg = obj_opr->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
354 Register lock_reg = lock_opr->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
355
a61af66fc99e Initial load
duke
parents:
diff changeset
356 // setup registers (lock_reg must be rax, for lock_object)
a61af66fc99e Initial load
duke
parents:
diff changeset
357 assert(obj_reg != SYNC_header && lock_reg != SYNC_header, "rax, must be available here");
a61af66fc99e Initial load
duke
parents:
diff changeset
358 Register hdr = lock_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
359 assert(new_hdr == SYNC_header, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
360 lock_reg = new_hdr;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // compute pointer to BasicLock
a61af66fc99e Initial load
duke
parents:
diff changeset
362 Address lock_addr = frame_map()->address_for_monitor_lock(monitor_no);
a61af66fc99e Initial load
duke
parents:
diff changeset
363 __ leal(lock_reg, lock_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // unlock object
a61af66fc99e Initial load
duke
parents:
diff changeset
365 MonitorAccessStub* slow_case = new MonitorExitStub(lock_opr, true, monitor_no);
a61af66fc99e Initial load
duke
parents:
diff changeset
366 // _slow_case_stubs->append(slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // temporary fix: must be created after exceptionhandler, therefore as call stub
a61af66fc99e Initial load
duke
parents:
diff changeset
368 _slow_case_stubs->append(slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
369 if (UseFastLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // try inlined fast unlocking first, revert to slow locking if it fails
a61af66fc99e Initial load
duke
parents:
diff changeset
371 // note: lock_reg points to the displaced header since the displaced header offset is 0!
a61af66fc99e Initial load
duke
parents:
diff changeset
372 assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
a61af66fc99e Initial load
duke
parents:
diff changeset
373 __ unlock_object(hdr, obj_reg, lock_reg, *slow_case->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
374 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
375 // always do slow unlocking
a61af66fc99e Initial load
duke
parents:
diff changeset
376 // note: the slow unlocking code could be inlined here, however if we use
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // slow unlocking, speed doesn't matter anyway and this solution is
a61af66fc99e Initial load
duke
parents:
diff changeset
378 // simpler and requires less duplicated code - additionally, the
a61af66fc99e Initial load
duke
parents:
diff changeset
379 // slow unlocking code is the same in either case which simplifies
a61af66fc99e Initial load
duke
parents:
diff changeset
380 // debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
381 __ jmp(*slow_case->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
382 }
a61af66fc99e Initial load
duke
parents:
diff changeset
383 // done
a61af66fc99e Initial load
duke
parents:
diff changeset
384 __ bind(*slow_case->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386 if (exception->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
387 // restore exception
a61af66fc99e Initial load
duke
parents:
diff changeset
388 __ movl (exception, Address(rsp, 2 * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
389 }
a61af66fc99e Initial load
duke
parents:
diff changeset
390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 // This specifies the rsp decrement needed to build the frame
a61af66fc99e Initial load
duke
parents:
diff changeset
393 int LIR_Assembler::initial_frame_size_in_bytes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
394 // if rounding, must let FrameMap know!
a61af66fc99e Initial load
duke
parents:
diff changeset
395 return (frame_map()->framesize() - 2) * BytesPerWord; // subtract two words to account for return address and link
a61af66fc99e Initial load
duke
parents:
diff changeset
396 }
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398
a61af66fc99e Initial load
duke
parents:
diff changeset
399 void LIR_Assembler::emit_exception_handler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
400 // if the last instruction is a call (typically to do a throw which
a61af66fc99e Initial load
duke
parents:
diff changeset
401 // is coming at the end after block reordering) the return address
a61af66fc99e Initial load
duke
parents:
diff changeset
402 // must still point into the code area in order to avoid assertion
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // failures when searching for the corresponding bci => add a nop
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // (was bug 5/14/1999 - gri)
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408 // generate code for exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
409 address handler_base = __ start_a_stub(exception_handler_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
410 if (handler_base == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // not enough space left for the handler
a61af66fc99e Initial load
duke
parents:
diff changeset
412 bailout("exception handler overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
413 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
416 int offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
417 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
418
a61af66fc99e Initial load
duke
parents:
diff changeset
419 compilation()->offsets()->set_value(CodeOffsets::Exceptions, code_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
420
a61af66fc99e Initial load
duke
parents:
diff changeset
421 // if the method does not have an exception handler, then there is
a61af66fc99e Initial load
duke
parents:
diff changeset
422 // no reason to search for one
a61af66fc99e Initial load
duke
parents:
diff changeset
423 if (compilation()->has_exception_handlers() || JvmtiExport::can_post_exceptions()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // the exception oop and pc are in rax, and rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
425 // no other registers need to be preserved, so invalidate them
a61af66fc99e Initial load
duke
parents:
diff changeset
426 __ invalidate_registers(false, true, true, false, true, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
427
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // check that there is really an exception
a61af66fc99e Initial load
duke
parents:
diff changeset
429 __ verify_not_null_oop(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
430
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // search an exception handler (rax: exception oop, rdx: throwing pc)
a61af66fc99e Initial load
duke
parents:
diff changeset
432 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::handle_exception_nofpu_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 // if the call returns here, then the exception handler for particular
a61af66fc99e Initial load
duke
parents:
diff changeset
435 // exception doesn't exist -> unwind activation and forward exception to caller
a61af66fc99e Initial load
duke
parents:
diff changeset
436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
437
a61af66fc99e Initial load
duke
parents:
diff changeset
438 // the exception oop is in rax,
a61af66fc99e Initial load
duke
parents:
diff changeset
439 // no other registers need to be preserved, so invalidate them
a61af66fc99e Initial load
duke
parents:
diff changeset
440 __ invalidate_registers(false, true, true, true, true, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442 // check that there is really an exception
a61af66fc99e Initial load
duke
parents:
diff changeset
443 __ verify_not_null_oop(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445 // unlock the receiver/klass if necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
446 // rax,: exception
a61af66fc99e Initial load
duke
parents:
diff changeset
447 ciMethod* method = compilation()->method();
a61af66fc99e Initial load
duke
parents:
diff changeset
448 if (method->is_synchronized() && GenerateSynchronizationCode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
449 monitorexit(FrameMap::rbx_oop_opr, FrameMap::rcx_opr, SYNC_header, 0, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
450 }
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 // unwind activation and forward exception to caller
a61af66fc99e Initial load
duke
parents:
diff changeset
453 // rax,: exception
a61af66fc99e Initial load
duke
parents:
diff changeset
454 __ jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
455
a61af66fc99e Initial load
duke
parents:
diff changeset
456 assert(code_offset() - offset <= exception_handler_size, "overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 __ end_a_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461 void LIR_Assembler::emit_deopt_handler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
462 // if the last instruction is a call (typically to do a throw which
a61af66fc99e Initial load
duke
parents:
diff changeset
463 // is coming at the end after block reordering) the return address
a61af66fc99e Initial load
duke
parents:
diff changeset
464 // must still point into the code area in order to avoid assertion
a61af66fc99e Initial load
duke
parents:
diff changeset
465 // failures when searching for the corresponding bci => add a nop
a61af66fc99e Initial load
duke
parents:
diff changeset
466 // (was bug 5/14/1999 - gri)
a61af66fc99e Initial load
duke
parents:
diff changeset
467
a61af66fc99e Initial load
duke
parents:
diff changeset
468 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
469
a61af66fc99e Initial load
duke
parents:
diff changeset
470 // generate code for exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
471 address handler_base = __ start_a_stub(deopt_handler_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
472 if (handler_base == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
473 // not enough space left for the handler
a61af66fc99e Initial load
duke
parents:
diff changeset
474 bailout("deopt handler overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
475 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
477 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
478 int offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
479 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 compilation()->offsets()->set_value(CodeOffsets::Deopt, code_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 InternalAddress here(__ pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
484 __ pushptr(here.addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
485
a61af66fc99e Initial load
duke
parents:
diff changeset
486 __ jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack()));
a61af66fc99e Initial load
duke
parents:
diff changeset
487
a61af66fc99e Initial load
duke
parents:
diff changeset
488 assert(code_offset() - offset <= deopt_handler_size, "overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
489
a61af66fc99e Initial load
duke
parents:
diff changeset
490 __ end_a_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
491
a61af66fc99e Initial load
duke
parents:
diff changeset
492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
493
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495 // This is the fast version of java.lang.String.compare; it has not
a61af66fc99e Initial load
duke
parents:
diff changeset
496 // OSR-entry and therefore, we generate a slow version for OSR's
a61af66fc99e Initial load
duke
parents:
diff changeset
497 void LIR_Assembler::emit_string_compare(LIR_Opr arg0, LIR_Opr arg1, LIR_Opr dst, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
498 __ movl (rbx, rcx); // receiver is in rcx
a61af66fc99e Initial load
duke
parents:
diff changeset
499 __ movl (rax, arg1->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
500
a61af66fc99e Initial load
duke
parents:
diff changeset
501 // Get addresses of first characters from both Strings
a61af66fc99e Initial load
duke
parents:
diff changeset
502 __ movl (rsi, Address(rax, java_lang_String::value_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
503 __ movl (rcx, Address(rax, java_lang_String::offset_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
504 __ leal (rsi, Address(rsi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR)));
a61af66fc99e Initial load
duke
parents:
diff changeset
505
a61af66fc99e Initial load
duke
parents:
diff changeset
506
a61af66fc99e Initial load
duke
parents:
diff changeset
507 // rbx, may be NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
508 add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
509 __ movl (rdi, Address(rbx, java_lang_String::value_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
510 __ movl (rcx, Address(rbx, java_lang_String::offset_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
511 __ leal (rdi, Address(rdi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR)));
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 // compute minimum length (in rax) and difference of lengths (on top of stack)
a61af66fc99e Initial load
duke
parents:
diff changeset
514 if (VM_Version::supports_cmov()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
515 __ movl (rbx, Address(rbx, java_lang_String::count_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
516 __ movl (rax, Address(rax, java_lang_String::count_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
517 __ movl (rcx, rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
518 __ subl (rbx, rax); // subtract lengths
a61af66fc99e Initial load
duke
parents:
diff changeset
519 __ pushl(rbx); // result
a61af66fc99e Initial load
duke
parents:
diff changeset
520 __ cmovl(Assembler::lessEqual, rax, rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
521 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
522 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
523 __ movl (rbx, Address(rbx, java_lang_String::count_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
524 __ movl (rcx, Address(rax, java_lang_String::count_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
525 __ movl (rax, rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
526 __ subl (rbx, rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
527 __ pushl(rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
528 __ jcc (Assembler::lessEqual, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
529 __ movl (rax, rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
530 __ bind (L);
a61af66fc99e Initial load
duke
parents:
diff changeset
531 }
a61af66fc99e Initial load
duke
parents:
diff changeset
532 // is minimum length 0?
a61af66fc99e Initial load
duke
parents:
diff changeset
533 Label noLoop, haveResult;
a61af66fc99e Initial load
duke
parents:
diff changeset
534 __ testl (rax, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
535 __ jcc (Assembler::zero, noLoop);
a61af66fc99e Initial load
duke
parents:
diff changeset
536
a61af66fc99e Initial load
duke
parents:
diff changeset
537 // compare first characters
a61af66fc99e Initial load
duke
parents:
diff changeset
538 __ load_unsigned_word(rcx, Address(rdi, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
539 __ load_unsigned_word(rbx, Address(rsi, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
540 __ subl(rcx, rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
541 __ jcc(Assembler::notZero, haveResult);
a61af66fc99e Initial load
duke
parents:
diff changeset
542 // starting loop
a61af66fc99e Initial load
duke
parents:
diff changeset
543 __ decrement(rax); // we already tested index: skip one
a61af66fc99e Initial load
duke
parents:
diff changeset
544 __ jcc(Assembler::zero, noLoop);
a61af66fc99e Initial load
duke
parents:
diff changeset
545
a61af66fc99e Initial load
duke
parents:
diff changeset
546 // set rsi.edi to the end of the arrays (arrays have same length)
a61af66fc99e Initial load
duke
parents:
diff changeset
547 // negate the index
a61af66fc99e Initial load
duke
parents:
diff changeset
548
29
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
549 __ leal(rsi, Address(rsi, rax, Address::times_2, type2aelembytes(T_CHAR)));
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
550 __ leal(rdi, Address(rdi, rax, Address::times_2, type2aelembytes(T_CHAR)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
551 __ negl(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
552
a61af66fc99e Initial load
duke
parents:
diff changeset
553 // compare the strings in a loop
a61af66fc99e Initial load
duke
parents:
diff changeset
554
a61af66fc99e Initial load
duke
parents:
diff changeset
555 Label loop;
a61af66fc99e Initial load
duke
parents:
diff changeset
556 __ align(wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
557 __ bind(loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
558 __ load_unsigned_word(rcx, Address(rdi, rax, Address::times_2, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
559 __ load_unsigned_word(rbx, Address(rsi, rax, Address::times_2, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
560 __ subl(rcx, rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
561 __ jcc(Assembler::notZero, haveResult);
a61af66fc99e Initial load
duke
parents:
diff changeset
562 __ increment(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
563 __ jcc(Assembler::notZero, loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
564
a61af66fc99e Initial load
duke
parents:
diff changeset
565 // strings are equal up to min length
a61af66fc99e Initial load
duke
parents:
diff changeset
566
a61af66fc99e Initial load
duke
parents:
diff changeset
567 __ bind(noLoop);
a61af66fc99e Initial load
duke
parents:
diff changeset
568 __ popl(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
569 return_op(LIR_OprFact::illegalOpr);
a61af66fc99e Initial load
duke
parents:
diff changeset
570
a61af66fc99e Initial load
duke
parents:
diff changeset
571 __ bind(haveResult);
a61af66fc99e Initial load
duke
parents:
diff changeset
572 // leave instruction is going to discard the TOS value
a61af66fc99e Initial load
duke
parents:
diff changeset
573 __ movl (rax, rcx); // result of call is in rax,
a61af66fc99e Initial load
duke
parents:
diff changeset
574 }
a61af66fc99e Initial load
duke
parents:
diff changeset
575
a61af66fc99e Initial load
duke
parents:
diff changeset
576
a61af66fc99e Initial load
duke
parents:
diff changeset
577 void LIR_Assembler::return_op(LIR_Opr result) {
a61af66fc99e Initial load
duke
parents:
diff changeset
578 assert(result->is_illegal() || !result->is_single_cpu() || result->as_register() == rax, "word returns are in rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
579 if (!result->is_illegal() && result->is_float_kind() && !result->is_xmm_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
580 assert(result->fpu() == 0, "result must already be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
581 }
a61af66fc99e Initial load
duke
parents:
diff changeset
582
a61af66fc99e Initial load
duke
parents:
diff changeset
583 // Pop the stack before the safepoint code
a61af66fc99e Initial load
duke
parents:
diff changeset
584 __ leave();
a61af66fc99e Initial load
duke
parents:
diff changeset
585
a61af66fc99e Initial load
duke
parents:
diff changeset
586 bool result_is_oop = result->is_valid() ? result->is_oop() : false;
a61af66fc99e Initial load
duke
parents:
diff changeset
587
a61af66fc99e Initial load
duke
parents:
diff changeset
588 // Note: we do not need to round double result; float result has the right precision
a61af66fc99e Initial load
duke
parents:
diff changeset
589 // the poll sets the condition code, but no data registers
a61af66fc99e Initial load
duke
parents:
diff changeset
590 AddressLiteral polling_page(os::get_polling_page() + (SafepointPollOffset % os::vm_page_size()),
a61af66fc99e Initial load
duke
parents:
diff changeset
591 relocInfo::poll_return_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
592 __ test32(rax, polling_page);
a61af66fc99e Initial load
duke
parents:
diff changeset
593
a61af66fc99e Initial load
duke
parents:
diff changeset
594 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
595 }
a61af66fc99e Initial load
duke
parents:
diff changeset
596
a61af66fc99e Initial load
duke
parents:
diff changeset
597
a61af66fc99e Initial load
duke
parents:
diff changeset
598 int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
599 AddressLiteral polling_page(os::get_polling_page() + (SafepointPollOffset % os::vm_page_size()),
a61af66fc99e Initial load
duke
parents:
diff changeset
600 relocInfo::poll_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
601
a61af66fc99e Initial load
duke
parents:
diff changeset
602 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
603 add_debug_info_for_branch(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
604 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
605 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
606 }
a61af66fc99e Initial load
duke
parents:
diff changeset
607
a61af66fc99e Initial load
duke
parents:
diff changeset
608 int offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
609 __ test32(rax, polling_page);
a61af66fc99e Initial load
duke
parents:
diff changeset
610 return offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
611 }
a61af66fc99e Initial load
duke
parents:
diff changeset
612
a61af66fc99e Initial load
duke
parents:
diff changeset
613
a61af66fc99e Initial load
duke
parents:
diff changeset
614 void LIR_Assembler::move_regs(Register from_reg, Register to_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
615 if (from_reg != to_reg) __ movl(to_reg, from_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
616 }
a61af66fc99e Initial load
duke
parents:
diff changeset
617
a61af66fc99e Initial load
duke
parents:
diff changeset
618 void LIR_Assembler::swap_reg(Register a, Register b) {
a61af66fc99e Initial load
duke
parents:
diff changeset
619 __ xchgl(a, b);
a61af66fc99e Initial load
duke
parents:
diff changeset
620 }
a61af66fc99e Initial load
duke
parents:
diff changeset
621
a61af66fc99e Initial load
duke
parents:
diff changeset
622
a61af66fc99e Initial load
duke
parents:
diff changeset
623 void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
624 assert(src->is_constant(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
625 assert(dest->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
626 LIR_Const* c = src->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
627
a61af66fc99e Initial load
duke
parents:
diff changeset
628 switch (c->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
629 case T_INT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
630 assert(patch_code == lir_patch_none, "no patching handled here");
a61af66fc99e Initial load
duke
parents:
diff changeset
631 __ movl(dest->as_register(), c->as_jint());
a61af66fc99e Initial load
duke
parents:
diff changeset
632 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
633 }
a61af66fc99e Initial load
duke
parents:
diff changeset
634
a61af66fc99e Initial load
duke
parents:
diff changeset
635 case T_LONG: {
a61af66fc99e Initial load
duke
parents:
diff changeset
636 assert(patch_code == lir_patch_none, "no patching handled here");
a61af66fc99e Initial load
duke
parents:
diff changeset
637 __ movl(dest->as_register_lo(), c->as_jint_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
638 __ movl(dest->as_register_hi(), c->as_jint_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
639 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
640 }
a61af66fc99e Initial load
duke
parents:
diff changeset
641
a61af66fc99e Initial load
duke
parents:
diff changeset
642 case T_OBJECT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
643 if (patch_code != lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
644 jobject2reg_with_patching(dest->as_register(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
645 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
646 __ movoop(dest->as_register(), c->as_jobject());
a61af66fc99e Initial load
duke
parents:
diff changeset
647 }
a61af66fc99e Initial load
duke
parents:
diff changeset
648 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
649 }
a61af66fc99e Initial load
duke
parents:
diff changeset
650
a61af66fc99e Initial load
duke
parents:
diff changeset
651 case T_FLOAT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
652 if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
653 if (c->is_zero_float()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
654 __ xorps(dest->as_xmm_float_reg(), dest->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
655 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
656 __ movflt(dest->as_xmm_float_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
657 InternalAddress(float_constant(c->as_jfloat())));
a61af66fc99e Initial load
duke
parents:
diff changeset
658 }
a61af66fc99e Initial load
duke
parents:
diff changeset
659 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
660 assert(dest->is_single_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
661 assert(dest->fpu_regnr() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
662 if (c->is_zero_float()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
663 __ fldz();
a61af66fc99e Initial load
duke
parents:
diff changeset
664 } else if (c->is_one_float()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
665 __ fld1();
a61af66fc99e Initial load
duke
parents:
diff changeset
666 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
667 __ fld_s (InternalAddress(float_constant(c->as_jfloat())));
a61af66fc99e Initial load
duke
parents:
diff changeset
668 }
a61af66fc99e Initial load
duke
parents:
diff changeset
669 }
a61af66fc99e Initial load
duke
parents:
diff changeset
670 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
671 }
a61af66fc99e Initial load
duke
parents:
diff changeset
672
a61af66fc99e Initial load
duke
parents:
diff changeset
673 case T_DOUBLE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
674 if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
675 if (c->is_zero_double()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
676 __ xorpd(dest->as_xmm_double_reg(), dest->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
677 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
678 __ movdbl(dest->as_xmm_double_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
679 InternalAddress(double_constant(c->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
680 }
a61af66fc99e Initial load
duke
parents:
diff changeset
681 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
682 assert(dest->is_double_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
683 assert(dest->fpu_regnrLo() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
684 if (c->is_zero_double()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
685 __ fldz();
a61af66fc99e Initial load
duke
parents:
diff changeset
686 } else if (c->is_one_double()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
687 __ fld1();
a61af66fc99e Initial load
duke
parents:
diff changeset
688 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
689 __ fld_d (InternalAddress(double_constant(c->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
690 }
a61af66fc99e Initial load
duke
parents:
diff changeset
691 }
a61af66fc99e Initial load
duke
parents:
diff changeset
692 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
693 }
a61af66fc99e Initial load
duke
parents:
diff changeset
694
a61af66fc99e Initial load
duke
parents:
diff changeset
695 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
696 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
697 }
a61af66fc99e Initial load
duke
parents:
diff changeset
698 }
a61af66fc99e Initial load
duke
parents:
diff changeset
699
a61af66fc99e Initial load
duke
parents:
diff changeset
700 void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
701 assert(src->is_constant(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
702 assert(dest->is_stack(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
703 LIR_Const* c = src->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
704
a61af66fc99e Initial load
duke
parents:
diff changeset
705 switch (c->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
706 case T_INT: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
707 case T_FLOAT:
a61af66fc99e Initial load
duke
parents:
diff changeset
708 __ movl(frame_map()->address_for_slot(dest->single_stack_ix()), c->as_jint_bits());
a61af66fc99e Initial load
duke
parents:
diff changeset
709 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
710
a61af66fc99e Initial load
duke
parents:
diff changeset
711 case T_OBJECT:
a61af66fc99e Initial load
duke
parents:
diff changeset
712 __ movoop(frame_map()->address_for_slot(dest->single_stack_ix()), c->as_jobject());
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 case T_LONG: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
716 case T_DOUBLE:
a61af66fc99e Initial load
duke
parents:
diff changeset
717 __ movl(frame_map()->address_for_slot(dest->double_stack_ix(),
a61af66fc99e Initial load
duke
parents:
diff changeset
718 lo_word_offset_in_bytes), c->as_jint_lo_bits());
a61af66fc99e Initial load
duke
parents:
diff changeset
719 __ movl(frame_map()->address_for_slot(dest->double_stack_ix(),
a61af66fc99e Initial load
duke
parents:
diff changeset
720 hi_word_offset_in_bytes), c->as_jint_hi_bits());
a61af66fc99e Initial load
duke
parents:
diff changeset
721 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
722
a61af66fc99e Initial load
duke
parents:
diff changeset
723 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
724 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
725 }
a61af66fc99e Initial load
duke
parents:
diff changeset
726 }
a61af66fc99e Initial load
duke
parents:
diff changeset
727
a61af66fc99e Initial load
duke
parents:
diff changeset
728 void LIR_Assembler::const2mem(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
729 assert(src->is_constant(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
730 assert(dest->is_address(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
731 LIR_Const* c = src->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
732 LIR_Address* addr = dest->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
733
a61af66fc99e Initial load
duke
parents:
diff changeset
734 if (info != NULL) add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
735 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
736 case T_INT: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
737 case T_FLOAT:
a61af66fc99e Initial load
duke
parents:
diff changeset
738 __ movl(as_Address(addr), c->as_jint_bits());
a61af66fc99e Initial load
duke
parents:
diff changeset
739 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
740
a61af66fc99e Initial load
duke
parents:
diff changeset
741 case T_OBJECT: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
742 case T_ARRAY:
a61af66fc99e Initial load
duke
parents:
diff changeset
743 if (c->as_jobject() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
744 __ movl(as_Address(addr), NULL_WORD);
a61af66fc99e Initial load
duke
parents:
diff changeset
745 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
746 __ movoop(as_Address(addr), c->as_jobject());
a61af66fc99e Initial load
duke
parents:
diff changeset
747 }
a61af66fc99e Initial load
duke
parents:
diff changeset
748 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
749
a61af66fc99e Initial load
duke
parents:
diff changeset
750 case T_LONG: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
751 case T_DOUBLE:
a61af66fc99e Initial load
duke
parents:
diff changeset
752 __ movl(as_Address_hi(addr), c->as_jint_hi_bits());
a61af66fc99e Initial load
duke
parents:
diff changeset
753 __ movl(as_Address_lo(addr), c->as_jint_lo_bits());
a61af66fc99e Initial load
duke
parents:
diff changeset
754 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
755
a61af66fc99e Initial load
duke
parents:
diff changeset
756 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
757 case T_BYTE:
a61af66fc99e Initial load
duke
parents:
diff changeset
758 __ movb(as_Address(addr), c->as_jint() & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
759 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
760
a61af66fc99e Initial load
duke
parents:
diff changeset
761 case T_CHAR: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
762 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
763 __ movw(as_Address(addr), c->as_jint() & 0xFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
764 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
765
a61af66fc99e Initial load
duke
parents:
diff changeset
766 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
767 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
768 };
a61af66fc99e Initial load
duke
parents:
diff changeset
769 }
a61af66fc99e Initial load
duke
parents:
diff changeset
770
a61af66fc99e Initial load
duke
parents:
diff changeset
771
a61af66fc99e Initial load
duke
parents:
diff changeset
772 void LIR_Assembler::reg2reg(LIR_Opr src, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
773 assert(src->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
774 assert(dest->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
775
a61af66fc99e Initial load
duke
parents:
diff changeset
776 // move between cpu-registers
a61af66fc99e Initial load
duke
parents:
diff changeset
777 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
778 assert(src->is_single_cpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
779 if (src->type() == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
780 __ verify_oop(src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
781 }
a61af66fc99e Initial load
duke
parents:
diff changeset
782 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
783
a61af66fc99e Initial load
duke
parents:
diff changeset
784 } else if (dest->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
785 assert(src->is_double_cpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
786 Register f_lo = src->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
787 Register f_hi = src->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
788 Register t_lo = dest->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
789 Register t_hi = dest->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
790 assert(f_lo != f_hi && t_lo != t_hi, "invalid register allocation");
a61af66fc99e Initial load
duke
parents:
diff changeset
791
a61af66fc99e Initial load
duke
parents:
diff changeset
792 if (f_lo == t_hi && f_hi == t_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
793 swap_reg(f_lo, f_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
794 } else if (f_hi == t_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
795 assert(f_lo != t_hi, "overwriting register");
a61af66fc99e Initial load
duke
parents:
diff changeset
796 move_regs(f_hi, t_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
797 move_regs(f_lo, t_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
798 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
799 assert(f_hi != t_lo, "overwriting register");
a61af66fc99e Initial load
duke
parents:
diff changeset
800 move_regs(f_lo, t_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
801 move_regs(f_hi, t_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
802 }
a61af66fc99e Initial load
duke
parents:
diff changeset
803
a61af66fc99e Initial load
duke
parents:
diff changeset
804 // special moves from fpu-register to xmm-register
a61af66fc99e Initial load
duke
parents:
diff changeset
805 // necessary for method results
a61af66fc99e Initial load
duke
parents:
diff changeset
806 } else if (src->is_single_xmm() && !dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
807 __ movflt(Address(rsp, 0), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
808 __ fld_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
809 } else if (src->is_double_xmm() && !dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
810 __ movdbl(Address(rsp, 0), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
811 __ fld_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
812 } else if (dest->is_single_xmm() && !src->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
813 __ fstp_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
814 __ movflt(dest->as_xmm_float_reg(), Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
815 } else if (dest->is_double_xmm() && !src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
816 __ fstp_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
817 __ movdbl(dest->as_xmm_double_reg(), Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
818
a61af66fc99e Initial load
duke
parents:
diff changeset
819 // move between xmm-registers
a61af66fc99e Initial load
duke
parents:
diff changeset
820 } else if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
821 assert(src->is_single_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
822 __ movflt(dest->as_xmm_float_reg(), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
823 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
824 assert(src->is_double_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
825 __ movdbl(dest->as_xmm_double_reg(), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
826
a61af66fc99e Initial load
duke
parents:
diff changeset
827 // move between fpu-registers (no instruction necessary because of fpu-stack)
a61af66fc99e Initial load
duke
parents:
diff changeset
828 } else if (dest->is_single_fpu() || dest->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
829 assert(src->is_single_fpu() || src->is_double_fpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
830 assert(src->fpu() == dest->fpu(), "currently should be nothing to do");
a61af66fc99e Initial load
duke
parents:
diff changeset
831 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
832 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
833 }
a61af66fc99e Initial load
duke
parents:
diff changeset
834 }
a61af66fc99e Initial load
duke
parents:
diff changeset
835
a61af66fc99e Initial load
duke
parents:
diff changeset
836 void LIR_Assembler::reg2stack(LIR_Opr src, LIR_Opr dest, BasicType type, bool pop_fpu_stack) {
a61af66fc99e Initial load
duke
parents:
diff changeset
837 assert(src->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
838 assert(dest->is_stack(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
839
a61af66fc99e Initial load
duke
parents:
diff changeset
840 if (src->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
841 Address dst = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
842 if (type == T_OBJECT || type == T_ARRAY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
843 __ verify_oop(src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
844 }
a61af66fc99e Initial load
duke
parents:
diff changeset
845 __ movl (dst, src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
846
a61af66fc99e Initial load
duke
parents:
diff changeset
847 } else if (src->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
848 Address dstLO = frame_map()->address_for_slot(dest->double_stack_ix(), lo_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
849 Address dstHI = frame_map()->address_for_slot(dest->double_stack_ix(), hi_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
850 __ movl (dstLO, src->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
851 __ movl (dstHI, src->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
852
a61af66fc99e Initial load
duke
parents:
diff changeset
853 } else if (src->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
854 Address dst_addr = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
855 __ movflt(dst_addr, src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
856
a61af66fc99e Initial load
duke
parents:
diff changeset
857 } else if (src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
858 Address dst_addr = frame_map()->address_for_slot(dest->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
859 __ movdbl(dst_addr, src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
860
a61af66fc99e Initial load
duke
parents:
diff changeset
861 } else if (src->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
862 assert(src->fpu_regnr() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
863 Address dst_addr = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
864 if (pop_fpu_stack) __ fstp_s (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
865 else __ fst_s (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
866
a61af66fc99e Initial load
duke
parents:
diff changeset
867 } else if (src->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
868 assert(src->fpu_regnrLo() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
869 Address dst_addr = frame_map()->address_for_slot(dest->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
870 if (pop_fpu_stack) __ fstp_d (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
871 else __ fst_d (dst_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
872
a61af66fc99e Initial load
duke
parents:
diff changeset
873 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
874 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
875 }
a61af66fc99e Initial load
duke
parents:
diff changeset
876 }
a61af66fc99e Initial load
duke
parents:
diff changeset
877
a61af66fc99e Initial load
duke
parents:
diff changeset
878
a61af66fc99e Initial load
duke
parents:
diff changeset
879 void LIR_Assembler::reg2mem(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack, bool /* unaligned */) {
a61af66fc99e Initial load
duke
parents:
diff changeset
880 LIR_Address* to_addr = dest->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
881 PatchingStub* patch = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
882
a61af66fc99e Initial load
duke
parents:
diff changeset
883 if (type == T_ARRAY || type == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
884 __ verify_oop(src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
885 }
a61af66fc99e Initial load
duke
parents:
diff changeset
886 if (patch_code != lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
887 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
888 }
a61af66fc99e Initial load
duke
parents:
diff changeset
889 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
890 add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
891 }
a61af66fc99e Initial load
duke
parents:
diff changeset
892
a61af66fc99e Initial load
duke
parents:
diff changeset
893 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
894 case T_FLOAT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
895 if (src->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
896 __ movflt(as_Address(to_addr), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
897 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
898 assert(src->is_single_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
899 assert(src->fpu_regnr() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
900 if (pop_fpu_stack) __ fstp_s(as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
901 else __ fst_s (as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
902 }
a61af66fc99e Initial load
duke
parents:
diff changeset
903 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
904 }
a61af66fc99e Initial load
duke
parents:
diff changeset
905
a61af66fc99e Initial load
duke
parents:
diff changeset
906 case T_DOUBLE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
907 if (src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
908 __ movdbl(as_Address(to_addr), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
909 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
910 assert(src->is_double_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
911 assert(src->fpu_regnrLo() == 0, "argument must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
912 if (pop_fpu_stack) __ fstp_d(as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
913 else __ fst_d (as_Address(to_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
914 }
a61af66fc99e Initial load
duke
parents:
diff changeset
915 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
916 }
a61af66fc99e Initial load
duke
parents:
diff changeset
917
a61af66fc99e Initial load
duke
parents:
diff changeset
918 case T_ADDRESS: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
919 case T_ARRAY: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
920 case T_OBJECT: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
921 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
922 __ movl(as_Address(to_addr), src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
923 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
924
a61af66fc99e Initial load
duke
parents:
diff changeset
925 case T_LONG: {
a61af66fc99e Initial load
duke
parents:
diff changeset
926 Register from_lo = src->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
927 Register from_hi = src->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
928 Register base = to_addr->base()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
929 Register index = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
930 if (to_addr->index()->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
931 index = to_addr->index()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
932 }
a61af66fc99e Initial load
duke
parents:
diff changeset
933 if (base == from_lo || index == from_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
934 assert(base != from_hi, "can't be");
a61af66fc99e Initial load
duke
parents:
diff changeset
935 assert(index == noreg || (index != base && index != from_hi), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
936 __ movl(as_Address_hi(to_addr), from_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
937 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
938 patching_epilog(patch, lir_patch_high, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
939 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
940 patch_code = lir_patch_low;
a61af66fc99e Initial load
duke
parents:
diff changeset
941 }
a61af66fc99e Initial load
duke
parents:
diff changeset
942 __ movl(as_Address_lo(to_addr), from_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
943 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
944 assert(index == noreg || (index != base && index != from_lo), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
945 __ movl(as_Address_lo(to_addr), from_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
946 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
947 patching_epilog(patch, lir_patch_low, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
948 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
949 patch_code = lir_patch_high;
a61af66fc99e Initial load
duke
parents:
diff changeset
950 }
a61af66fc99e Initial load
duke
parents:
diff changeset
951 __ movl(as_Address_hi(to_addr), from_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
952 }
a61af66fc99e Initial load
duke
parents:
diff changeset
953 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
954 }
a61af66fc99e Initial load
duke
parents:
diff changeset
955
a61af66fc99e Initial load
duke
parents:
diff changeset
956 case T_BYTE: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
957 case T_BOOLEAN: {
a61af66fc99e Initial load
duke
parents:
diff changeset
958 Register src_reg = src->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
959 Address dst_addr = as_Address(to_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
960 assert(VM_Version::is_P6() || src_reg->has_byte_register(), "must use byte registers if not P6");
a61af66fc99e Initial load
duke
parents:
diff changeset
961 __ movb(dst_addr, src_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
962 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
963 }
a61af66fc99e Initial load
duke
parents:
diff changeset
964
a61af66fc99e Initial load
duke
parents:
diff changeset
965 case T_CHAR: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
966 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
967 __ movw(as_Address(to_addr), src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
968 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
969
a61af66fc99e Initial load
duke
parents:
diff changeset
970 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
971 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
972 }
a61af66fc99e Initial load
duke
parents:
diff changeset
973
a61af66fc99e Initial load
duke
parents:
diff changeset
974 if (patch_code != lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
975 patching_epilog(patch, patch_code, to_addr->base()->as_register(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
976 }
a61af66fc99e Initial load
duke
parents:
diff changeset
977 }
a61af66fc99e Initial load
duke
parents:
diff changeset
978
a61af66fc99e Initial load
duke
parents:
diff changeset
979
a61af66fc99e Initial load
duke
parents:
diff changeset
980 void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
981 assert(src->is_stack(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
982 assert(dest->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
983
a61af66fc99e Initial load
duke
parents:
diff changeset
984 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
985 __ movl(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
986 if (type == T_ARRAY || type == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
987 __ verify_oop(dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
988 }
a61af66fc99e Initial load
duke
parents:
diff changeset
989
a61af66fc99e Initial load
duke
parents:
diff changeset
990 } else if (dest->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
991 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
992 Address src_addr_HI = frame_map()->address_for_slot(src->double_stack_ix(), hi_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
993 __ movl(dest->as_register_hi(), src_addr_HI);
a61af66fc99e Initial load
duke
parents:
diff changeset
994 __ movl(dest->as_register_lo(), src_addr_LO);
a61af66fc99e Initial load
duke
parents:
diff changeset
995
a61af66fc99e Initial load
duke
parents:
diff changeset
996 } else if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
997 Address src_addr = frame_map()->address_for_slot(src->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
998 __ movflt(dest->as_xmm_float_reg(), src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
999
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 Address src_addr = frame_map()->address_for_slot(src->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 __ movdbl(dest->as_xmm_double_reg(), src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1003
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 } else if (dest->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 assert(dest->fpu_regnr() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 Address src_addr = frame_map()->address_for_slot(src->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 __ fld_s(src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1008
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 } else if (dest->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 assert(dest->fpu_regnrLo() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 Address src_addr = frame_map()->address_for_slot(src->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 __ fld_d(src_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1013
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1018
a61af66fc99e Initial load
duke
parents:
diff changeset
1019
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 if (src->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 __ pushl(frame_map()->address_for_slot(src ->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 __ popl (frame_map()->address_for_slot(dest->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1024
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 } else if (src->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 __ pushl(frame_map()->address_for_slot(src ->double_stack_ix(), 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 // push and pop the part at src + 4, adding 4 for the previous push
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 __ pushl(frame_map()->address_for_slot(src ->double_stack_ix(), 4 + 4));
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 __ popl (frame_map()->address_for_slot(dest->double_stack_ix(), 4 + 4));
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 __ popl (frame_map()->address_for_slot(dest->double_stack_ix(), 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1031
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1036
a61af66fc99e Initial load
duke
parents:
diff changeset
1037
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool /* unaligned */) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 assert(src->is_address(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 assert(dest->is_register(), "should not call otherwise");
a61af66fc99e Initial load
duke
parents:
diff changeset
1041
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 LIR_Address* addr = src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 Address from_addr = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1044
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 case T_BYTE: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 case T_CHAR: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 if (!VM_Version::is_P6() && !from_addr.uses(dest->as_register())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 // on pre P6 processors we may get partial register stalls
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 // so blow away the value of to_rinfo before loading a
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 // partial word into it. Do it here so that it precedes
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 // the potential patch point below.
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 __ xorl(dest->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1059
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 PatchingStub* patch = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 if (patch_code != lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1067
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 case T_FLOAT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 __ movflt(dest->as_xmm_float_reg(), from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 assert(dest->is_single_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 assert(dest->fpu_regnr() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 __ fld_s(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1079
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 case T_DOUBLE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 __ movdbl(dest->as_xmm_double_reg(), from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 assert(dest->is_double_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 assert(dest->fpu_regnrLo() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 __ fld_d(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1090
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 case T_ADDRESS: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 case T_OBJECT: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 case T_ARRAY: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 __ movl(dest->as_register(), from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1097
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 case T_LONG: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 Register to_lo = dest->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 Register to_hi = dest->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 Register base = addr->base()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 Register index = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 if (addr->index()->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 index = addr->index()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 if ((base == to_lo && index == to_hi) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 (base == to_hi && index == to_lo)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 // addresses with 2 registers are only formed as a result of
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 // array access so this code will never have to deal with
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 // patches or null checks.
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 assert(info == NULL && patch == NULL, "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 __ leal(to_hi, as_Address(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 __ movl(to_lo, Address(to_hi, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 __ movl(to_hi, Address(to_hi, BytesPerWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 } else if (base == to_lo || index == to_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 assert(base != to_hi, "can't be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 assert(index == noreg || (index != base && index != to_hi), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 __ movl(to_hi, as_Address_hi(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 patching_epilog(patch, lir_patch_high, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 patch_code = lir_patch_low;
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 __ movl(to_lo, as_Address_lo(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 assert(index == noreg || (index != base && index != to_lo), "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 __ movl(to_lo, as_Address_lo(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 patching_epilog(patch, lir_patch_low, base, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 patch_code = lir_patch_high;
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 __ movl(to_hi, as_Address_hi(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1137
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 case T_BYTE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 Register dest_reg = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6");
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 __ movsxb(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 __ movb(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 __ shll(dest_reg, 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 __ sarl(dest_reg, 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1151
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 case T_CHAR: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 Register dest_reg = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6");
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 __ movzxw(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 __ movw(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1162
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 case T_SHORT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 Register dest_reg = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 __ movsxw(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 __ movw(dest_reg, from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 __ shll(dest_reg, 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 __ sarl(dest_reg, 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1174
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1178
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 patching_epilog(patch, patch_code, addr->base()->as_register(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1182
a61af66fc99e Initial load
duke
parents:
diff changeset
1183 if (type == T_ARRAY || type == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 __ verify_oop(dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1187
a61af66fc99e Initial load
duke
parents:
diff changeset
1188
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 void LIR_Assembler::prefetchr(LIR_Opr src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 LIR_Address* addr = src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 Address from_addr = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1192
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 if (VM_Version::supports_sse()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 switch (ReadPrefetchInstr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 case 0:
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 __ prefetchnta(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 __ prefetcht0(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 __ prefetcht2(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 ShouldNotReachHere(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 } else if (VM_Version::supports_3dnow()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 __ prefetchr(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1208
a61af66fc99e Initial load
duke
parents:
diff changeset
1209
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 void LIR_Assembler::prefetchw(LIR_Opr src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 LIR_Address* addr = src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 Address from_addr = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1213
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 if (VM_Version::supports_sse()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 switch (AllocatePrefetchInstr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 case 0:
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 __ prefetchnta(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 __ prefetcht0(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 __ prefetcht2(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 case 3:
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 __ prefetchw(from_addr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 ShouldNotReachHere(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 } else if (VM_Version::supports_3dnow()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 __ prefetchw(from_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1231
a61af66fc99e Initial load
duke
parents:
diff changeset
1232
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 NEEDS_CLEANUP; // This could be static?
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 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
1235 int elem_size = type2aelembytes(type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 switch (elem_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 case 1: return Address::times_1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 case 2: return Address::times_2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 case 4: return Address::times_4;
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 case 8: return Address::times_8;
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 return Address::no_scale;
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1245
a61af66fc99e Initial load
duke
parents:
diff changeset
1246
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 void LIR_Assembler::emit_op3(LIR_Op3* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 switch (op->code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 case lir_idiv:
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 case lir_irem:
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 arithmetic_idiv(op->code(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 op->in_opr1(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 op->in_opr2(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 op->in_opr3(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 op->result_opr(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 default: ShouldNotReachHere(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1261
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 void LIR_Assembler::emit_opBranch(LIR_OpBranch* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 assert(op->block() == NULL || op->block()->label() == op->label(), "wrong label");
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 if (op->block() != NULL) _branch_target_blocks.append(op->block());
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 if (op->ublock() != NULL) _branch_target_blocks.append(op->ublock());
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1268
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 if (op->cond() == lir_cond_always) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 if (op->info() != NULL) add_debug_info_for_branch(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 __ jmp (*(op->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 Assembler::Condition acond = Assembler::zero;
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 if (op->code() == lir_cond_float_branch) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 assert(op->ublock() != NULL, "must have unordered successor");
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 __ jcc(Assembler::parity, *(op->ublock()->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 switch(op->cond()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 case lir_cond_equal: acond = Assembler::equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 case lir_cond_notEqual: acond = Assembler::notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 case lir_cond_less: acond = Assembler::below; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 case lir_cond_lessEqual: acond = Assembler::belowEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 case lir_cond_greaterEqual: acond = Assembler::aboveEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 case lir_cond_greater: acond = Assembler::above; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 switch (op->cond()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 case lir_cond_equal: acond = Assembler::equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 case lir_cond_notEqual: acond = Assembler::notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 case lir_cond_less: acond = Assembler::less; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 case lir_cond_lessEqual: acond = Assembler::lessEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 case lir_cond_greaterEqual: acond = Assembler::greaterEqual;break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 case lir_cond_greater: acond = Assembler::greater; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 case lir_cond_belowEqual: acond = Assembler::belowEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 case lir_cond_aboveEqual: acond = Assembler::aboveEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 __ jcc(acond,*(op->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1302
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 LIR_Opr src = op->in_opr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 LIR_Opr dest = op->result_opr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1306
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 switch (op->bytecode()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 case Bytecodes::_i2l:
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 move_regs(src->as_register(), dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 move_regs(src->as_register(), dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 __ sarl(dest->as_register_hi(), 31);
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1313
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 case Bytecodes::_l2i:
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 move_regs(src->as_register_lo(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1317
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 case Bytecodes::_i2b:
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 __ sign_extend_byte(dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1322
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 case Bytecodes::_i2c:
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 __ andl(dest->as_register(), 0xFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1327
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 case Bytecodes::_i2s:
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 move_regs(src->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 __ sign_extend_short(dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1332
a61af66fc99e Initial load
duke
parents:
diff changeset
1333
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 case Bytecodes::_f2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 case Bytecodes::_d2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 __ cvtsd2ss(dest->as_xmm_float_reg(), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 __ cvtss2sd(dest->as_xmm_double_reg(), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 assert(src->fpu() == dest->fpu(), "register must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
1342 // do nothing (float result is rounded later through spilling)
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1345
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 case Bytecodes::_i2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 case Bytecodes::_i2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 __ cvtsi2ss(dest->as_xmm_float_reg(), src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 __ cvtsi2sd(dest->as_xmm_double_reg(), src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 assert(dest->fpu() == 0, "result must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 __ movl(Address(rsp, 0), src->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 __ fild_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1358
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 case Bytecodes::_f2i:
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 case Bytecodes::_d2i:
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 if (src->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1362 __ cvttss2si(dest->as_register(), src->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 } else if (src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 __ cvttsd2si(dest->as_register(), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 assert(src->fpu() == 0, "input must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_trunc()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 __ fist_s(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 __ movl(dest->as_register(), Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1372
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 // IA32 conversion instructions do not match JLS for overflow, underflow and NaN -> fixup in stub
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 assert(op->stub() != NULL, "stub required");
a61af66fc99e Initial load
duke
parents:
diff changeset
1375 __ cmpl(dest->as_register(), 0x80000000);
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 __ jcc(Assembler::equal, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
1378 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1379
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 case Bytecodes::_l2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 case Bytecodes::_l2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
1382 assert(!dest->is_xmm_register(), "result in xmm register not supported (no SSE instruction present)");
a61af66fc99e Initial load
duke
parents:
diff changeset
1383 assert(dest->fpu() == 0, "result must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1384
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 __ movl(Address(rsp, 0), src->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 __ movl(Address(rsp, BytesPerWord), src->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 __ fild_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 // float result is rounded later through spilling
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1390
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 case Bytecodes::_f2l:
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 case Bytecodes::_d2l:
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 assert(!src->is_xmm_register(), "input in xmm register not supported (no SSE instruction present)");
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 assert(src->fpu() == 0, "input must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 assert(dest == FrameMap::rax_rdx_long_opr, "runtime stub places result in these registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1396
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 // instruction sequence too long to inline it here
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::fpu2long_stub_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1402
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1406
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 if (op->init_check()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 __ cmpl(Address(op->klass()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc)),
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 instanceKlass::fully_initialized);
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 add_debug_info_for_null_check_here(op->stub()->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 __ jcc(Assembler::notEqual, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1415 __ allocate_object(op->obj()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1416 op->tmp1()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 op->tmp2()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 op->header_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 op->object_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1420 op->klass()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
1423 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1424
a61af66fc99e Initial load
duke
parents:
diff changeset
1425 void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1426 if (UseSlowPath ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 (!UseFastNewObjectArray && (op->type() == T_OBJECT || op->type() == T_ARRAY)) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 (!UseFastNewTypeArray && (op->type() != T_OBJECT && op->type() != T_ARRAY))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 __ jmp(*op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1430 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 Register len = op->len()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 Register tmp1 = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 Register tmp2 = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1434 Register tmp3 = op->tmp3()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 if (len == tmp1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1436 tmp1 = tmp3;
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 } else if (len == tmp2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 tmp2 = tmp3;
a61af66fc99e Initial load
duke
parents:
diff changeset
1439 } else if (len == tmp3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 // everything is ok
a61af66fc99e Initial load
duke
parents:
diff changeset
1441 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1442 __ movl(tmp3, len);
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1444 __ allocate_array(op->obj()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1445 len,
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 tmp1,
a61af66fc99e Initial load
duke
parents:
diff changeset
1447 tmp2,
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 arrayOopDesc::header_size(op->type()),
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 array_element_size(op->type()),
a61af66fc99e Initial load
duke
parents:
diff changeset
1450 op->klass()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1452 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1453 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1455
a61af66fc99e Initial load
duke
parents:
diff changeset
1456
a61af66fc99e Initial load
duke
parents:
diff changeset
1457
a61af66fc99e Initial load
duke
parents:
diff changeset
1458 void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1459 LIR_Code code = op->code();
a61af66fc99e Initial load
duke
parents:
diff changeset
1460 if (code == lir_store_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 Register value = op->object()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1462 Register array = op->array()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1463 Register k_RInfo = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 Register klass_RInfo = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1465 Register Rtmp1 = op->tmp3()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1466
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 CodeStub* stub = op->stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
1468 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 __ cmpl(value, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1470 __ jcc(Assembler::equal, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 add_debug_info_for_null_check_here(op->info_for_exception());
a61af66fc99e Initial load
duke
parents:
diff changeset
1472 __ movl(k_RInfo, Address(array, oopDesc::klass_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 __ movl(klass_RInfo, Address(value, oopDesc::klass_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1474
a61af66fc99e Initial load
duke
parents:
diff changeset
1475 // get instance klass
a61af66fc99e Initial load
duke
parents:
diff changeset
1476 __ movl(k_RInfo, Address(k_RInfo, objArrayKlass::element_klass_offset_in_bytes() + sizeof(oopDesc)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 // get super_check_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 __ movl(Rtmp1, Address(k_RInfo, sizeof(oopDesc) + Klass::super_check_offset_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1479 // See if we get an immediate positive hit
a61af66fc99e Initial load
duke
parents:
diff changeset
1480 __ cmpl(k_RInfo, Address(klass_RInfo, Rtmp1, Address::times_1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1481 __ jcc(Assembler::equal, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 // check for immediate negative hit
a61af66fc99e Initial load
duke
parents:
diff changeset
1483 __ cmpl(Rtmp1, sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
1484 __ jcc(Assembler::notEqual, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1485 // check for self
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 __ cmpl(klass_RInfo, k_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1487 __ jcc(Assembler::equal, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1488
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 __ pushl(klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 __ pushl(k_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1491 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1492 __ popl(klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 __ popl(k_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1494 __ cmpl(k_RInfo, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 __ jcc(Assembler::equal, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1496 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 } else if (op->code() == lir_checkcast) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1498 // we always need a stub for the failure case.
a61af66fc99e Initial load
duke
parents:
diff changeset
1499 CodeStub* stub = op->stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
1500 Register obj = op->object()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 Register k_RInfo = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1502 Register klass_RInfo = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 Register dst = op->result_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1504 ciKlass* k = op->klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 Register Rtmp1 = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1506
a61af66fc99e Initial load
duke
parents:
diff changeset
1507 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 if (obj == k_RInfo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1509 k_RInfo = dst;
a61af66fc99e Initial load
duke
parents:
diff changeset
1510 } else if (obj == klass_RInfo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1511 klass_RInfo = dst;
a61af66fc99e Initial load
duke
parents:
diff changeset
1512 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1513 if (k->is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1514 select_different_registers(obj, dst, k_RInfo, klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1515 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1516 Rtmp1 = op->tmp3()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1517 select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1518 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1519
a61af66fc99e Initial load
duke
parents:
diff changeset
1520 assert_different_registers(obj, k_RInfo, klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1521 if (!k->is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1522 jobject2reg_with_patching(k_RInfo, op->info_for_patch());
a61af66fc99e Initial load
duke
parents:
diff changeset
1523 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1524 k_RInfo = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1525 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 assert(obj != k_RInfo, "must be different");
a61af66fc99e Initial load
duke
parents:
diff changeset
1527 __ cmpl(obj, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1528 if (op->profiled_method() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1529 ciMethod* method = op->profiled_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
1530 int bci = op->profiled_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
1531
a61af66fc99e Initial load
duke
parents:
diff changeset
1532 Label profile_done;
a61af66fc99e Initial load
duke
parents:
diff changeset
1533 __ jcc(Assembler::notEqual, profile_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1534 // Object is null; update methodDataOop
a61af66fc99e Initial load
duke
parents:
diff changeset
1535 ciMethodData* md = method->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
1536 if (md == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1537 bailout("out of memory building methodDataOop");
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1540 ciProfileData* data = md->bci_to_data(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 assert(data != NULL, "need data for checkcast");
a61af66fc99e Initial load
duke
parents:
diff changeset
1542 assert(data->is_BitData(), "need BitData for checkcast");
a61af66fc99e Initial load
duke
parents:
diff changeset
1543 Register mdo = klass_RInfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1544 __ movoop(mdo, md->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1545 Address data_addr(mdo, md->byte_offset_of_slot(data, DataLayout::header_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1546 int header_bits = DataLayout::flag_mask_to_header_mask(BitData::null_seen_byte_constant());
a61af66fc99e Initial load
duke
parents:
diff changeset
1547 __ orl(data_addr, header_bits);
a61af66fc99e Initial load
duke
parents:
diff changeset
1548 __ jmp(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1549 __ bind(profile_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1550 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 __ jcc(Assembler::equal, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1552 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1553 __ verify_oop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
1554
a61af66fc99e Initial load
duke
parents:
diff changeset
1555 if (op->fast_check()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1556 // get object classo
a61af66fc99e Initial load
duke
parents:
diff changeset
1557 // not a safepoint as obj null check happens earlier
a61af66fc99e Initial load
duke
parents:
diff changeset
1558 if (k->is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1559 __ cmpoop(Address(obj, oopDesc::klass_offset_in_bytes()), k->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1560 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1561 __ cmpl(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1562
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1564 __ jcc(Assembler::notEqual, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1565 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1566 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 // get object class
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 // not a safepoint as obj null check happens earlier
a61af66fc99e Initial load
duke
parents:
diff changeset
1569 __ movl(klass_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 if (k->is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 // See if we get an immediate positive hit
a61af66fc99e Initial load
duke
parents:
diff changeset
1572 __ cmpoop(Address(klass_RInfo, k->super_check_offset()), k->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1573 if (sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes() != k->super_check_offset()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1574 __ jcc(Assembler::notEqual, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1576 // See if we get an immediate positive hit
a61af66fc99e Initial load
duke
parents:
diff changeset
1577 __ jcc(Assembler::equal, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1578 // check for self
a61af66fc99e Initial load
duke
parents:
diff changeset
1579 __ cmpoop(klass_RInfo, k->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1580 __ jcc(Assembler::equal, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1581
a61af66fc99e Initial load
duke
parents:
diff changeset
1582 __ pushl(klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1583 __ pushoop(k->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1585 __ popl(klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 __ popl(klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1587 __ cmpl(klass_RInfo, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1588 __ jcc(Assembler::equal, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1591 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1592 __ movl(Rtmp1, Address(k_RInfo, sizeof(oopDesc) + Klass::super_check_offset_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1593 // See if we get an immediate positive hit
a61af66fc99e Initial load
duke
parents:
diff changeset
1594 __ cmpl(k_RInfo, Address(klass_RInfo, Rtmp1, Address::times_1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1595 __ jcc(Assembler::equal, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1596 // check for immediate negative hit
a61af66fc99e Initial load
duke
parents:
diff changeset
1597 __ cmpl(Rtmp1, sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
1598 __ jcc(Assembler::notEqual, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1599 // check for self
a61af66fc99e Initial load
duke
parents:
diff changeset
1600 __ cmpl(klass_RInfo, k_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1601 __ jcc(Assembler::equal, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1602
a61af66fc99e Initial load
duke
parents:
diff changeset
1603 __ pushl(klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1604 __ pushl(k_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1605 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1606 __ popl(klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1607 __ popl(k_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1608 __ cmpl(k_RInfo, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 __ jcc(Assembler::equal, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
1610 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1611 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1612
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 if (dst != obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 __ movl(dst, obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
1616 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1617 } else if (code == lir_instanceof) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1618 Register obj = op->object()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1619 Register k_RInfo = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 Register klass_RInfo = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1621 Register dst = op->result_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1622 ciKlass* k = op->klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
1623
a61af66fc99e Initial load
duke
parents:
diff changeset
1624 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
1625 Label zero;
a61af66fc99e Initial load
duke
parents:
diff changeset
1626 Label one;
a61af66fc99e Initial load
duke
parents:
diff changeset
1627 if (obj == k_RInfo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 k_RInfo = klass_RInfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1629 klass_RInfo = obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
1630 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 // patching may screw with our temporaries on sparc,
a61af66fc99e Initial load
duke
parents:
diff changeset
1632 // so let's do it before loading the class
a61af66fc99e Initial load
duke
parents:
diff changeset
1633 if (!k->is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1634 jobject2reg_with_patching(k_RInfo, op->info_for_patch());
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 assert(obj != k_RInfo, "must be different");
a61af66fc99e Initial load
duke
parents:
diff changeset
1637
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 __ verify_oop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
1639 if (op->fast_check()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1640 __ cmpl(obj, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 __ jcc(Assembler::equal, zero);
a61af66fc99e Initial load
duke
parents:
diff changeset
1642 // get object class
a61af66fc99e Initial load
duke
parents:
diff changeset
1643 // not a safepoint as obj null check happens earlier
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 if (k->is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 __ cmpoop(Address(obj, oopDesc::klass_offset_in_bytes()), k->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 k_RInfo = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1647 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1648 __ cmpl(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1649
a61af66fc99e Initial load
duke
parents:
diff changeset
1650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1651 __ jcc(Assembler::equal, one);
a61af66fc99e Initial load
duke
parents:
diff changeset
1652 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 // get object class
a61af66fc99e Initial load
duke
parents:
diff changeset
1654 // not a safepoint as obj null check happens earlier
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 __ cmpl(obj, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 __ jcc(Assembler::equal, zero);
a61af66fc99e Initial load
duke
parents:
diff changeset
1657 __ movl(klass_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 if (k->is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1659 // See if we get an immediate positive hit
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 __ cmpoop(Address(klass_RInfo, k->super_check_offset()), k->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 __ jcc(Assembler::equal, one);
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 if (sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes() == k->super_check_offset()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1663 // check for self
a61af66fc99e Initial load
duke
parents:
diff changeset
1664 __ cmpoop(klass_RInfo, k->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1665 __ jcc(Assembler::equal, one);
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 __ pushl(klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 __ pushoop(k->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 __ popl(klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1670 __ popl(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
1671 __ jmp(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1672 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1673 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1674 assert(dst != klass_RInfo && dst != k_RInfo, "need 3 registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1675
a61af66fc99e Initial load
duke
parents:
diff changeset
1676 __ movl(dst, Address(k_RInfo, sizeof(oopDesc) + Klass::super_check_offset_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 // See if we get an immediate positive hit
a61af66fc99e Initial load
duke
parents:
diff changeset
1678 __ cmpl(k_RInfo, Address(klass_RInfo, dst, Address::times_1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1679 __ jcc(Assembler::equal, one);
a61af66fc99e Initial load
duke
parents:
diff changeset
1680 // check for immediate negative hit
a61af66fc99e Initial load
duke
parents:
diff changeset
1681 __ cmpl(dst, sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
1682 __ jcc(Assembler::notEqual, zero);
a61af66fc99e Initial load
duke
parents:
diff changeset
1683 // check for self
a61af66fc99e Initial load
duke
parents:
diff changeset
1684 __ cmpl(klass_RInfo, k_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1685 __ jcc(Assembler::equal, one);
a61af66fc99e Initial load
duke
parents:
diff changeset
1686
a61af66fc99e Initial load
duke
parents:
diff changeset
1687 __ pushl(klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1688 __ pushl(k_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1689 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1690 __ popl(klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1691 __ popl(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
1692 __ jmp(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1693 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1694 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1695 __ bind(zero);
a61af66fc99e Initial load
duke
parents:
diff changeset
1696 __ xorl(dst, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
1697 __ jmp(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1698 __ bind(one);
a61af66fc99e Initial load
duke
parents:
diff changeset
1699 __ movl(dst, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1700 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
1701 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1702 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1703 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1704
a61af66fc99e Initial load
duke
parents:
diff changeset
1705 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1706
a61af66fc99e Initial load
duke
parents:
diff changeset
1707
a61af66fc99e Initial load
duke
parents:
diff changeset
1708 void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1709 if (op->code() == lir_cas_long) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1710 assert(VM_Version::supports_cx8(), "wrong machine");
a61af66fc99e Initial load
duke
parents:
diff changeset
1711 assert(op->cmp_value()->as_register_lo() == rax, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1712 assert(op->cmp_value()->as_register_hi() == rdx, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1713 assert(op->new_value()->as_register_lo() == rbx, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1714 assert(op->new_value()->as_register_hi() == rcx, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1715 Register addr = op->addr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1716 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1717 __ lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
1718 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1719 __ cmpxchg8(Address(addr, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1720
a61af66fc99e Initial load
duke
parents:
diff changeset
1721 } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1722 Register addr = op->addr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1723 Register newval = op->new_value()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1724 Register cmpval = op->cmp_value()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1725 assert(cmpval == rax, "wrong register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1726 assert(newval != NULL, "new val must be register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1727 assert(cmpval != newval, "cmp and new values must be in different registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1728 assert(cmpval != addr, "cmp and addr must be in different registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1729 assert(newval != addr, "new value and addr must be in different registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1730 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1731 __ lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
1732 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1733 __ cmpxchg(newval, Address(addr, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
1734 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1735 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
1736 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1737 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1738
a61af66fc99e Initial load
duke
parents:
diff changeset
1739
a61af66fc99e Initial load
duke
parents:
diff changeset
1740 void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1741 Assembler::Condition acond, ncond;
a61af66fc99e Initial load
duke
parents:
diff changeset
1742 switch (condition) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1743 case lir_cond_equal: acond = Assembler::equal; ncond = Assembler::notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1744 case lir_cond_notEqual: acond = Assembler::notEqual; ncond = Assembler::equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1745 case lir_cond_less: acond = Assembler::less; ncond = Assembler::greaterEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1746 case lir_cond_lessEqual: acond = Assembler::lessEqual; ncond = Assembler::greater; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1747 case lir_cond_greaterEqual: acond = Assembler::greaterEqual; ncond = Assembler::less; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1748 case lir_cond_greater: acond = Assembler::greater; ncond = Assembler::lessEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1749 case lir_cond_belowEqual: acond = Assembler::belowEqual; ncond = Assembler::above; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1750 case lir_cond_aboveEqual: acond = Assembler::aboveEqual; ncond = Assembler::below; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1751 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1752 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1753
a61af66fc99e Initial load
duke
parents:
diff changeset
1754 if (opr1->is_cpu_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1755 reg2reg(opr1, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
1756 } else if (opr1->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1757 stack2reg(opr1, result, result->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
1758 } else if (opr1->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1759 const2reg(opr1, result, lir_patch_none, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1760 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1761 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1762 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1763
a61af66fc99e Initial load
duke
parents:
diff changeset
1764 if (VM_Version::supports_cmov() && !opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1765 // optimized version that does not require a branch
a61af66fc99e Initial load
duke
parents:
diff changeset
1766 if (opr2->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1767 assert(opr2->cpu_regnr() != result->cpu_regnr(), "opr2 already overwritten by previous move");
a61af66fc99e Initial load
duke
parents:
diff changeset
1768 __ cmovl(ncond, result->as_register(), opr2->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1769 } else if (opr2->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1770 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
1771 assert(opr2->cpu_regnrHi() != result->cpu_regnrLo() && opr2->cpu_regnrHi() != result->cpu_regnrHi(), "opr2 already overwritten by previous move");
a61af66fc99e Initial load
duke
parents:
diff changeset
1772 __ cmovl(ncond, result->as_register_lo(), opr2->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1773 __ cmovl(ncond, result->as_register_hi(), opr2->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1774 } else if (opr2->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1775 __ cmovl(ncond, result->as_register(), frame_map()->address_for_slot(opr2->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1776 } else if (opr2->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1777 __ cmovl(ncond, result->as_register_lo(), frame_map()->address_for_slot(opr2->double_stack_ix(), lo_word_offset_in_bytes));
a61af66fc99e Initial load
duke
parents:
diff changeset
1778 __ cmovl(ncond, result->as_register_hi(), frame_map()->address_for_slot(opr2->double_stack_ix(), hi_word_offset_in_bytes));
a61af66fc99e Initial load
duke
parents:
diff changeset
1779 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1780 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1781 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1782
a61af66fc99e Initial load
duke
parents:
diff changeset
1783 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1784 Label skip;
a61af66fc99e Initial load
duke
parents:
diff changeset
1785 __ jcc (acond, skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
1786 if (opr2->is_cpu_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1787 reg2reg(opr2, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
1788 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1789 stack2reg(opr2, result, result->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
1790 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1791 const2reg(opr2, result, lir_patch_none, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1792 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1793 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1794 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1795 __ bind(skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
1796 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1797 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1798
a61af66fc99e Initial load
duke
parents:
diff changeset
1799
a61af66fc99e Initial load
duke
parents:
diff changeset
1800 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
1801 assert(info == NULL, "should never be used, idiv/irem and ldiv/lrem not handled by this method");
a61af66fc99e Initial load
duke
parents:
diff changeset
1802
a61af66fc99e Initial load
duke
parents:
diff changeset
1803 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1804 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
1805 Register lreg = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1806
a61af66fc99e Initial load
duke
parents:
diff changeset
1807 if (right->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1808 // cpu register - cpu register
a61af66fc99e Initial load
duke
parents:
diff changeset
1809 Register rreg = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1810 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1811 case lir_add: __ addl (lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1812 case lir_sub: __ subl (lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1813 case lir_mul: __ imull(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1814 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1815 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1816
a61af66fc99e Initial load
duke
parents:
diff changeset
1817 } else if (right->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1818 // cpu register - stack
a61af66fc99e Initial load
duke
parents:
diff changeset
1819 Address raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1820 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1821 case lir_add: __ addl(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1822 case lir_sub: __ subl(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1823 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1824 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1825
a61af66fc99e Initial load
duke
parents:
diff changeset
1826 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1827 // cpu register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1828 jint c = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
1829 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1830 case lir_add: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1831 __ increment(lreg, c);
a61af66fc99e Initial load
duke
parents:
diff changeset
1832 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1833 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1834 case lir_sub: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1835 __ decrement(lreg, c);
a61af66fc99e Initial load
duke
parents:
diff changeset
1836 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1837 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1838 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1839 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1840
a61af66fc99e Initial load
duke
parents:
diff changeset
1841 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1842 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1843 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1844
a61af66fc99e Initial load
duke
parents:
diff changeset
1845 } else if (left->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1846 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
1847 Register lreg_lo = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1848 Register lreg_hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
1849
a61af66fc99e Initial load
duke
parents:
diff changeset
1850 if (right->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1851 // cpu register - cpu register
a61af66fc99e Initial load
duke
parents:
diff changeset
1852 Register rreg_lo = right->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1853 Register rreg_hi = right->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
1854 assert_different_registers(lreg_lo, lreg_hi, rreg_lo, rreg_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1855 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1856 case lir_add:
a61af66fc99e Initial load
duke
parents:
diff changeset
1857 __ addl(lreg_lo, rreg_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1858 __ adcl(lreg_hi, rreg_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1859 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1860 case lir_sub:
a61af66fc99e Initial load
duke
parents:
diff changeset
1861 __ subl(lreg_lo, rreg_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1862 __ sbbl(lreg_hi, rreg_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1863 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1864 case lir_mul:
a61af66fc99e Initial load
duke
parents:
diff changeset
1865 assert(lreg_lo == rax && lreg_hi == rdx, "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
1866 __ imull(lreg_hi, rreg_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1867 __ imull(rreg_hi, lreg_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1868 __ addl (rreg_hi, lreg_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1869 __ mull (rreg_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1870 __ addl (lreg_hi, rreg_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1871 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1872 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1873 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1874 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1875
a61af66fc99e Initial load
duke
parents:
diff changeset
1876 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1877 // cpu register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1878 jint c_lo = right->as_constant_ptr()->as_jint_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1879 jint c_hi = right->as_constant_ptr()->as_jint_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
1880 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1881 case lir_add:
a61af66fc99e Initial load
duke
parents:
diff changeset
1882 __ addl(lreg_lo, c_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1883 __ adcl(lreg_hi, c_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1884 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1885 case lir_sub:
a61af66fc99e Initial load
duke
parents:
diff changeset
1886 __ subl(lreg_lo, c_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1887 __ sbbl(lreg_hi, c_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1888 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1889 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1890 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1891 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1892
a61af66fc99e Initial load
duke
parents:
diff changeset
1893 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1894 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1895 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1896
a61af66fc99e Initial load
duke
parents:
diff changeset
1897 } else if (left->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1898 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
1899 XMMRegister lreg = left->as_xmm_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1900
a61af66fc99e Initial load
duke
parents:
diff changeset
1901 if (right->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1902 XMMRegister rreg = right->as_xmm_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1903 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1904 case lir_add: __ addss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1905 case lir_sub: __ subss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1906 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1907 case lir_mul: __ mulss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1908 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1909 case lir_div: __ divss(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1910 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1911 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1912 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1913 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1914 if (right->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1915 raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1916 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1917 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
1918 raddr = __ as_Address(InternalAddress(float_constant(right->as_jfloat())));
a61af66fc99e Initial load
duke
parents:
diff changeset
1919 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1920 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1921 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1922 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1923 case lir_add: __ addss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1924 case lir_sub: __ subss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1925 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1926 case lir_mul: __ mulss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1927 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1928 case lir_div: __ divss(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1929 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1930 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1931 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1932
a61af66fc99e Initial load
duke
parents:
diff changeset
1933 } else if (left->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1934 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
1935
a61af66fc99e Initial load
duke
parents:
diff changeset
1936 XMMRegister lreg = left->as_xmm_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1937 if (right->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1938 XMMRegister rreg = right->as_xmm_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1939 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1940 case lir_add: __ addsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1941 case lir_sub: __ subsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1942 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1943 case lir_mul: __ mulsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1944 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1945 case lir_div: __ divsd(lreg, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1946 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1947 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1948 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1949 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1950 if (right->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1951 raddr = frame_map()->address_for_slot(right->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1952 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1953 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
1954 raddr = __ as_Address(InternalAddress(double_constant(right->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
1955 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1956 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1957 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1958 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1959 case lir_add: __ addsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1960 case lir_sub: __ subsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1961 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1962 case lir_mul: __ mulsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1963 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1964 case lir_div: __ divsd(lreg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1965 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1966 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1967 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1968
a61af66fc99e Initial load
duke
parents:
diff changeset
1969 } else if (left->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1970 assert(dest->is_single_fpu(), "fpu stack allocation required");
a61af66fc99e Initial load
duke
parents:
diff changeset
1971
a61af66fc99e Initial load
duke
parents:
diff changeset
1972 if (right->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1973 arith_fpu_implementation(code, left->fpu_regnr(), right->fpu_regnr(), dest->fpu_regnr(), pop_fpu_stack);
a61af66fc99e Initial load
duke
parents:
diff changeset
1974
a61af66fc99e Initial load
duke
parents:
diff changeset
1975 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1976 assert(left->fpu_regnr() == 0, "left must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1977 assert(dest->fpu_regnr() == 0, "dest must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
1978
a61af66fc99e Initial load
duke
parents:
diff changeset
1979 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1980 if (right->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1981 raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1982 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1983 address const_addr = float_constant(right->as_jfloat());
a61af66fc99e Initial load
duke
parents:
diff changeset
1984 assert(const_addr != NULL, "incorrect float/double constant maintainance");
a61af66fc99e Initial load
duke
parents:
diff changeset
1985 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
1986 raddr = __ as_Address(InternalAddress(const_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1987 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1988 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1989 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1990
a61af66fc99e Initial load
duke
parents:
diff changeset
1991 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1992 case lir_add: __ fadd_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1993 case lir_sub: __ fsub_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1994 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1995 case lir_mul: __ fmul_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1996 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1997 case lir_div: __ fdiv_s(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1998 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1999 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2000 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2001
a61af66fc99e Initial load
duke
parents:
diff changeset
2002 } else if (left->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2003 assert(dest->is_double_fpu(), "fpu stack allocation required");
a61af66fc99e Initial load
duke
parents:
diff changeset
2004
a61af66fc99e Initial load
duke
parents:
diff changeset
2005 if (code == lir_mul_strictfp || code == lir_div_strictfp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2006 // Double values require special handling for strictfp mul/div on x86
a61af66fc99e Initial load
duke
parents:
diff changeset
2007 __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias1()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2008 __ fmulp(left->fpu_regnrLo() + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2009 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2010
a61af66fc99e Initial load
duke
parents:
diff changeset
2011 if (right->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2012 arith_fpu_implementation(code, left->fpu_regnrLo(), right->fpu_regnrLo(), dest->fpu_regnrLo(), pop_fpu_stack);
a61af66fc99e Initial load
duke
parents:
diff changeset
2013
a61af66fc99e Initial load
duke
parents:
diff changeset
2014 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2015 assert(left->fpu_regnrLo() == 0, "left must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2016 assert(dest->fpu_regnrLo() == 0, "dest must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2017
a61af66fc99e Initial load
duke
parents:
diff changeset
2018 Address raddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2019 if (right->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2020 raddr = frame_map()->address_for_slot(right->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2021 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2022 // hack for now
a61af66fc99e Initial load
duke
parents:
diff changeset
2023 raddr = __ as_Address(InternalAddress(double_constant(right->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2024 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2025 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2026 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2027
a61af66fc99e Initial load
duke
parents:
diff changeset
2028 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2029 case lir_add: __ fadd_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2030 case lir_sub: __ fsub_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2031 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2032 case lir_mul: __ fmul_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2033 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2034 case lir_div: __ fdiv_d(raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2035 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2036 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2037 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2038
a61af66fc99e Initial load
duke
parents:
diff changeset
2039 if (code == lir_mul_strictfp || code == lir_div_strictfp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2040 // Double values require special handling for strictfp mul/div on x86
a61af66fc99e Initial load
duke
parents:
diff changeset
2041 __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias2()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2042 __ fmulp(dest->fpu_regnrLo() + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2043 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2044
a61af66fc99e Initial load
duke
parents:
diff changeset
2045 } else if (left->is_single_stack() || left->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2046 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2047
a61af66fc99e Initial load
duke
parents:
diff changeset
2048 Address laddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2049 if (left->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2050 laddr = frame_map()->address_for_slot(left->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2051 } else if (left->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2052 laddr = as_Address(left->as_address_ptr());
a61af66fc99e Initial load
duke
parents:
diff changeset
2053 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2054 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2055 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2056
a61af66fc99e Initial load
duke
parents:
diff changeset
2057 if (right->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2058 Register rreg = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2059 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2060 case lir_add: __ addl(laddr, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2061 case lir_sub: __ subl(laddr, rreg); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2062 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2063 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2064 } else if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2065 jint c = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
2066 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2067 case lir_add: {
a61af66fc99e Initial load
duke
parents:
diff changeset
2068 __ increment(laddr, c);
a61af66fc99e Initial load
duke
parents:
diff changeset
2069 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2070 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2071 case lir_sub: {
a61af66fc99e Initial load
duke
parents:
diff changeset
2072 __ decrement(laddr, c);
a61af66fc99e Initial load
duke
parents:
diff changeset
2073 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2074 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2075 default: ShouldNotReachHere();
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 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2079 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2080
a61af66fc99e Initial load
duke
parents:
diff changeset
2081 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2082 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2083 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2084 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2085
a61af66fc99e Initial load
duke
parents:
diff changeset
2086 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
2087 assert(pop_fpu_stack || (left_index == dest_index || right_index == dest_index), "invalid LIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
2088 assert(!pop_fpu_stack || (left_index - 1 == dest_index || right_index - 1 == dest_index), "invalid LIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
2089 assert(left_index == 0 || right_index == 0, "either must be on top of stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
2090
a61af66fc99e Initial load
duke
parents:
diff changeset
2091 bool left_is_tos = (left_index == 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2092 bool dest_is_tos = (dest_index == 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2093 int non_tos_index = (left_is_tos ? right_index : left_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2094
a61af66fc99e Initial load
duke
parents:
diff changeset
2095 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2096 case lir_add:
a61af66fc99e Initial load
duke
parents:
diff changeset
2097 if (pop_fpu_stack) __ faddp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2098 else if (dest_is_tos) __ fadd (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2099 else __ fadda(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2100 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2101
a61af66fc99e Initial load
duke
parents:
diff changeset
2102 case lir_sub:
a61af66fc99e Initial load
duke
parents:
diff changeset
2103 if (left_is_tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2104 if (pop_fpu_stack) __ fsubrp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2105 else if (dest_is_tos) __ fsub (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2106 else __ fsubra(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2107 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2108 if (pop_fpu_stack) __ fsubp (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2109 else if (dest_is_tos) __ fsubr (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2110 else __ fsuba (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2112 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2113
a61af66fc99e Initial load
duke
parents:
diff changeset
2114 case lir_mul_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2115 case lir_mul:
a61af66fc99e Initial load
duke
parents:
diff changeset
2116 if (pop_fpu_stack) __ fmulp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2117 else if (dest_is_tos) __ fmul (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2118 else __ fmula(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2119 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2120
a61af66fc99e Initial load
duke
parents:
diff changeset
2121 case lir_div_strictfp: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
2122 case lir_div:
a61af66fc99e Initial load
duke
parents:
diff changeset
2123 if (left_is_tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2124 if (pop_fpu_stack) __ fdivrp(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2125 else if (dest_is_tos) __ fdiv (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2126 else __ fdivra(non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2127 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2128 if (pop_fpu_stack) __ fdivp (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2129 else if (dest_is_tos) __ fdivr (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2130 else __ fdiva (non_tos_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2132 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2133
a61af66fc99e Initial load
duke
parents:
diff changeset
2134 case lir_rem:
a61af66fc99e Initial load
duke
parents:
diff changeset
2135 assert(left_is_tos && dest_is_tos && right_index == 1, "must be guaranteed by FPU stack allocation");
a61af66fc99e Initial load
duke
parents:
diff changeset
2136 __ fremr(noreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2137 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2138
a61af66fc99e Initial load
duke
parents:
diff changeset
2139 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
2140 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2143
a61af66fc99e Initial load
duke
parents:
diff changeset
2144
a61af66fc99e Initial load
duke
parents:
diff changeset
2145 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
2146 if (value->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2147 switch(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2148 case lir_abs :
a61af66fc99e Initial load
duke
parents:
diff changeset
2149 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2150 if (dest->as_xmm_double_reg() != value->as_xmm_double_reg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2151 __ movdbl(dest->as_xmm_double_reg(), value->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
2152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2153 __ andpd(dest->as_xmm_double_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2154 ExternalAddress((address)double_signmask_pool));
a61af66fc99e Initial load
duke
parents:
diff changeset
2155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2156 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2157
a61af66fc99e Initial load
duke
parents:
diff changeset
2158 case lir_sqrt: __ sqrtsd(dest->as_xmm_double_reg(), value->as_xmm_double_reg()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2159 // all other intrinsics are not available in the SSE instruction set, so FPU is used
a61af66fc99e Initial load
duke
parents:
diff changeset
2160 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2162
a61af66fc99e Initial load
duke
parents:
diff changeset
2163 } else if (value->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2164 assert(value->fpu_regnrLo() == 0 && dest->fpu_regnrLo() == 0, "both must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2165 switch(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2166 case lir_log : __ flog() ; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2167 case lir_log10 : __ flog10() ; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2168 case lir_abs : __ fabs() ; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2169 case lir_sqrt : __ fsqrt(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2170 case lir_sin :
a61af66fc99e Initial load
duke
parents:
diff changeset
2171 // Should consider not saving rbx, if not necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
2172 __ trigfunc('s', op->as_Op2()->fpu_stack_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
2173 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2174 case lir_cos :
a61af66fc99e Initial load
duke
parents:
diff changeset
2175 // Should consider not saving rbx, if not necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
2176 assert(op->as_Op2()->fpu_stack_size() <= 6, "sin and cos need two free stack slots");
a61af66fc99e Initial load
duke
parents:
diff changeset
2177 __ trigfunc('c', op->as_Op2()->fpu_stack_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
2178 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2179 case lir_tan :
a61af66fc99e Initial load
duke
parents:
diff changeset
2180 // Should consider not saving rbx, if not necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
2181 __ trigfunc('t', op->as_Op2()->fpu_stack_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
2182 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2183 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2185 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2186 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2189
a61af66fc99e Initial load
duke
parents:
diff changeset
2190 void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2191 // assert(left->destroys_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
2192 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2193 Register reg = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2194 if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2195 int val = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
2196 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2197 case lir_logic_and: __ andl (reg, val); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2198 case lir_logic_or: __ orl (reg, val); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2199 case lir_logic_xor: __ xorl (reg, val); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2200 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2202 } else if (right->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2203 // added support for stack operands
a61af66fc99e Initial load
duke
parents:
diff changeset
2204 Address raddr = frame_map()->address_for_slot(right->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
2205 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2206 case lir_logic_and: __ andl (reg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2207 case lir_logic_or: __ orl (reg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2208 case lir_logic_xor: __ xorl (reg, raddr); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2209 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2211 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2212 Register rright = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2213 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2214 case lir_logic_and: __ andl (reg, rright); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2215 case lir_logic_or : __ orl (reg, rright); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2216 case lir_logic_xor: __ xorl (reg, rright); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2217 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2220 move_regs(reg, dst->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
2221 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2222 Register l_lo = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2223 Register l_hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2224 if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2225 int r_lo = right->as_constant_ptr()->as_jint_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2226 int r_hi = right->as_constant_ptr()->as_jint_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2227 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2228 case lir_logic_and:
a61af66fc99e Initial load
duke
parents:
diff changeset
2229 __ andl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2230 __ andl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2231 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2232 case lir_logic_or:
a61af66fc99e Initial load
duke
parents:
diff changeset
2233 __ orl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2234 __ orl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2235 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2236 case lir_logic_xor:
a61af66fc99e Initial load
duke
parents:
diff changeset
2237 __ xorl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2238 __ xorl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2239 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2240 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2242 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2243 Register r_lo = right->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2244 Register r_hi = right->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2245 assert(l_lo != r_hi, "overwriting registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
2246 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2247 case lir_logic_and:
a61af66fc99e Initial load
duke
parents:
diff changeset
2248 __ andl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2249 __ andl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2250 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2251 case lir_logic_or:
a61af66fc99e Initial load
duke
parents:
diff changeset
2252 __ orl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2253 __ orl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2254 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2255 case lir_logic_xor:
a61af66fc99e Initial load
duke
parents:
diff changeset
2256 __ xorl(l_lo, r_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2257 __ xorl(l_hi, r_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2258 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2259 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2262
a61af66fc99e Initial load
duke
parents:
diff changeset
2263 Register dst_lo = dst->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2264 Register dst_hi = dst->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2265
a61af66fc99e Initial load
duke
parents:
diff changeset
2266 if (dst_lo == l_hi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2267 assert(dst_hi != l_lo, "overwriting registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
2268 move_regs(l_hi, dst_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2269 move_regs(l_lo, dst_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2270 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2271 assert(dst_lo != l_hi, "overwriting registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
2272 move_regs(l_lo, dst_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2273 move_regs(l_hi, dst_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2277
a61af66fc99e Initial load
duke
parents:
diff changeset
2278
a61af66fc99e Initial load
duke
parents:
diff changeset
2279 // we assume that rax, and rdx can be overwritten
a61af66fc99e Initial load
duke
parents:
diff changeset
2280 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
2281
a61af66fc99e Initial load
duke
parents:
diff changeset
2282 assert(left->is_single_cpu(), "left must be register");
a61af66fc99e Initial load
duke
parents:
diff changeset
2283 assert(right->is_single_cpu() || right->is_constant(), "right must be register or constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
2284 assert(result->is_single_cpu(), "result must be register");
a61af66fc99e Initial load
duke
parents:
diff changeset
2285
a61af66fc99e Initial load
duke
parents:
diff changeset
2286 // assert(left->destroys_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
2287 // assert(right->destroys_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
2288
a61af66fc99e Initial load
duke
parents:
diff changeset
2289 Register lreg = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2290 Register dreg = result->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2291
a61af66fc99e Initial load
duke
parents:
diff changeset
2292 if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2293 int divisor = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
2294 assert(divisor > 0 && is_power_of_2(divisor), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
2295 if (code == lir_idiv) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2296 assert(lreg == rax, "must be rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
2297 assert(temp->as_register() == rdx, "tmp register must be rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
2298 __ cdql(); // sign extend into rdx:rax
a61af66fc99e Initial load
duke
parents:
diff changeset
2299 if (divisor == 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2300 __ subl(lreg, rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2301 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2302 __ andl(rdx, divisor - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2303 __ addl(lreg, rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2305 __ sarl(lreg, log2_intptr(divisor));
a61af66fc99e Initial load
duke
parents:
diff changeset
2306 move_regs(lreg, dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2307 } else if (code == lir_irem) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2308 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
2309 __ movl(dreg, lreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2310 __ andl(dreg, 0x80000000 | (divisor - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2311 __ jcc(Assembler::positive, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2312 __ decrement(dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2313 __ orl(dreg, ~(divisor - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2314 __ increment(dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2315 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2316 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2317 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2319 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2320 Register rreg = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2321 assert(lreg == rax, "left register must be rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
2322 assert(rreg != rdx, "right register must not be rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
2323 assert(temp->as_register() == rdx, "tmp register must be rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
2324
a61af66fc99e Initial load
duke
parents:
diff changeset
2325 move_regs(lreg, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2326
a61af66fc99e Initial load
duke
parents:
diff changeset
2327 int idivl_offset = __ corrected_idivl(rreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2328 add_debug_info_for_div0(idivl_offset, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2329 if (code == lir_irem) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2330 move_regs(rdx, dreg); // result is in rdx
a61af66fc99e Initial load
duke
parents:
diff changeset
2331 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2332 move_regs(rax, dreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2336
a61af66fc99e Initial load
duke
parents:
diff changeset
2337
a61af66fc99e Initial load
duke
parents:
diff changeset
2338 void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2339 if (opr1->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2340 Register reg1 = opr1->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2341 if (opr2->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2342 // cpu register - cpu register
a61af66fc99e Initial load
duke
parents:
diff changeset
2343 __ cmpl(reg1, opr2->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
2344 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2345 // cpu register - stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2346 __ cmpl(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2347 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2348 // cpu register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2349 LIR_Const* c = opr2->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2350 if (c->type() == T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2351 __ cmpl(reg1, c->as_jint());
a61af66fc99e Initial load
duke
parents:
diff changeset
2352 } else if (c->type() == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2353 jobject o = c->as_jobject();
a61af66fc99e Initial load
duke
parents:
diff changeset
2354 if (o == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2355 __ cmpl(reg1, NULL_WORD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2356 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2357 __ cmpoop(reg1, c->as_jobject());
a61af66fc99e Initial load
duke
parents:
diff changeset
2358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2359 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2360 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2362 // cpu register - address
a61af66fc99e Initial load
duke
parents:
diff changeset
2363 } else if (opr2->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2364 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2365 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2366 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2367 __ cmpl(reg1, as_Address(opr2->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2368 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2369 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2371
a61af66fc99e Initial load
duke
parents:
diff changeset
2372 } else if(opr1->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2373 Register xlo = opr1->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2374 Register xhi = opr1->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2375 if (opr2->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2376 // cpu register - cpu register
a61af66fc99e Initial load
duke
parents:
diff changeset
2377 Register ylo = opr2->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2378 Register yhi = opr2->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2379 __ subl(xlo, ylo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2380 __ sbbl(xhi, yhi);
a61af66fc99e Initial load
duke
parents:
diff changeset
2381 if (condition == lir_cond_equal || condition == lir_cond_notEqual) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2382 __ orl(xhi, xlo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2384 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2385 // cpu register - constant 0
a61af66fc99e Initial load
duke
parents:
diff changeset
2386 assert(opr2->as_jlong() == (jlong)0, "only handles zero");
a61af66fc99e Initial load
duke
parents:
diff changeset
2387 assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "only handles equals case");
a61af66fc99e Initial load
duke
parents:
diff changeset
2388 __ orl(xhi, xlo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2389 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2390 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2392
a61af66fc99e Initial load
duke
parents:
diff changeset
2393 } else if (opr1->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2394 XMMRegister reg1 = opr1->as_xmm_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2395 if (opr2->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2396 // xmm register - xmm register
a61af66fc99e Initial load
duke
parents:
diff changeset
2397 __ ucomiss(reg1, opr2->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
2398 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2399 // xmm register - stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2400 __ ucomiss(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2401 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2402 // xmm register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2403 __ ucomiss(reg1, InternalAddress(float_constant(opr2->as_jfloat())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2404 } else if (opr2->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2405 // xmm register - address
a61af66fc99e Initial load
duke
parents:
diff changeset
2406 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2407 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2408 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2409 __ ucomiss(reg1, as_Address(opr2->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2410 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2411 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2413
a61af66fc99e Initial load
duke
parents:
diff changeset
2414 } else if (opr1->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2415 XMMRegister reg1 = opr1->as_xmm_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
2416 if (opr2->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2417 // xmm register - xmm register
a61af66fc99e Initial load
duke
parents:
diff changeset
2418 __ ucomisd(reg1, opr2->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
2419 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2420 // xmm register - stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2421 __ ucomisd(reg1, frame_map()->address_for_slot(opr2->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2422 } else if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2423 // xmm register - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2424 __ ucomisd(reg1, InternalAddress(double_constant(opr2->as_jdouble())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2425 } else if (opr2->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2426 // xmm register - address
a61af66fc99e Initial load
duke
parents:
diff changeset
2427 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2428 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2429 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2430 __ ucomisd(reg1, as_Address(opr2->pointer()->as_address()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2431 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2432 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2434
a61af66fc99e Initial load
duke
parents:
diff changeset
2435 } else if(opr1->is_single_fpu() || opr1->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2436 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
2437 assert(opr2->is_fpu_register(), "both must be registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
2438 __ fcmp(noreg, opr2->fpu(), op->fpu_pop_count() > 0, op->fpu_pop_count() > 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2439
a61af66fc99e Initial load
duke
parents:
diff changeset
2440 } else if (opr1->is_address() && opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2441 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2442 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2444 // special case: address - constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2445 LIR_Address* addr = opr1->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2446 LIR_Const* c = opr2->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2447 if (c->type() == T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2448 __ cmpl(as_Address(addr), c->as_jint());
a61af66fc99e Initial load
duke
parents:
diff changeset
2449 } else if (c->type() == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2450 __ cmpoop(as_Address(addr), c->as_jobject());
a61af66fc99e Initial load
duke
parents:
diff changeset
2451 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2452 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2453 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2454
a61af66fc99e Initial load
duke
parents:
diff changeset
2455 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2456 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2459
a61af66fc99e Initial load
duke
parents:
diff changeset
2460 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
2461 if (code == lir_cmp_fd2i || code == lir_ucmp_fd2i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2462 if (left->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2463 assert(right->is_single_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2464 __ 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
2465 } else if (left->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2466 assert(right->is_double_xmm(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2467 __ 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
2468
a61af66fc99e Initial load
duke
parents:
diff changeset
2469 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2470 assert(left->is_single_fpu() || left->is_double_fpu(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
2471 assert(right->is_single_fpu() || right->is_double_fpu(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2472
a61af66fc99e Initial load
duke
parents:
diff changeset
2473 assert(left->fpu() == 0, "left must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
2474 __ fcmp2int(dst->as_register(), code == lir_ucmp_fd2i, right->fpu(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2475 op->fpu_pop_count() > 0, op->fpu_pop_count() > 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2477 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2478 assert(code == lir_cmp_l2i, "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
2479 __ lcmp2int(left->as_register_hi(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2480 left->as_register_lo(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2481 right->as_register_hi(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2482 right->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
2483 move_regs(left->as_register_hi(), dst->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
2484 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2485 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2486
a61af66fc99e Initial load
duke
parents:
diff changeset
2487
a61af66fc99e Initial load
duke
parents:
diff changeset
2488 void LIR_Assembler::align_call(LIR_Code code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2489 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2490 // make sure that the displacement word of the call ends up word aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
2491 int offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2492 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2493 case lir_static_call:
a61af66fc99e Initial load
duke
parents:
diff changeset
2494 case lir_optvirtual_call:
a61af66fc99e Initial load
duke
parents:
diff changeset
2495 offset += NativeCall::displacement_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
2496 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2497 case lir_icvirtual_call:
a61af66fc99e Initial load
duke
parents:
diff changeset
2498 offset += NativeCall::displacement_offset + NativeMovConstReg::instruction_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
2499 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2500 case lir_virtual_call: // currently, sparc-specific for niagara
a61af66fc99e Initial load
duke
parents:
diff changeset
2501 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2502 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2503 while (offset++ % BytesPerWord != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2504 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2505 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2506 }
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::call(address entry, relocInfo::relocType rtype, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2511 assert(!os::is_MP() || (__ offset() + NativeCall::displacement_offset) % BytesPerWord == 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
2512 "must be aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
2513 __ call(AddressLiteral(entry, rtype));
a61af66fc99e Initial load
duke
parents:
diff changeset
2514 add_call_info(code_offset(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2515 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2516
a61af66fc99e Initial load
duke
parents:
diff changeset
2517
a61af66fc99e Initial load
duke
parents:
diff changeset
2518 void LIR_Assembler::ic_call(address entry, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2519 RelocationHolder rh = virtual_call_Relocation::spec(pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
2520 __ movoop(IC_Klass, (jobject)Universe::non_oop_word());
a61af66fc99e Initial load
duke
parents:
diff changeset
2521 assert(!os::is_MP() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
2522 (__ offset() + NativeCall::displacement_offset) % BytesPerWord == 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
2523 "must be aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
2524 __ call(AddressLiteral(entry, rh));
a61af66fc99e Initial load
duke
parents:
diff changeset
2525 add_call_info(code_offset(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2526 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2527
a61af66fc99e Initial load
duke
parents:
diff changeset
2528
a61af66fc99e Initial load
duke
parents:
diff changeset
2529 /* Currently, vtable-dispatch is only enabled for sparc platforms */
a61af66fc99e Initial load
duke
parents:
diff changeset
2530 void LIR_Assembler::vtable_call(int vtable_offset, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2531 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2532 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2533
a61af66fc99e Initial load
duke
parents:
diff changeset
2534 void LIR_Assembler::emit_static_call_stub() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2535 address call_pc = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
2536 address stub = __ start_a_stub(call_stub_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
2537 if (stub == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2538 bailout("static call stub overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
2539 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2541
a61af66fc99e Initial load
duke
parents:
diff changeset
2542 int start = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2543 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2544 // make sure that the displacement word of the call ends up word aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
2545 int offset = __ offset() + NativeMovConstReg::instruction_size + NativeCall::displacement_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
2546 while (offset++ % BytesPerWord != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2547 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2548 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2549 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2550 __ relocate(static_stub_Relocation::spec(call_pc));
a61af66fc99e Initial load
duke
parents:
diff changeset
2551 __ movoop(rbx, (jobject)NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2552 // must be set to -1 at code generation time
a61af66fc99e Initial load
duke
parents:
diff changeset
2553 assert(!os::is_MP() || ((__ offset() + 1) % BytesPerWord) == 0, "must be aligned on MP");
a61af66fc99e Initial load
duke
parents:
diff changeset
2554 __ jump(RuntimeAddress((address)-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2555
a61af66fc99e Initial load
duke
parents:
diff changeset
2556 assert(__ offset() - start <= call_stub_size, "stub too big")
a61af66fc99e Initial load
duke
parents:
diff changeset
2557 __ end_a_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
2558 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2559
a61af66fc99e Initial load
duke
parents:
diff changeset
2560
a61af66fc99e Initial load
duke
parents:
diff changeset
2561 void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info, bool unwind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2562 assert(exceptionOop->as_register() == rax, "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2563 assert(unwind || exceptionPC->as_register() == rdx, "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2564
a61af66fc99e Initial load
duke
parents:
diff changeset
2565 // exception object is not added to oop map by LinearScan
a61af66fc99e Initial load
duke
parents:
diff changeset
2566 // (LinearScan assumes that no oops are in fixed registers)
a61af66fc99e Initial load
duke
parents:
diff changeset
2567 info->add_register_oop(exceptionOop);
a61af66fc99e Initial load
duke
parents:
diff changeset
2568 Runtime1::StubID unwind_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
2569
a61af66fc99e Initial load
duke
parents:
diff changeset
2570 if (!unwind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2571 // get current pc information
a61af66fc99e Initial load
duke
parents:
diff changeset
2572 // pc is only needed if the method has an exception handler, the unwind code does not need it.
a61af66fc99e Initial load
duke
parents:
diff changeset
2573 int pc_for_athrow_offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2574 InternalAddress pc_for_athrow(__ pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
2575 __ lea(exceptionPC->as_register(), pc_for_athrow);
a61af66fc99e Initial load
duke
parents:
diff changeset
2576 add_call_info(pc_for_athrow_offset, info); // for exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
2577
a61af66fc99e Initial load
duke
parents:
diff changeset
2578 __ verify_not_null_oop(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
2579 // search an exception handler (rax: exception oop, rdx: throwing pc)
a61af66fc99e Initial load
duke
parents:
diff changeset
2580 if (compilation()->has_fpu_code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2581 unwind_id = Runtime1::handle_exception_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
2582 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2583 unwind_id = Runtime1::handle_exception_nofpu_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
2584 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2585 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2586 unwind_id = Runtime1::unwind_exception_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
2587 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2588 __ call(RuntimeAddress(Runtime1::entry_for(unwind_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
2589
a61af66fc99e Initial load
duke
parents:
diff changeset
2590 // enough room for two byte trap
a61af66fc99e Initial load
duke
parents:
diff changeset
2591 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2592 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2593
a61af66fc99e Initial load
duke
parents:
diff changeset
2594
a61af66fc99e Initial load
duke
parents:
diff changeset
2595 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
2596
a61af66fc99e Initial load
duke
parents:
diff changeset
2597 // optimized version for linear scan:
a61af66fc99e Initial load
duke
parents:
diff changeset
2598 // * count must be already in ECX (guaranteed by LinearScan)
a61af66fc99e Initial load
duke
parents:
diff changeset
2599 // * left and dest must be equal
a61af66fc99e Initial load
duke
parents:
diff changeset
2600 // * tmp must be unused
a61af66fc99e Initial load
duke
parents:
diff changeset
2601 assert(count->as_register() == SHIFT_count, "count must be in ECX");
a61af66fc99e Initial load
duke
parents:
diff changeset
2602 assert(left == dest, "left and dest must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
2603 assert(tmp->is_illegal(), "wasting a register if tmp is allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
2604
a61af66fc99e Initial load
duke
parents:
diff changeset
2605 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2606 Register value = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2607 assert(value != SHIFT_count, "left cannot be ECX");
a61af66fc99e Initial load
duke
parents:
diff changeset
2608
a61af66fc99e Initial load
duke
parents:
diff changeset
2609 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2610 case lir_shl: __ shll(value); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2611 case lir_shr: __ sarl(value); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2612 case lir_ushr: __ shrl(value); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2613 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2614 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2615 } else if (left->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2616 Register lo = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2617 Register hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2618 assert(lo != SHIFT_count && hi != SHIFT_count, "left cannot be ECX");
a61af66fc99e Initial load
duke
parents:
diff changeset
2619
a61af66fc99e Initial load
duke
parents:
diff changeset
2620 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2621 case lir_shl: __ lshl(hi, lo); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2622 case lir_shr: __ lshr(hi, lo, true); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2623 case lir_ushr: __ lshr(hi, lo, false); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2624 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2625 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2626 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2627 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2628 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2629 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2630
a61af66fc99e Initial load
duke
parents:
diff changeset
2631
a61af66fc99e Initial load
duke
parents:
diff changeset
2632 void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2633 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2634 // first move left into dest so that left is not destroyed by the shift
a61af66fc99e Initial load
duke
parents:
diff changeset
2635 Register value = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2636 count = count & 0x1F; // Java spec
a61af66fc99e Initial load
duke
parents:
diff changeset
2637
a61af66fc99e Initial load
duke
parents:
diff changeset
2638 move_regs(left->as_register(), value);
a61af66fc99e Initial load
duke
parents:
diff changeset
2639 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2640 case lir_shl: __ shll(value, count); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2641 case lir_shr: __ sarl(value, count); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2642 case lir_ushr: __ shrl(value, count); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2643 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2644 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2645 } else if (dest->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2646 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2647 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2648 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2649 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2651
a61af66fc99e Initial load
duke
parents:
diff changeset
2652
a61af66fc99e Initial load
duke
parents:
diff changeset
2653 void LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2654 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
a61af66fc99e Initial load
duke
parents:
diff changeset
2655 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
2656 assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
2657 __ movl (Address(rsp, offset_from_rsp_in_bytes), r);
a61af66fc99e Initial load
duke
parents:
diff changeset
2658 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2659
a61af66fc99e Initial load
duke
parents:
diff changeset
2660
a61af66fc99e Initial load
duke
parents:
diff changeset
2661 void LIR_Assembler::store_parameter(jint c, int offset_from_rsp_in_words) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2662 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
a61af66fc99e Initial load
duke
parents:
diff changeset
2663 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
2664 assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
2665 __ movl (Address(rsp, offset_from_rsp_in_bytes), c);
a61af66fc99e Initial load
duke
parents:
diff changeset
2666 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2667
a61af66fc99e Initial load
duke
parents:
diff changeset
2668
a61af66fc99e Initial load
duke
parents:
diff changeset
2669 void LIR_Assembler::store_parameter(jobject o, int offset_from_rsp_in_words) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2670 assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
a61af66fc99e Initial load
duke
parents:
diff changeset
2671 int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
2672 assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
2673 __ movoop (Address(rsp, offset_from_rsp_in_bytes), o);
a61af66fc99e Initial load
duke
parents:
diff changeset
2674 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2675
a61af66fc99e Initial load
duke
parents:
diff changeset
2676
a61af66fc99e Initial load
duke
parents:
diff changeset
2677 // This code replaces a call to arraycopy; no exception may
a61af66fc99e Initial load
duke
parents:
diff changeset
2678 // be thrown in this code, they must be thrown in the System.arraycopy
a61af66fc99e Initial load
duke
parents:
diff changeset
2679 // activation frame; we could save some checks if this would not be the case
a61af66fc99e Initial load
duke
parents:
diff changeset
2680 void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2681 ciArrayKlass* default_type = op->expected_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
2682 Register src = op->src()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2683 Register dst = op->dst()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2684 Register src_pos = op->src_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2685 Register dst_pos = op->dst_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2686 Register length = op->length()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2687 Register tmp = op->tmp()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2688
a61af66fc99e Initial load
duke
parents:
diff changeset
2689 CodeStub* stub = op->stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
2690 int flags = op->flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
2691 BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2692 if (basic_type == T_ARRAY) basic_type = T_OBJECT;
a61af66fc99e Initial load
duke
parents:
diff changeset
2693
a61af66fc99e Initial load
duke
parents:
diff changeset
2694 // if we don't know anything or it's an object array, just go through the generic arraycopy
a61af66fc99e Initial load
duke
parents:
diff changeset
2695 if (default_type == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2696 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
2697 // save outgoing arguments on stack in case call to System.arraycopy is needed
a61af66fc99e Initial load
duke
parents:
diff changeset
2698 // HACK ALERT. This code used to push the parameters in a hardwired fashion
a61af66fc99e Initial load
duke
parents:
diff changeset
2699 // for interpreter calling conventions. Now we have to do it in new style conventions.
a61af66fc99e Initial load
duke
parents:
diff changeset
2700 // For the moment until C1 gets the new register allocator I just force all the
a61af66fc99e Initial load
duke
parents:
diff changeset
2701 // args to the right place (except the register args) and then on the back side
a61af66fc99e Initial load
duke
parents:
diff changeset
2702 // reload the register args properly if we go slow path. Yuck
a61af66fc99e Initial load
duke
parents:
diff changeset
2703
a61af66fc99e Initial load
duke
parents:
diff changeset
2704 // These are proper for the calling convention
a61af66fc99e Initial load
duke
parents:
diff changeset
2705
a61af66fc99e Initial load
duke
parents:
diff changeset
2706 store_parameter(length, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2707 store_parameter(dst_pos, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2708 store_parameter(dst, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2709
a61af66fc99e Initial load
duke
parents:
diff changeset
2710 // these are just temporary placements until we need to reload
a61af66fc99e Initial load
duke
parents:
diff changeset
2711 store_parameter(src_pos, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
2712 store_parameter(src, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2713 assert(src == rcx && src_pos == rdx, "mismatch in calling convention");
a61af66fc99e Initial load
duke
parents:
diff changeset
2714
a61af66fc99e Initial load
duke
parents:
diff changeset
2715 // pass arguments: may push as this is not a safepoint; SP must be fix at each safepoint
a61af66fc99e Initial load
duke
parents:
diff changeset
2716 __ pushl(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
2717 __ pushl(dst_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
2718 __ pushl(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2719 __ pushl(src_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
2720 __ pushl(src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2721 address entry = CAST_FROM_FN_PTR(address, Runtime1::arraycopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
2722 __ call_VM_leaf(entry, 5); // removes pushed parameter from the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2723
a61af66fc99e Initial load
duke
parents:
diff changeset
2724 __ cmpl(rax, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2725 __ jcc(Assembler::equal, *stub->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
2726
a61af66fc99e Initial load
duke
parents:
diff changeset
2727 // Reload values from the stack so they are where the stub
a61af66fc99e Initial load
duke
parents:
diff changeset
2728 // expects them.
a61af66fc99e Initial load
duke
parents:
diff changeset
2729 __ movl (dst, Address(rsp, 0*BytesPerWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
2730 __ movl (dst_pos, Address(rsp, 1*BytesPerWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
2731 __ movl (length, Address(rsp, 2*BytesPerWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
2732 __ movl (src_pos, Address(rsp, 3*BytesPerWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
2733 __ movl (src, Address(rsp, 4*BytesPerWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
2734 __ jmp(*stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2735
a61af66fc99e Initial load
duke
parents:
diff changeset
2736 __ bind(*stub->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
2737 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2738 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2739
a61af66fc99e Initial load
duke
parents:
diff changeset
2740 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
2741
29
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
2742 int elem_size = type2aelembytes(basic_type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2743 int shift_amount;
a61af66fc99e Initial load
duke
parents:
diff changeset
2744 Address::ScaleFactor scale;
a61af66fc99e Initial load
duke
parents:
diff changeset
2745
a61af66fc99e Initial load
duke
parents:
diff changeset
2746 switch (elem_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2747 case 1 :
a61af66fc99e Initial load
duke
parents:
diff changeset
2748 shift_amount = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2749 scale = Address::times_1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2750 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2751 case 2 :
a61af66fc99e Initial load
duke
parents:
diff changeset
2752 shift_amount = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2753 scale = Address::times_2;
a61af66fc99e Initial load
duke
parents:
diff changeset
2754 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2755 case 4 :
a61af66fc99e Initial load
duke
parents:
diff changeset
2756 shift_amount = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
2757 scale = Address::times_4;
a61af66fc99e Initial load
duke
parents:
diff changeset
2758 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2759 case 8 :
a61af66fc99e Initial load
duke
parents:
diff changeset
2760 shift_amount = 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
2761 scale = Address::times_8;
a61af66fc99e Initial load
duke
parents:
diff changeset
2762 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2763 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
2764 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2765 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2766
a61af66fc99e Initial load
duke
parents:
diff changeset
2767 Address src_length_addr = Address(src, arrayOopDesc::length_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2768 Address dst_length_addr = Address(dst, arrayOopDesc::length_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2769 Address src_klass_addr = Address(src, oopDesc::klass_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2770 Address dst_klass_addr = Address(dst, oopDesc::klass_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2771
a61af66fc99e Initial load
duke
parents:
diff changeset
2772 // test for NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
2773 if (flags & LIR_OpArrayCopy::src_null_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2774 __ testl(src, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2775 __ jcc(Assembler::zero, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2776 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2777 if (flags & LIR_OpArrayCopy::dst_null_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2778 __ testl(dst, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2779 __ jcc(Assembler::zero, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2780 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2781
a61af66fc99e Initial load
duke
parents:
diff changeset
2782 // check if negative
a61af66fc99e Initial load
duke
parents:
diff changeset
2783 if (flags & LIR_OpArrayCopy::src_pos_positive_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2784 __ testl(src_pos, src_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
2785 __ jcc(Assembler::less, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2786 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2787 if (flags & LIR_OpArrayCopy::dst_pos_positive_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2788 __ testl(dst_pos, dst_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
2789 __ jcc(Assembler::less, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2790 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2791 if (flags & LIR_OpArrayCopy::length_positive_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2792 __ testl(length, length);
a61af66fc99e Initial load
duke
parents:
diff changeset
2793 __ jcc(Assembler::less, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2794 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2795
a61af66fc99e Initial load
duke
parents:
diff changeset
2796 if (flags & LIR_OpArrayCopy::src_range_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2797 __ leal(tmp, Address(src_pos, length, Address::times_1, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
2798 __ cmpl(tmp, src_length_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2799 __ jcc(Assembler::above, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2800 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2801 if (flags & LIR_OpArrayCopy::dst_range_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2802 __ leal(tmp, Address(dst_pos, length, Address::times_1, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
2803 __ cmpl(tmp, dst_length_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2804 __ jcc(Assembler::above, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2805 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2806
a61af66fc99e Initial load
duke
parents:
diff changeset
2807 if (flags & LIR_OpArrayCopy::type_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2808 __ movl(tmp, src_klass_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2809 __ cmpl(tmp, dst_klass_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2810 __ jcc(Assembler::notEqual, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2811 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2812
a61af66fc99e Initial load
duke
parents:
diff changeset
2813 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2814 if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2815 // Sanity check the known type with the incoming class. For the
a61af66fc99e Initial load
duke
parents:
diff changeset
2816 // primitive case the types must match exactly with src.klass and
a61af66fc99e Initial load
duke
parents:
diff changeset
2817 // dst.klass each exactly matching the default type. For the
a61af66fc99e Initial load
duke
parents:
diff changeset
2818 // object array case, if no type check is needed then either the
a61af66fc99e Initial load
duke
parents:
diff changeset
2819 // dst type is exactly the expected type and the src type is a
a61af66fc99e Initial load
duke
parents:
diff changeset
2820 // subtype which we can't check or src is the same array as dst
a61af66fc99e Initial load
duke
parents:
diff changeset
2821 // but not necessarily exactly of type default_type.
a61af66fc99e Initial load
duke
parents:
diff changeset
2822 Label known_ok, halt;
a61af66fc99e Initial load
duke
parents:
diff changeset
2823 __ movoop(tmp, default_type->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
2824 if (basic_type != T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2825 __ cmpl(tmp, dst_klass_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2826 __ jcc(Assembler::notEqual, halt);
a61af66fc99e Initial load
duke
parents:
diff changeset
2827 __ cmpl(tmp, src_klass_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2828 __ jcc(Assembler::equal, known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
2829 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2830 __ cmpl(tmp, dst_klass_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2831 __ jcc(Assembler::equal, known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
2832 __ cmpl(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2833 __ jcc(Assembler::equal, known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
2834 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2835 __ bind(halt);
a61af66fc99e Initial load
duke
parents:
diff changeset
2836 __ stop("incorrect type information in arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2837 __ bind(known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
2838 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2839 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2840
a61af66fc99e Initial load
duke
parents:
diff changeset
2841 __ leal(tmp, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
a61af66fc99e Initial load
duke
parents:
diff changeset
2842 store_parameter(tmp, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2843 __ leal(tmp, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
a61af66fc99e Initial load
duke
parents:
diff changeset
2844 store_parameter(tmp, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2845 if (shift_amount > 0 && basic_type != T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2846 __ shll(length, shift_amount);
a61af66fc99e Initial load
duke
parents:
diff changeset
2847 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2848 store_parameter(length, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2849 if (basic_type == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2850 __ call_VM_leaf(CAST_FROM_FN_PTR(address, Runtime1::oop_arraycopy), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2851 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2852 __ call_VM_leaf(CAST_FROM_FN_PTR(address, Runtime1::primitive_arraycopy), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2853 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2854
a61af66fc99e Initial load
duke
parents:
diff changeset
2855 __ bind(*stub->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
2856 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2857
a61af66fc99e Initial load
duke
parents:
diff changeset
2858
a61af66fc99e Initial load
duke
parents:
diff changeset
2859 void LIR_Assembler::emit_lock(LIR_OpLock* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2860 Register obj = op->obj_opr()->as_register(); // may not be an oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2861 Register hdr = op->hdr_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2862 Register lock = op->lock_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2863 if (!UseFastLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2864 __ jmp(*op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2865 } else if (op->code() == lir_lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2866 Register scratch = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
2867 if (UseBiasedLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2868 scratch = op->scratch_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2869 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2870 assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
a61af66fc99e Initial load
duke
parents:
diff changeset
2871 // add debug info for NullPointerException only if one is possible
a61af66fc99e Initial load
duke
parents:
diff changeset
2872 int null_check_offset = __ lock_object(hdr, obj, lock, scratch, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2873 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2874 add_debug_info_for_null_check(null_check_offset, op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2875 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2876 // done
a61af66fc99e Initial load
duke
parents:
diff changeset
2877 } else if (op->code() == lir_unlock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2878 assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
a61af66fc99e Initial load
duke
parents:
diff changeset
2879 __ unlock_object(hdr, obj, lock, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2880 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2881 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2882 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2883 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
2884 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2885
a61af66fc99e Initial load
duke
parents:
diff changeset
2886
a61af66fc99e Initial load
duke
parents:
diff changeset
2887 void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2888 ciMethod* method = op->profiled_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
2889 int bci = op->profiled_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
2890
a61af66fc99e Initial load
duke
parents:
diff changeset
2891 // Update counter for all call types
a61af66fc99e Initial load
duke
parents:
diff changeset
2892 ciMethodData* md = method->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
2893 if (md == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2894 bailout("out of memory building methodDataOop");
a61af66fc99e Initial load
duke
parents:
diff changeset
2895 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2896 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2897 ciProfileData* data = md->bci_to_data(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
2898 assert(data->is_CounterData(), "need CounterData for calls");
a61af66fc99e Initial load
duke
parents:
diff changeset
2899 assert(op->mdo()->is_single_cpu(), "mdo must be allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
2900 Register mdo = op->mdo()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2901 __ movoop(mdo, md->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
2902 Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2903 __ addl(counter_addr, DataLayout::counter_increment);
a61af66fc99e Initial load
duke
parents:
diff changeset
2904 Bytecodes::Code bc = method->java_code_at_bci(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
2905 // Perform additional virtual call profiling for invokevirtual and
a61af66fc99e Initial load
duke
parents:
diff changeset
2906 // invokeinterface bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
2907 if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
2908 Tier1ProfileVirtualCalls) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2909 assert(op->recv()->is_single_cpu(), "recv must be allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
2910 Register recv = op->recv()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2911 assert_different_registers(mdo, recv);
a61af66fc99e Initial load
duke
parents:
diff changeset
2912 assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls");
a61af66fc99e Initial load
duke
parents:
diff changeset
2913 ciKlass* known_klass = op->known_holder();
a61af66fc99e Initial load
duke
parents:
diff changeset
2914 if (Tier1OptimizeVirtualCallProfiling && known_klass != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2915 // We know the type that will be seen at this call site; we can
a61af66fc99e Initial load
duke
parents:
diff changeset
2916 // statically update the methodDataOop rather than needing to do
a61af66fc99e Initial load
duke
parents:
diff changeset
2917 // dynamic tests on the receiver type
a61af66fc99e Initial load
duke
parents:
diff changeset
2918
a61af66fc99e Initial load
duke
parents:
diff changeset
2919 // NOTE: we should probably put a lock around this search to
a61af66fc99e Initial load
duke
parents:
diff changeset
2920 // avoid collisions by concurrent compilations
a61af66fc99e Initial load
duke
parents:
diff changeset
2921 ciVirtualCallData* vc_data = (ciVirtualCallData*) data;
a61af66fc99e Initial load
duke
parents:
diff changeset
2922 uint i;
a61af66fc99e Initial load
duke
parents:
diff changeset
2923 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2924 ciKlass* receiver = vc_data->receiver(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2925 if (known_klass->equals(receiver)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2926 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
a61af66fc99e Initial load
duke
parents:
diff changeset
2927 __ addl(data_addr, DataLayout::counter_increment);
a61af66fc99e Initial load
duke
parents:
diff changeset
2928 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2929 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2930 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2931
a61af66fc99e Initial load
duke
parents:
diff changeset
2932 // Receiver type not found in profile data; select an empty slot
a61af66fc99e Initial load
duke
parents:
diff changeset
2933
a61af66fc99e Initial load
duke
parents:
diff changeset
2934 // Note that this is less efficient than it should be because it
a61af66fc99e Initial load
duke
parents:
diff changeset
2935 // always does a write to the receiver part of the
a61af66fc99e Initial load
duke
parents:
diff changeset
2936 // VirtualCallData rather than just the first time
a61af66fc99e Initial load
duke
parents:
diff changeset
2937 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2938 ciKlass* receiver = vc_data->receiver(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2939 if (receiver == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2940 Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)));
a61af66fc99e Initial load
duke
parents:
diff changeset
2941 __ movoop(recv_addr, known_klass->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
2942 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
a61af66fc99e Initial load
duke
parents:
diff changeset
2943 __ addl(data_addr, DataLayout::counter_increment);
a61af66fc99e Initial load
duke
parents:
diff changeset
2944 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2945 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2946 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2947 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2948 __ movl(recv, Address(recv, oopDesc::klass_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2949 Label update_done;
a61af66fc99e Initial load
duke
parents:
diff changeset
2950 uint i;
a61af66fc99e Initial load
duke
parents:
diff changeset
2951 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2952 Label next_test;
a61af66fc99e Initial load
duke
parents:
diff changeset
2953 // See if the receiver is receiver[n].
a61af66fc99e Initial load
duke
parents:
diff changeset
2954 __ cmpl(recv, Address(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i))));
a61af66fc99e Initial load
duke
parents:
diff changeset
2955 __ jcc(Assembler::notEqual, next_test);
a61af66fc99e Initial load
duke
parents:
diff changeset
2956 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
a61af66fc99e Initial load
duke
parents:
diff changeset
2957 __ addl(data_addr, DataLayout::counter_increment);
a61af66fc99e Initial load
duke
parents:
diff changeset
2958 __ jmp(update_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2959 __ bind(next_test);
a61af66fc99e Initial load
duke
parents:
diff changeset
2960 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2961
a61af66fc99e Initial load
duke
parents:
diff changeset
2962 // Didn't find receiver; find next empty slot and fill it in
a61af66fc99e Initial load
duke
parents:
diff changeset
2963 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2964 Label next_test;
a61af66fc99e Initial load
duke
parents:
diff changeset
2965 Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)));
a61af66fc99e Initial load
duke
parents:
diff changeset
2966 __ cmpl(recv_addr, NULL_WORD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2967 __ jcc(Assembler::notEqual, next_test);
a61af66fc99e Initial load
duke
parents:
diff changeset
2968 __ movl(recv_addr, recv);
a61af66fc99e Initial load
duke
parents:
diff changeset
2969 __ movl(Address(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i))), DataLayout::counter_increment);
a61af66fc99e Initial load
duke
parents:
diff changeset
2970 if (i < (VirtualCallData::row_limit() - 1)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2971 __ jmp(update_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2972 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2973 __ bind(next_test);
a61af66fc99e Initial load
duke
parents:
diff changeset
2974 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2975
a61af66fc99e Initial load
duke
parents:
diff changeset
2976 __ bind(update_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2977 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2978 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2979 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2980
a61af66fc99e Initial load
duke
parents:
diff changeset
2981
a61af66fc99e Initial load
duke
parents:
diff changeset
2982 void LIR_Assembler::emit_delay(LIR_OpDelay*) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2983 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2984 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2985
a61af66fc99e Initial load
duke
parents:
diff changeset
2986
a61af66fc99e Initial load
duke
parents:
diff changeset
2987 void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2988 __ leal(dst->as_register(), frame_map()->address_for_monitor_lock(monitor_no));
a61af66fc99e Initial load
duke
parents:
diff changeset
2989 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2990
a61af66fc99e Initial load
duke
parents:
diff changeset
2991
a61af66fc99e Initial load
duke
parents:
diff changeset
2992 void LIR_Assembler::align_backward_branch_target() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2993 __ align(BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
2994 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2995
a61af66fc99e Initial load
duke
parents:
diff changeset
2996
a61af66fc99e Initial load
duke
parents:
diff changeset
2997 void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2998 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2999 __ negl(left->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
3000 move_regs(left->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
3001
a61af66fc99e Initial load
duke
parents:
diff changeset
3002 } else if (left->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3003 Register lo = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
3004 Register hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
3005 __ lneg(hi, lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
3006 if (dest->as_register_lo() == hi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3007 assert(dest->as_register_hi() != lo, "destroying register");
a61af66fc99e Initial load
duke
parents:
diff changeset
3008 move_regs(hi, dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
3009 move_regs(lo, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
3010 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3011 move_regs(lo, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
3012 move_regs(hi, dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
3013 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3014
a61af66fc99e Initial load
duke
parents:
diff changeset
3015 } else if (dest->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3016 if (left->as_xmm_float_reg() != dest->as_xmm_float_reg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3017 __ movflt(dest->as_xmm_float_reg(), left->as_xmm_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3018 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3019 __ xorps(dest->as_xmm_float_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
3020 ExternalAddress((address)float_signflip_pool));
a61af66fc99e Initial load
duke
parents:
diff changeset
3021
a61af66fc99e Initial load
duke
parents:
diff changeset
3022 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3023 if (left->as_xmm_double_reg() != dest->as_xmm_double_reg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3024 __ movdbl(dest->as_xmm_double_reg(), left->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3025 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3026 __ xorpd(dest->as_xmm_double_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
3027 ExternalAddress((address)double_signflip_pool));
a61af66fc99e Initial load
duke
parents:
diff changeset
3028
a61af66fc99e Initial load
duke
parents:
diff changeset
3029 } else if (left->is_single_fpu() || left->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3030 assert(left->fpu() == 0, "arg must be on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3031 assert(dest->fpu() == 0, "dest must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3032 __ fchs();
a61af66fc99e Initial load
duke
parents:
diff changeset
3033
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::leal(LIR_Opr addr, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3041 assert(addr->is_address() && dest->is_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
3042 Register reg = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
3043 __ leal(dest->as_register(), as_Address(addr->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3044 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3045
a61af66fc99e Initial load
duke
parents:
diff changeset
3046
a61af66fc99e Initial load
duke
parents:
diff changeset
3047
a61af66fc99e Initial load
duke
parents:
diff changeset
3048 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
3049 assert(!tmp->is_valid(), "don't need temporary");
a61af66fc99e Initial load
duke
parents:
diff changeset
3050 __ call(RuntimeAddress(dest));
a61af66fc99e Initial load
duke
parents:
diff changeset
3051 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3052 add_call_info_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
3053 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3054 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3055
a61af66fc99e Initial load
duke
parents:
diff changeset
3056
a61af66fc99e Initial load
duke
parents:
diff changeset
3057 void LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3058 assert(type == T_LONG, "only for volatile long fields");
a61af66fc99e Initial load
duke
parents:
diff changeset
3059
a61af66fc99e Initial load
duke
parents:
diff changeset
3060 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3061 add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
3062 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3063
a61af66fc99e Initial load
duke
parents:
diff changeset
3064 if (src->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3065 if (dest->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3066 __ movd(dest->as_register_lo(), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3067 __ psrlq(src->as_xmm_double_reg(), 32);
a61af66fc99e Initial load
duke
parents:
diff changeset
3068 __ movd(dest->as_register_hi(), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3069 } else if (dest->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3070 __ movdbl(frame_map()->address_for_slot(dest->double_stack_ix()), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3071 } else if (dest->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3072 __ movdbl(as_Address(dest->as_address_ptr()), src->as_xmm_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
3073 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3074 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3075 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3076
a61af66fc99e Initial load
duke
parents:
diff changeset
3077 } else if (dest->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3078 if (src->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3079 __ movdbl(dest->as_xmm_double_reg(), frame_map()->address_for_slot(src->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3080 } else if (src->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3081 __ movdbl(dest->as_xmm_double_reg(), as_Address(src->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3082 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3083 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3084 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3085
a61af66fc99e Initial load
duke
parents:
diff changeset
3086 } else if (src->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3087 assert(src->fpu_regnrLo() == 0, "must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3088 if (dest->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3089 __ fistp_d(frame_map()->address_for_slot(dest->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3090 } else if (dest->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3091 __ fistp_d(as_Address(dest->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3092 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3093 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3094 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3095
a61af66fc99e Initial load
duke
parents:
diff changeset
3096 } else if (dest->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3097 assert(dest->fpu_regnrLo() == 0, "must be TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
3098 if (src->is_double_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3099 __ fild_d(frame_map()->address_for_slot(src->double_stack_ix()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3100 } else if (src->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3101 __ fild_d(as_Address(src->as_address_ptr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3102 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3103 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3105 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3106 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3109
a61af66fc99e Initial load
duke
parents:
diff changeset
3110
a61af66fc99e Initial load
duke
parents:
diff changeset
3111 void LIR_Assembler::membar() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3112 __ membar();
a61af66fc99e Initial load
duke
parents:
diff changeset
3113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3114
a61af66fc99e Initial load
duke
parents:
diff changeset
3115 void LIR_Assembler::membar_acquire() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3116 // No x86 machines currently require load fences
a61af66fc99e Initial load
duke
parents:
diff changeset
3117 // __ load_fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
3118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3119
a61af66fc99e Initial load
duke
parents:
diff changeset
3120 void LIR_Assembler::membar_release() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3121 // No x86 machines currently require store fences
a61af66fc99e Initial load
duke
parents:
diff changeset
3122 // __ store_fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
3123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3124
a61af66fc99e Initial load
duke
parents:
diff changeset
3125 void LIR_Assembler::get_thread(LIR_Opr result_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3126 assert(result_reg->is_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
3127 __ get_thread(result_reg->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
3128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3129
a61af66fc99e Initial load
duke
parents:
diff changeset
3130
a61af66fc99e Initial load
duke
parents:
diff changeset
3131 void LIR_Assembler::peephole(LIR_List*) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3132 // do nothing for now
a61af66fc99e Initial load
duke
parents:
diff changeset
3133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3134
a61af66fc99e Initial load
duke
parents:
diff changeset
3135
a61af66fc99e Initial load
duke
parents:
diff changeset
3136 #undef __