< prev index next >

src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp

Print this page

163       cmpxchgptr(disp_hdr, hdr, obj, rscratch2, done, &slow_case);
164     }
165     // done
166     bind(done);
167   }
168   decrement(Address(rthread, JavaThread::held_monitor_count_offset()));
169 }
170 
171 
172 // Defines obj, preserves var_size_in_bytes
173 void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register t1, Register t2, Label& slow_case) {
174   if (UseTLAB) {
175     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
176   } else {
177     b(slow_case);
178   }
179 }
180 
181 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
182   assert_different_registers(obj, klass, len);
183   // This assumes that all prototype bits fit in an int32_t
184   mov(t1, (int32_t)(intptr_t)markWord::prototype().value());
185   str(t1, Address(obj, oopDesc::mark_offset_in_bytes()));
186 
187   if (UseCompressedClassPointers) { // Take care not to kill klass
188     encode_klass_not_null(t1, klass);
189     strw(t1, Address(obj, oopDesc::klass_offset_in_bytes()));
190   } else {
191     str(klass, Address(obj, oopDesc::klass_offset_in_bytes()));









192   }
193 
194   if (len->is_valid()) {
195     strw(len, Address(obj, arrayOopDesc::length_offset_in_bytes()));
196   } else if (UseCompressedClassPointers) {
197     store_klass_gap(obj, zr);
198   }
199 }
200 
201 // preserves obj, destroys len_in_bytes
202 //
203 // Scratch registers: t1 = r10, t2 = r11
204 //
205 void C1_MacroAssembler::initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1, Register t2) {
206   assert(hdr_size_in_bytes >= 0, "header size must be positive or 0");
207   assert(t1 == r10 && t2 == r11, "must be");
208 
209   Label done;
210 
211   // len_in_bytes is positive and ptr sized
212   subs(len_in_bytes, len_in_bytes, hdr_size_in_bytes);
213   br(Assembler::EQ, done);
214 
215   // zero_words() takes ptr in r10 and count in words in r11
216   mov(rscratch1, len_in_bytes);

254      } else if (con_size_in_bytes > hdr_size_in_bytes) {
255        con_size_in_bytes -= hdr_size_in_bytes;
256        lea(t1, Address(obj, hdr_size_in_bytes));
257        address tpc = zero_words(t1, con_size_in_bytes / BytesPerWord);
258        if (tpc == nullptr) {
259          Compilation::current()->bailout("no space for trampoline stub");
260          return;
261        }
262      }
263   }
264 
265   membar(StoreStore);
266 
267   if (CURRENT_ENV->dtrace_alloc_probes()) {
268     assert(obj == r0, "must be");
269     far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
270   }
271 
272   verify_oop(obj);
273 }
274 void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1, Register t2, int header_size, int f, Register klass, Label& slow_case) {
275   assert_different_registers(obj, len, t1, t2, klass);
276 
277   // determine alignment mask
278   assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");
279 
280   // check for negative or excessive length
281   mov(rscratch1, (int32_t)max_array_allocation_length);
282   cmp(len, rscratch1);
283   br(Assembler::HS, slow_case);
284 
285   const Register arr_size = t2; // okay to be the same
286   // align object end
287   mov(arr_size, (int32_t)header_size * BytesPerWord + MinObjAlignmentInBytesMask);
288   add(arr_size, arr_size, len, ext::uxtw, f);
289   andr(arr_size, arr_size, ~MinObjAlignmentInBytesMask);
290 
291   try_allocate(obj, arr_size, 0, t1, t2, slow_case);
292 
293   initialize_header(obj, klass, len, t1, t2);
294 











295   // clear rest of allocated space
296   initialize_body(obj, arr_size, header_size * BytesPerWord, t1, t2);
297   if (Compilation::current()->bailed_out()) {
298     return;
299   }
300 
301   membar(StoreStore);
302 
303   if (CURRENT_ENV->dtrace_alloc_probes()) {
304     assert(obj == r0, "must be");
305     far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
306   }
307 
308   verify_oop(obj);
309 }
310 
311 
312 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
313   verify_oop(receiver);
314   // explicit null check not needed since load from [klass_offset] causes a trap
315   // check against inline cache
316   assert(!MacroAssembler::needs_explicit_null_check(oopDesc::klass_offset_in_bytes()), "must add explicit null check");
317 
318   cmp_klass(receiver, iCache, rscratch1);
319 }
320 
321 
322 void C1_MacroAssembler::build_frame(int framesize, int bang_size_in_bytes) {
323   assert(bang_size_in_bytes >= framesize, "stack bang size incorrect");
324   // Make sure there is enough stack space for this method's activation.
325   // Note that we do this before creating a frame.
326   generate_stack_overflow_check(bang_size_in_bytes);
327   MacroAssembler::build_frame(framesize);
328 
329   // Insert nmethod entry barrier into frame.
330   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
331   bs->nmethod_entry_barrier(this, nullptr /* slow_path */, nullptr /* continuation */, nullptr /* guard */);
332 }
333 
334 void C1_MacroAssembler::remove_frame(int framesize) {
335   MacroAssembler::remove_frame(framesize);
336 }
337 

