270 Register len_in_bytes = Z_R1_scratch;
271 z_la(object_fields, hdr_size_in_bytes, obj);
272 load_const_optimized(len_in_bytes, con_size_in_bytes - hdr_size_in_bytes);
273 initialize_body(object_fields, len_in_bytes, Rzero);
274 }
275
276 // Dtrace support is unimplemented.
277 // if (CURRENT_ENV->dtrace_alloc_probes()) {
278 // assert(obj == rax, "must be");
279 // call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id)));
280 // }
281
282 verify_oop(obj, FILE_AND_LINE);
283 }
284
285 void C1_MacroAssembler::allocate_array(
286 Register obj, // result: Pointer to array after successful allocation.
287 Register len, // array length
288 Register t1, // temp register
289 Register t2, // temp register
290 int hdr_size, // object header size in words
291 int elt_size, // element size in bytes
292 Register klass, // object klass
293 Label& slow_case // Continuation point if fast allocation fails.
294 ) {
295 assert_different_registers(obj, len, t1, t2, klass);
296
297 // Determine alignment mask.
298 assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");
299
300 // Check for negative or excessive length.
301 compareU64_and_branch(len, (int32_t)max_array_allocation_length, bcondHigh, slow_case);
302
303 // Compute array size.
304 // Note: If 0 <= len <= max_length, len*elt_size + header + alignment is
305 // smaller or equal to the largest integer. Also, since top is always
306 // aligned, we can do the alignment here instead of at the end address
307 // computation.
308 const Register arr_size = t2;
309 switch (elt_size) {
310 case 1: lgr_if_needed(arr_size, len); break;
311 case 2: z_sllg(arr_size, len, 1); break;
312 case 4: z_sllg(arr_size, len, 2); break;
313 case 8: z_sllg(arr_size, len, 3); break;
314 default: ShouldNotReachHere();
315 }
316 add2reg(arr_size, hdr_size * wordSize + MinObjAlignmentInBytesMask); // Add space for header & alignment.
317 z_nill(arr_size, (~MinObjAlignmentInBytesMask) & 0xffff); // Align array size.
318
319 try_allocate(obj, arr_size, 0, t1, slow_case);
320
321 initialize_header(obj, klass, len, noreg, t1);
322
323 // Clear rest of allocated space.
324 Label done;
325 Register object_fields = t1;
326 Register Rzero = Z_R1_scratch;
327 z_aghi(arr_size, -(hdr_size * BytesPerWord));
328 z_bre(done); // Jump if size of fields is zero.
329 z_la(object_fields, hdr_size * BytesPerWord, obj);
330 z_xgr(Rzero, Rzero);
331 initialize_body(object_fields, arr_size, Rzero);
332 bind(done);
333
334 // Dtrace support is unimplemented.
335 // if (CURRENT_ENV->dtrace_alloc_probes()) {
336 // assert(obj == rax, "must be");
337 // call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id)));
338 // }
339
340 verify_oop(obj, FILE_AND_LINE);
341 }
342
343
344 #ifndef PRODUCT
345
346 void C1_MacroAssembler::verify_stack_oop(int stack_offset) {
347 if (!VerifyOops) return;
348 verify_oop_addr(Address(Z_SP, stack_offset), FILE_AND_LINE);
349 }
|
270 Register len_in_bytes = Z_R1_scratch;
271 z_la(object_fields, hdr_size_in_bytes, obj);
272 load_const_optimized(len_in_bytes, con_size_in_bytes - hdr_size_in_bytes);
273 initialize_body(object_fields, len_in_bytes, Rzero);
274 }
275
276 // Dtrace support is unimplemented.
277 // if (CURRENT_ENV->dtrace_alloc_probes()) {
278 // assert(obj == rax, "must be");
279 // call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id)));
280 // }
281
282 verify_oop(obj, FILE_AND_LINE);
283 }
284
285 void C1_MacroAssembler::allocate_array(
286 Register obj, // result: Pointer to array after successful allocation.
287 Register len, // array length
288 Register t1, // temp register
289 Register t2, // temp register
290 int base_offset_in_bytes, // elements offset in bytes
291 int elt_size, // element size in bytes
292 Register klass, // object klass
293 Label& slow_case // Continuation point if fast allocation fails.
294 ) {
295 assert_different_registers(obj, len, t1, t2, klass);
296
297 // Determine alignment mask.
298 assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");
299
300 // Check for negative or excessive length.
301 compareU64_and_branch(len, (int32_t)max_array_allocation_length, bcondHigh, slow_case);
302
303 // Compute array size.
304 // Note: If 0 <= len <= max_length, len*elt_size + header + alignment is
305 // smaller or equal to the largest integer. Also, since top is always
306 // aligned, we can do the alignment here instead of at the end address
307 // computation.
308 const Register arr_size = t2;
309 switch (elt_size) {
310 case 1: lgr_if_needed(arr_size, len); break;
311 case 2: z_sllg(arr_size, len, 1); break;
312 case 4: z_sllg(arr_size, len, 2); break;
313 case 8: z_sllg(arr_size, len, 3); break;
314 default: ShouldNotReachHere();
315 }
316 add2reg(arr_size, base_offset_in_bytes + MinObjAlignmentInBytesMask); // Add space for header & alignment.
317 z_nill(arr_size, (~MinObjAlignmentInBytesMask) & 0xffff); // Align array size.
318
319 try_allocate(obj, arr_size, 0, t1, slow_case);
320
321 initialize_header(obj, klass, len, noreg, t1);
322
323 // Clear rest of allocated space.
324 Label done;
325 Register object_fields = t1;
326 Register Rzero = Z_R1_scratch;
327 z_aghi(arr_size, -base_offset_in_bytes);
328 z_bre(done); // Jump if size of fields is zero.
329 z_la(object_fields, base_offset_in_bytes, obj);
330 z_xgr(Rzero, Rzero);
331 initialize_body(object_fields, arr_size, Rzero);
332 bind(done);
333
334 // Dtrace support is unimplemented.
335 // if (CURRENT_ENV->dtrace_alloc_probes()) {
336 // assert(obj == rax, "must be");
337 // call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id)));
338 // }
339
340 verify_oop(obj, FILE_AND_LINE);
341 }
342
343
344 #ifndef PRODUCT
345
346 void C1_MacroAssembler::verify_stack_oop(int stack_offset) {
347 if (!VerifyOops) return;
348 verify_oop_addr(Address(Z_SP, stack_offset), FILE_AND_LINE);
349 }
|