< prev index next >

src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp

Print this page

140                                         Register klass, Label& slow_case) {
141   assert_different_registers(obj, tmp1, tmp2, tmp3, klass, Rtemp);
142   assert(header_size >= 0 && object_size >= header_size, "illegal sizes");
143   const int object_size_in_bytes = object_size * BytesPerWord;
144 
145   const Register obj_end = tmp1;
146   const Register len = noreg;
147 
148   if (Assembler::is_arith_imm_in_range(object_size_in_bytes)) {
149     try_allocate(obj, obj_end, tmp2, tmp3, object_size_in_bytes, slow_case);
150   } else {
151     // Rtemp should be free at c1 LIR level
152     mov_slow(Rtemp, object_size_in_bytes);
153     try_allocate(obj, obj_end, tmp2, tmp3, Rtemp, slow_case);
154   }
155   initialize_object(obj, obj_end, klass, len, tmp2, tmp3, instanceOopDesc::header_size() * HeapWordSize, object_size_in_bytes, /* is_tlab_allocated */ UseTLAB);
156 }
157 
158 void C1_MacroAssembler::allocate_array(Register obj, Register len,
159                                        Register tmp1, Register tmp2, Register tmp3,
160                                        int header_size, int element_size,
161                                        Register klass, Label& slow_case) {
162   assert_different_registers(obj, len, tmp1, tmp2, tmp3, klass, Rtemp);
163   const int header_size_in_bytes = header_size * BytesPerWord;
164   const int scale_shift = exact_log2(element_size);
165   const Register obj_size = Rtemp; // Rtemp should be free at c1 LIR level
166 
167   cmp_32(len, max_array_allocation_length);
168   b(slow_case, hs);
169 
170   bool align_header = ((header_size_in_bytes | element_size) & MinObjAlignmentInBytesMask) != 0;
171   assert(align_header || ((header_size_in_bytes & MinObjAlignmentInBytesMask) == 0), "must be");
172   assert(align_header || ((element_size & MinObjAlignmentInBytesMask) == 0), "must be");
173 
174   mov(obj_size, header_size_in_bytes + (align_header ? (MinObjAlignmentInBytes - 1) : 0));
175   add_ptr_scaled_int32(obj_size, obj_size, len, scale_shift);
176 
177   if (align_header) {
178     align_reg(obj_size, obj_size, MinObjAlignmentInBytes);
179   }
180 
181   try_allocate(obj, tmp1, tmp2, tmp3, obj_size, slow_case);
182   initialize_object(obj, tmp1, klass, len, tmp2, tmp3, header_size_in_bytes, -1, /* is_tlab_allocated */ UseTLAB);
183 }
184 
185 int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
186   Label done, fast_lock, fast_lock_done;
187   int null_check_offset = 0;
188 
189   const Register tmp2 = Rtemp; // Rtemp should be free at c1 LIR level
190   assert_different_registers(hdr, obj, disp_hdr, tmp2);
191 
192   assert(BasicObjectLock::lock_offset_in_bytes() == 0, "adjust this code");
193   const int obj_offset = BasicObjectLock::obj_offset_in_bytes();
194   const int mark_offset = BasicLock::displaced_header_offset_in_bytes();
195 
196   str(obj, Address(disp_hdr, obj_offset));
197 
198   null_check_offset = offset();
199 
200   if (DiagnoseSyncOnValueBasedClasses != 0) {
201     load_klass(tmp2, obj);
202     ldr_u32(tmp2, Address(tmp2, Klass::access_flags_offset()));
203     tst(tmp2, JVM_ACC_IS_VALUE_BASED_CLASS);
204     b(slow_case, ne);
205   }
206 
207   assert(oopDesc::mark_offset_in_bytes() == 0, "Required by atomic instructions");
208 
209   // On MP platforms the next load could return a 'stale' value if the memory location has been modified by another thread.
210   // That would be acceptable as ether CAS or slow case path is taken in that case.
211 
212   // Must be the first instruction here, because implicit null check relies on it
213   ldr(hdr, Address(obj, oopDesc::mark_offset_in_bytes()));
214 
215   tst(hdr, markWord::unlocked_value);
216   b(fast_lock, ne);
217 
218   // Check for recursive locking
219   // See comments in InterpreterMacroAssembler::lock_object for
220   // explanations on the fast recursive locking check.
221   // -1- test low 2 bits
222   movs(tmp2, AsmOperand(hdr, lsl, 30));
223   // -2- test (hdr - SP) if the low two bits are 0
224   sub(tmp2, hdr, SP, eq);
225   movs(tmp2, AsmOperand(tmp2, lsr, exact_log2(os::vm_page_size())), eq);
226   // If still 'eq' then recursive locking OK
227   // set to zero if recursive lock, set to non zero otherwise (see discussion in JDK-8267042)
228   str(tmp2, Address(disp_hdr, mark_offset));
229   b(fast_lock_done, eq);
230   // else need slow case
231   b(slow_case);
232 
233 
234   bind(fast_lock);
235   // Save previous object header in BasicLock structure and update the header
236   str(hdr, Address(disp_hdr, mark_offset));
237 
238   cas_for_lock_acquire(hdr, disp_hdr, obj, tmp2, slow_case);
239 
240   bind(fast_lock_done);
241   bind(done);
242 
243   return null_check_offset;
244 }
245 
246 void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
247   assert_different_registers(hdr, obj, disp_hdr, Rtemp);
248   Register tmp2 = Rtemp;
249 
250   assert(BasicObjectLock::lock_offset_in_bytes() == 0, "adjust this code");
251   const int obj_offset = BasicObjectLock::obj_offset_in_bytes();
252   const int mark_offset = BasicLock::displaced_header_offset_in_bytes();
253 
254   Label done;
255 
256   assert(oopDesc::mark_offset_in_bytes() == 0, "Required by atomic instructions");
257 
258   // Load displaced header and object from the lock
259   ldr(hdr, Address(disp_hdr, mark_offset));
260   // If hdr is NULL, we've got recursive locking and there's nothing more to do
261   cbz(hdr, done);
262 
263   // load object
264   ldr(obj, Address(disp_hdr, obj_offset));
265 
266   // Restore the object header
267   cas_for_lock_release(disp_hdr, hdr, obj, tmp2, slow_case);
268 
269   bind(done);
270 }
271 
272 
273 #ifndef PRODUCT
274 
275 void C1_MacroAssembler::verify_stack_oop(int stack_offset) {
276   if (!VerifyOops) return;
277   verify_oop_addr(Address(SP, stack_offset));
278 }
279 
280 void C1_MacroAssembler::verify_not_null_oop(Register r) {
281   Label not_null;
282   cbnz(r, not_null);
283   stop("non-null oop required");
284   bind(not_null);
285   if (!VerifyOops) return;
286   verify_oop(r);
287 }
288 
289 #endif // !PRODUCT

