annotate src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @ 1201:24128c2ffa87

6921339: backout 6917766 Reviewed-by: mr
author twisti
date Fri, 29 Jan 2010 08:33:24 -0800
parents ba263cfb7611
children 18a389214829
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
2 * Copyright 2000-2009 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_sparc.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 #define __ _masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 //------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 bool LIR_Assembler::is_small_constant(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 if (opr->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 LIR_Const* constant = opr->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
37 switch (constant->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 case T_INT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 jint value = constant->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
40 return Assembler::is_simm13(value);
a61af66fc99e Initial load
duke
parents:
diff changeset
41 }
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
44 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 }
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 bool LIR_Assembler::is_single_instruction(LIR_Op* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 switch (op->code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 case lir_null_check:
a61af66fc99e Initial load
duke
parents:
diff changeset
54 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 case lir_add:
a61af66fc99e Initial load
duke
parents:
diff changeset
58 case lir_ushr:
a61af66fc99e Initial load
duke
parents:
diff changeset
59 case lir_shr:
a61af66fc99e Initial load
duke
parents:
diff changeset
60 case lir_shl:
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // integer shifts and adds are always one instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
62 return op->result_opr()->is_single_cpu();
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 case lir_move: {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 LIR_Op1* op1 = op->as_Op1();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 LIR_Opr src = op1->in_opr();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 LIR_Opr dst = op1->result_opr();
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 if (src == dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 NEEDS_CLEANUP;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // this works around a problem where moves with the same src and dst
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // end up in the delay slot and then the assembler swallows the mov
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // since it has no effect and then it complains because the delay slot
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // is empty. returning false stops the optimizer from putting this in
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // the delay slot
a61af66fc99e Initial load
duke
parents:
diff changeset
77 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // don't put moves involving oops into the delay slot since the VerifyOops code
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // will make it much larger than a single instruction.
a61af66fc99e Initial load
duke
parents:
diff changeset
82 if (VerifyOops) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 if (src->is_double_cpu() || dst->is_double_cpu() || op1->patch_code() != lir_patch_none ||
a61af66fc99e Initial load
duke
parents:
diff changeset
87 ((src->is_double_fpu() || dst->is_double_fpu()) && op1->move_kind() != lir_move_normal)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 if (dst->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 if (src->is_address() && Assembler::is_simm13(src->as_address_ptr()->disp())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 return !PatchALot;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 } else if (src->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 return true;
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 if (src->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 if (dst->is_address() && Assembler::is_simm13(dst->as_address_ptr()->disp())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 return !PatchALot;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 } else if (dst->is_single_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 if (dst->is_register() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
108 ((src->is_register() && src->is_single_word() && src->is_same_type(dst)) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
109 (src->is_constant() && LIR_Assembler::is_small_constant(op->as_Op1()->in_opr())))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
117 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
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::receiverOpr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 return FrameMap::O0_oop_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
a61af66fc99e Initial load
duke
parents:
diff changeset
128 LIR_Opr LIR_Assembler::incomingReceiverOpr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 return FrameMap::I0_oop_opr;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 LIR_Opr LIR_Assembler::osrBufferPointer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 return FrameMap::I0_opr;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 int LIR_Assembler::initial_frame_size_in_bytes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 return in_bytes(frame_map()->framesize_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // inline cache check: the inline cached class is in G5_inline_cache_reg(G5);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // we fetch the class of the receiver (O0) and compare it with the cached class.
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // If they do not match we jump to slow case.
a61af66fc99e Initial load
duke
parents:
diff changeset
146 int LIR_Assembler::check_icache() {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 int offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
148 __ inline_cache_check(O0, G5_inline_cache_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 return offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 void LIR_Assembler::osr_entry() {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // On-stack-replacement entry sequence (interpreter frame layout described in interpreter_sparc.cpp):
a61af66fc99e Initial load
duke
parents:
diff changeset
155 //
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // 1. Create a new compiled activation.
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // 2. Initialize local variables in the compiled activation. The expression stack must be empty
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // at the osr_bci; it is not initialized.
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // 3. Jump to the continuation address in compiled code to resume execution.
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // OSR entry point
a61af66fc99e Initial load
duke
parents:
diff changeset
162 offsets()->set_value(CodeOffsets::OSR_Entry, code_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
163 BlockBegin* osr_entry = compilation()->hir()->osr_entry();
a61af66fc99e Initial load
duke
parents:
diff changeset
164 ValueStack* entry_state = osr_entry->end()->state();
a61af66fc99e Initial load
duke
parents:
diff changeset
165 int number_of_locks = entry_state->locks_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // Create a frame for the compiled activation.
a61af66fc99e Initial load
duke
parents:
diff changeset
168 __ build_frame(initial_frame_size_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // OSR buffer is
a61af66fc99e Initial load
duke
parents:
diff changeset
171 //
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // locals[nlocals-1..0]
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // monitors[number_of_locks-1..0]
a61af66fc99e Initial load
duke
parents:
diff changeset
174 //
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // locals is a direct copy of the interpreter frame so in the osr buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // so first slot in the local array is the last local from the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // and last slot is local[0] (receiver) from the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
178 //
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // Similarly with locks. The first lock slot in the osr buffer is the nth lock
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // from the interpreter frame, the nth lock slot in the osr buffer is 0th lock
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // in the interpreter frame (the method lock if a sync method)
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // Initialize monitors in the compiled activation.
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // I0: pointer to osr buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
185 //
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // All other registers are dead at this point and the locals will be
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // copied into place by code emitted in the IR.
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 Register OSR_buf = osrBufferPointer()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
190 { assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below");
a61af66fc99e Initial load
duke
parents:
diff changeset
191 int monitor_offset = BytesPerWord * method()->max_locals() +
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
192 (2 * BytesPerWord) * (number_of_locks - 1);
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
193 // SharedRuntime::OSR_migration_begin() packs BasicObjectLocks in
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
194 // the OSR buffer using 2 word entries: first the lock and then
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
195 // the oop.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
196 for (int i = 0; i < number_of_locks; i++) {
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
197 int slot_offset = monitor_offset - ((i * 2) * BytesPerWord);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
198 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // verify the interpreter's monitor has a non-null object
a61af66fc99e Initial load
duke
parents:
diff changeset
200 {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 Label L;
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
202 __ ld_ptr(OSR_buf, slot_offset + 1*BytesPerWord, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
203 __ cmp(G0, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 __ br(Assembler::notEqual, false, Assembler::pt, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
206 __ stop("locked object is NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
207 __ bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // Copy the lock field into the compiled activation.
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
211 __ ld_ptr(OSR_buf, slot_offset + 0, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
212 __ st_ptr(O7, frame_map()->address_for_monitor_lock(i));
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
213 __ ld_ptr(OSR_buf, slot_offset + 1*BytesPerWord, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
214 __ st_ptr(O7, frame_map()->address_for_monitor_object(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // Optimized Library calls
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // This is the fast version of java.lang.String.compare; it has not
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // OSR-entry and therefore, we generate a slow version for OSR's
a61af66fc99e Initial load
duke
parents:
diff changeset
223 void LIR_Assembler::emit_string_compare(LIR_Opr left, LIR_Opr right, LIR_Opr dst, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 Register str0 = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
225 Register str1 = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 Label Ldone;
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 Register result = dst->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
230 {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // Get a pointer to the first character of string0 in tmp0 and get string0.count in str0
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // Get a pointer to the first character of string1 in tmp1 and get string1.count in str1
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // Also, get string0.count-string1.count in o7 and get the condition code set
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // Note: some instructions have been hoisted for better instruction scheduling
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 Register tmp0 = L0;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 Register tmp1 = L1;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 Register tmp2 = L2;
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 int value_offset = java_lang_String:: value_offset_in_bytes(); // char array
a61af66fc99e Initial load
duke
parents:
diff changeset
241 int offset_offset = java_lang_String::offset_offset_in_bytes(); // first character position
a61af66fc99e Initial load
duke
parents:
diff changeset
242 int count_offset = java_lang_String:: count_offset_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
243
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
244 __ ld_ptr(str0, value_offset, tmp0);
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
245 __ ld(str0, offset_offset, tmp2);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
246 __ add(tmp0, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp0);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
247 __ ld(str0, count_offset, str0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
248 __ sll(tmp2, exact_log2(sizeof(jchar)), tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // str1 may be null
a61af66fc99e Initial load
duke
parents:
diff changeset
251 add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
252
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
253 __ ld_ptr(str1, value_offset, tmp1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
254 __ add(tmp0, tmp2, tmp0);
a61af66fc99e Initial load
duke
parents:
diff changeset
255
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
256 __ ld(str1, offset_offset, tmp2);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
257 __ add(tmp1, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp1);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
258 __ ld(str1, count_offset, str1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
259 __ sll(tmp2, exact_log2(sizeof(jchar)), tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
260 __ subcc(str0, str1, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 __ add(tmp1, tmp2, tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // Compute the minimum of the string lengths, scale it and store it in limit
a61af66fc99e Initial load
duke
parents:
diff changeset
266 Register count0 = I0;
a61af66fc99e Initial load
duke
parents:
diff changeset
267 Register count1 = I1;
a61af66fc99e Initial load
duke
parents:
diff changeset
268 Register limit = L3;
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 Label Lskip;
a61af66fc99e Initial load
duke
parents:
diff changeset
271 __ sll(count0, exact_log2(sizeof(jchar)), limit); // string0 is shorter
a61af66fc99e Initial load
duke
parents:
diff changeset
272 __ br(Assembler::greater, true, Assembler::pt, Lskip);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 __ delayed()->sll(count1, exact_log2(sizeof(jchar)), limit); // string1 is shorter
a61af66fc99e Initial load
duke
parents:
diff changeset
274 __ bind(Lskip);
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // If either string is empty (or both of them) the result is the difference in lengths
a61af66fc99e Initial load
duke
parents:
diff changeset
277 __ cmp(limit, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 __ br(Assembler::equal, true, Assembler::pn, Ldone);
a61af66fc99e Initial load
duke
parents:
diff changeset
279 __ delayed()->mov(O7, result); // result is difference in lengths
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // Neither string is empty
a61af66fc99e Initial load
duke
parents:
diff changeset
284 Label Lloop;
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286 Register base0 = L0;
a61af66fc99e Initial load
duke
parents:
diff changeset
287 Register base1 = L1;
a61af66fc99e Initial load
duke
parents:
diff changeset
288 Register chr0 = I0;
a61af66fc99e Initial load
duke
parents:
diff changeset
289 Register chr1 = I1;
a61af66fc99e Initial load
duke
parents:
diff changeset
290 Register limit = L3;
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 // Shift base0 and base1 to the end of the arrays, negate limit
a61af66fc99e Initial load
duke
parents:
diff changeset
293 __ add(base0, limit, base0);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 __ add(base1, limit, base1);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 __ neg(limit); // limit = -min{string0.count, strin1.count}
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 __ lduh(base0, limit, chr0);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 __ bind(Lloop);
a61af66fc99e Initial load
duke
parents:
diff changeset
299 __ lduh(base1, limit, chr1);
a61af66fc99e Initial load
duke
parents:
diff changeset
300 __ subcc(chr0, chr1, chr0);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 __ br(Assembler::notZero, false, Assembler::pn, Ldone);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 assert(chr0 == result, "result must be pre-placed");
a61af66fc99e Initial load
duke
parents:
diff changeset
303 __ delayed()->inccc(limit, sizeof(jchar));
a61af66fc99e Initial load
duke
parents:
diff changeset
304 __ br(Assembler::notZero, true, Assembler::pt, Lloop);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 __ delayed()->lduh(base0, limit, chr0);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 // If strings are equal up to min length, return the length difference.
a61af66fc99e Initial load
duke
parents:
diff changeset
309 __ mov(O7, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311 // Otherwise, return the difference between the first mismatched chars.
a61af66fc99e Initial load
duke
parents:
diff changeset
312 __ bind(Ldone);
a61af66fc99e Initial load
duke
parents:
diff changeset
313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 // --------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 void LIR_Assembler::monitorexit(LIR_Opr obj_opr, LIR_Opr lock_opr, Register hdr, int monitor_no) {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 if (!GenerateSynchronizationCode) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 Register obj_reg = obj_opr->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
322 Register lock_reg = lock_opr->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 Address mon_addr = frame_map()->address_for_monitor_lock(monitor_no);
a61af66fc99e Initial load
duke
parents:
diff changeset
325 Register reg = mon_addr.base();
a61af66fc99e Initial load
duke
parents:
diff changeset
326 int offset = mon_addr.disp();
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // compute pointer to BasicLock
a61af66fc99e Initial load
duke
parents:
diff changeset
328 if (mon_addr.is_simm13()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
329 __ add(reg, offset, lock_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
332 __ set(offset, lock_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
333 __ add(reg, lock_reg, lock_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
335 // unlock object
a61af66fc99e Initial load
duke
parents:
diff changeset
336 MonitorAccessStub* slow_case = new MonitorExitStub(lock_opr, UseFastLocking, monitor_no);
a61af66fc99e Initial load
duke
parents:
diff changeset
337 // _slow_case_stubs->append(slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // temporary fix: must be created after exceptionhandler, therefore as call stub
a61af66fc99e Initial load
duke
parents:
diff changeset
339 _slow_case_stubs->append(slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
340 if (UseFastLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // try inlined fast unlocking first, revert to slow locking if it fails
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // note: lock_reg points to the displaced header since the displaced header offset is 0!
a61af66fc99e Initial load
duke
parents:
diff changeset
343 assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
a61af66fc99e Initial load
duke
parents:
diff changeset
344 __ unlock_object(hdr, obj_reg, lock_reg, *slow_case->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
345 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // always do slow unlocking
a61af66fc99e Initial load
duke
parents:
diff changeset
347 // note: the slow unlocking code could be inlined here, however if we use
a61af66fc99e Initial load
duke
parents:
diff changeset
348 // slow unlocking, speed doesn't matter anyway and this solution is
a61af66fc99e Initial load
duke
parents:
diff changeset
349 // simpler and requires less duplicated code - additionally, the
a61af66fc99e Initial load
duke
parents:
diff changeset
350 // slow unlocking code is the same in either case which simplifies
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
352 __ br(Assembler::always, false, Assembler::pt, *slow_case->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
353 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
355 // done
a61af66fc99e Initial load
duke
parents:
diff changeset
356 __ bind(*slow_case->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
360 void LIR_Assembler::emit_exception_handler() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // if the last instruction is a call (typically to do a throw which
a61af66fc99e Initial load
duke
parents:
diff changeset
362 // is coming at the end after block reordering) the return address
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // must still point into the code area in order to avoid assertion
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // failures when searching for the corresponding bci => add a nop
a61af66fc99e Initial load
duke
parents:
diff changeset
365 // (was bug 5/14/1999 - gri)
a61af66fc99e Initial load
duke
parents:
diff changeset
366 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 // generate code for exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
369 ciMethod* method = compilation()->method();
a61af66fc99e Initial load
duke
parents:
diff changeset
370
a61af66fc99e Initial load
duke
parents:
diff changeset
371 address handler_base = __ start_a_stub(exception_handler_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
372
a61af66fc99e Initial load
duke
parents:
diff changeset
373 if (handler_base == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
374 // not enough space left for the handler
a61af66fc99e Initial load
duke
parents:
diff changeset
375 bailout("exception handler overflow");
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
376 return;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
377 }
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
378 #ifdef ASSERT
0
a61af66fc99e Initial load
duke
parents:
diff changeset
379 int offset = code_offset();
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
380 #endif // ASSERT
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
381 compilation()->offsets()->set_value(CodeOffsets::Exceptions, code_offset());
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
382
0
a61af66fc99e Initial load
duke
parents:
diff changeset
383
780
c96bf21b756f 6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents: 727
diff changeset
384 if (compilation()->has_exception_handlers() || compilation()->env()->jvmti_can_post_exceptions()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
385 __ call(Runtime1::entry_for(Runtime1::handle_exception_id), relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
386 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
388
a61af66fc99e Initial load
duke
parents:
diff changeset
389 __ call(Runtime1::entry_for(Runtime1::unwind_exception_id), relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
390 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
391 debug_only(__ stop("should have gone to the caller");)
a61af66fc99e Initial load
duke
parents:
diff changeset
392 assert(code_offset() - offset <= exception_handler_size, "overflow");
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
393
0
a61af66fc99e Initial load
duke
parents:
diff changeset
394 __ end_a_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
395 }
a61af66fc99e Initial load
duke
parents:
diff changeset
396
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
397 void LIR_Assembler::emit_deopt_handler() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
398 // if the last instruction is a call (typically to do a throw which
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // is coming at the end after block reordering) the return address
a61af66fc99e Initial load
duke
parents:
diff changeset
400 // must still point into the code area in order to avoid assertion
a61af66fc99e Initial load
duke
parents:
diff changeset
401 // failures when searching for the corresponding bci => add a nop
a61af66fc99e Initial load
duke
parents:
diff changeset
402 // (was bug 5/14/1999 - gri)
a61af66fc99e Initial load
duke
parents:
diff changeset
403 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 // generate code for deopt handler
a61af66fc99e Initial load
duke
parents:
diff changeset
406 ciMethod* method = compilation()->method();
a61af66fc99e Initial load
duke
parents:
diff changeset
407 address handler_base = __ start_a_stub(deopt_handler_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
408 if (handler_base == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
409 // not enough space left for the handler
a61af66fc99e Initial load
duke
parents:
diff changeset
410 bailout("deopt handler overflow");
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
411 return;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
413 #ifdef ASSERT
0
a61af66fc99e Initial load
duke
parents:
diff changeset
414 int offset = code_offset();
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
415 #endif // ASSERT
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
416 compilation()->offsets()->set_value(CodeOffsets::Deopt, code_offset());
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
417
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
418 AddressLiteral deopt_blob(SharedRuntime::deopt_blob()->unpack());
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
419
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
420 __ JUMP(deopt_blob, G3_scratch, 0); // sethi;jmp
0
a61af66fc99e Initial load
duke
parents:
diff changeset
421 __ delayed()->nop();
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
422
0
a61af66fc99e Initial load
duke
parents:
diff changeset
423 assert(code_offset() - offset <= deopt_handler_size, "overflow");
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
424
0
a61af66fc99e Initial load
duke
parents:
diff changeset
425 debug_only(__ stop("should have gone to the caller");)
1201
24128c2ffa87 6921339: backout 6917766
twisti
parents: 1200
diff changeset
426
0
a61af66fc99e Initial load
duke
parents:
diff changeset
427 __ end_a_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
428 }
a61af66fc99e Initial load
duke
parents:
diff changeset
429
a61af66fc99e Initial load
duke
parents:
diff changeset
430
a61af66fc99e Initial load
duke
parents:
diff changeset
431 void LIR_Assembler::jobject2reg(jobject o, Register reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
432 if (o == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 __ set(NULL_WORD, reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
434 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
435 int oop_index = __ oop_recorder()->find_index(o);
a61af66fc99e Initial load
duke
parents:
diff changeset
436 RelocationHolder rspec = oop_Relocation::spec(oop_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
437 __ set(NULL_WORD, reg, rspec); // Will be set when the nmethod is created
a61af66fc99e Initial load
duke
parents:
diff changeset
438 }
a61af66fc99e Initial load
duke
parents:
diff changeset
439 }
a61af66fc99e Initial load
duke
parents:
diff changeset
440
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442 void LIR_Assembler::jobject2reg_with_patching(Register reg, CodeEmitInfo *info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 // Allocate a new index in oop table to hold the oop once it's been patched
a61af66fc99e Initial load
duke
parents:
diff changeset
444 int oop_index = __ oop_recorder()->allocate_index((jobject)NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
445 PatchingStub* patch = new PatchingStub(_masm, PatchingStub::load_klass_id, oop_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
446
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
447 AddressLiteral addrlit(NULL, oop_Relocation::spec(oop_index));
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
448 assert(addrlit.rspec().type() == relocInfo::oop_type, "must be an oop reloc");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
449 // It may not seem necessary to use a sethi/add pair to load a NULL into dest, but the
a61af66fc99e Initial load
duke
parents:
diff changeset
450 // NULL will be dynamically patched later and the patched value may be large. We must
a61af66fc99e Initial load
duke
parents:
diff changeset
451 // therefore generate the sethi/add as a placeholders
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
452 __ patchable_set(addrlit, reg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
453
a61af66fc99e Initial load
duke
parents:
diff changeset
454 patching_epilog(patch, lir_patch_normal, reg, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
456
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 void LIR_Assembler::emit_op3(LIR_Op3* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 Register Rdividend = op->in_opr1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
460 Register Rdivisor = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
461 Register Rscratch = op->in_opr3()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
462 Register Rresult = op->result_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
463 int divisor = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
464
a61af66fc99e Initial load
duke
parents:
diff changeset
465 if (op->in_opr2()->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
466 Rdivisor = op->in_opr2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
467 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
468 divisor = op->in_opr2()->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
469 assert(Assembler::is_simm13(divisor), "can only handle simm13");
a61af66fc99e Initial load
duke
parents:
diff changeset
470 }
a61af66fc99e Initial load
duke
parents:
diff changeset
471
a61af66fc99e Initial load
duke
parents:
diff changeset
472 assert(Rdividend != Rscratch, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
473 assert(Rdivisor != Rscratch, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
474 assert(op->code() == lir_idiv || op->code() == lir_irem, "Must be irem or idiv");
a61af66fc99e Initial load
duke
parents:
diff changeset
475
a61af66fc99e Initial load
duke
parents:
diff changeset
476 if (Rdivisor == noreg && is_power_of_2(divisor)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
477 // convert division by a power of two into some shifts and logical operations
a61af66fc99e Initial load
duke
parents:
diff changeset
478 if (op->code() == lir_idiv) {
a61af66fc99e Initial load
duke
parents:
diff changeset
479 if (divisor == 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
480 __ srl(Rdividend, 31, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
481 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
482 __ sra(Rdividend, 31, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
483 __ and3(Rscratch, divisor - 1, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
484 }
a61af66fc99e Initial load
duke
parents:
diff changeset
485 __ add(Rdividend, Rscratch, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
486 __ sra(Rscratch, log2_intptr(divisor), Rresult);
a61af66fc99e Initial load
duke
parents:
diff changeset
487 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
488 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
489 if (divisor == 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
490 __ srl(Rdividend, 31, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
491 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
492 __ sra(Rdividend, 31, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
493 __ and3(Rscratch, divisor - 1,Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
495 __ add(Rdividend, Rscratch, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
496 __ andn(Rscratch, divisor - 1,Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
497 __ sub(Rdividend, Rscratch, Rresult);
a61af66fc99e Initial load
duke
parents:
diff changeset
498 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
499 }
a61af66fc99e Initial load
duke
parents:
diff changeset
500 }
a61af66fc99e Initial load
duke
parents:
diff changeset
501
a61af66fc99e Initial load
duke
parents:
diff changeset
502 __ sra(Rdividend, 31, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
503 __ wry(Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
504 if (!VM_Version::v9_instructions_work()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // v9 doesn't require these nops
a61af66fc99e Initial load
duke
parents:
diff changeset
506 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
507 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
508 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
509 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
510 }
a61af66fc99e Initial load
duke
parents:
diff changeset
511
a61af66fc99e Initial load
duke
parents:
diff changeset
512 add_debug_info_for_div0_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
513
a61af66fc99e Initial load
duke
parents:
diff changeset
514 if (Rdivisor != noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
515 __ sdivcc(Rdividend, Rdivisor, (op->code() == lir_idiv ? Rresult : Rscratch));
a61af66fc99e Initial load
duke
parents:
diff changeset
516 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
517 assert(Assembler::is_simm13(divisor), "can only handle simm13");
a61af66fc99e Initial load
duke
parents:
diff changeset
518 __ sdivcc(Rdividend, divisor, (op->code() == lir_idiv ? Rresult : Rscratch));
a61af66fc99e Initial load
duke
parents:
diff changeset
519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
520
a61af66fc99e Initial load
duke
parents:
diff changeset
521 Label skip;
a61af66fc99e Initial load
duke
parents:
diff changeset
522 __ br(Assembler::overflowSet, true, Assembler::pn, skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
523 __ delayed()->Assembler::sethi(0x80000000, (op->code() == lir_idiv ? Rresult : Rscratch));
a61af66fc99e Initial load
duke
parents:
diff changeset
524 __ bind(skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526 if (op->code() == lir_irem) {
a61af66fc99e Initial load
duke
parents:
diff changeset
527 if (Rdivisor != noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
528 __ smul(Rscratch, Rdivisor, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
529 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
530 __ smul(Rscratch, divisor, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
531 }
a61af66fc99e Initial load
duke
parents:
diff changeset
532 __ sub(Rdividend, Rscratch, Rresult);
a61af66fc99e Initial load
duke
parents:
diff changeset
533 }
a61af66fc99e Initial load
duke
parents:
diff changeset
534 }
a61af66fc99e Initial load
duke
parents:
diff changeset
535
a61af66fc99e Initial load
duke
parents:
diff changeset
536
a61af66fc99e Initial load
duke
parents:
diff changeset
537 void LIR_Assembler::emit_opBranch(LIR_OpBranch* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
538 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
539 assert(op->block() == NULL || op->block()->label() == op->label(), "wrong label");
a61af66fc99e Initial load
duke
parents:
diff changeset
540 if (op->block() != NULL) _branch_target_blocks.append(op->block());
a61af66fc99e Initial load
duke
parents:
diff changeset
541 if (op->ublock() != NULL) _branch_target_blocks.append(op->ublock());
a61af66fc99e Initial load
duke
parents:
diff changeset
542 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
543 assert(op->info() == NULL, "shouldn't have CodeEmitInfo");
a61af66fc99e Initial load
duke
parents:
diff changeset
544
a61af66fc99e Initial load
duke
parents:
diff changeset
545 if (op->cond() == lir_cond_always) {
a61af66fc99e Initial load
duke
parents:
diff changeset
546 __ br(Assembler::always, false, Assembler::pt, *(op->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
547 } else if (op->code() == lir_cond_float_branch) {
a61af66fc99e Initial load
duke
parents:
diff changeset
548 assert(op->ublock() != NULL, "must have unordered successor");
a61af66fc99e Initial load
duke
parents:
diff changeset
549 bool is_unordered = (op->ublock() == op->block());
a61af66fc99e Initial load
duke
parents:
diff changeset
550 Assembler::Condition acond;
a61af66fc99e Initial load
duke
parents:
diff changeset
551 switch (op->cond()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
552 case lir_cond_equal: acond = Assembler::f_equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
553 case lir_cond_notEqual: acond = Assembler::f_notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
554 case lir_cond_less: acond = (is_unordered ? Assembler::f_unorderedOrLess : Assembler::f_less); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
555 case lir_cond_greater: acond = (is_unordered ? Assembler::f_unorderedOrGreater : Assembler::f_greater); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
556 case lir_cond_lessEqual: acond = (is_unordered ? Assembler::f_unorderedOrLessOrEqual : Assembler::f_lessOrEqual); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
557 case lir_cond_greaterEqual: acond = (is_unordered ? Assembler::f_unorderedOrGreaterOrEqual: Assembler::f_greaterOrEqual); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
558 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
559 };
a61af66fc99e Initial load
duke
parents:
diff changeset
560
a61af66fc99e Initial load
duke
parents:
diff changeset
561 if (!VM_Version::v9_instructions_work()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
562 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
563 }
a61af66fc99e Initial load
duke
parents:
diff changeset
564 __ fb( acond, false, Assembler::pn, *(op->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
565 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
566 assert (op->code() == lir_branch, "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
567
a61af66fc99e Initial load
duke
parents:
diff changeset
568 Assembler::Condition acond;
a61af66fc99e Initial load
duke
parents:
diff changeset
569 switch (op->cond()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
570 case lir_cond_equal: acond = Assembler::equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
571 case lir_cond_notEqual: acond = Assembler::notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
572 case lir_cond_less: acond = Assembler::less; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
573 case lir_cond_lessEqual: acond = Assembler::lessEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
574 case lir_cond_greaterEqual: acond = Assembler::greaterEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
575 case lir_cond_greater: acond = Assembler::greater; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
576 case lir_cond_aboveEqual: acond = Assembler::greaterEqualUnsigned; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
577 case lir_cond_belowEqual: acond = Assembler::lessEqualUnsigned; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
578 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
579 };
a61af66fc99e Initial load
duke
parents:
diff changeset
580
a61af66fc99e Initial load
duke
parents:
diff changeset
581 // sparc has different condition codes for testing 32-bit
a61af66fc99e Initial load
duke
parents:
diff changeset
582 // vs. 64-bit values. We could always test xcc is we could
a61af66fc99e Initial load
duke
parents:
diff changeset
583 // guarantee that 32-bit loads always sign extended but that isn't
a61af66fc99e Initial load
duke
parents:
diff changeset
584 // true and since sign extension isn't free, it would impose a
a61af66fc99e Initial load
duke
parents:
diff changeset
585 // slight cost.
a61af66fc99e Initial load
duke
parents:
diff changeset
586 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
587 if (op->type() == T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
588 __ br(acond, false, Assembler::pn, *(op->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
589 } else
a61af66fc99e Initial load
duke
parents:
diff changeset
590 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
591 __ brx(acond, false, Assembler::pn, *(op->label()));
a61af66fc99e Initial load
duke
parents:
diff changeset
592 }
a61af66fc99e Initial load
duke
parents:
diff changeset
593 // The peephole pass fills the delay slot
a61af66fc99e Initial load
duke
parents:
diff changeset
594 }
a61af66fc99e Initial load
duke
parents:
diff changeset
595
a61af66fc99e Initial load
duke
parents:
diff changeset
596
a61af66fc99e Initial load
duke
parents:
diff changeset
597 void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
598 Bytecodes::Code code = op->bytecode();
a61af66fc99e Initial load
duke
parents:
diff changeset
599 LIR_Opr dst = op->result_opr();
a61af66fc99e Initial load
duke
parents:
diff changeset
600
a61af66fc99e Initial load
duke
parents:
diff changeset
601 switch(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
602 case Bytecodes::_i2l: {
a61af66fc99e Initial load
duke
parents:
diff changeset
603 Register rlo = dst->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
604 Register rhi = dst->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
605 Register rval = op->in_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
606 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
607 __ sra(rval, 0, rlo);
a61af66fc99e Initial load
duke
parents:
diff changeset
608 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
609 __ mov(rval, rlo);
a61af66fc99e Initial load
duke
parents:
diff changeset
610 __ sra(rval, BitsPerInt-1, rhi);
a61af66fc99e Initial load
duke
parents:
diff changeset
611 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
612 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
613 }
a61af66fc99e Initial load
duke
parents:
diff changeset
614 case Bytecodes::_i2d:
a61af66fc99e Initial load
duke
parents:
diff changeset
615 case Bytecodes::_i2f: {
a61af66fc99e Initial load
duke
parents:
diff changeset
616 bool is_double = (code == Bytecodes::_i2d);
a61af66fc99e Initial load
duke
parents:
diff changeset
617 FloatRegister rdst = is_double ? dst->as_double_reg() : dst->as_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
618 FloatRegisterImpl::Width w = is_double ? FloatRegisterImpl::D : FloatRegisterImpl::S;
a61af66fc99e Initial load
duke
parents:
diff changeset
619 FloatRegister rsrc = op->in_opr()->as_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
620 if (rsrc != rdst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
621 __ fmov(FloatRegisterImpl::S, rsrc, rdst);
a61af66fc99e Initial load
duke
parents:
diff changeset
622 }
a61af66fc99e Initial load
duke
parents:
diff changeset
623 __ fitof(w, rdst, rdst);
a61af66fc99e Initial load
duke
parents:
diff changeset
624 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
625 }
a61af66fc99e Initial load
duke
parents:
diff changeset
626 case Bytecodes::_f2i:{
a61af66fc99e Initial load
duke
parents:
diff changeset
627 FloatRegister rsrc = op->in_opr()->as_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
628 Address addr = frame_map()->address_for_slot(dst->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
629 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
630 // result must be 0 if value is NaN; test by comparing value to itself
a61af66fc99e Initial load
duke
parents:
diff changeset
631 __ fcmp(FloatRegisterImpl::S, Assembler::fcc0, rsrc, rsrc);
a61af66fc99e Initial load
duke
parents:
diff changeset
632 if (!VM_Version::v9_instructions_work()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
633 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
634 }
a61af66fc99e Initial load
duke
parents:
diff changeset
635 __ fb(Assembler::f_unordered, true, Assembler::pn, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
636 __ delayed()->st(G0, addr); // annuled if contents of rsrc is not NaN
a61af66fc99e Initial load
duke
parents:
diff changeset
637 __ ftoi(FloatRegisterImpl::S, rsrc, rsrc);
a61af66fc99e Initial load
duke
parents:
diff changeset
638 // move integer result from float register to int register
a61af66fc99e Initial load
duke
parents:
diff changeset
639 __ stf(FloatRegisterImpl::S, rsrc, addr.base(), addr.disp());
a61af66fc99e Initial load
duke
parents:
diff changeset
640 __ bind (L);
a61af66fc99e Initial load
duke
parents:
diff changeset
641 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
642 }
a61af66fc99e Initial load
duke
parents:
diff changeset
643 case Bytecodes::_l2i: {
a61af66fc99e Initial load
duke
parents:
diff changeset
644 Register rlo = op->in_opr()->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
645 Register rhi = op->in_opr()->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
646 Register rdst = dst->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
647 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
648 __ sra(rlo, 0, rdst);
a61af66fc99e Initial load
duke
parents:
diff changeset
649 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
650 __ mov(rlo, rdst);
a61af66fc99e Initial load
duke
parents:
diff changeset
651 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
652 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
653 }
a61af66fc99e Initial load
duke
parents:
diff changeset
654 case Bytecodes::_d2f:
a61af66fc99e Initial load
duke
parents:
diff changeset
655 case Bytecodes::_f2d: {
a61af66fc99e Initial load
duke
parents:
diff changeset
656 bool is_double = (code == Bytecodes::_f2d);
a61af66fc99e Initial load
duke
parents:
diff changeset
657 assert((!is_double && dst->is_single_fpu()) || (is_double && dst->is_double_fpu()), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
658 LIR_Opr val = op->in_opr();
a61af66fc99e Initial load
duke
parents:
diff changeset
659 FloatRegister rval = (code == Bytecodes::_d2f) ? val->as_double_reg() : val->as_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
660 FloatRegister rdst = is_double ? dst->as_double_reg() : dst->as_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
661 FloatRegisterImpl::Width vw = is_double ? FloatRegisterImpl::S : FloatRegisterImpl::D;
a61af66fc99e Initial load
duke
parents:
diff changeset
662 FloatRegisterImpl::Width dw = is_double ? FloatRegisterImpl::D : FloatRegisterImpl::S;
a61af66fc99e Initial load
duke
parents:
diff changeset
663 __ ftof(vw, dw, rval, rdst);
a61af66fc99e Initial load
duke
parents:
diff changeset
664 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
665 }
a61af66fc99e Initial load
duke
parents:
diff changeset
666 case Bytecodes::_i2s:
a61af66fc99e Initial load
duke
parents:
diff changeset
667 case Bytecodes::_i2b: {
a61af66fc99e Initial load
duke
parents:
diff changeset
668 Register rval = op->in_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
669 Register rdst = dst->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
670 int shift = (code == Bytecodes::_i2b) ? (BitsPerInt - T_BYTE_aelem_bytes * BitsPerByte) : (BitsPerInt - BitsPerShort);
a61af66fc99e Initial load
duke
parents:
diff changeset
671 __ sll (rval, shift, rdst);
a61af66fc99e Initial load
duke
parents:
diff changeset
672 __ sra (rdst, shift, rdst);
a61af66fc99e Initial load
duke
parents:
diff changeset
673 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
674 }
a61af66fc99e Initial load
duke
parents:
diff changeset
675 case Bytecodes::_i2c: {
a61af66fc99e Initial load
duke
parents:
diff changeset
676 Register rval = op->in_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
677 Register rdst = dst->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
678 int shift = BitsPerInt - T_CHAR_aelem_bytes * BitsPerByte;
a61af66fc99e Initial load
duke
parents:
diff changeset
679 __ sll (rval, shift, rdst);
a61af66fc99e Initial load
duke
parents:
diff changeset
680 __ srl (rdst, shift, rdst);
a61af66fc99e Initial load
duke
parents:
diff changeset
681 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
682 }
a61af66fc99e Initial load
duke
parents:
diff changeset
683
a61af66fc99e Initial load
duke
parents:
diff changeset
684 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
685 }
a61af66fc99e Initial load
duke
parents:
diff changeset
686 }
a61af66fc99e Initial load
duke
parents:
diff changeset
687
a61af66fc99e Initial load
duke
parents:
diff changeset
688
a61af66fc99e Initial load
duke
parents:
diff changeset
689 void LIR_Assembler::align_call(LIR_Code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
690 // do nothing since all instructions are word aligned on sparc
a61af66fc99e Initial load
duke
parents:
diff changeset
691 }
a61af66fc99e Initial load
duke
parents:
diff changeset
692
a61af66fc99e Initial load
duke
parents:
diff changeset
693
a61af66fc99e Initial load
duke
parents:
diff changeset
694 void LIR_Assembler::call(address entry, relocInfo::relocType rtype, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
695 __ call(entry, rtype);
a61af66fc99e Initial load
duke
parents:
diff changeset
696 // the peephole pass fills the delay slot
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::ic_call(address entry, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
701 RelocationHolder rspec = virtual_call_Relocation::spec(pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
702 __ set_oop((jobject)Universe::non_oop_word(), G5_inline_cache_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
703 __ relocate(rspec);
a61af66fc99e Initial load
duke
parents:
diff changeset
704 __ call(entry, relocInfo::none);
a61af66fc99e Initial load
duke
parents:
diff changeset
705 // the peephole pass fills the delay slot
a61af66fc99e Initial load
duke
parents:
diff changeset
706 }
a61af66fc99e Initial load
duke
parents:
diff changeset
707
a61af66fc99e Initial load
duke
parents:
diff changeset
708
a61af66fc99e Initial load
duke
parents:
diff changeset
709 void LIR_Assembler::vtable_call(int vtable_offset, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
710 add_debug_info_for_null_check_here(info);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
711 __ ld_ptr(O0, oopDesc::klass_offset_in_bytes(), G3_scratch);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
712 if (__ is_simm13(vtable_offset) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
713 __ ld_ptr(G3_scratch, vtable_offset, G5_method);
a61af66fc99e Initial load
duke
parents:
diff changeset
714 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
715 // This will generate 2 instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
716 __ set(vtable_offset, G5_method);
a61af66fc99e Initial load
duke
parents:
diff changeset
717 // ld_ptr, set_hi, set
a61af66fc99e Initial load
duke
parents:
diff changeset
718 __ ld_ptr(G3_scratch, G5_method, G5_method);
a61af66fc99e Initial load
duke
parents:
diff changeset
719 }
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
720 __ ld_ptr(G5_method, methodOopDesc::from_compiled_offset(), G3_scratch);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
721 __ callr(G3_scratch, G0);
a61af66fc99e Initial load
duke
parents:
diff changeset
722 // the peephole pass fills the delay slot
a61af66fc99e Initial load
duke
parents:
diff changeset
723 }
a61af66fc99e Initial load
duke
parents:
diff changeset
724
a61af66fc99e Initial load
duke
parents:
diff changeset
725
a61af66fc99e Initial load
duke
parents:
diff changeset
726 // load with 32-bit displacement
a61af66fc99e Initial load
duke
parents:
diff changeset
727 int LIR_Assembler::load(Register s, int disp, Register d, BasicType ld_type, CodeEmitInfo *info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
728 int load_offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
729 if (Assembler::is_simm13(disp)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
730 if (info != NULL) add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
731 switch(ld_type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
732 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
733 case T_BYTE : __ ldsb(s, disp, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
734 case T_CHAR : __ lduh(s, disp, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
735 case T_SHORT : __ ldsh(s, disp, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
736 case T_INT : __ ld(s, disp, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
737 case T_ADDRESS:// fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
738 case T_ARRAY : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
739 case T_OBJECT: __ ld_ptr(s, disp, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
740 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
741 }
a61af66fc99e Initial load
duke
parents:
diff changeset
742 } else {
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
743 __ set(disp, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
744 if (info != NULL) add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
745 load_offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
746 switch(ld_type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
747 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
748 case T_BYTE : __ ldsb(s, O7, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
749 case T_CHAR : __ lduh(s, O7, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
750 case T_SHORT : __ ldsh(s, O7, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
751 case T_INT : __ ld(s, O7, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
752 case T_ADDRESS:// fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
753 case T_ARRAY : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
754 case T_OBJECT: __ ld_ptr(s, O7, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
755 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
756 }
a61af66fc99e Initial load
duke
parents:
diff changeset
757 }
a61af66fc99e Initial load
duke
parents:
diff changeset
758 if (ld_type == T_ARRAY || ld_type == T_OBJECT) __ verify_oop(d);
a61af66fc99e Initial load
duke
parents:
diff changeset
759 return load_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
760 }
a61af66fc99e Initial load
duke
parents:
diff changeset
761
a61af66fc99e Initial load
duke
parents:
diff changeset
762
a61af66fc99e Initial load
duke
parents:
diff changeset
763 // store with 32-bit displacement
a61af66fc99e Initial load
duke
parents:
diff changeset
764 void LIR_Assembler::store(Register value, Register base, int offset, BasicType type, CodeEmitInfo *info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
765 if (Assembler::is_simm13(offset)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
766 if (info != NULL) add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
767 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
768 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
769 case T_BYTE : __ stb(value, base, offset); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
770 case T_CHAR : __ sth(value, base, offset); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
771 case T_SHORT : __ sth(value, base, offset); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
772 case T_INT : __ stw(value, base, offset); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
773 case T_ADDRESS:// fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
774 case T_ARRAY : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
775 case T_OBJECT: __ st_ptr(value, base, offset); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
776 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
777 }
a61af66fc99e Initial load
duke
parents:
diff changeset
778 } else {
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
779 __ set(offset, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
780 if (info != NULL) add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
781 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
782 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
783 case T_BYTE : __ stb(value, base, O7); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
784 case T_CHAR : __ sth(value, base, O7); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
785 case T_SHORT : __ sth(value, base, O7); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
786 case T_INT : __ stw(value, base, O7); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
787 case T_ADDRESS:// fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
788 case T_ARRAY : //fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
789 case T_OBJECT: __ st_ptr(value, base, O7); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
790 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
791 }
a61af66fc99e Initial load
duke
parents:
diff changeset
792 }
a61af66fc99e Initial load
duke
parents:
diff changeset
793 // Note: Do the store before verification as the code might be patched!
a61af66fc99e Initial load
duke
parents:
diff changeset
794 if (type == T_ARRAY || type == T_OBJECT) __ verify_oop(value);
a61af66fc99e Initial load
duke
parents:
diff changeset
795 }
a61af66fc99e Initial load
duke
parents:
diff changeset
796
a61af66fc99e Initial load
duke
parents:
diff changeset
797
a61af66fc99e Initial load
duke
parents:
diff changeset
798 // load float with 32-bit displacement
a61af66fc99e Initial load
duke
parents:
diff changeset
799 void LIR_Assembler::load(Register s, int disp, FloatRegister d, BasicType ld_type, CodeEmitInfo *info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
800 FloatRegisterImpl::Width w;
a61af66fc99e Initial load
duke
parents:
diff changeset
801 switch(ld_type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
802 case T_FLOAT : w = FloatRegisterImpl::S; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
803 case T_DOUBLE: w = FloatRegisterImpl::D; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
804 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
805 }
a61af66fc99e Initial load
duke
parents:
diff changeset
806
a61af66fc99e Initial load
duke
parents:
diff changeset
807 if (Assembler::is_simm13(disp)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
808 if (info != NULL) add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
809 if (disp % BytesPerLong != 0 && w == FloatRegisterImpl::D) {
a61af66fc99e Initial load
duke
parents:
diff changeset
810 __ ldf(FloatRegisterImpl::S, s, disp + BytesPerWord, d->successor());
a61af66fc99e Initial load
duke
parents:
diff changeset
811 __ ldf(FloatRegisterImpl::S, s, disp , d);
a61af66fc99e Initial load
duke
parents:
diff changeset
812 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
813 __ ldf(w, s, disp, d);
a61af66fc99e Initial load
duke
parents:
diff changeset
814 }
a61af66fc99e Initial load
duke
parents:
diff changeset
815 } else {
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
816 __ set(disp, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
817 if (info != NULL) add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
818 __ ldf(w, s, O7, d);
a61af66fc99e Initial load
duke
parents:
diff changeset
819 }
a61af66fc99e Initial load
duke
parents:
diff changeset
820 }
a61af66fc99e Initial load
duke
parents:
diff changeset
821
a61af66fc99e Initial load
duke
parents:
diff changeset
822
a61af66fc99e Initial load
duke
parents:
diff changeset
823 // store float with 32-bit displacement
a61af66fc99e Initial load
duke
parents:
diff changeset
824 void LIR_Assembler::store(FloatRegister value, Register base, int offset, BasicType type, CodeEmitInfo *info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
825 FloatRegisterImpl::Width w;
a61af66fc99e Initial load
duke
parents:
diff changeset
826 switch(type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
827 case T_FLOAT : w = FloatRegisterImpl::S; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
828 case T_DOUBLE: w = FloatRegisterImpl::D; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
829 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
830 }
a61af66fc99e Initial load
duke
parents:
diff changeset
831
a61af66fc99e Initial load
duke
parents:
diff changeset
832 if (Assembler::is_simm13(offset)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
833 if (info != NULL) add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
834 if (w == FloatRegisterImpl::D && offset % BytesPerLong != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
835 __ stf(FloatRegisterImpl::S, value->successor(), base, offset + BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
836 __ stf(FloatRegisterImpl::S, value , base, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
837 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
838 __ stf(w, value, base, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
839 }
a61af66fc99e Initial load
duke
parents:
diff changeset
840 } else {
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
841 __ set(offset, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
842 if (info != NULL) add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
843 __ stf(w, value, O7, base);
a61af66fc99e Initial load
duke
parents:
diff changeset
844 }
a61af66fc99e Initial load
duke
parents:
diff changeset
845 }
a61af66fc99e Initial load
duke
parents:
diff changeset
846
a61af66fc99e Initial load
duke
parents:
diff changeset
847
a61af66fc99e Initial load
duke
parents:
diff changeset
848 int LIR_Assembler::store(LIR_Opr from_reg, Register base, int offset, BasicType type, bool unaligned) {
a61af66fc99e Initial load
duke
parents:
diff changeset
849 int store_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
850 if (!Assembler::is_simm13(offset + (type == T_LONG) ? wordSize : 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
851 assert(!unaligned, "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
852 // for offsets larger than a simm13 we setup the offset in O7
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
853 __ set(offset, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
854 store_offset = store(from_reg, base, O7, type);
a61af66fc99e Initial load
duke
parents:
diff changeset
855 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
856 if (type == T_ARRAY || type == T_OBJECT) __ verify_oop(from_reg->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
857 store_offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
858 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
859 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
860 case T_BYTE : __ stb(from_reg->as_register(), base, offset); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
861 case T_CHAR : __ sth(from_reg->as_register(), base, offset); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
862 case T_SHORT : __ sth(from_reg->as_register(), base, offset); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
863 case T_INT : __ stw(from_reg->as_register(), base, offset); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
864 case T_LONG :
a61af66fc99e Initial load
duke
parents:
diff changeset
865 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
866 if (unaligned || PatchALot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
867 __ srax(from_reg->as_register_lo(), 32, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
868 __ stw(from_reg->as_register_lo(), base, offset + lo_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
869 __ stw(O7, base, offset + hi_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
870 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
871 __ stx(from_reg->as_register_lo(), base, offset);
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 assert(Assembler::is_simm13(offset + 4), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
875 __ stw(from_reg->as_register_lo(), base, offset + lo_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
876 __ stw(from_reg->as_register_hi(), base, offset + hi_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
877 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
878 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
879 case T_ADDRESS:// fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
880 case T_ARRAY : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
881 case T_OBJECT: __ st_ptr(from_reg->as_register(), base, offset); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
882 case T_FLOAT : __ stf(FloatRegisterImpl::S, from_reg->as_float_reg(), base, offset); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
883 case T_DOUBLE:
a61af66fc99e Initial load
duke
parents:
diff changeset
884 {
a61af66fc99e Initial load
duke
parents:
diff changeset
885 FloatRegister reg = from_reg->as_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
886 // split unaligned stores
a61af66fc99e Initial load
duke
parents:
diff changeset
887 if (unaligned || PatchALot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
888 assert(Assembler::is_simm13(offset + 4), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
889 __ stf(FloatRegisterImpl::S, reg->successor(), base, offset + 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
890 __ stf(FloatRegisterImpl::S, reg, base, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
891 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
892 __ stf(FloatRegisterImpl::D, reg, base, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
893 }
a61af66fc99e Initial load
duke
parents:
diff changeset
894 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
895 }
a61af66fc99e Initial load
duke
parents:
diff changeset
896 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
897 }
a61af66fc99e Initial load
duke
parents:
diff changeset
898 }
a61af66fc99e Initial load
duke
parents:
diff changeset
899 return store_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
900 }
a61af66fc99e Initial load
duke
parents:
diff changeset
901
a61af66fc99e Initial load
duke
parents:
diff changeset
902
a61af66fc99e Initial load
duke
parents:
diff changeset
903 int LIR_Assembler::store(LIR_Opr from_reg, Register base, Register disp, BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
904 if (type == T_ARRAY || type == T_OBJECT) __ verify_oop(from_reg->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
905 int store_offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
906 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
907 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
908 case T_BYTE : __ stb(from_reg->as_register(), base, disp); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
909 case T_CHAR : __ sth(from_reg->as_register(), base, disp); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
910 case T_SHORT : __ sth(from_reg->as_register(), base, disp); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
911 case T_INT : __ stw(from_reg->as_register(), base, disp); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
912 case T_LONG :
a61af66fc99e Initial load
duke
parents:
diff changeset
913 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
914 __ stx(from_reg->as_register_lo(), base, disp);
a61af66fc99e Initial load
duke
parents:
diff changeset
915 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
916 assert(from_reg->as_register_hi()->successor() == from_reg->as_register_lo(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
917 __ std(from_reg->as_register_hi(), base, disp);
a61af66fc99e Initial load
duke
parents:
diff changeset
918 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
919 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
920 case T_ADDRESS:// fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
921 case T_ARRAY : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
922 case T_OBJECT: __ st_ptr(from_reg->as_register(), base, disp); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
923 case T_FLOAT : __ stf(FloatRegisterImpl::S, from_reg->as_float_reg(), base, disp); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
924 case T_DOUBLE: __ stf(FloatRegisterImpl::D, from_reg->as_double_reg(), base, disp); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
925 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
926 }
a61af66fc99e Initial load
duke
parents:
diff changeset
927 return store_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
928 }
a61af66fc99e Initial load
duke
parents:
diff changeset
929
a61af66fc99e Initial load
duke
parents:
diff changeset
930
a61af66fc99e Initial load
duke
parents:
diff changeset
931 int LIR_Assembler::load(Register base, int offset, LIR_Opr to_reg, BasicType type, bool unaligned) {
a61af66fc99e Initial load
duke
parents:
diff changeset
932 int load_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
933 if (!Assembler::is_simm13(offset + (type == T_LONG) ? wordSize : 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
934 assert(base != O7, "destroying register");
a61af66fc99e Initial load
duke
parents:
diff changeset
935 assert(!unaligned, "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
936 // for offsets larger than a simm13 we setup the offset in O7
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
937 __ set(offset, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
938 load_offset = load(base, O7, to_reg, type);
a61af66fc99e Initial load
duke
parents:
diff changeset
939 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
940 load_offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
941 switch(type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
942 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
943 case T_BYTE : __ ldsb(base, offset, to_reg->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
944 case T_CHAR : __ lduh(base, offset, to_reg->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
945 case T_SHORT : __ ldsh(base, offset, to_reg->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
946 case T_INT : __ ld(base, offset, to_reg->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
947 case T_LONG :
a61af66fc99e Initial load
duke
parents:
diff changeset
948 if (!unaligned) {
a61af66fc99e Initial load
duke
parents:
diff changeset
949 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
950 __ ldx(base, offset, to_reg->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
951 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
952 assert(to_reg->as_register_hi()->successor() == to_reg->as_register_lo(),
a61af66fc99e Initial load
duke
parents:
diff changeset
953 "must be sequential");
a61af66fc99e Initial load
duke
parents:
diff changeset
954 __ ldd(base, offset, to_reg->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
955 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
956 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
957 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
958 assert(base != to_reg->as_register_lo(), "can't handle this");
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
959 assert(O7 != to_reg->as_register_lo(), "can't handle this");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
960 __ ld(base, offset + hi_word_offset_in_bytes, to_reg->as_register_lo());
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
961 __ lduw(base, offset + lo_word_offset_in_bytes, O7); // in case O7 is base or offset, use it last
0
a61af66fc99e Initial load
duke
parents:
diff changeset
962 __ sllx(to_reg->as_register_lo(), 32, to_reg->as_register_lo());
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
963 __ or3(to_reg->as_register_lo(), O7, to_reg->as_register_lo());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
964 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
965 if (base == to_reg->as_register_lo()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
966 __ ld(base, offset + hi_word_offset_in_bytes, to_reg->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
967 __ ld(base, offset + lo_word_offset_in_bytes, to_reg->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
968 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
969 __ ld(base, offset + lo_word_offset_in_bytes, to_reg->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
970 __ ld(base, offset + hi_word_offset_in_bytes, to_reg->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
971 }
a61af66fc99e Initial load
duke
parents:
diff changeset
972 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
973 }
a61af66fc99e Initial load
duke
parents:
diff changeset
974 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
975 case T_ADDRESS:// fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
976 case T_ARRAY : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
977 case T_OBJECT: __ ld_ptr(base, offset, to_reg->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
978 case T_FLOAT: __ ldf(FloatRegisterImpl::S, base, offset, to_reg->as_float_reg()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
979 case T_DOUBLE:
a61af66fc99e Initial load
duke
parents:
diff changeset
980 {
a61af66fc99e Initial load
duke
parents:
diff changeset
981 FloatRegister reg = to_reg->as_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
982 // split unaligned loads
a61af66fc99e Initial load
duke
parents:
diff changeset
983 if (unaligned || PatchALot) {
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
984 __ ldf(FloatRegisterImpl::S, base, offset + 4, reg->successor());
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
985 __ ldf(FloatRegisterImpl::S, base, offset, reg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
986 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
987 __ ldf(FloatRegisterImpl::D, base, offset, to_reg->as_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
988 }
a61af66fc99e Initial load
duke
parents:
diff changeset
989 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
990 }
a61af66fc99e Initial load
duke
parents:
diff changeset
991 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
992 }
a61af66fc99e Initial load
duke
parents:
diff changeset
993 if (type == T_ARRAY || type == T_OBJECT) __ verify_oop(to_reg->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
994 }
a61af66fc99e Initial load
duke
parents:
diff changeset
995 return load_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
996 }
a61af66fc99e Initial load
duke
parents:
diff changeset
997
a61af66fc99e Initial load
duke
parents:
diff changeset
998
a61af66fc99e Initial load
duke
parents:
diff changeset
999 int LIR_Assembler::load(Register base, Register disp, LIR_Opr to_reg, BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 int load_offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 switch(type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 case T_BOOLEAN: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 case T_BYTE : __ ldsb(base, disp, to_reg->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 case T_CHAR : __ lduh(base, disp, to_reg->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 case T_SHORT : __ ldsh(base, disp, to_reg->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 case T_INT : __ ld(base, disp, to_reg->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 case T_ADDRESS:// fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 case T_ARRAY : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 case T_OBJECT: __ ld_ptr(base, disp, to_reg->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 case T_FLOAT: __ ldf(FloatRegisterImpl::S, base, disp, to_reg->as_float_reg()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 case T_DOUBLE: __ ldf(FloatRegisterImpl::D, base, disp, to_reg->as_double_reg()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 case T_LONG :
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 __ ldx(base, disp, to_reg->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 assert(to_reg->as_register_hi()->successor() == to_reg->as_register_lo(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 "must be sequential");
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 __ ldd(base, disp, to_reg->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 default : ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 if (type == T_ARRAY || type == T_OBJECT) __ verify_oop(to_reg->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 return load_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1026
a61af66fc99e Initial load
duke
parents:
diff changeset
1027
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 // load/store with an Address
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 void LIR_Assembler::load(const Address& a, Register d, BasicType ld_type, CodeEmitInfo *info, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 load(a.base(), a.disp() + offset, d, ld_type, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1032
a61af66fc99e Initial load
duke
parents:
diff changeset
1033
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 void LIR_Assembler::store(Register value, const Address& dest, BasicType type, CodeEmitInfo *info, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 store(value, dest.base(), dest.disp() + offset, type, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1037
a61af66fc99e Initial load
duke
parents:
diff changeset
1038
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 // loadf/storef with an Address
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 void LIR_Assembler::load(const Address& a, FloatRegister d, BasicType ld_type, CodeEmitInfo *info, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 load(a.base(), a.disp() + offset, d, ld_type, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1043
a61af66fc99e Initial load
duke
parents:
diff changeset
1044
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 void LIR_Assembler::store(FloatRegister value, const Address& dest, BasicType type, CodeEmitInfo *info, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 store(value, dest.base(), dest.disp() + offset, type, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1048
a61af66fc99e Initial load
duke
parents:
diff changeset
1049
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 // load/store with an Address
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 void LIR_Assembler::load(LIR_Address* a, Register d, BasicType ld_type, CodeEmitInfo *info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 load(as_Address(a), d, ld_type, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1054
a61af66fc99e Initial load
duke
parents:
diff changeset
1055
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 void LIR_Assembler::store(Register value, LIR_Address* dest, BasicType type, CodeEmitInfo *info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 store(value, as_Address(dest), type, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1059
a61af66fc99e Initial load
duke
parents:
diff changeset
1060
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 // loadf/storef with an Address
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 void LIR_Assembler::load(LIR_Address* a, FloatRegister d, BasicType ld_type, CodeEmitInfo *info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 load(as_Address(a), d, ld_type, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1065
a61af66fc99e Initial load
duke
parents:
diff changeset
1066
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 void LIR_Assembler::store(FloatRegister value, LIR_Address* dest, BasicType type, CodeEmitInfo *info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 store(value, as_Address(dest), type, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1070
a61af66fc99e Initial load
duke
parents:
diff changeset
1071
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 LIR_Const* c = src->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 switch (c->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 case T_FLOAT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 Register src_reg = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 int value = c->as_jint_bits();
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 if (value == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 src_reg = G0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 __ set(value, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 Address addr = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 __ stw(src_reg, addr.base(), addr.disp());
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 case T_OBJECT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 Register src_reg = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 jobject2reg(c->as_jobject(), src_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 Address addr = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 __ st_ptr(src_reg, addr.base(), addr.disp());
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 case T_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 case T_DOUBLE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 Address addr = frame_map()->address_for_double_slot(dest->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1098
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 Register tmp = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 int value_lo = c->as_jint_lo_bits();
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 if (value_lo == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 tmp = G0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 __ set(value_lo, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 __ stw(tmp, addr.base(), addr.disp() + lo_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 int value_hi = c->as_jint_hi_bits();
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 if (value_hi == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 tmp = G0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 __ set(value_hi, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 __ stw(tmp, addr.base(), addr.disp() + hi_word_offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1120
a61af66fc99e Initial load
duke
parents:
diff changeset
1121
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 void LIR_Assembler::const2mem(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 LIR_Const* c = src->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 LIR_Address* addr = dest->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 Register base = addr->base()->as_pointer_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1126
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 add_debug_info_for_null_check_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 switch (c->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 case T_FLOAT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 LIR_Opr tmp = FrameMap::O7_opr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 int value = c->as_jint_bits();
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 if (value == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 tmp = FrameMap::G0_opr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 } else if (Assembler::is_simm13(value)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 __ set(value, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 if (addr->index()->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 assert(addr->disp() == 0, "must be zero");
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 store(tmp, base, addr->index()->as_pointer_register(), type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 assert(Assembler::is_simm13(addr->disp()), "can't handle larger addresses");
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 store(tmp, base, addr->disp(), type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 case T_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 case T_DOUBLE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 assert(!addr->index()->is_valid(), "can't handle reg reg address here");
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 assert(Assembler::is_simm13(addr->disp()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 Assembler::is_simm13(addr->disp() + 4), "can't handle larger addresses");
a61af66fc99e Initial load
duke
parents:
diff changeset
1154
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 Register tmp = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 int value_lo = c->as_jint_lo_bits();
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 if (value_lo == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 tmp = G0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 __ set(value_lo, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 store(tmp, base, addr->disp() + lo_word_offset_in_bytes, T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 int value_hi = c->as_jint_hi_bits();
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 if (value_hi == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 tmp = G0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 __ set(value_hi, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 store(tmp, base, addr->disp() + hi_word_offset_in_bytes, T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 case T_OBJECT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 jobject obj = c->as_jobject();
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 LIR_Opr tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 if (obj == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 tmp = FrameMap::G0_opr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 tmp = FrameMap::O7_opr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 jobject2reg(c->as_jobject(), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 // handle either reg+reg or reg+disp address
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 if (addr->index()->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1183 assert(addr->disp() == 0, "must be zero");
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 store(tmp, base, addr->index()->as_pointer_register(), type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 assert(Assembler::is_simm13(addr->disp()), "can't handle larger addresses");
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 store(tmp, base, addr->disp(), type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1189
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1196
a61af66fc99e Initial load
duke
parents:
diff changeset
1197
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 LIR_Const* c = src->as_constant_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 LIR_Opr to_reg = dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
1201
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 switch (c->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 jint con = c->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 if (to_reg->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 assert(patch_code == lir_patch_none, "no patching handled here");
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 __ set(con, to_reg->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 assert(to_reg->is_single_fpu(), "wrong register kind");
a61af66fc99e Initial load
duke
parents:
diff changeset
1212
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 __ set(con, O7);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1214 Address temp_slot(SP, (frame::register_save_words * wordSize) + STACK_BIAS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 __ st(O7, temp_slot);
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 __ ldf(FloatRegisterImpl::S, temp_slot, to_reg->as_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1220
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 case T_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 jlong con = c->as_jlong();
a61af66fc99e Initial load
duke
parents:
diff changeset
1224
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 if (to_reg->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 __ set(con, to_reg->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 __ set(low(con), to_reg->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 __ set(high(con), to_reg->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 } else if (to_reg->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 __ set(con, to_reg->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 assert(to_reg->is_double_fpu(), "wrong register kind");
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1239 Address temp_slot_lo(SP, ((frame::register_save_words ) * wordSize) + STACK_BIAS);
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1240 Address temp_slot_hi(SP, ((frame::register_save_words) * wordSize) + (longSize/2) + STACK_BIAS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 __ set(low(con), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 __ st(O7, temp_slot_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 __ set(high(con), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 __ st(O7, temp_slot_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 __ ldf(FloatRegisterImpl::D, temp_slot_lo, to_reg->as_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1249
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 case T_OBJECT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 if (patch_code == lir_patch_none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 jobject2reg(c->as_jobject(), to_reg->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 jobject2reg_with_patching(to_reg->as_register(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1259
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 case T_FLOAT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 address const_addr = __ float_constant(c->as_jfloat());
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 if (const_addr == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 bailout("const section overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 RelocationHolder rspec = internal_word_Relocation::spec(const_addr);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1268 AddressLiteral const_addrlit(const_addr, rspec);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 if (to_reg->is_single_fpu()) {
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1270 __ patchable_sethi(const_addrlit, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 __ relocate(rspec);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1272 __ ldf(FloatRegisterImpl::S, O7, const_addrlit.low10(), to_reg->as_float_reg());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1273
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 assert(to_reg->is_single_cpu(), "Must be a cpu register.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1276
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1277 __ set(const_addrlit, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 load(O7, 0, to_reg->as_register(), T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1282
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 case T_DOUBLE:
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 address const_addr = __ double_constant(c->as_jdouble());
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 if (const_addr == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 bailout("const section overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 RelocationHolder rspec = internal_word_Relocation::spec(const_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1291
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 if (to_reg->is_double_fpu()) {
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1293 AddressLiteral const_addrlit(const_addr, rspec);
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1294 __ patchable_sethi(const_addrlit, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 __ relocate(rspec);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1296 __ ldf (FloatRegisterImpl::D, O7, const_addrlit.low10(), to_reg->as_double_reg());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 assert(to_reg->is_double_cpu(), "Must be a long register.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 __ set(jlong_cast(c->as_jdouble()), to_reg->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 __ set(low(jlong_cast(c->as_jdouble())), to_reg->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 __ set(high(jlong_cast(c->as_jdouble())), to_reg->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1306
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1309
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1314
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 Address LIR_Assembler::as_Address(LIR_Address* addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 Register reg = addr->base()->as_register();
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1317 return Address(reg, addr->disp());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1319
a61af66fc99e Initial load
duke
parents:
diff changeset
1320
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 case T_FLOAT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 Register tmp = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 Address from = frame_map()->address_for_slot(src->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 Address to = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 __ lduw(from.base(), from.disp(), tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 __ stw(tmp, to.base(), to.disp());
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 case T_OBJECT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 Register tmp = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 Address from = frame_map()->address_for_slot(src->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 Address to = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 __ ld_ptr(from.base(), from.disp(), tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 __ st_ptr(tmp, to.base(), to.disp());
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 case T_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 case T_DOUBLE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1342 Register tmp = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 Address from = frame_map()->address_for_double_slot(src->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 Address to = frame_map()->address_for_double_slot(dest->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 __ lduw(from.base(), from.disp(), tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 __ stw(tmp, to.base(), to.disp());
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 __ lduw(from.base(), from.disp() + 4, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 __ stw(tmp, to.base(), to.disp() + 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1351
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1356
a61af66fc99e Initial load
duke
parents:
diff changeset
1357
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 Address LIR_Assembler::as_Address_hi(LIR_Address* addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 Address base = as_Address(addr);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1360 return Address(base.base(), base.disp() + hi_word_offset_in_bytes);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1362
a61af66fc99e Initial load
duke
parents:
diff changeset
1363
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 Address LIR_Assembler::as_Address_lo(LIR_Address* addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 Address base = as_Address(addr);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1366 return Address(base.base(), base.disp() + lo_word_offset_in_bytes);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1368
a61af66fc99e Initial load
duke
parents:
diff changeset
1369
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 void LIR_Assembler::mem2reg(LIR_Opr src_opr, LIR_Opr dest, BasicType type,
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 LIR_PatchCode patch_code, CodeEmitInfo* info, bool unaligned) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1372
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 LIR_Address* addr = src_opr->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 LIR_Opr to_reg = dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
1375
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 Register src = addr->base()->as_pointer_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 Register disp_reg = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1378 int disp_value = addr->disp();
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 bool needs_patching = (patch_code != lir_patch_none);
a61af66fc99e Initial load
duke
parents:
diff changeset
1380
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 if (addr->base()->type() == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1382 __ verify_oop(src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1384
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 PatchingStub* patch = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 if (needs_patching) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 assert(!to_reg->is_double_cpu() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 patch_code == lir_patch_none ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 patch_code == lir_patch_normal, "patching doesn't match register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1392
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 if (addr->index()->is_illegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 if (!Assembler::is_simm13(disp_value) && (!unaligned || Assembler::is_simm13(disp_value + 4))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 if (needs_patching) {
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1396 __ patchable_set(0, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 __ set(disp_value, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 disp_reg = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 } else if (unaligned || PatchALot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 __ add(src, addr->index()->as_register(), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 src = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1405 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 disp_reg = addr->index()->as_pointer_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 assert(disp_value == 0, "can't handle 3 operand addresses");
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1409
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 // remember the offset of the load. The patching_epilog must be done
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 // before the call to add_debug_info, otherwise the PcDescs don't get
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 // entered in increasing order.
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 int offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1414
a61af66fc99e Initial load
duke
parents:
diff changeset
1415 assert(disp_reg != noreg || Assembler::is_simm13(disp_value), "should have set this up");
a61af66fc99e Initial load
duke
parents:
diff changeset
1416 if (disp_reg == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 offset = load(src, disp_value, to_reg, type, unaligned);
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 assert(!unaligned, "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1420 offset = load(src, disp_reg, to_reg, type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1422
a61af66fc99e Initial load
duke
parents:
diff changeset
1423 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1424 patching_epilog(patch, patch_code, src, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1425 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1426
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 if (info != NULL) add_debug_info_for_null_check(offset, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1429
a61af66fc99e Initial load
duke
parents:
diff changeset
1430
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 void LIR_Assembler::prefetchr(LIR_Opr src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 LIR_Address* addr = src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 Address from_addr = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1434
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 if (VM_Version::has_v9()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1436 __ prefetch(from_addr, Assembler::severalReads);
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1439
a61af66fc99e Initial load
duke
parents:
diff changeset
1440
a61af66fc99e Initial load
duke
parents:
diff changeset
1441 void LIR_Assembler::prefetchw(LIR_Opr src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1442 LIR_Address* addr = src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 Address from_addr = as_Address(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1444
a61af66fc99e Initial load
duke
parents:
diff changeset
1445 if (VM_Version::has_v9()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 __ prefetch(from_addr, Assembler::severalWritesAndPossiblyReads);
a61af66fc99e Initial load
duke
parents:
diff changeset
1447 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1449
a61af66fc99e Initial load
duke
parents:
diff changeset
1450
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1452 Address addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1453 if (src->is_single_word()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 addr = frame_map()->address_for_slot(src->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1455 } else if (src->is_double_word()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 addr = frame_map()->address_for_double_slot(src->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1458
a61af66fc99e Initial load
duke
parents:
diff changeset
1459 bool unaligned = (addr.disp() - STACK_BIAS) % 8 != 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1460 load(addr.base(), addr.disp(), dest, dest->type(), unaligned);
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1462
a61af66fc99e Initial load
duke
parents:
diff changeset
1463
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 void LIR_Assembler::reg2stack(LIR_Opr from_reg, LIR_Opr dest, BasicType type, bool pop_fpu_stack) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1465 Address addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1466 if (dest->is_single_word()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 addr = frame_map()->address_for_slot(dest->single_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1468 } else if (dest->is_double_word()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 addr = frame_map()->address_for_slot(dest->double_stack_ix());
a61af66fc99e Initial load
duke
parents:
diff changeset
1470 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 bool unaligned = (addr.disp() - STACK_BIAS) % 8 != 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1472 store(from_reg, addr.base(), addr.disp(), from_reg->type(), unaligned);
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1474
a61af66fc99e Initial load
duke
parents:
diff changeset
1475
a61af66fc99e Initial load
duke
parents:
diff changeset
1476 void LIR_Assembler::reg2reg(LIR_Opr from_reg, LIR_Opr to_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 if (from_reg->is_float_kind() && to_reg->is_float_kind()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 if (from_reg->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1479 // double to double moves
a61af66fc99e Initial load
duke
parents:
diff changeset
1480 assert(to_reg->is_double_fpu(), "should match");
a61af66fc99e Initial load
duke
parents:
diff changeset
1481 __ fmov(FloatRegisterImpl::D, from_reg->as_double_reg(), to_reg->as_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1483 // float to float moves
a61af66fc99e Initial load
duke
parents:
diff changeset
1484 assert(to_reg->is_single_fpu(), "should match");
a61af66fc99e Initial load
duke
parents:
diff changeset
1485 __ fmov(FloatRegisterImpl::S, from_reg->as_float_reg(), to_reg->as_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1487 } else if (!from_reg->is_float_kind() && !to_reg->is_float_kind()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1488 if (from_reg->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 __ mov(from_reg->as_pointer_register(), to_reg->as_pointer_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1491 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
1492 assert(to_reg->is_double_cpu() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 from_reg->as_register_hi() != to_reg->as_register_lo() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1494 from_reg->as_register_lo() != to_reg->as_register_hi(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 "should both be long and not overlap");
a61af66fc99e Initial load
duke
parents:
diff changeset
1496 // long to long moves
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 __ mov(from_reg->as_register_hi(), to_reg->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1498 __ mov(from_reg->as_register_lo(), to_reg->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1499 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1500 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 } else if (to_reg->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1502 // int to int moves
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 __ mov(from_reg->as_register(), to_reg->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1504 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1506 // int to int moves
a61af66fc99e Initial load
duke
parents:
diff changeset
1507 __ mov(from_reg->as_register(), to_reg->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1509 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1510 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1512 if (to_reg->type() == T_OBJECT || to_reg->type() == T_ARRAY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1513 __ verify_oop(to_reg->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1514 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1515 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1516
a61af66fc99e Initial load
duke
parents:
diff changeset
1517
a61af66fc99e Initial load
duke
parents:
diff changeset
1518 void LIR_Assembler::reg2mem(LIR_Opr from_reg, LIR_Opr dest, BasicType type,
a61af66fc99e Initial load
duke
parents:
diff changeset
1519 LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
1520 bool unaligned) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1521 LIR_Address* addr = dest->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1522
a61af66fc99e Initial load
duke
parents:
diff changeset
1523 Register src = addr->base()->as_pointer_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1524 Register disp_reg = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1525 int disp_value = addr->disp();
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 bool needs_patching = (patch_code != lir_patch_none);
a61af66fc99e Initial load
duke
parents:
diff changeset
1527
a61af66fc99e Initial load
duke
parents:
diff changeset
1528 if (addr->base()->is_oop_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1529 __ verify_oop(src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1530 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1531
a61af66fc99e Initial load
duke
parents:
diff changeset
1532 PatchingStub* patch = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1533 if (needs_patching) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1534 patch = new PatchingStub(_masm, PatchingStub::access_field_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
1535 assert(!from_reg->is_double_cpu() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1536 patch_code == lir_patch_none ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1537 patch_code == lir_patch_normal, "patching doesn't match register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1539
a61af66fc99e Initial load
duke
parents:
diff changeset
1540 if (addr->index()->is_illegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 if (!Assembler::is_simm13(disp_value) && (!unaligned || Assembler::is_simm13(disp_value + 4))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1542 if (needs_patching) {
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1543 __ patchable_set(0, O7);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1544 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1545 __ set(disp_value, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1546 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1547 disp_reg = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1548 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1549 } else if (unaligned || PatchALot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1550 __ add(src, addr->index()->as_register(), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 src = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1552 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1553 disp_reg = addr->index()->as_pointer_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1554 assert(disp_value == 0, "can't handle 3 operand addresses");
a61af66fc99e Initial load
duke
parents:
diff changeset
1555 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1556
a61af66fc99e Initial load
duke
parents:
diff changeset
1557 // remember the offset of the store. The patching_epilog must be done
a61af66fc99e Initial load
duke
parents:
diff changeset
1558 // before the call to add_debug_info_for_null_check, otherwise the PcDescs don't get
a61af66fc99e Initial load
duke
parents:
diff changeset
1559 // entered in increasing order.
a61af66fc99e Initial load
duke
parents:
diff changeset
1560 int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1561
a61af66fc99e Initial load
duke
parents:
diff changeset
1562 assert(disp_reg != noreg || Assembler::is_simm13(disp_value), "should have set this up");
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 if (disp_reg == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1564 offset = store(from_reg, src, disp_value, type, unaligned);
a61af66fc99e Initial load
duke
parents:
diff changeset
1565 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1566 assert(!unaligned, "can't handle this");
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 offset = store(from_reg, src, disp_reg, type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1569
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 if (patch != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 patching_epilog(patch, patch_code, src, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1572 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1573
a61af66fc99e Initial load
duke
parents:
diff changeset
1574 if (info != NULL) add_debug_info_for_null_check(offset, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1576
a61af66fc99e Initial load
duke
parents:
diff changeset
1577
a61af66fc99e Initial load
duke
parents:
diff changeset
1578 void LIR_Assembler::return_op(LIR_Opr result) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1579 // the poll may need a register so just pick one that isn't the return register
a61af66fc99e Initial load
duke
parents:
diff changeset
1580 #ifdef TIERED
a61af66fc99e Initial load
duke
parents:
diff changeset
1581 if (result->type_field() == LIR_OprDesc::long_type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1582 // Must move the result to G1
a61af66fc99e Initial load
duke
parents:
diff changeset
1583 // Must leave proper result in O0,O1 and G1 (TIERED only)
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 __ sllx(I0, 32, G1); // Shift bits into high G1
a61af66fc99e Initial load
duke
parents:
diff changeset
1585 __ srl (I1, 0, I1); // Zero extend O1 (harmless?)
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 __ or3 (I1, G1, G1); // OR 64 bits into G1
a61af66fc99e Initial load
duke
parents:
diff changeset
1587 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1588 #endif // TIERED
a61af66fc99e Initial load
duke
parents:
diff changeset
1589 __ set((intptr_t)os::get_polling_page(), L0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 __ relocate(relocInfo::poll_return_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1591 __ ld_ptr(L0, 0, G0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1592 __ ret();
a61af66fc99e Initial load
duke
parents:
diff changeset
1593 __ delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
1594 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1595
a61af66fc99e Initial load
duke
parents:
diff changeset
1596
a61af66fc99e Initial load
duke
parents:
diff changeset
1597 int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1598 __ set((intptr_t)os::get_polling_page(), tmp->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1599 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1600 add_debug_info_for_branch(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1601 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1602 __ relocate(relocInfo::poll_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1603 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1604
a61af66fc99e Initial load
duke
parents:
diff changeset
1605 int offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1606 __ ld_ptr(tmp->as_register(), 0, G0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1607
a61af66fc99e Initial load
duke
parents:
diff changeset
1608 return offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1610
a61af66fc99e Initial load
duke
parents:
diff changeset
1611
a61af66fc99e Initial load
duke
parents:
diff changeset
1612 void LIR_Assembler::emit_static_call_stub() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 address call_pc = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 address stub = __ start_a_stub(call_stub_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 if (stub == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1616 bailout("static call stub overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
1617 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1618 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1619
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 int start = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1621 __ relocate(static_stub_Relocation::spec(call_pc));
a61af66fc99e Initial load
duke
parents:
diff changeset
1622
a61af66fc99e Initial load
duke
parents:
diff changeset
1623 __ set_oop(NULL, G5);
a61af66fc99e Initial load
duke
parents:
diff changeset
1624 // must be set to -1 at code generation time
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1625 AddressLiteral addrlit(-1);
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
1626 __ jump_to(addrlit, G3);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1627 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
1628
a61af66fc99e Initial load
duke
parents:
diff changeset
1629 assert(__ offset() - start <= call_stub_size, "stub too big");
a61af66fc99e Initial load
duke
parents:
diff changeset
1630 __ end_a_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1632
a61af66fc99e Initial load
duke
parents:
diff changeset
1633
a61af66fc99e Initial load
duke
parents:
diff changeset
1634 void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 if (opr1->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 __ fcmp(FloatRegisterImpl::S, Assembler::fcc0, opr1->as_float_reg(), opr2->as_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 } else if (opr1->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 __ fcmp(FloatRegisterImpl::D, Assembler::fcc0, opr1->as_double_reg(), opr2->as_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
1639 } else if (opr1->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1640 if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 switch (opr2->as_constant_ptr()->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1642 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1643 { jint con = opr2->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 if (Assembler::is_simm13(con)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 __ cmp(opr1->as_register(), con);
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1647 __ set(con, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1648 __ cmp(opr1->as_register(), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1649 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1651 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1652
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 case T_OBJECT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1654 // there are only equal/notequal comparisions on objects
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 { jobject con = opr2->as_constant_ptr()->as_jobject();
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 if (con == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1657 __ cmp(opr1->as_register(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1659 jobject2reg(con, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 __ cmp(opr1->as_register(), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1663 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1664
a61af66fc99e Initial load
duke
parents:
diff changeset
1665 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1670 if (opr2->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1671 LIR_Address * addr = opr2->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1672 BasicType type = addr->type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1673 if ( type == T_OBJECT ) __ ld_ptr(as_Address(addr), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1674 else __ ld(as_Address(addr), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1675 __ cmp(opr1->as_register(), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1676 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 __ cmp(opr1->as_register(), opr2->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1678 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1679 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1680 } else if (opr1->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1681 Register xlo = opr1->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1682 Register xhi = opr1->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
1683 if (opr2->is_constant() && opr2->as_jlong() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1684 assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "only handles these cases");
a61af66fc99e Initial load
duke
parents:
diff changeset
1685 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1686 __ orcc(xhi, G0, G0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1687 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
1688 __ orcc(xhi, xlo, G0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1689 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1690 } else if (opr2->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1691 Register ylo = opr2->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1692 Register yhi = opr2->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
1693 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1694 __ cmp(xlo, ylo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1695 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
1696 __ subcc(xlo, ylo, xlo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1697 __ subccc(xhi, yhi, xhi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1698 if (condition == lir_cond_equal || condition == lir_cond_notEqual) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1699 __ orcc(xhi, xlo, G0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1700 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1701 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1702 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1703 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1704 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1705 } else if (opr1->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1706 LIR_Address * addr = opr1->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1707 BasicType type = addr->type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1708 assert (opr2->is_constant(), "Checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
1709 if ( type == T_OBJECT ) __ ld_ptr(as_Address(addr), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1710 else __ ld(as_Address(addr), O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1711 __ cmp(O7, opr2->as_constant_ptr()->as_jint());
a61af66fc99e Initial load
duke
parents:
diff changeset
1712 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1713 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1714 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1715 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1716
a61af66fc99e Initial load
duke
parents:
diff changeset
1717
a61af66fc99e Initial load
duke
parents:
diff changeset
1718 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
1719 if (code == lir_cmp_fd2i || code == lir_ucmp_fd2i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1720 bool is_unordered_less = (code == lir_ucmp_fd2i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1721 if (left->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1722 __ float_cmp(true, is_unordered_less ? -1 : 1, left->as_float_reg(), right->as_float_reg(), dst->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1723 } else if (left->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1724 __ float_cmp(false, is_unordered_less ? -1 : 1, left->as_double_reg(), right->as_double_reg(), dst->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1725 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1726 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1727 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1728 } else if (code == lir_cmp_l2i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1729 __ lcmp(left->as_register_hi(), left->as_register_lo(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1730 right->as_register_hi(), right->as_register_lo(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1731 dst->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
1732 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1733 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1734 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1735 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1736
a61af66fc99e Initial load
duke
parents:
diff changeset
1737
a61af66fc99e Initial load
duke
parents:
diff changeset
1738 void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1739
a61af66fc99e Initial load
duke
parents:
diff changeset
1740 Assembler::Condition acond;
a61af66fc99e Initial load
duke
parents:
diff changeset
1741 switch (condition) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1742 case lir_cond_equal: acond = Assembler::equal; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1743 case lir_cond_notEqual: acond = Assembler::notEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1744 case lir_cond_less: acond = Assembler::less; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1745 case lir_cond_lessEqual: acond = Assembler::lessEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1746 case lir_cond_greaterEqual: acond = Assembler::greaterEqual; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1747 case lir_cond_greater: acond = Assembler::greater; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1748 case lir_cond_aboveEqual: acond = Assembler::greaterEqualUnsigned; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1749 case lir_cond_belowEqual: acond = Assembler::lessEqualUnsigned; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1750 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1751 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1752
a61af66fc99e Initial load
duke
parents:
diff changeset
1753 if (opr1->is_constant() && opr1->type() == T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1754 Register dest = result->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1755 // load up first part of constant before branch
a61af66fc99e Initial load
duke
parents:
diff changeset
1756 // and do the rest in the delay slot.
a61af66fc99e Initial load
duke
parents:
diff changeset
1757 if (!Assembler::is_simm13(opr1->as_jint())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1758 __ sethi(opr1->as_jint(), dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
1759 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1760 } else if (opr1->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1761 const2reg(opr1, result, lir_patch_none, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1762 } else if (opr1->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1763 reg2reg(opr1, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
1764 } else if (opr1->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1765 stack2reg(opr1, result, result->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
1766 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1767 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1768 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1769 Label skip;
a61af66fc99e Initial load
duke
parents:
diff changeset
1770 __ br(acond, false, Assembler::pt, skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
1771 if (opr1->is_constant() && opr1->type() == T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1772 Register dest = result->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1773 if (Assembler::is_simm13(opr1->as_jint())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1774 __ delayed()->or3(G0, opr1->as_jint(), dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
1775 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1776 // the sethi has been done above, so just put in the low 10 bits
a61af66fc99e Initial load
duke
parents:
diff changeset
1777 __ delayed()->or3(dest, opr1->as_jint() & 0x3ff, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
1778 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1779 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1780 // can't do anything useful in the delay slot
a61af66fc99e Initial load
duke
parents:
diff changeset
1781 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
1782 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1783 if (opr2->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1784 const2reg(opr2, result, lir_patch_none, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1785 } else if (opr2->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1786 reg2reg(opr2, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
1787 } else if (opr2->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1788 stack2reg(opr2, result, result->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
1789 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1790 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1791 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1792 __ bind(skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
1793 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1794
a61af66fc99e Initial load
duke
parents:
diff changeset
1795
a61af66fc99e Initial load
duke
parents:
diff changeset
1796 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
1797 assert(info == NULL, "unused on this code path");
a61af66fc99e Initial load
duke
parents:
diff changeset
1798 assert(left->is_register(), "wrong items state");
a61af66fc99e Initial load
duke
parents:
diff changeset
1799 assert(dest->is_register(), "wrong items state");
a61af66fc99e Initial load
duke
parents:
diff changeset
1800
a61af66fc99e Initial load
duke
parents:
diff changeset
1801 if (right->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1802 if (dest->is_float_kind()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1803
a61af66fc99e Initial load
duke
parents:
diff changeset
1804 FloatRegister lreg, rreg, res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1805 FloatRegisterImpl::Width w;
a61af66fc99e Initial load
duke
parents:
diff changeset
1806 if (right->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1807 w = FloatRegisterImpl::S;
a61af66fc99e Initial load
duke
parents:
diff changeset
1808 lreg = left->as_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1809 rreg = right->as_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1810 res = dest->as_float_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1811 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1812 w = FloatRegisterImpl::D;
a61af66fc99e Initial load
duke
parents:
diff changeset
1813 lreg = left->as_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1814 rreg = right->as_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1815 res = dest->as_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1816 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1817
a61af66fc99e Initial load
duke
parents:
diff changeset
1818 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1819 case lir_add: __ fadd(w, lreg, rreg, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1820 case lir_sub: __ fsub(w, lreg, rreg, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1821 case lir_mul: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1822 case lir_mul_strictfp: __ fmul(w, lreg, rreg, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1823 case lir_div: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1824 case lir_div_strictfp: __ fdiv(w, lreg, rreg, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1825 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1826 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1827
a61af66fc99e Initial load
duke
parents:
diff changeset
1828 } else if (dest->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1829 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1830 Register dst_lo = dest->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1831 Register op1_lo = left->as_pointer_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1832 Register op2_lo = right->as_pointer_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1833
a61af66fc99e Initial load
duke
parents:
diff changeset
1834 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1835 case lir_add:
a61af66fc99e Initial load
duke
parents:
diff changeset
1836 __ add(op1_lo, op2_lo, dst_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1837 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1838
a61af66fc99e Initial load
duke
parents:
diff changeset
1839 case lir_sub:
a61af66fc99e Initial load
duke
parents:
diff changeset
1840 __ sub(op1_lo, op2_lo, dst_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1841 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1842
a61af66fc99e Initial load
duke
parents:
diff changeset
1843 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1844 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1845 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
1846 Register op1_lo = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1847 Register op1_hi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
1848 Register op2_lo = right->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1849 Register op2_hi = right->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
1850 Register dst_lo = dest->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1851 Register dst_hi = dest->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
1852
a61af66fc99e Initial load
duke
parents:
diff changeset
1853 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1854 case lir_add:
a61af66fc99e Initial load
duke
parents:
diff changeset
1855 __ addcc(op1_lo, op2_lo, dst_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1856 __ addc (op1_hi, op2_hi, dst_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1857 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1858
a61af66fc99e Initial load
duke
parents:
diff changeset
1859 case lir_sub:
a61af66fc99e Initial load
duke
parents:
diff changeset
1860 __ subcc(op1_lo, op2_lo, dst_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1861 __ subc (op1_hi, op2_hi, dst_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1862 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1863
a61af66fc99e Initial load
duke
parents:
diff changeset
1864 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1865 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1866 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1867 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1868 assert (right->is_single_cpu(), "Just Checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
1869
a61af66fc99e Initial load
duke
parents:
diff changeset
1870 Register lreg = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1871 Register res = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1872 Register rreg = right->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1873 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1874 case lir_add: __ add (lreg, rreg, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1875 case lir_sub: __ sub (lreg, rreg, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1876 case lir_mul: __ mult (lreg, rreg, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1877 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1878 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1879 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1880 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1881 assert (right->is_constant(), "must be constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
1882
a61af66fc99e Initial load
duke
parents:
diff changeset
1883 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1884 Register lreg = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1885 Register res = dest->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1886 int simm13 = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
1887
a61af66fc99e Initial load
duke
parents:
diff changeset
1888 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1889 case lir_add: __ add (lreg, simm13, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1890 case lir_sub: __ sub (lreg, simm13, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1891 case lir_mul: __ mult (lreg, simm13, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1892 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1893 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1894 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1895 Register lreg = left->as_pointer_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1896 Register res = dest->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1897 long con = right->as_constant_ptr()->as_jlong();
a61af66fc99e Initial load
duke
parents:
diff changeset
1898 assert(Assembler::is_simm13(con), "must be simm13");
a61af66fc99e Initial load
duke
parents:
diff changeset
1899
a61af66fc99e Initial load
duke
parents:
diff changeset
1900 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1901 case lir_add: __ add (lreg, (int)con, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1902 case lir_sub: __ sub (lreg, (int)con, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1903 case lir_mul: __ mult (lreg, (int)con, res); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1904 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1905 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1906 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1907 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1908 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1909
a61af66fc99e Initial load
duke
parents:
diff changeset
1910
a61af66fc99e Initial load
duke
parents:
diff changeset
1911 void LIR_Assembler::fpop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1912 // do nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
1913 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1914
a61af66fc99e Initial load
duke
parents:
diff changeset
1915
a61af66fc99e Initial load
duke
parents:
diff changeset
1916 void LIR_Assembler::intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr thread, LIR_Opr dest, LIR_Op* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1917 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1918 case lir_sin:
a61af66fc99e Initial load
duke
parents:
diff changeset
1919 case lir_tan:
a61af66fc99e Initial load
duke
parents:
diff changeset
1920 case lir_cos: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1921 assert(thread->is_valid(), "preserve the thread object for performance reasons");
a61af66fc99e Initial load
duke
parents:
diff changeset
1922 assert(dest->as_double_reg() == F0, "the result will be in f0/f1");
a61af66fc99e Initial load
duke
parents:
diff changeset
1923 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1924 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1925 case lir_sqrt: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1926 assert(!thread->is_valid(), "there is no need for a thread_reg for dsqrt");
a61af66fc99e Initial load
duke
parents:
diff changeset
1927 FloatRegister src_reg = value->as_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1928 FloatRegister dst_reg = dest->as_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1929 __ fsqrt(FloatRegisterImpl::D, src_reg, dst_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1930 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1931 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1932 case lir_abs: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1933 assert(!thread->is_valid(), "there is no need for a thread_reg for fabs");
a61af66fc99e Initial load
duke
parents:
diff changeset
1934 FloatRegister src_reg = value->as_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1935 FloatRegister dst_reg = dest->as_double_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1936 __ fabs(FloatRegisterImpl::D, src_reg, dst_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1937 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1938 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1939 default: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1940 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1941 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1942 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1943 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1944 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1945
a61af66fc99e Initial load
duke
parents:
diff changeset
1946
a61af66fc99e Initial load
duke
parents:
diff changeset
1947 void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1948 if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1949 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1950 int simm13 = right->as_constant_ptr()->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
1951 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1952 case lir_logic_and: __ and3 (left->as_register(), simm13, dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1953 case lir_logic_or: __ or3 (left->as_register(), simm13, dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1954 case lir_logic_xor: __ xor3 (left->as_register(), simm13, dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1955 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1956 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1957 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1958 long c = right->as_constant_ptr()->as_jlong();
a61af66fc99e Initial load
duke
parents:
diff changeset
1959 assert(c == (int)c && Assembler::is_simm13(c), "out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
1960 int simm13 = (int)c;
a61af66fc99e Initial load
duke
parents:
diff changeset
1961 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1962 case lir_logic_and:
a61af66fc99e Initial load
duke
parents:
diff changeset
1963 #ifndef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1964 __ and3 (left->as_register_hi(), 0, dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1965 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1966 __ and3 (left->as_register_lo(), simm13, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1967 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1968
a61af66fc99e Initial load
duke
parents:
diff changeset
1969 case lir_logic_or:
a61af66fc99e Initial load
duke
parents:
diff changeset
1970 #ifndef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1971 __ or3 (left->as_register_hi(), 0, dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1972 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1973 __ or3 (left->as_register_lo(), simm13, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1974 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1975
a61af66fc99e Initial load
duke
parents:
diff changeset
1976 case lir_logic_xor:
a61af66fc99e Initial load
duke
parents:
diff changeset
1977 #ifndef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1978 __ xor3 (left->as_register_hi(), 0, dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
1979 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1980 __ xor3 (left->as_register_lo(), simm13, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
1981 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1982
a61af66fc99e Initial load
duke
parents:
diff changeset
1983 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1984 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1985 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1986 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1987 assert(right->is_register(), "right should be in register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1988
a61af66fc99e Initial load
duke
parents:
diff changeset
1989 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1990 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1991 case lir_logic_and: __ and3 (left->as_register(), right->as_register(), dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1992 case lir_logic_or: __ or3 (left->as_register(), right->as_register(), dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1993 case lir_logic_xor: __ xor3 (left->as_register(), right->as_register(), dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1994 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1995 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1996 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1997 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1998 Register l = (left->is_single_cpu() && left->is_oop_register()) ? left->as_register() :
a61af66fc99e Initial load
duke
parents:
diff changeset
1999 left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2000 Register r = (right->is_single_cpu() && right->is_oop_register()) ? right->as_register() :
a61af66fc99e Initial load
duke
parents:
diff changeset
2001 right->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2002
a61af66fc99e Initial load
duke
parents:
diff changeset
2003 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2004 case lir_logic_and: __ and3 (l, r, dest->as_register_lo()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2005 case lir_logic_or: __ or3 (l, r, dest->as_register_lo()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2006 case lir_logic_xor: __ xor3 (l, r, dest->as_register_lo()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2007 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2008 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2009 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
2010 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2011 case lir_logic_and:
a61af66fc99e Initial load
duke
parents:
diff changeset
2012 __ and3 (left->as_register_hi(), right->as_register_hi(), dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
2013 __ and3 (left->as_register_lo(), right->as_register_lo(), dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
2014 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2015
a61af66fc99e Initial load
duke
parents:
diff changeset
2016 case lir_logic_or:
a61af66fc99e Initial load
duke
parents:
diff changeset
2017 __ or3 (left->as_register_hi(), right->as_register_hi(), dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
2018 __ or3 (left->as_register_lo(), right->as_register_lo(), dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
2019 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2020
a61af66fc99e Initial load
duke
parents:
diff changeset
2021 case lir_logic_xor:
a61af66fc99e Initial load
duke
parents:
diff changeset
2022 __ xor3 (left->as_register_hi(), right->as_register_hi(), dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
2023 __ xor3 (left->as_register_lo(), right->as_register_lo(), dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
2024 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2025
a61af66fc99e Initial load
duke
parents:
diff changeset
2026 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2027 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2028 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2029 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2030 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2031 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2032
a61af66fc99e Initial load
duke
parents:
diff changeset
2033
a61af66fc99e Initial load
duke
parents:
diff changeset
2034 int LIR_Assembler::shift_amount(BasicType t) {
29
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
2035 int elem_size = type2aelembytes(t);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2036 switch (elem_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2037 case 1 : return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2038 case 2 : return 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2039 case 4 : return 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
2040 case 8 : return 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
2041 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2042 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2043 return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2044 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2045
a61af66fc99e Initial load
duke
parents:
diff changeset
2046
a61af66fc99e Initial load
duke
parents:
diff changeset
2047 void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info, bool unwind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2048 assert(exceptionOop->as_register() == Oexception, "should match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2049 assert(unwind || exceptionPC->as_register() == Oissuing_pc, "should match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2050
a61af66fc99e Initial load
duke
parents:
diff changeset
2051 info->add_register_oop(exceptionOop);
a61af66fc99e Initial load
duke
parents:
diff changeset
2052
a61af66fc99e Initial load
duke
parents:
diff changeset
2053 if (unwind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2054 __ call(Runtime1::entry_for(Runtime1::unwind_exception_id), relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
2055 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2056 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2057 // reuse the debug info from the safepoint poll for the throw op itself
a61af66fc99e Initial load
duke
parents:
diff changeset
2058 address pc_for_athrow = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
2059 int pc_for_athrow_offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2060 RelocationHolder rspec = internal_word_Relocation::spec(pc_for_athrow);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2061 __ set(pc_for_athrow, Oissuing_pc, rspec);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2062 add_call_info(pc_for_athrow_offset, info); // for exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
2063
a61af66fc99e Initial load
duke
parents:
diff changeset
2064 __ call(Runtime1::entry_for(Runtime1::handle_exception_id), relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
2065 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2066 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2067 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2068
a61af66fc99e Initial load
duke
parents:
diff changeset
2069
a61af66fc99e Initial load
duke
parents:
diff changeset
2070 void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2071 Register src = op->src()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2072 Register dst = op->dst()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2073 Register src_pos = op->src_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2074 Register dst_pos = op->dst_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2075 Register length = op->length()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2076 Register tmp = op->tmp()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2077 Register tmp2 = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
2078
a61af66fc99e Initial load
duke
parents:
diff changeset
2079 int flags = op->flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
2080 ciArrayKlass* default_type = op->expected_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
2081 BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2082 if (basic_type == T_ARRAY) basic_type = T_OBJECT;
a61af66fc99e Initial load
duke
parents:
diff changeset
2083
a61af66fc99e Initial load
duke
parents:
diff changeset
2084 // set up the arraycopy stub information
a61af66fc99e Initial load
duke
parents:
diff changeset
2085 ArrayCopyStub* stub = op->stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
2086
a61af66fc99e Initial load
duke
parents:
diff changeset
2087 // always do stub if no type information is available. it's ok if
a61af66fc99e Initial load
duke
parents:
diff changeset
2088 // the known type isn't loaded since the code sanity checks
a61af66fc99e Initial load
duke
parents:
diff changeset
2089 // in debug mode and the type isn't required when we know the exact type
a61af66fc99e Initial load
duke
parents:
diff changeset
2090 // also check that the type is an array type.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 29
diff changeset
2091 // We also, for now, always call the stub if the barrier set requires a
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 29
diff changeset
2092 // write_ref_pre barrier (which the stub does, but none of the optimized
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 29
diff changeset
2093 // cases currently does).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 29
diff changeset
2094 if (op->expected_type() == NULL ||
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 29
diff changeset
2095 Universe::heap()->barrier_set()->has_write_ref_pre_barrier()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2096 __ mov(src, O0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2097 __ mov(src_pos, O1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2098 __ mov(dst, O2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2099 __ mov(dst_pos, O3);
a61af66fc99e Initial load
duke
parents:
diff changeset
2100 __ mov(length, O4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2101 __ call_VM_leaf(tmp, CAST_FROM_FN_PTR(address, Runtime1::arraycopy));
a61af66fc99e Initial load
duke
parents:
diff changeset
2102
a61af66fc99e Initial load
duke
parents:
diff changeset
2103 __ br_zero(Assembler::less, false, Assembler::pn, O0, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2104 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2105 __ bind(*stub->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
2106 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2108
a61af66fc99e Initial load
duke
parents:
diff changeset
2109 assert(default_type != NULL && default_type->is_array_klass(), "must be true at this point");
a61af66fc99e Initial load
duke
parents:
diff changeset
2110
a61af66fc99e Initial load
duke
parents:
diff changeset
2111 // make sure src and dst are non-null and load array length
a61af66fc99e Initial load
duke
parents:
diff changeset
2112 if (flags & LIR_OpArrayCopy::src_null_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2113 __ tst(src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2114 __ br(Assembler::equal, false, Assembler::pn, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2115 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2117
a61af66fc99e Initial load
duke
parents:
diff changeset
2118 if (flags & LIR_OpArrayCopy::dst_null_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2119 __ tst(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2120 __ br(Assembler::equal, false, Assembler::pn, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2121 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2123
a61af66fc99e Initial load
duke
parents:
diff changeset
2124 if (flags & LIR_OpArrayCopy::src_pos_positive_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2125 // test src_pos register
a61af66fc99e Initial load
duke
parents:
diff changeset
2126 __ tst(src_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
2127 __ br(Assembler::less, false, Assembler::pn, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2128 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2130
a61af66fc99e Initial load
duke
parents:
diff changeset
2131 if (flags & LIR_OpArrayCopy::dst_pos_positive_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2132 // test dst_pos register
a61af66fc99e Initial load
duke
parents:
diff changeset
2133 __ tst(dst_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
2134 __ br(Assembler::less, false, Assembler::pn, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2135 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2137
a61af66fc99e Initial load
duke
parents:
diff changeset
2138 if (flags & LIR_OpArrayCopy::length_positive_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2139 // make sure length isn't negative
a61af66fc99e Initial load
duke
parents:
diff changeset
2140 __ tst(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
2141 __ br(Assembler::less, false, Assembler::pn, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2142 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2144
a61af66fc99e Initial load
duke
parents:
diff changeset
2145 if (flags & LIR_OpArrayCopy::src_range_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2146 __ ld(src, arrayOopDesc::length_offset_in_bytes(), tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2147 __ add(length, src_pos, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2148 __ cmp(tmp2, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2149 __ br(Assembler::carrySet, false, Assembler::pn, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2150 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2152
a61af66fc99e Initial load
duke
parents:
diff changeset
2153 if (flags & LIR_OpArrayCopy::dst_range_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2154 __ ld(dst, arrayOopDesc::length_offset_in_bytes(), tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2155 __ add(length, dst_pos, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2156 __ cmp(tmp2, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2157 __ br(Assembler::carrySet, false, Assembler::pn, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2158 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2160
a61af66fc99e Initial load
duke
parents:
diff changeset
2161 if (flags & LIR_OpArrayCopy::type_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2162 __ ld_ptr(src, oopDesc::klass_offset_in_bytes(), tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2163 __ ld_ptr(dst, oopDesc::klass_offset_in_bytes(), tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2164 __ cmp(tmp, tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2165 __ br(Assembler::notEqual, false, Assembler::pt, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2166 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2168
a61af66fc99e Initial load
duke
parents:
diff changeset
2169 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2170 if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2171 // Sanity check the known type with the incoming class. For the
a61af66fc99e Initial load
duke
parents:
diff changeset
2172 // primitive case the types must match exactly with src.klass and
a61af66fc99e Initial load
duke
parents:
diff changeset
2173 // dst.klass each exactly matching the default type. For the
a61af66fc99e Initial load
duke
parents:
diff changeset
2174 // object array case, if no type check is needed then either the
a61af66fc99e Initial load
duke
parents:
diff changeset
2175 // dst type is exactly the expected type and the src type is a
a61af66fc99e Initial load
duke
parents:
diff changeset
2176 // subtype which we can't check or src is the same array as dst
a61af66fc99e Initial load
duke
parents:
diff changeset
2177 // but not necessarily exactly of type default_type.
a61af66fc99e Initial load
duke
parents:
diff changeset
2178 Label known_ok, halt;
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 780
diff changeset
2179 jobject2reg(op->expected_type()->constant_encoding(), tmp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2180 __ ld_ptr(dst, oopDesc::klass_offset_in_bytes(), tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2181 if (basic_type != T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2182 __ cmp(tmp, tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2183 __ br(Assembler::notEqual, false, Assembler::pn, halt);
a61af66fc99e Initial load
duke
parents:
diff changeset
2184 __ delayed()->ld_ptr(src, oopDesc::klass_offset_in_bytes(), tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2185 __ cmp(tmp, tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2186 __ br(Assembler::equal, false, Assembler::pn, known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
2187 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2188 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2189 __ cmp(tmp, tmp2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2190 __ br(Assembler::equal, false, Assembler::pn, known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
2191 __ delayed()->cmp(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2192 __ br(Assembler::equal, false, Assembler::pn, known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
2193 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2195 __ bind(halt);
a61af66fc99e Initial load
duke
parents:
diff changeset
2196 __ stop("incorrect type information in arraycopy");
a61af66fc99e Initial load
duke
parents:
diff changeset
2197 __ bind(known_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
2198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2199 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2200
a61af66fc99e Initial load
duke
parents:
diff changeset
2201 int shift = shift_amount(basic_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
2202
a61af66fc99e Initial load
duke
parents:
diff changeset
2203 Register src_ptr = O0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2204 Register dst_ptr = O1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2205 Register len = O2;
a61af66fc99e Initial load
duke
parents:
diff changeset
2206
a61af66fc99e Initial load
duke
parents:
diff changeset
2207 __ add(src, arrayOopDesc::base_offset_in_bytes(basic_type), src_ptr);
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
2208 LP64_ONLY(__ sra(src_pos, 0, src_pos);) //higher 32bits must be null
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2209 if (shift == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2210 __ add(src_ptr, src_pos, src_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2211 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2212 __ sll(src_pos, shift, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2213 __ add(src_ptr, tmp, src_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2215
a61af66fc99e Initial load
duke
parents:
diff changeset
2216 __ add(dst, arrayOopDesc::base_offset_in_bytes(basic_type), dst_ptr);
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
2217 LP64_ONLY(__ sra(dst_pos, 0, dst_pos);) //higher 32bits must be null
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2218 if (shift == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2219 __ add(dst_ptr, dst_pos, dst_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2220 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2221 __ sll(dst_pos, shift, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2222 __ add(dst_ptr, tmp, dst_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2224
a61af66fc99e Initial load
duke
parents:
diff changeset
2225 if (basic_type != T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2226 if (shift == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2227 __ mov(length, len);
a61af66fc99e Initial load
duke
parents:
diff changeset
2228 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2229 __ sll(length, shift, len);
a61af66fc99e Initial load
duke
parents:
diff changeset
2230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2231 __ call_VM_leaf(tmp, CAST_FROM_FN_PTR(address, Runtime1::primitive_arraycopy));
a61af66fc99e Initial load
duke
parents:
diff changeset
2232 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2233 // oop_arraycopy takes a length in number of elements, so don't scale it.
a61af66fc99e Initial load
duke
parents:
diff changeset
2234 __ mov(length, len);
a61af66fc99e Initial load
duke
parents:
diff changeset
2235 __ call_VM_leaf(tmp, CAST_FROM_FN_PTR(address, Runtime1::oop_arraycopy));
a61af66fc99e Initial load
duke
parents:
diff changeset
2236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2237
a61af66fc99e Initial load
duke
parents:
diff changeset
2238 __ bind(*stub->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
2239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2240
a61af66fc99e Initial load
duke
parents:
diff changeset
2241
a61af66fc99e Initial load
duke
parents:
diff changeset
2242 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
2243 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2244 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
2245 if (left->type() == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2246 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2247 case lir_shl: __ sllx (left->as_register(), count->as_register(), dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2248 case lir_shr: __ srax (left->as_register(), count->as_register(), dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2249 case lir_ushr: __ srl (left->as_register(), count->as_register(), dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2250 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2252 } else
a61af66fc99e Initial load
duke
parents:
diff changeset
2253 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2254 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2255 case lir_shl: __ sll (left->as_register(), count->as_register(), dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2256 case lir_shr: __ sra (left->as_register(), count->as_register(), dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2257 case lir_ushr: __ srl (left->as_register(), count->as_register(), dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2258 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2260 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2261 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
2262 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2263 case lir_shl: __ sllx (left->as_register_lo(), count->as_register(), dest->as_register_lo()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2264 case lir_shr: __ srax (left->as_register_lo(), count->as_register(), dest->as_register_lo()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2265 case lir_ushr: __ srlx (left->as_register_lo(), count->as_register(), dest->as_register_lo()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2266 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2268 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
2269 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2270 case lir_shl: __ lshl (left->as_register_hi(), left->as_register_lo(), count->as_register(), dest->as_register_hi(), dest->as_register_lo(), G3_scratch); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2271 case lir_shr: __ lshr (left->as_register_hi(), left->as_register_lo(), count->as_register(), dest->as_register_hi(), dest->as_register_lo(), G3_scratch); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2272 case lir_ushr: __ lushr (left->as_register_hi(), left->as_register_lo(), count->as_register(), dest->as_register_hi(), dest->as_register_lo(), G3_scratch); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2273 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2275 #endif
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
a61af66fc99e Initial load
duke
parents:
diff changeset
2280 void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2281 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
2282 if (left->type() == T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2283 count = count & 63; // shouldn't shift by more than sizeof(intptr_t)
a61af66fc99e Initial load
duke
parents:
diff changeset
2284 Register l = left->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2285 Register d = dest->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2286 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2287 case lir_shl: __ sllx (l, count, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2288 case lir_shr: __ srax (l, count, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2289 case lir_ushr: __ srlx (l, count, d); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2290 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2292 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2294 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2295
a61af66fc99e Initial load
duke
parents:
diff changeset
2296 if (dest->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2297 count = count & 0x1F; // Java spec
a61af66fc99e Initial load
duke
parents:
diff changeset
2298 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2299 case lir_shl: __ sll (left->as_register(), count, dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2300 case lir_shr: __ sra (left->as_register(), count, dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2301 case lir_ushr: __ srl (left->as_register(), count, dest->as_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2302 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2304 } else if (dest->is_double_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2305 count = count & 63; // Java spec
a61af66fc99e Initial load
duke
parents:
diff changeset
2306 switch (code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2307 case lir_shl: __ sllx (left->as_pointer_register(), count, dest->as_pointer_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2308 case lir_shr: __ srax (left->as_pointer_register(), count, dest->as_pointer_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2309 case lir_ushr: __ srlx (left->as_pointer_register(), count, dest->as_pointer_register()); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2310 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2312 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2313 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2316
a61af66fc99e Initial load
duke
parents:
diff changeset
2317
a61af66fc99e Initial load
duke
parents:
diff changeset
2318 void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2319 assert(op->tmp1()->as_register() == G1 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
2320 op->tmp2()->as_register() == G3 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
2321 op->tmp3()->as_register() == G4 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
2322 op->obj()->as_register() == O0 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
2323 op->klass()->as_register() == G5, "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
2324 if (op->init_check()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2325 __ ld(op->klass()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2326 instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc),
a61af66fc99e Initial load
duke
parents:
diff changeset
2327 op->tmp1()->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
2328 add_debug_info_for_null_check_here(op->stub()->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2329 __ cmp(op->tmp1()->as_register(), instanceKlass::fully_initialized);
a61af66fc99e Initial load
duke
parents:
diff changeset
2330 __ br(Assembler::notEqual, false, Assembler::pn, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2331 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2333 __ allocate_object(op->obj()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2334 op->tmp1()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2335 op->tmp2()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2336 op->tmp3()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2337 op->header_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2338 op->object_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2339 op->klass()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2340 *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2341 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
2342 __ verify_oop(op->obj()->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
2343 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2344
a61af66fc99e Initial load
duke
parents:
diff changeset
2345
a61af66fc99e Initial load
duke
parents:
diff changeset
2346 void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2347 assert(op->tmp1()->as_register() == G1 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
2348 op->tmp2()->as_register() == G3 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
2349 op->tmp3()->as_register() == G4 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
2350 op->tmp4()->as_register() == O1 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
2351 op->klass()->as_register() == G5, "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
2352 if (UseSlowPath ||
a61af66fc99e Initial load
duke
parents:
diff changeset
2353 (!UseFastNewObjectArray && (op->type() == T_OBJECT || op->type() == T_ARRAY)) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
2354 (!UseFastNewTypeArray && (op->type() != T_OBJECT && op->type() != T_ARRAY))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2355 __ br(Assembler::always, false, Assembler::pn, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2356 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2357 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2358 __ allocate_array(op->obj()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2359 op->len()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2360 op->tmp1()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2361 op->tmp2()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2362 op->tmp3()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2363 arrayOopDesc::header_size(op->type()),
29
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
2364 type2aelembytes(op->type()),
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2365 op->klass()->as_register(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2366 *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2368 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
2369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2370
a61af66fc99e Initial load
duke
parents:
diff changeset
2371
a61af66fc99e Initial load
duke
parents:
diff changeset
2372 void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2373 LIR_Code code = op->code();
a61af66fc99e Initial load
duke
parents:
diff changeset
2374 if (code == lir_store_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2375 Register value = op->object()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2376 Register array = op->array()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2377 Register k_RInfo = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2378 Register klass_RInfo = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2379 Register Rtmp1 = op->tmp3()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2380
a61af66fc99e Initial load
duke
parents:
diff changeset
2381 __ verify_oop(value);
a61af66fc99e Initial load
duke
parents:
diff changeset
2382
a61af66fc99e Initial load
duke
parents:
diff changeset
2383 CodeStub* stub = op->stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
2384 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
2385 __ cmp(value, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2386 __ br(Assembler::equal, false, Assembler::pn, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2387 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2388 load(array, oopDesc::klass_offset_in_bytes(), k_RInfo, T_OBJECT, op->info_for_exception());
a61af66fc99e Initial load
duke
parents:
diff changeset
2389 load(value, oopDesc::klass_offset_in_bytes(), klass_RInfo, T_OBJECT, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2390
a61af66fc99e Initial load
duke
parents:
diff changeset
2391 // get instance klass
a61af66fc99e Initial load
duke
parents:
diff changeset
2392 load(k_RInfo, objArrayKlass::element_klass_offset_in_bytes() + sizeof(oopDesc), k_RInfo, T_OBJECT, NULL);
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2393 // perform the fast part of the checking logic
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2394 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, O7, &done, stub->entry(), NULL);
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2395
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2396 // call out-of-line instance of __ check_klass_subtype_slow_path(...):
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2397 assert(klass_RInfo == G3 && k_RInfo == G1, "incorrect call setup");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2398 __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
2399 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2400 __ cmp(G3, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2401 __ br(Assembler::equal, false, Assembler::pn, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2402 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2403 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2404 } else if (op->code() == lir_checkcast) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2405 // we always need a stub for the failure case.
a61af66fc99e Initial load
duke
parents:
diff changeset
2406 CodeStub* stub = op->stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
2407 Register obj = op->object()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2408 Register k_RInfo = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2409 Register klass_RInfo = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2410 Register dst = op->result_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2411 Register Rtmp1 = op->tmp3()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2412 ciKlass* k = op->klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
2413
a61af66fc99e Initial load
duke
parents:
diff changeset
2414 if (obj == k_RInfo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2415 k_RInfo = klass_RInfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
2416 klass_RInfo = obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
2417 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2418 if (op->profiled_method() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2419 ciMethod* method = op->profiled_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
2420 int bci = op->profiled_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
2421
a61af66fc99e Initial load
duke
parents:
diff changeset
2422 // We need two temporaries to perform this operation on SPARC,
a61af66fc99e Initial load
duke
parents:
diff changeset
2423 // so to keep things simple we perform a redundant test here
a61af66fc99e Initial load
duke
parents:
diff changeset
2424 Label profile_done;
a61af66fc99e Initial load
duke
parents:
diff changeset
2425 __ cmp(obj, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2426 __ br(Assembler::notEqual, false, Assembler::pn, profile_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2427 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2428 // Object is null; update methodDataOop
a61af66fc99e Initial load
duke
parents:
diff changeset
2429 ciMethodData* md = method->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
2430 if (md == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2431 bailout("out of memory building methodDataOop");
a61af66fc99e Initial load
duke
parents:
diff changeset
2432 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2434 ciProfileData* data = md->bci_to_data(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
2435 assert(data != NULL, "need data for checkcast");
a61af66fc99e Initial load
duke
parents:
diff changeset
2436 assert(data->is_BitData(), "need BitData for checkcast");
a61af66fc99e Initial load
duke
parents:
diff changeset
2437 Register mdo = k_RInfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
2438 Register data_val = Rtmp1;
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 780
diff changeset
2439 jobject2reg(md->constant_encoding(), mdo);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2440
a61af66fc99e Initial load
duke
parents:
diff changeset
2441 int mdo_offset_bias = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2442 if (!Assembler::is_simm13(md->byte_offset_of_slot(data, DataLayout::header_offset()) + data->size_in_bytes())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2443 // The offset is large so bias the mdo by the base of the slot so
a61af66fc99e Initial load
duke
parents:
diff changeset
2444 // that the ld can use simm13s to reference the slots of the data
a61af66fc99e Initial load
duke
parents:
diff changeset
2445 mdo_offset_bias = md->byte_offset_of_slot(data, DataLayout::header_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
2446 __ set(mdo_offset_bias, data_val);
a61af66fc99e Initial load
duke
parents:
diff changeset
2447 __ add(mdo, data_val, mdo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2449
a61af66fc99e Initial load
duke
parents:
diff changeset
2450
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2451 Address flags_addr(mdo, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2452 __ ldub(flags_addr, data_val);
a61af66fc99e Initial load
duke
parents:
diff changeset
2453 __ or3(data_val, BitData::null_seen_byte_constant(), data_val);
a61af66fc99e Initial load
duke
parents:
diff changeset
2454 __ stb(data_val, flags_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2455 __ bind(profile_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2456 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2457
a61af66fc99e Initial load
duke
parents:
diff changeset
2458 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
2459 // patching may screw with our temporaries on sparc,
a61af66fc99e Initial load
duke
parents:
diff changeset
2460 // so let's do it before loading the class
a61af66fc99e Initial load
duke
parents:
diff changeset
2461 if (k->is_loaded()) {
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 780
diff changeset
2462 jobject2reg(k->constant_encoding(), k_RInfo);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2463 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2464 jobject2reg_with_patching(k_RInfo, op->info_for_patch());
a61af66fc99e Initial load
duke
parents:
diff changeset
2465 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2466 assert(obj != k_RInfo, "must be different");
a61af66fc99e Initial load
duke
parents:
diff changeset
2467 __ cmp(obj, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2468 __ br(Assembler::equal, false, Assembler::pn, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2469 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2470
a61af66fc99e Initial load
duke
parents:
diff changeset
2471 // get object class
a61af66fc99e Initial load
duke
parents:
diff changeset
2472 // not a safepoint as obj null check happens earlier
a61af66fc99e Initial load
duke
parents:
diff changeset
2473 load(obj, oopDesc::klass_offset_in_bytes(), klass_RInfo, T_OBJECT, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2474 if (op->fast_check()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2475 assert_different_registers(klass_RInfo, k_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2476 __ cmp(k_RInfo, klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2477 __ br(Assembler::notEqual, false, Assembler::pt, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2478 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2479 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2480 } else {
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2481 bool need_slow_path = true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2482 if (k->is_loaded()) {
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2483 if (k->super_check_offset() != sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes())
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2484 need_slow_path = false;
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2485 // perform the fast part of the checking logic
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2486 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, noreg,
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2487 (need_slow_path ? &done : NULL),
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2488 stub->entry(), NULL,
665
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 644
diff changeset
2489 RegisterOrConstant(k->super_check_offset()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2490 } else {
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2491 // perform the fast part of the checking logic
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2492 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, O7,
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2493 &done, stub->entry(), NULL);
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2494 }
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2495 if (need_slow_path) {
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2496 // call out-of-line instance of __ check_klass_subtype_slow_path(...):
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2497 assert(klass_RInfo == G3 && k_RInfo == G1, "incorrect call setup");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2498 __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
2499 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2500 __ cmp(G3, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2501 __ br(Assembler::equal, false, Assembler::pn, *stub->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2502 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2503 }
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2504 __ bind(done);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2505 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2506 __ mov(obj, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2507 } else if (code == lir_instanceof) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2508 Register obj = op->object()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2509 Register k_RInfo = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2510 Register klass_RInfo = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2511 Register dst = op->result_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2512 Register Rtmp1 = op->tmp3()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2513 ciKlass* k = op->klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
2514
a61af66fc99e Initial load
duke
parents:
diff changeset
2515 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
2516 if (obj == k_RInfo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2517 k_RInfo = klass_RInfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
2518 klass_RInfo = obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
2519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2520 // patching may screw with our temporaries on sparc,
a61af66fc99e Initial load
duke
parents:
diff changeset
2521 // so let's do it before loading the class
a61af66fc99e Initial load
duke
parents:
diff changeset
2522 if (k->is_loaded()) {
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 780
diff changeset
2523 jobject2reg(k->constant_encoding(), k_RInfo);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2524 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2525 jobject2reg_with_patching(k_RInfo, op->info_for_patch());
a61af66fc99e Initial load
duke
parents:
diff changeset
2526 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2527 assert(obj != k_RInfo, "must be different");
a61af66fc99e Initial load
duke
parents:
diff changeset
2528 __ cmp(obj, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2529 __ br(Assembler::equal, true, Assembler::pn, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2530 __ delayed()->set(0, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2531
a61af66fc99e Initial load
duke
parents:
diff changeset
2532 // get object class
a61af66fc99e Initial load
duke
parents:
diff changeset
2533 // not a safepoint as obj null check happens earlier
a61af66fc99e Initial load
duke
parents:
diff changeset
2534 load(obj, oopDesc::klass_offset_in_bytes(), klass_RInfo, T_OBJECT, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2535 if (op->fast_check()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2536 __ cmp(k_RInfo, klass_RInfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2537 __ br(Assembler::equal, true, Assembler::pt, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2538 __ delayed()->set(1, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2539 __ set(0, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2540 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2541 } else {
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2542 bool need_slow_path = true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2543 if (k->is_loaded()) {
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2544 if (k->super_check_offset() != sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes())
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2545 need_slow_path = false;
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2546 // perform the fast part of the checking logic
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2547 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, O7, noreg,
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2548 (need_slow_path ? &done : NULL),
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2549 (need_slow_path ? &done : NULL), NULL,
665
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 644
diff changeset
2550 RegisterOrConstant(k->super_check_offset()),
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2551 dst);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2552 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2553 assert(dst != klass_RInfo && dst != k_RInfo, "need 3 registers");
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2554 // perform the fast part of the checking logic
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2555 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, O7, dst,
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2556 &done, &done, NULL,
665
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 644
diff changeset
2557 RegisterOrConstant(-1),
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2558 dst);
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2559 }
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2560 if (need_slow_path) {
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2561 // call out-of-line instance of __ check_klass_subtype_slow_path(...):
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2562 assert(klass_RInfo == G3 && k_RInfo == G1, "incorrect call setup");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2563 __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
2564 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2565 __ mov(G3, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2566 }
644
c517646eef23 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 356
diff changeset
2567 __ bind(done);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2569 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2570 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2571 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2572
a61af66fc99e Initial load
duke
parents:
diff changeset
2573 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2574
a61af66fc99e Initial load
duke
parents:
diff changeset
2575
a61af66fc99e Initial load
duke
parents:
diff changeset
2576 void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2577 if (op->code() == lir_cas_long) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2578 assert(VM_Version::supports_cx8(), "wrong machine");
a61af66fc99e Initial load
duke
parents:
diff changeset
2579 Register addr = op->addr()->as_pointer_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2580 Register cmp_value_lo = op->cmp_value()->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2581 Register cmp_value_hi = op->cmp_value()->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2582 Register new_value_lo = op->new_value()->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2583 Register new_value_hi = op->new_value()->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2584 Register t1 = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2585 Register t2 = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2586 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
2587 __ mov(cmp_value_lo, t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2588 __ mov(new_value_lo, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2589 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
2590 // move high and low halves of long values into single registers
a61af66fc99e Initial load
duke
parents:
diff changeset
2591 __ sllx(cmp_value_hi, 32, t1); // shift high half into temp reg
a61af66fc99e Initial load
duke
parents:
diff changeset
2592 __ srl(cmp_value_lo, 0, cmp_value_lo); // clear upper 32 bits of low half
a61af66fc99e Initial load
duke
parents:
diff changeset
2593 __ or3(t1, cmp_value_lo, t1); // t1 holds 64-bit compare value
a61af66fc99e Initial load
duke
parents:
diff changeset
2594 __ sllx(new_value_hi, 32, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2595 __ srl(new_value_lo, 0, new_value_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2596 __ or3(t2, new_value_lo, t2); // t2 holds 64-bit value to swap
a61af66fc99e Initial load
duke
parents:
diff changeset
2597 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2598 // perform the compare and swap operation
a61af66fc99e Initial load
duke
parents:
diff changeset
2599 __ casx(addr, t1, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2600 // generate condition code - if the swap succeeded, t2 ("new value" reg) was
a61af66fc99e Initial load
duke
parents:
diff changeset
2601 // overwritten with the original value in "addr" and will be equal to t1.
a61af66fc99e Initial load
duke
parents:
diff changeset
2602 __ cmp(t1, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2603
a61af66fc99e Initial load
duke
parents:
diff changeset
2604 } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2605 Register addr = op->addr()->as_pointer_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2606 Register cmp_value = op->cmp_value()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2607 Register new_value = op->new_value()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2608 Register t1 = op->tmp1()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2609 Register t2 = op->tmp2()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2610 __ mov(cmp_value, t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2611 __ mov(new_value, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2612 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
2613 if (op->code() == lir_cas_obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2614 __ casx(addr, t1, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2615 } else
a61af66fc99e Initial load
duke
parents:
diff changeset
2616 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2617 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2618 __ cas(addr, t1, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2619 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2620 __ cmp(t1, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2621 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2622 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2623 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2624 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2625
a61af66fc99e Initial load
duke
parents:
diff changeset
2626 void LIR_Assembler::set_24bit_FPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2627 Unimplemented();
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 void LIR_Assembler::reset_FPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2632 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2633 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2634
a61af66fc99e Initial load
duke
parents:
diff changeset
2635
a61af66fc99e Initial load
duke
parents:
diff changeset
2636 void LIR_Assembler::breakpoint() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2637 __ breakpoint_trap();
a61af66fc99e Initial load
duke
parents:
diff changeset
2638 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2639
a61af66fc99e Initial load
duke
parents:
diff changeset
2640
a61af66fc99e Initial load
duke
parents:
diff changeset
2641 void LIR_Assembler::push(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2642 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2643 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2644
a61af66fc99e Initial load
duke
parents:
diff changeset
2645
a61af66fc99e Initial load
duke
parents:
diff changeset
2646 void LIR_Assembler::pop(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2647 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2648 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2649
a61af66fc99e Initial load
duke
parents:
diff changeset
2650
a61af66fc99e Initial load
duke
parents:
diff changeset
2651 void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst_opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2652 Address mon_addr = frame_map()->address_for_monitor_lock(monitor_no);
a61af66fc99e Initial load
duke
parents:
diff changeset
2653 Register dst = dst_opr->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2654 Register reg = mon_addr.base();
a61af66fc99e Initial load
duke
parents:
diff changeset
2655 int offset = mon_addr.disp();
a61af66fc99e Initial load
duke
parents:
diff changeset
2656 // compute pointer to BasicLock
a61af66fc99e Initial load
duke
parents:
diff changeset
2657 if (mon_addr.is_simm13()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2658 __ add(reg, offset, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2659 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2660 __ set(offset, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2661 __ add(dst, reg, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2663 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2664
a61af66fc99e Initial load
duke
parents:
diff changeset
2665
a61af66fc99e Initial load
duke
parents:
diff changeset
2666 void LIR_Assembler::emit_lock(LIR_OpLock* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2667 Register obj = op->obj_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2668 Register hdr = op->hdr_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2669 Register lock = op->lock_opr()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2670
a61af66fc99e Initial load
duke
parents:
diff changeset
2671 // obj may not be an oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2672 if (op->code() == lir_lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2673 MonitorEnterStub* stub = (MonitorEnterStub*)op->stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
2674 if (UseFastLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2675 assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
a61af66fc99e Initial load
duke
parents:
diff changeset
2676 // add debug info for NullPointerException only if one is possible
a61af66fc99e Initial load
duke
parents:
diff changeset
2677 if (op->info() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2678 add_debug_info_for_null_check_here(op->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
2679 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2680 __ lock_object(hdr, obj, lock, op->scratch_opr()->as_register(), *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2681 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2682 // always do slow locking
a61af66fc99e Initial load
duke
parents:
diff changeset
2683 // note: the slow locking code could be inlined here, however if we use
a61af66fc99e Initial load
duke
parents:
diff changeset
2684 // slow locking, speed doesn't matter anyway and this solution is
a61af66fc99e Initial load
duke
parents:
diff changeset
2685 // simpler and requires less duplicated code - additionally, the
a61af66fc99e Initial load
duke
parents:
diff changeset
2686 // slow locking code is the same in either case which simplifies
a61af66fc99e Initial load
duke
parents:
diff changeset
2687 // debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
2688 __ br(Assembler::always, false, Assembler::pt, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2689 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2690 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2691 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2692 assert (op->code() == lir_unlock, "Invalid code, expected lir_unlock");
a61af66fc99e Initial load
duke
parents:
diff changeset
2693 if (UseFastLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2694 assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
a61af66fc99e Initial load
duke
parents:
diff changeset
2695 __ unlock_object(hdr, obj, lock, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2696 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2697 // always do slow unlocking
a61af66fc99e Initial load
duke
parents:
diff changeset
2698 // note: the slow unlocking code could be inlined here, however if we use
a61af66fc99e Initial load
duke
parents:
diff changeset
2699 // slow unlocking, speed doesn't matter anyway and this solution is
a61af66fc99e Initial load
duke
parents:
diff changeset
2700 // simpler and requires less duplicated code - additionally, the
a61af66fc99e Initial load
duke
parents:
diff changeset
2701 // slow unlocking code is the same in either case which simplifies
a61af66fc99e Initial load
duke
parents:
diff changeset
2702 // debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
2703 __ br(Assembler::always, false, Assembler::pt, *op->stub()->entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2704 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2705 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2706 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2707 __ bind(*op->stub()->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
2708 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2709
a61af66fc99e Initial load
duke
parents:
diff changeset
2710
a61af66fc99e Initial load
duke
parents:
diff changeset
2711 void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2712 ciMethod* method = op->profiled_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
2713 int bci = op->profiled_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
2714
a61af66fc99e Initial load
duke
parents:
diff changeset
2715 // Update counter for all call types
a61af66fc99e Initial load
duke
parents:
diff changeset
2716 ciMethodData* md = method->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
2717 if (md == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2718 bailout("out of memory building methodDataOop");
a61af66fc99e Initial load
duke
parents:
diff changeset
2719 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2720 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2721 ciProfileData* data = md->bci_to_data(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
2722 assert(data->is_CounterData(), "need CounterData for calls");
a61af66fc99e Initial load
duke
parents:
diff changeset
2723 assert(op->mdo()->is_single_cpu(), "mdo must be allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
2724 assert(op->tmp1()->is_single_cpu(), "tmp1 must be allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
2725 Register mdo = op->mdo()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2726 Register tmp1 = op->tmp1()->as_register();
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 780
diff changeset
2727 jobject2reg(md->constant_encoding(), mdo);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2728 int mdo_offset_bias = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2729 if (!Assembler::is_simm13(md->byte_offset_of_slot(data, CounterData::count_offset()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
2730 data->size_in_bytes())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2731 // The offset is large so bias the mdo by the base of the slot so
a61af66fc99e Initial load
duke
parents:
diff changeset
2732 // that the ld can use simm13s to reference the slots of the data
a61af66fc99e Initial load
duke
parents:
diff changeset
2733 mdo_offset_bias = md->byte_offset_of_slot(data, CounterData::count_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
2734 __ set(mdo_offset_bias, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
2735 __ add(mdo, O7, mdo);
a61af66fc99e Initial load
duke
parents:
diff changeset
2736 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2737
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2738 Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2739 __ lduw(counter_addr, tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2740 __ add(tmp1, DataLayout::counter_increment, tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2741 __ stw(tmp1, counter_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2742 Bytecodes::Code bc = method->java_code_at_bci(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
2743 // Perform additional virtual call profiling for invokevirtual and
a61af66fc99e Initial load
duke
parents:
diff changeset
2744 // invokeinterface bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
2745 if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
2746 Tier1ProfileVirtualCalls) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2747 assert(op->recv()->is_single_cpu(), "recv must be allocated");
a61af66fc99e Initial load
duke
parents:
diff changeset
2748 Register recv = op->recv()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2749 assert_different_registers(mdo, tmp1, recv);
a61af66fc99e Initial load
duke
parents:
diff changeset
2750 assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls");
a61af66fc99e Initial load
duke
parents:
diff changeset
2751 ciKlass* known_klass = op->known_holder();
a61af66fc99e Initial load
duke
parents:
diff changeset
2752 if (Tier1OptimizeVirtualCallProfiling && known_klass != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2753 // We know the type that will be seen at this call site; we can
a61af66fc99e Initial load
duke
parents:
diff changeset
2754 // statically update the methodDataOop rather than needing to do
a61af66fc99e Initial load
duke
parents:
diff changeset
2755 // dynamic tests on the receiver type
a61af66fc99e Initial load
duke
parents:
diff changeset
2756
a61af66fc99e Initial load
duke
parents:
diff changeset
2757 // NOTE: we should probably put a lock around this search to
a61af66fc99e Initial load
duke
parents:
diff changeset
2758 // avoid collisions by concurrent compilations
a61af66fc99e Initial load
duke
parents:
diff changeset
2759 ciVirtualCallData* vc_data = (ciVirtualCallData*) data;
a61af66fc99e Initial load
duke
parents:
diff changeset
2760 uint i;
a61af66fc99e Initial load
duke
parents:
diff changeset
2761 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2762 ciKlass* receiver = vc_data->receiver(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2763 if (known_klass->equals(receiver)) {
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2764 Address data_addr(mdo, md->byte_offset_of_slot(data,
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2765 VirtualCallData::receiver_count_offset(i)) -
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2766 mdo_offset_bias);
a61af66fc99e Initial load
duke
parents:
diff changeset
2767 __ lduw(data_addr, tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2768 __ add(tmp1, DataLayout::counter_increment, tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2769 __ stw(tmp1, data_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2770 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2771 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2772 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2773
a61af66fc99e Initial load
duke
parents:
diff changeset
2774 // Receiver type not found in profile data; select an empty slot
a61af66fc99e Initial load
duke
parents:
diff changeset
2775
a61af66fc99e Initial load
duke
parents:
diff changeset
2776 // Note that this is less efficient than it should be because it
a61af66fc99e Initial load
duke
parents:
diff changeset
2777 // always does a write to the receiver part of the
a61af66fc99e Initial load
duke
parents:
diff changeset
2778 // VirtualCallData rather than just the first time
a61af66fc99e Initial load
duke
parents:
diff changeset
2779 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2780 ciKlass* receiver = vc_data->receiver(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2781 if (receiver == NULL) {
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2782 Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)) -
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2783 mdo_offset_bias);
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 780
diff changeset
2784 jobject2reg(known_klass->constant_encoding(), tmp1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2785 __ st_ptr(tmp1, recv_addr);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2786 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) -
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2787 mdo_offset_bias);
a61af66fc99e Initial load
duke
parents:
diff changeset
2788 __ lduw(data_addr, tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2789 __ add(tmp1, DataLayout::counter_increment, tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2790 __ stw(tmp1, data_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2791 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2792 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2793 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2794 } else {
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2795 load(Address(recv, oopDesc::klass_offset_in_bytes()), recv, T_OBJECT);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2796 Label update_done;
a61af66fc99e Initial load
duke
parents:
diff changeset
2797 uint i;
a61af66fc99e Initial load
duke
parents:
diff changeset
2798 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2799 Label next_test;
a61af66fc99e Initial load
duke
parents:
diff changeset
2800 // See if the receiver is receiver[n].
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2801 Address receiver_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)) -
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2802 mdo_offset_bias);
a61af66fc99e Initial load
duke
parents:
diff changeset
2803 __ ld_ptr(receiver_addr, tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2804 __ verify_oop(tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2805 __ cmp(recv, tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2806 __ brx(Assembler::notEqual, false, Assembler::pt, next_test);
a61af66fc99e Initial load
duke
parents:
diff changeset
2807 __ delayed()->nop();
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2808 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) -
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2809 mdo_offset_bias);
a61af66fc99e Initial load
duke
parents:
diff changeset
2810 __ lduw(data_addr, tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2811 __ add(tmp1, DataLayout::counter_increment, tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2812 __ stw(tmp1, data_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2813 __ br(Assembler::always, false, Assembler::pt, update_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2814 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2815 __ bind(next_test);
a61af66fc99e Initial load
duke
parents:
diff changeset
2816 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2817
a61af66fc99e Initial load
duke
parents:
diff changeset
2818 // Didn't find receiver; find next empty slot and fill it in
a61af66fc99e Initial load
duke
parents:
diff changeset
2819 for (i = 0; i < VirtualCallData::row_limit(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2820 Label next_test;
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2821 Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)) -
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2822 mdo_offset_bias);
a61af66fc99e Initial load
duke
parents:
diff changeset
2823 load(recv_addr, tmp1, T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
2824 __ tst(tmp1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2825 __ brx(Assembler::notEqual, false, Assembler::pt, next_test);
a61af66fc99e Initial load
duke
parents:
diff changeset
2826 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2827 __ st_ptr(recv, recv_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2828 __ set(DataLayout::counter_increment, tmp1);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2829 __ st_ptr(tmp1, mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) -
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 665
diff changeset
2830 mdo_offset_bias);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2831 if (i < (VirtualCallData::row_limit() - 1)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2832 __ br(Assembler::always, false, Assembler::pt, update_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2833 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2834 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2835 __ bind(next_test);
a61af66fc99e Initial load
duke
parents:
diff changeset
2836 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2837
a61af66fc99e Initial load
duke
parents:
diff changeset
2838 __ bind(update_done);
a61af66fc99e Initial load
duke
parents:
diff changeset
2839 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2840 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2841 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2842
a61af66fc99e Initial load
duke
parents:
diff changeset
2843
a61af66fc99e Initial load
duke
parents:
diff changeset
2844 void LIR_Assembler::align_backward_branch_target() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2845 __ align(16);
a61af66fc99e Initial load
duke
parents:
diff changeset
2846 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2847
a61af66fc99e Initial load
duke
parents:
diff changeset
2848
a61af66fc99e Initial load
duke
parents:
diff changeset
2849 void LIR_Assembler::emit_delay(LIR_OpDelay* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2850 // make sure we are expecting a delay
a61af66fc99e Initial load
duke
parents:
diff changeset
2851 // this has the side effect of clearing the delay state
a61af66fc99e Initial load
duke
parents:
diff changeset
2852 // so we can use _masm instead of _masm->delayed() to do the
a61af66fc99e Initial load
duke
parents:
diff changeset
2853 // code generation.
a61af66fc99e Initial load
duke
parents:
diff changeset
2854 __ delayed();
a61af66fc99e Initial load
duke
parents:
diff changeset
2855
a61af66fc99e Initial load
duke
parents:
diff changeset
2856 // make sure we only emit one instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
2857 int offset = code_offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2858 op->delay_op()->emit_code(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2859 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2860 if (code_offset() - offset != NativeInstruction::nop_instruction_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2861 op->delay_op()->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
2862 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2863 assert(code_offset() - offset == NativeInstruction::nop_instruction_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
2864 "only one instruction can go in a delay slot");
a61af66fc99e Initial load
duke
parents:
diff changeset
2865 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2866
a61af66fc99e Initial load
duke
parents:
diff changeset
2867 // we may also be emitting the call info for the instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
2868 // which we are the delay slot of.
a61af66fc99e Initial load
duke
parents:
diff changeset
2869 CodeEmitInfo * call_info = op->call_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
2870 if (call_info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2871 add_call_info(code_offset(), call_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2872 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2873
a61af66fc99e Initial load
duke
parents:
diff changeset
2874 if (VerifyStackAtCalls) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2875 _masm->sub(FP, SP, O7);
a61af66fc99e Initial load
duke
parents:
diff changeset
2876 _masm->cmp(O7, initial_frame_size_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
2877 _masm->trap(Assembler::notEqual, Assembler::ptr_cc, G0, ST_RESERVED_FOR_USER_0+2 );
a61af66fc99e Initial load
duke
parents:
diff changeset
2878 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2879 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2880
a61af66fc99e Initial load
duke
parents:
diff changeset
2881
a61af66fc99e Initial load
duke
parents:
diff changeset
2882 void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2883 assert(left->is_register(), "can only handle registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
2884
a61af66fc99e Initial load
duke
parents:
diff changeset
2885 if (left->is_single_cpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2886 __ neg(left->as_register(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
2887 } else if (left->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2888 __ fneg(FloatRegisterImpl::S, left->as_float_reg(), dest->as_float_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
2889 } else if (left->is_double_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2890 __ fneg(FloatRegisterImpl::D, left->as_double_reg(), dest->as_double_reg());
a61af66fc99e Initial load
duke
parents:
diff changeset
2891 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2892 assert (left->is_double_cpu(), "Must be a long");
a61af66fc99e Initial load
duke
parents:
diff changeset
2893 Register Rlow = left->as_register_lo();
a61af66fc99e Initial load
duke
parents:
diff changeset
2894 Register Rhi = left->as_register_hi();
a61af66fc99e Initial load
duke
parents:
diff changeset
2895 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
2896 __ sub(G0, Rlow, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
2897 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
2898 __ subcc(G0, Rlow, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
2899 __ subc (G0, Rhi, dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
2900 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2901 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2902 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2903
a61af66fc99e Initial load
duke
parents:
diff changeset
2904
a61af66fc99e Initial load
duke
parents:
diff changeset
2905 void LIR_Assembler::fxch(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2906 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2907 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2908
a61af66fc99e Initial load
duke
parents:
diff changeset
2909 void LIR_Assembler::fld(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2910 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2911 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2912
a61af66fc99e Initial load
duke
parents:
diff changeset
2913 void LIR_Assembler::ffree(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2914 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
2915 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2916
a61af66fc99e Initial load
duke
parents:
diff changeset
2917 void LIR_Assembler::rt_call(LIR_Opr result, address dest,
a61af66fc99e Initial load
duke
parents:
diff changeset
2918 const LIR_OprList* args, LIR_Opr tmp, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2919
a61af66fc99e Initial load
duke
parents:
diff changeset
2920 // if tmp is invalid, then the function being called doesn't destroy the thread
a61af66fc99e Initial load
duke
parents:
diff changeset
2921 if (tmp->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2922 __ save_thread(tmp->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
2923 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2924 __ call(dest, relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
2925 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
2926 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2927 add_call_info_here(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2928 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2929 if (tmp->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2930 __ restore_thread(tmp->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
2931 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2932
a61af66fc99e Initial load
duke
parents:
diff changeset
2933 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2934 __ verify_thread();
a61af66fc99e Initial load
duke
parents:
diff changeset
2935 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2936 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2937
a61af66fc99e Initial load
duke
parents:
diff changeset
2938
a61af66fc99e Initial load
duke
parents:
diff changeset
2939 void LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2940 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
2941 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2942 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2943
a61af66fc99e Initial load
duke
parents:
diff changeset
2944 NEEDS_CLEANUP;
a61af66fc99e Initial load
duke
parents:
diff changeset
2945 if (type == T_LONG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2946 LIR_Address* mem_addr = dest->is_address() ? dest->as_address_ptr() : src->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2947
a61af66fc99e Initial load
duke
parents:
diff changeset
2948 // (extended to allow indexed as well as constant displaced for JSR-166)
a61af66fc99e Initial load
duke
parents:
diff changeset
2949 Register idx = noreg; // contains either constant offset or index
a61af66fc99e Initial load
duke
parents:
diff changeset
2950
a61af66fc99e Initial load
duke
parents:
diff changeset
2951 int disp = mem_addr->disp();
a61af66fc99e Initial load
duke
parents:
diff changeset
2952 if (mem_addr->index() == LIR_OprFact::illegalOpr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2953 if (!Assembler::is_simm13(disp)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2954 idx = O7;
a61af66fc99e Initial load
duke
parents:
diff changeset
2955 __ set(disp, idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2956 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2957 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2958 assert(disp == 0, "not both indexed and disp");
a61af66fc99e Initial load
duke
parents:
diff changeset
2959 idx = mem_addr->index()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2960 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2961
a61af66fc99e Initial load
duke
parents:
diff changeset
2962 int null_check_offset = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
2963
a61af66fc99e Initial load
duke
parents:
diff changeset
2964 Register base = mem_addr->base()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
2965 if (src->is_register() && dest->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2966 // G4 is high half, G5 is low half
a61af66fc99e Initial load
duke
parents:
diff changeset
2967 if (VM_Version::v9_instructions_work()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2968 // clear the top bits of G5, and scale up G4
a61af66fc99e Initial load
duke
parents:
diff changeset
2969 __ srl (src->as_register_lo(), 0, G5);
a61af66fc99e Initial load
duke
parents:
diff changeset
2970 __ sllx(src->as_register_hi(), 32, G4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2971 // combine the two halves into the 64 bits of G4
a61af66fc99e Initial load
duke
parents:
diff changeset
2972 __ or3(G4, G5, G4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2973 null_check_offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2974 if (idx == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2975 __ stx(G4, base, disp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2976 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2977 __ stx(G4, base, idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2978 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2979 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2980 __ mov (src->as_register_hi(), G4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2981 __ mov (src->as_register_lo(), G5);
a61af66fc99e Initial load
duke
parents:
diff changeset
2982 null_check_offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2983 if (idx == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2984 __ std(G4, base, disp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2985 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2986 __ std(G4, base, idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
2987 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2988 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2989 } else if (src->is_address() && dest->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2990 null_check_offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2991 if (VM_Version::v9_instructions_work()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2992 if (idx == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2993 __ ldx(base, disp, G5);
a61af66fc99e Initial load
duke
parents:
diff changeset
2994 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2995 __ ldx(base, idx, G5);
a61af66fc99e Initial load
duke
parents:
diff changeset
2996 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2997 __ srax(G5, 32, dest->as_register_hi()); // fetch the high half into hi
a61af66fc99e Initial load
duke
parents:
diff changeset
2998 __ mov (G5, dest->as_register_lo()); // copy low half into lo
a61af66fc99e Initial load
duke
parents:
diff changeset
2999 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3000 if (idx == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3001 __ ldd(base, disp, G4);
a61af66fc99e Initial load
duke
parents:
diff changeset
3002 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3003 __ ldd(base, idx, G4);
a61af66fc99e Initial load
duke
parents:
diff changeset
3004 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3005 // G4 is high half, G5 is low half
a61af66fc99e Initial load
duke
parents:
diff changeset
3006 __ mov (G4, dest->as_register_hi());
a61af66fc99e Initial load
duke
parents:
diff changeset
3007 __ mov (G5, dest->as_register_lo());
a61af66fc99e Initial load
duke
parents:
diff changeset
3008 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3009 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3010 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
3011 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3012 if (info != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3013 add_debug_info_for_null_check(null_check_offset, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
3014 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3015
a61af66fc99e Initial load
duke
parents:
diff changeset
3016 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3017 // use normal move for all other volatiles since they don't need
a61af66fc99e Initial load
duke
parents:
diff changeset
3018 // special handling to remain atomic.
a61af66fc99e Initial load
duke
parents:
diff changeset
3019 move_op(src, dest, type, lir_patch_none, info, false, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
3020 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3021 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3022
a61af66fc99e Initial load
duke
parents:
diff changeset
3023 void LIR_Assembler::membar() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3024 // only StoreLoad membars are ever explicitly needed on sparcs in TSO mode
a61af66fc99e Initial load
duke
parents:
diff changeset
3025 __ membar( Assembler::Membar_mask_bits(Assembler::StoreLoad) );
a61af66fc99e Initial load
duke
parents:
diff changeset
3026 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3027
a61af66fc99e Initial load
duke
parents:
diff changeset
3028 void LIR_Assembler::membar_acquire() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3029 // no-op on TSO
a61af66fc99e Initial load
duke
parents:
diff changeset
3030 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3031
a61af66fc99e Initial load
duke
parents:
diff changeset
3032 void LIR_Assembler::membar_release() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3033 // no-op on TSO
a61af66fc99e Initial load
duke
parents:
diff changeset
3034 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3035
a61af66fc99e Initial load
duke
parents:
diff changeset
3036 // Macro to Pack two sequential registers containing 32 bit values
a61af66fc99e Initial load
duke
parents:
diff changeset
3037 // into a single 64 bit register.
a61af66fc99e Initial load
duke
parents:
diff changeset
3038 // rs and rs->successor() are packed into rd
a61af66fc99e Initial load
duke
parents:
diff changeset
3039 // rd and rs may be the same register.
a61af66fc99e Initial load
duke
parents:
diff changeset
3040 // Note: rs and rs->successor() are destroyed.
a61af66fc99e Initial load
duke
parents:
diff changeset
3041 void LIR_Assembler::pack64( Register rs, Register rd ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3042 __ sllx(rs, 32, rs);
a61af66fc99e Initial load
duke
parents:
diff changeset
3043 __ srl(rs->successor(), 0, rs->successor());
a61af66fc99e Initial load
duke
parents:
diff changeset
3044 __ or3(rs, rs->successor(), rd);
a61af66fc99e Initial load
duke
parents:
diff changeset
3045 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3046
a61af66fc99e Initial load
duke
parents:
diff changeset
3047 // Macro to unpack a 64 bit value in a register into
a61af66fc99e Initial load
duke
parents:
diff changeset
3048 // two sequential registers.
a61af66fc99e Initial load
duke
parents:
diff changeset
3049 // rd is unpacked into rd and rd->successor()
a61af66fc99e Initial load
duke
parents:
diff changeset
3050 void LIR_Assembler::unpack64( Register rd ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3051 __ mov(rd, rd->successor());
a61af66fc99e Initial load
duke
parents:
diff changeset
3052 __ srax(rd, 32, rd);
a61af66fc99e Initial load
duke
parents:
diff changeset
3053 __ sra(rd->successor(), 0, rd->successor());
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::leal(LIR_Opr addr_opr, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3058 LIR_Address* addr = addr_opr->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
3059 assert(addr->index()->is_illegal() && addr->scale() == LIR_Address::times_1 && Assembler::is_simm13(addr->disp()), "can't handle complex addresses yet");
a61af66fc99e Initial load
duke
parents:
diff changeset
3060 __ add(addr->base()->as_register(), addr->disp(), dest->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
3061 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3062
a61af66fc99e Initial load
duke
parents:
diff changeset
3063
a61af66fc99e Initial load
duke
parents:
diff changeset
3064 void LIR_Assembler::get_thread(LIR_Opr result_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3065 assert(result_reg->is_register(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
3066 __ mov(G2_thread, result_reg->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
3067 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3068
a61af66fc99e Initial load
duke
parents:
diff changeset
3069
a61af66fc99e Initial load
duke
parents:
diff changeset
3070 void LIR_Assembler::peephole(LIR_List* lir) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3071 LIR_OpList* inst = lir->instructions_list();
a61af66fc99e Initial load
duke
parents:
diff changeset
3072 for (int i = 0; i < inst->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3073 LIR_Op* op = inst->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
3074 switch (op->code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3075 case lir_cond_float_branch:
a61af66fc99e Initial load
duke
parents:
diff changeset
3076 case lir_branch: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3077 LIR_OpBranch* branch = op->as_OpBranch();
a61af66fc99e Initial load
duke
parents:
diff changeset
3078 assert(branch->info() == NULL, "shouldn't be state on branches anymore");
a61af66fc99e Initial load
duke
parents:
diff changeset
3079 LIR_Op* delay_op = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
3080 // we'd like to be able to pull following instructions into
a61af66fc99e Initial load
duke
parents:
diff changeset
3081 // this slot but we don't know enough to do it safely yet so
a61af66fc99e Initial load
duke
parents:
diff changeset
3082 // only optimize block to block control flow.
a61af66fc99e Initial load
duke
parents:
diff changeset
3083 if (LIRFillDelaySlots && branch->block()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3084 LIR_Op* prev = inst->at(i - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3085 if (prev && LIR_Assembler::is_single_instruction(prev) && prev->info() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3086 // swap previous instruction into delay slot
a61af66fc99e Initial load
duke
parents:
diff changeset
3087 inst->at_put(i - 1, op);
a61af66fc99e Initial load
duke
parents:
diff changeset
3088 inst->at_put(i, new LIR_OpDelay(prev, op->info()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3089 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
3090 if (LIRTracePeephole) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3091 tty->print_cr("delayed");
a61af66fc99e Initial load
duke
parents:
diff changeset
3092 inst->at(i - 1)->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
3093 inst->at(i)->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
3094 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3095 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
3096 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
3097 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3098 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3099
a61af66fc99e Initial load
duke
parents:
diff changeset
3100 if (!delay_op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3101 delay_op = new LIR_OpDelay(new LIR_Op0(lir_nop), NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
3102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3103 inst->insert_before(i + 1, delay_op);
a61af66fc99e Initial load
duke
parents:
diff changeset
3104 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3106 case lir_static_call:
a61af66fc99e Initial load
duke
parents:
diff changeset
3107 case lir_virtual_call:
a61af66fc99e Initial load
duke
parents:
diff changeset
3108 case lir_icvirtual_call:
a61af66fc99e Initial load
duke
parents:
diff changeset
3109 case lir_optvirtual_call: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3110 LIR_Op* delay_op = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
3111 LIR_Op* prev = inst->at(i - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3112 if (LIRFillDelaySlots && prev && prev->code() == lir_move && prev->info() == NULL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3113 (op->code() != lir_virtual_call ||
a61af66fc99e Initial load
duke
parents:
diff changeset
3114 !prev->result_opr()->is_single_cpu() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
3115 prev->result_opr()->as_register() != O0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3116 LIR_Assembler::is_single_instruction(prev)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3117 // Only moves without info can be put into the delay slot.
a61af66fc99e Initial load
duke
parents:
diff changeset
3118 // Also don't allow the setup of the receiver in the delay
a61af66fc99e Initial load
duke
parents:
diff changeset
3119 // slot for vtable calls.
a61af66fc99e Initial load
duke
parents:
diff changeset
3120 inst->at_put(i - 1, op);
a61af66fc99e Initial load
duke
parents:
diff changeset
3121 inst->at_put(i, new LIR_OpDelay(prev, op->info()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3122 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
3123 if (LIRTracePeephole) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3124 tty->print_cr("delayed");
a61af66fc99e Initial load
duke
parents:
diff changeset
3125 inst->at(i - 1)->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
3126 inst->at(i)->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
3127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3128 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
3129 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
3130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3131
a61af66fc99e Initial load
duke
parents:
diff changeset
3132 if (!delay_op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3133 delay_op = new LIR_OpDelay(new LIR_Op0(lir_nop), op->as_OpJavaCall()->info());
a61af66fc99e Initial load
duke
parents:
diff changeset
3134 inst->insert_before(i + 1, delay_op);
a61af66fc99e Initial load
duke
parents:
diff changeset
3135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3136 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3141
a61af66fc99e Initial load
duke
parents:
diff changeset
3142
a61af66fc99e Initial load
duke
parents:
diff changeset
3143
a61af66fc99e Initial load
duke
parents:
diff changeset
3144
a61af66fc99e Initial load
duke
parents:
diff changeset
3145 #undef __