< prev index next >

src/hotspot/share/opto/runtime.cpp

Print this page

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

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

 546   return TypeFunc::make(domain, range);
 547 }
 548 
 549 const TypeFunc *OptoRuntime::uncommon_trap_Type() {
 550   // create input type (domain)
 551   const Type **fields = TypeTuple::fields(1);
 552   fields[TypeFunc::Parms+0] = TypeInt::INT; // trap_reason (deopt reason and action)
 553   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
 554 
 555   // create result type (range)
 556   fields = TypeTuple::fields(0);
 557   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 558 
 559   return TypeFunc::make(domain, range);
 560 }
 561 
 562 //-----------------------------------------------------------------------------
 563 // Monitor Handling
 564 const TypeFunc *OptoRuntime::complete_monitor_enter_Type() {
 565   // create input type (domain)
 566   const Type **fields = TypeTuple::fields(2);
 567   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 568   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;   // Address of stack location for lock
 569   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
 570 
 571   // create result type (range)
 572   fields = TypeTuple::fields(0);
 573 
 574   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
 575 
 576   return TypeFunc::make(domain,range);
 577 }
 578 
 579 
 580 //-----------------------------------------------------------------------------
 581 const TypeFunc *OptoRuntime::complete_monitor_exit_Type() {
 582   // create input type (domain)
 583   const Type **fields = TypeTuple::fields(3);
 584   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 585   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;    // Address of stack location for lock - BasicLock
 586   fields[TypeFunc::Parms+2] = TypeRawPtr::BOTTOM;    // Thread pointer (Self)
 587   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields);
 588 
 589   // create result type (range)
 590   fields = TypeTuple::fields(0);
 591 
 592   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 593 
 594   return TypeFunc::make(domain, range);
 595 }
 596 
 597 const TypeFunc *OptoRuntime::monitor_notify_Type() {
 598   // create input type (domain)
 599   const Type **fields = TypeTuple::fields(1);
 600   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 601   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
 602 
 603   // create result type (range)
 604   fields = TypeTuple::fields(0);
 605   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 606   return TypeFunc::make(domain, range);
 607 }

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

 547   return TypeFunc::make(domain, range);
 548 }
 549 
 550 const TypeFunc *OptoRuntime::uncommon_trap_Type() {
 551   // create input type (domain)
 552   const Type **fields = TypeTuple::fields(1);
 553   fields[TypeFunc::Parms+0] = TypeInt::INT; // trap_reason (deopt reason and action)
 554   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
 555 
 556   // create result type (range)
 557   fields = TypeTuple::fields(0);
 558   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 559 
 560   return TypeFunc::make(domain, range);
 561 }
 562 
 563 //-----------------------------------------------------------------------------
 564 // Monitor Handling
 565 const TypeFunc *OptoRuntime::complete_monitor_enter_Type() {
 566   // create input type (domain)
 567   const Type **fields = TypeTuple::fields(1);
 568   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 569   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);

 570 
 571   // create result type (range)
 572   fields = TypeTuple::fields(0);
 573 
 574   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
 575 
 576   return TypeFunc::make(domain,range);
 577 }
 578 
 579 
 580 //-----------------------------------------------------------------------------
 581 const TypeFunc *OptoRuntime::complete_monitor_exit_Type() {
 582   // create input type (domain)
 583   const Type **fields = TypeTuple::fields(2);
 584   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 585   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;    // Thread pointer (Self)
 586   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);

 587 
 588   // create result type (range)
 589   fields = TypeTuple::fields(0);
 590 
 591   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 592 
 593   return TypeFunc::make(domain, range);
 594 }
 595 
 596 const TypeFunc *OptoRuntime::monitor_notify_Type() {
 597   // create input type (domain)
 598   const Type **fields = TypeTuple::fields(1);
 599   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 600   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
 601 
 602   // create result type (range)
 603   fields = TypeTuple::fields(0);
 604   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 605   return TypeFunc::make(domain, range);
 606 }
< prev index next >