140                                         Register klass, Label& slow_case) {
141   assert_different_registers(obj, tmp1, tmp2, tmp3, klass, Rtemp);
142   assert(header_size >= 0 && object_size >= header_size, "illegal sizes");
143   const int object_size_in_bytes = object_size * BytesPerWord;
144 
145   const Register obj_end = tmp1;
146   const Register len = noreg;
147 
148   if (Assembler::is_arith_imm_in_range(object_size_in_bytes)) {
149     try_allocate(obj, obj_end, tmp2, tmp3, object_size_in_bytes, slow_case);
150   } else {
151     // Rtemp should be free at c1 LIR level
152     mov_slow(Rtemp, object_size_in_bytes);
153     try_allocate(obj, obj_end, tmp2, tmp3, Rtemp, slow_case);
154   }
155   initialize_object(obj, obj_end, klass, len, tmp2, tmp3, instanceOopDesc::header_size() * HeapWordSize, object_size_in_bytes, /* is_tlab_allocated */ UseTLAB);
156 }
157 
158 void C1_MacroAssembler::allocate_array(Register obj, Register len,
159                                        Register tmp1, Register tmp2, Register tmp3,
160                                        int header_size_in_bytes, int element_size,
161                                        Register klass, Label& slow_case) {
162   assert_different_registers(obj, len, tmp1, tmp2, tmp3, klass, Rtemp);

163   const int scale_shift = exact_log2(element_size);
164   const Register obj_size = Rtemp; // Rtemp should be free at c1 LIR level
165 
166   cmp_32(len, max_array_allocation_length);
167   b(slow_case, hs);
168 
169   bool align_header = ((header_size_in_bytes | element_size) & MinObjAlignmentInBytesMask) != 0;
170   assert(align_header || ((header_size_in_bytes & MinObjAlignmentInBytesMask) == 0), "must be");
171   assert(align_header || ((element_size & MinObjAlignmentInBytesMask) == 0), "must be");
172 
173   mov(obj_size, header_size_in_bytes + (align_header ? (MinObjAlignmentInBytes - 1) : 0));
174   add_ptr_scaled_int32(obj_size, obj_size, len, scale_shift);
175 
176   if (align_header) {
177     align_reg(obj_size, obj_size, MinObjAlignmentInBytes);
178   }
179 
180   try_allocate(obj, tmp1, tmp2, tmp3, obj_size, slow_case);
181   initialize_object(obj, tmp1, klass, len, tmp2, tmp3, header_size_in_bytes, -1, /* is_tlab_allocated */ UseTLAB);
182 }
183 
























































































184 #ifndef PRODUCT
185 
186 void C1_MacroAssembler::verify_stack_oop(int stack_offset) {
187   if (!VerifyOops) return;
188   verify_oop_addr(Address(SP, stack_offset));
189 }
190 
191 void C1_MacroAssembler::verify_not_null_oop(Register r) {
192   Label not_null;
193   cbnz(r, not_null);
194   stop("non-null oop required");
195   bind(not_null);
196   if (!VerifyOops) return;
197   verify_oop(r);
198 }
199 
200 #endif // !PRODUCT
< prev index next >