< 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 != NULL) &&
 303       is_deoptimized_caller_frame(current)) {
 304     // Zero array here if the caller is deoptimized.
 305     const size_t 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 != NULL) &&
 303       is_deoptimized_caller_frame(current)) {
 304     // Zero array here if the caller is deoptimized.
 305     const size_t size = TypeArrayKlass::cast(array_type)->oop_size(result);
 306     BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
 307     const size_t hs_bytes = arrayOopDesc::base_offset_in_bytes(elem_type);
 308     // Align to next 8 bytes to avoid trashing arrays's length.
 309     const size_t aligned_hs_bytes = align_up(hs_bytes, BytesPerLong);
 310     HeapWord* obj = cast_from_oop<HeapWord*>(result);
 311     if (aligned_hs_bytes > hs_bytes) {
 312       Copy::zero_to_bytes(obj + hs_bytes, aligned_hs_bytes - hs_bytes);
 313     }
 314     // Optimized zeroing.
 315     const size_t aligned_hs = aligned_hs_bytes / HeapWordSize;
 316     Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs);
 317   }
 318 
 319 JRT_END
 320 
 321 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array.
 322 
 323 // multianewarray for 2 dimensions
 324 JRT_ENTRY(void, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread* current))
 325 #ifndef PRODUCT
 326   SharedRuntime::_multi2_ctr++;                // multianewarray for 1 dimension
 327 #endif
 328   assert(check_compiled_frame(current), "incorrect caller");
 329   assert(elem_type->is_klass(), "not a class");
 330   jint dims[2];
 331   dims[0] = len1;
 332   dims[1] = len2;
 333   Handle holder(current, elem_type->klass_holder()); // keep the klass alive
 334   oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD);
 335   deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
< prev index next >