< prev index next >

src/hotspot/share/opto/runtime.cpp

Print this page

 287   result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD);
 288 
 289   // Pass oops back through thread local storage.  Our apparent type to Java
 290   // is that we return an oop, but we can block on exit from this routine and
 291   // a GC can trash the oop in C's return register.  The generated stub will
 292   // fetch the oop from TLS after any possible GC.
 293   deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
 294   current->set_vm_result(result);
 295   JRT_BLOCK_END;
 296 
 297 
 298   // inform GC that we won't do card marks for initializing writes.
 299   SharedRuntime::on_slowpath_allocation_exit(current);
 300 
 301   oop result = current->vm_result();
 302   if ((len > 0) && (result != nullptr) &&
 303       is_deoptimized_caller_frame(current)) {
 304     // Zero array here if the caller is deoptimized.
 305     int size = TypeArrayKlass::cast(array_type)->oop_size(result);
 306     BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
 307     const size_t hs = arrayOopDesc::header_size(elem_type);
 308     // Align to next 8 bytes to avoid trashing arrays's length.
 309     const size_t aligned_hs = align_object_offset(hs);
 310     HeapWord* obj = cast_from_oop<HeapWord*>(result);
 311     if (aligned_hs > hs) {
 312       Copy::zero_to_words(obj+hs, aligned_hs-hs);

 313     }

 314     // Optimized zeroing.


 315     Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs);
 316   }
 317 
 318 JRT_END
 319 
 320 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array.
 321 
 322 // multianewarray for 2 dimensions
 323 JRT_ENTRY(void, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread* current))
 324 #ifndef PRODUCT
 325   SharedRuntime::_multi2_ctr++;                // multianewarray for 1 dimension
 326 #endif
 327   assert(check_compiled_frame(current), "incorrect caller");
 328   assert(elem_type->is_klass(), "not a class");
 329   jint dims[2];
 330   dims[0] = len1;
 331   dims[1] = len2;
 332   Handle holder(current, elem_type->klass_holder()); // keep the klass alive
 333   oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD);
 334   deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);

 287   result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD);
 288 
 289   // Pass oops back through thread local storage.  Our apparent type to Java
 290   // is that we return an oop, but we can block on exit from this routine and
 291   // a GC can trash the oop in C's return register.  The generated stub will
 292   // fetch the oop from TLS after any possible GC.
 293   deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
 294   current->set_vm_result(result);
 295   JRT_BLOCK_END;
 296 
 297 
 298   // inform GC that we won't do card marks for initializing writes.
 299   SharedRuntime::on_slowpath_allocation_exit(current);
 300 
 301   oop result = current->vm_result();
 302   if ((len > 0) && (result != nullptr) &&
 303       is_deoptimized_caller_frame(current)) {
 304     // Zero array here if the caller is deoptimized.
 305     int size = TypeArrayKlass::cast(array_type)->oop_size(result);
 306     BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
 307     size_t hs_bytes = arrayOopDesc::base_offset_in_bytes(elem_type);
 308     assert(is_aligned(hs_bytes, BytesPerInt), "must be 4 byte aligned");

 309     HeapWord* obj = cast_from_oop<HeapWord*>(result);
 310     if (!is_aligned(hs_bytes, BytesPerLong)) {
 311       *reinterpret_cast<jint*>(reinterpret_cast<char*>(obj) + hs_bytes) = 0;
 312       hs_bytes += BytesPerInt;
 313     }
 314 
 315     // Optimized zeroing.
 316     assert(is_aligned(hs_bytes, BytesPerLong), "must be 8-byte aligned");
 317     const size_t aligned_hs = hs_bytes / BytesPerLong;
 318     Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs);
 319   }
 320 
 321 JRT_END
 322 
 323 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array.
 324 
 325 // multianewarray for 2 dimensions
 326 JRT_ENTRY(void, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread* current))
 327 #ifndef PRODUCT
 328   SharedRuntime::_multi2_ctr++;                // multianewarray for 1 dimension
 329 #endif
 330   assert(check_compiled_frame(current), "incorrect caller");
 331   assert(elem_type->is_klass(), "not a class");
 332   jint dims[2];
 333   dims[0] = len1;
 334   dims[1] = len2;
 335   Handle holder(current, elem_type->klass_holder()); // keep the klass alive
 336   oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD);
 337   deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
< prev index next >