163       cmpxchgptr(disp_hdr, hdr, obj, rscratch2, done, &slow_case);
164     }
165     // done
166     bind(done);
167   }
168   decrement(Address(rthread, JavaThread::held_monitor_count_offset()));
169 }
170 
171 
172 // Defines obj, preserves var_size_in_bytes
173 void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register t1, Register t2, Label& slow_case) {
174   if (UseTLAB) {
175     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
176   } else {
177     b(slow_case);
178   }
179 }
180 
181 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
182   assert_different_registers(obj, klass, len);
183   if (UseCompactObjectHeaders) {
184     ldr(t1, Address(klass, Klass::prototype_header_offset()));
185     str(t1, Address(obj, oopDesc::mark_offset_in_bytes()));




186   } else {
187     // This assumes that all prototype bits fit in an int32_t
188     mov(t1, (int32_t)(intptr_t)markWord::prototype().value());
189     str(t1, Address(obj, oopDesc::mark_offset_in_bytes()));
190 
191     if (UseCompressedClassPointers) { // Take care not to kill klass
192       encode_klass_not_null(t1, klass);
193       strw(t1, Address(obj, oopDesc::klass_offset_in_bytes()));
194     } else {
195       str(klass, Address(obj, oopDesc::klass_offset_in_bytes()));
196     }
197   }
198 
199   if (len->is_valid()) {
200     strw(len, Address(obj, arrayOopDesc::length_offset_in_bytes()));
201   } else if (UseCompressedClassPointers && !UseCompactObjectHeaders) {
202     store_klass_gap(obj, zr);
203   }
204 }
205 
206 // preserves obj, destroys len_in_bytes
207 //
208 // Scratch registers: t1 = r10, t2 = r11
209 //
210 void C1_MacroAssembler::initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1, Register t2) {
211   assert(hdr_size_in_bytes >= 0, "header size must be positive or 0");
212   assert(t1 == r10 && t2 == r11, "must be");
213 
214   Label done;
215 
216   // len_in_bytes is positive and ptr sized
217   subs(len_in_bytes, len_in_bytes, hdr_size_in_bytes);
218   br(Assembler::EQ, done);
219 
220   // zero_words() takes ptr in r10 and count in words in r11
221   mov(rscratch1, len_in_bytes);

259      } else if (con_size_in_bytes > hdr_size_in_bytes) {
260        con_size_in_bytes -= hdr_size_in_bytes;
261        lea(t1, Address(obj, hdr_size_in_bytes));
262        address tpc = zero_words(t1, con_size_in_bytes / BytesPerWord);
263        if (tpc == nullptr) {
264          Compilation::current()->bailout("no space for trampoline stub");
265          return;
266        }
267      }
268   }
269 
270   membar(StoreStore);
271 
272   if (CURRENT_ENV->dtrace_alloc_probes()) {
273     assert(obj == r0, "must be");
274     far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
275   }
276 
277   verify_oop(obj);
278 }
279 void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1, Register t2, int base_offset_in_bytes, int f, Register klass, Label& slow_case) {
280   assert_different_registers(obj, len, t1, t2, klass);
281 
282   // determine alignment mask
283   assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");
284 
285   // check for negative or excessive length
286   mov(rscratch1, (int32_t)max_array_allocation_length);
287   cmp(len, rscratch1);
288   br(Assembler::HS, slow_case);
289 
290   const Register arr_size = t2; // okay to be the same
291   // align object end
292   mov(arr_size, (int32_t)base_offset_in_bytes + MinObjAlignmentInBytesMask);
293   add(arr_size, arr_size, len, ext::uxtw, f);
294   andr(arr_size, arr_size, ~MinObjAlignmentInBytesMask);
295 
296   try_allocate(obj, arr_size, 0, t1, t2, slow_case);
297 
298   initialize_header(obj, klass, len, t1, t2);
299 
300   // Clear leading 4 bytes, if necessary.
301   // TODO: This could perhaps go into initialize_body() and also clear the leading 4 bytes
302   // for non-array objects, thereby replacing the klass-gap clearing code in initialize_header().
303   int base_offset = base_offset_in_bytes;
304   if (!is_aligned(base_offset, BytesPerWord)) {
305     assert(is_aligned(base_offset, BytesPerInt), "must be 4-byte aligned");
306     strw(zr, Address(obj, base_offset));
307     base_offset += BytesPerInt;
308   }
309   assert(is_aligned(base_offset, BytesPerWord), "must be word-aligned");
310 
311   // clear rest of allocated space
312   initialize_body(obj, arr_size, base_offset, t1, t2);
313   if (Compilation::current()->bailed_out()) {
314     return;
315   }
316 
317   membar(StoreStore);
318 
319   if (CURRENT_ENV->dtrace_alloc_probes()) {
320     assert(obj == r0, "must be");
321     far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
322   }
323 
324   verify_oop(obj);
325 }
326 
327 
328 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
329   verify_oop(receiver);
330   // explicit null check not needed since load from [klass_offset] causes a trap
331   // check against inline cache. This is checked in Universe::genesis()..


332   cmp_klass(receiver, iCache, rscratch1);
333 }
334 
335 
336 void C1_MacroAssembler::build_frame(int framesize, int bang_size_in_bytes) {
337   assert(bang_size_in_bytes >= framesize, "stack bang size incorrect");
338   // Make sure there is enough stack space for this method's activation.
339   // Note that we do this before creating a frame.
340   generate_stack_overflow_check(bang_size_in_bytes);
341   MacroAssembler::build_frame(framesize);
342 
343   // Insert nmethod entry barrier into frame.
344   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
345   bs->nmethod_entry_barrier(this, nullptr /* slow_path */, nullptr /* continuation */, nullptr /* guard */);
346 }
347 
348 void C1_MacroAssembler::remove_frame(int framesize) {
349   MacroAssembler::remove_frame(framesize);
350 }
351 
< prev index next >