303 result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD);
304
305 // Pass oops back through thread local storage. Our apparent type to Java
306 // is that we return an oop, but we can block on exit from this routine and
307 // a GC can trash the oop in C's return register. The generated stub will
308 // fetch the oop from TLS after any possible GC.
309 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
310 current->set_vm_result(result);
311 JRT_BLOCK_END;
312
313
314 // inform GC that we won't do card marks for initializing writes.
315 SharedRuntime::on_slowpath_allocation_exit(current);
316
317 oop result = current->vm_result();
318 if ((len > 0) && (result != nullptr) &&
319 is_deoptimized_caller_frame(current)) {
320 // Zero array here if the caller is deoptimized.
321 const size_t size = TypeArrayKlass::cast(array_type)->oop_size(result);
322 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
323 const size_t hs = arrayOopDesc::header_size(elem_type);
324 // Align to next 8 bytes to avoid trashing arrays's length.
325 const size_t aligned_hs = align_object_offset(hs);
326 HeapWord* obj = cast_from_oop<HeapWord*>(result);
327 if (aligned_hs > hs) {
328 Copy::zero_to_words(obj+hs, aligned_hs-hs);
329 }
330 // Optimized zeroing.
331 Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs);
332 }
333
334 JRT_END
335
336 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array.
337
338 // multianewarray for 2 dimensions
339 JRT_ENTRY(void, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread* current))
340 #ifndef PRODUCT
341 SharedRuntime::_multi2_ctr++; // multianewarray for 1 dimension
342 #endif
343 assert(check_compiled_frame(current), "incorrect caller");
344 assert(elem_type->is_klass(), "not a class");
345 jint dims[2];
346 dims[0] = len1;
347 dims[1] = len2;
348 Handle holder(current, elem_type->klass_holder()); // keep the klass alive
349 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD);
350 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
|
303 result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD);
304
305 // Pass oops back through thread local storage. Our apparent type to Java
306 // is that we return an oop, but we can block on exit from this routine and
307 // a GC can trash the oop in C's return register. The generated stub will
308 // fetch the oop from TLS after any possible GC.
309 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
310 current->set_vm_result(result);
311 JRT_BLOCK_END;
312
313
314 // inform GC that we won't do card marks for initializing writes.
315 SharedRuntime::on_slowpath_allocation_exit(current);
316
317 oop result = current->vm_result();
318 if ((len > 0) && (result != nullptr) &&
319 is_deoptimized_caller_frame(current)) {
320 // Zero array here if the caller is deoptimized.
321 const size_t size = TypeArrayKlass::cast(array_type)->oop_size(result);
322 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
323 size_t hs_bytes = arrayOopDesc::base_offset_in_bytes(elem_type);
324 assert(is_aligned(hs_bytes, BytesPerInt), "must be 4 byte aligned");
325 HeapWord* obj = cast_from_oop<HeapWord*>(result);
326 if (!is_aligned(hs_bytes, BytesPerLong)) {
327 *reinterpret_cast<jint*>(reinterpret_cast<char*>(obj) + hs_bytes) = 0;
328 hs_bytes += BytesPerInt;
329 }
330
331 // Optimized zeroing.
332 assert(is_aligned(hs_bytes, BytesPerLong), "must be 8-byte aligned");
333 const size_t aligned_hs = hs_bytes / BytesPerLong;
334 Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs);
335 }
336
337 JRT_END
338
339 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array.
340
341 // multianewarray for 2 dimensions
342 JRT_ENTRY(void, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread* current))
343 #ifndef PRODUCT
344 SharedRuntime::_multi2_ctr++; // multianewarray for 1 dimension
345 #endif
346 assert(check_compiled_frame(current), "incorrect caller");
347 assert(elem_type->is_klass(), "not a class");
348 jint dims[2];
349 dims[0] = len1;
350 dims[1] = len2;
351 Handle holder(current, elem_type->klass_holder()); // keep the klass alive
352 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD);
353 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
|