< prev index next >

src/hotspot/share/opto/runtime.cpp

Print this page
*** 42,10 ***
--- 42,12 ---
  #include "interpreter/linkResolver.hpp"
  #include "logging/log.hpp"
  #include "logging/logStream.hpp"
  #include "memory/oopFactory.hpp"
  #include "memory/resourceArea.hpp"
+ #include "oops/flatArrayKlass.hpp"
+ #include "oops/flatArrayOop.inline.hpp"
  #include "oops/objArrayKlass.hpp"
  #include "oops/klass.inline.hpp"
  #include "oops/oop.inline.hpp"
  #include "oops/typeArrayOop.inline.hpp"
  #include "opto/ad.hpp"

*** 194,10 ***
--- 196,11 ---
  #undef GEN_C2_JVMTI_STUB
  // #undef gen
  
  const TypeFunc* OptoRuntime::_new_instance_Type                   = nullptr;
  const TypeFunc* OptoRuntime::_new_array_Type                      = nullptr;
+ const TypeFunc* OptoRuntime::_new_array_nozero_Type               = nullptr;
  const TypeFunc* OptoRuntime::_multianewarray2_Type                = nullptr;
  const TypeFunc* OptoRuntime::_multianewarray3_Type                = nullptr;
  const TypeFunc* OptoRuntime::_multianewarray4_Type                = nullptr;
  const TypeFunc* OptoRuntime::_multianewarray5_Type                = nullptr;
  const TypeFunc* OptoRuntime::_multianewarrayN_Type                = nullptr;

*** 319,11 ***
  //=============================allocation======================================
  // We failed the fast-path allocation.  Now we need to do a scavenge or GC
  // and try allocation again.
  
  // object allocation
! JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, JavaThread* current))
    JRT_BLOCK;
  #ifndef PRODUCT
    SharedRuntime::_new_instance_ctr++;         // new instance requires GC
  #endif
    assert(check_compiled_frame(current), "incorrect caller");
--- 322,11 ---
  //=============================allocation======================================
  // We failed the fast-path allocation.  Now we need to do a scavenge or GC
  // and try allocation again.
  
  // object allocation
! JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, bool is_larval, JavaThread* current))
    JRT_BLOCK;
  #ifndef PRODUCT
    SharedRuntime::_new_instance_ctr++;         // new instance requires GC
  #endif
    assert(check_compiled_frame(current), "incorrect caller");

*** 339,11 ***
    }
  
    if (!HAS_PENDING_EXCEPTION) {
      // Scavenge and allocate an instance.
      Handle holder(current, klass->klass_holder()); // keep the klass alive
!     oop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);
      current->set_vm_result(result);
  
      // Pass oops back through thread local storage.  Our apparent type to Java
      // is that we return an oop, but we can block on exit from this routine and
      // a GC can trash the oop in C's return register.  The generated stub will
--- 342,15 ---
    }
  
    if (!HAS_PENDING_EXCEPTION) {
      // Scavenge and allocate an instance.
      Handle holder(current, klass->klass_holder()); // keep the klass alive
!     instanceOop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);
+     if (is_larval) {
+       // Check if this is a larval buffer allocation
+       result->set_mark(result->mark().enter_larval_state());
+     }
      current->set_vm_result(result);
  
      // Pass oops back through thread local storage.  Our apparent type to Java
      // is that we return an oop, but we can block on exit from this routine and
      // a GC can trash the oop in C's return register.  The generated stub will

*** 357,32 ***
    SharedRuntime::on_slowpath_allocation_exit(current);
  JRT_END
  
  
  // array allocation
! JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, JavaThread* current))
    JRT_BLOCK;
  #ifndef PRODUCT
    SharedRuntime::_new_array_ctr++;            // new array requires GC
  #endif
    assert(check_compiled_frame(current), "incorrect caller");
  
    // Scavenge and allocate an instance.
    oop result;
  
!   if (array_type->is_typeArray_klass()) {
      // The oopFactory likes to work with the element type.
      // (We could bypass the oopFactory, since it doesn't add much value.)
      BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
      result = oopFactory::new_typeArray(elem_type, len, THREAD);
    } else {
-     // Although the oopFactory likes to work with the elem_type,
-     // the compiler prefers the array_type, since it must already have
-     // that latter value in hand for the fast path.
      Handle holder(current, array_type->klass_holder()); // keep the array klass alive
!     Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
!     result = oopFactory::new_objArray(elem_type, len, THREAD);
    }
  
    // Pass oops back through thread local storage.  Our apparent type to Java
    // is that we return an oop, but we can block on exit from this routine and
    // a GC can trash the oop in C's return register.  The generated stub will
--- 364,47 ---
    SharedRuntime::on_slowpath_allocation_exit(current);
  JRT_END
  
  
  // array allocation
! JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, oopDesc* init_val, JavaThread* current))
    JRT_BLOCK;
  #ifndef PRODUCT
    SharedRuntime::_new_array_ctr++;            // new array requires GC
  #endif
    assert(check_compiled_frame(current), "incorrect caller");
  
    // Scavenge and allocate an instance.
    oop result;
+   Handle h_init_val(current, init_val); // keep the init_val object alive
  
!   if (array_type->is_flatArray_klass()) {
+     Handle holder(current, array_type->klass_holder()); // keep the array klass alive
+     FlatArrayKlass* fak = FlatArrayKlass::cast(array_type);
+     InlineKlass* vk = fak->element_klass();
+     result = oopFactory::new_flatArray(vk, len, fak->layout_kind(), THREAD);
+     if (array_type->is_null_free_array_klass() && !h_init_val.is_null()) {
+       // Null-free arrays need to be initialized
+       for (int i = 0; i < len; i++) {
+         vk->write_value_to_addr(h_init_val(), ((flatArrayOop)result)->value_at_addr(i, fak->layout_helper()), fak->layout_kind(), true, CHECK);
+       }
+     }
+   } else if (array_type->is_typeArray_klass()) {
      // The oopFactory likes to work with the element type.
      // (We could bypass the oopFactory, since it doesn't add much value.)
      BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
      result = oopFactory::new_typeArray(elem_type, len, THREAD);
    } else {
      Handle holder(current, array_type->klass_holder()); // keep the array klass alive
!     ObjArrayKlass* array_klass = ObjArrayKlass::cast(array_type);
!     result = array_klass->allocate(len, THREAD);
+     if (array_type->is_null_free_array_klass() && !h_init_val.is_null()) {
+       // Null-free arrays need to be initialized
+       for (int i = 0; i < len; i++) {
+         ((objArrayOop)result)->obj_at_put(i, h_init_val());
+       }
+     }
    }
  
    // Pass oops back through thread local storage.  Our apparent type to Java
    // is that we return an oop, but we can block on exit from this routine and
    // a GC can trash the oop in C's return register.  The generated stub will

*** 575,13 ***
    JRT_BLOCK_END;
  JRT_END
  
  static const TypeFunc* make_new_instance_Type() {
    // create input type (domain)
!   const Type **fields = TypeTuple::fields(1);
    fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
!   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
  
    // create result type (range)
    fields = TypeTuple::fields(1);
    fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
  
--- 597,14 ---
    JRT_BLOCK_END;
  JRT_END
  
  static const TypeFunc* make_new_instance_Type() {
    // create input type (domain)
!   const Type **fields = TypeTuple::fields(2);
    fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
!   fields[TypeFunc::Parms+1] = TypeInt::BOOL;        // is_larval
+   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
  
    // create result type (range)
    fields = TypeTuple::fields(1);
    fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
  

*** 620,10 ***
--- 643,27 ---
  
    return TypeFunc::make(domain, range);
  }
  
  static const TypeFunc* make_new_array_Type() {
+   // create input type (domain)
+   const Type **fields = TypeTuple::fields(3);
+   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass
+   fields[TypeFunc::Parms+1] = TypeInt::INT;       // array size
+   fields[TypeFunc::Parms+2] = TypeInstPtr::NOTNULL;       // init value
+   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields);
+ 
+   // create result type (range)
+   fields = TypeTuple::fields(1);
+   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
+ 
+   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
+ 
+   return TypeFunc::make(domain, range);
+ }
+ 
+ static const TypeFunc* make_new_array_nozero_Type() {
    // create input type (domain)
    const Type **fields = TypeTuple::fields(2);
    fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass
    fields[TypeFunc::Parms+1] = TypeInt::INT;       // array size
    const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);

*** 695,11 ***
    // create result type (range)
    fields = TypeTuple::fields(0);
  
    const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
  
!   return TypeFunc::make(domain,range);
  }
  
  //-----------------------------------------------------------------------------
  
  static const TypeFunc* make_complete_monitor_exit_Type() {
--- 735,11 ---
    // create result type (range)
    fields = TypeTuple::fields(0);
  
    const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
  
!   return TypeFunc::make(domain, range);
  }
  
  //-----------------------------------------------------------------------------
  
  static const TypeFunc* make_complete_monitor_exit_Type() {

*** 1933,11 ***
    // create result type (range)
    fields = TypeTuple::fields(0);
  
    const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
  
!   return TypeFunc::make(domain,range);
  }
  
  #if INCLUDE_JFR
  static const TypeFunc* make_class_id_load_barrier_Type() {
    // create input type (domain)
--- 1973,11 ---
    // create result type (range)
    fields = TypeTuple::fields(0);
  
    const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
  
!   return TypeFunc::make(domain, range);
  }
  
  #if INCLUDE_JFR
  static const TypeFunc* make_class_id_load_barrier_Type() {
    // create input type (domain)

*** 1965,11 ***
    // create result type (range)
    fields = TypeTuple::fields(0);
  
    const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
  
!   return TypeFunc::make(domain,range);
  }
  
  static const TypeFunc* make_dtrace_object_alloc_Type() {
    // create input type (domain)
    const Type **fields = TypeTuple::fields(2);
--- 2005,11 ---
    // create result type (range)
    fields = TypeTuple::fields(0);
  
    const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
  
!   return TypeFunc::make(domain, range);
  }
  
  static const TypeFunc* make_dtrace_object_alloc_Type() {
    // create input type (domain)
    const Type **fields = TypeTuple::fields(2);

*** 1981,11 ***
    // create result type (range)
    fields = TypeTuple::fields(0);
  
    const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
  
!   return TypeFunc::make(domain,range);
  }
  
  JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer_C(oopDesc* obj, JavaThread* current))
    assert(oopDesc::is_oop(obj), "must be a valid oop");
    assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
--- 2021,11 ---
    // create result type (range)
    fields = TypeTuple::fields(0);
  
    const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
  
!   return TypeFunc::make(domain, range);
  }
  
  JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer_C(oopDesc* obj, JavaThread* current))
    assert(oopDesc::is_oop(obj), "must be a valid oop");
    assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");

*** 2072,10 ***
--- 2112,11 ---
  }
  
  void OptoRuntime::initialize_types() {
    _new_instance_Type                  = make_new_instance_Type();
    _new_array_Type                     = make_new_array_Type();
+   _new_array_nozero_Type              = make_new_array_nozero_Type();
    _multianewarray2_Type               = multianewarray_Type(2);
    _multianewarray3_Type               = multianewarray_Type(3);
    _multianewarray4_Type               = multianewarray_Type(4);
    _multianewarray5_Type               = multianewarray_Type(5);
    _multianewarrayN_Type               = make_multianewarrayN_Type();

*** 2167,5 ***
--- 2208,110 ---
    tempst.print(" at " INTPTR_FORMAT,  p2i(exception_pc));
    tempst.print("]");
  
    st->print_raw_cr(tempst.freeze());
  }
+ 
+ const TypeFunc *OptoRuntime::store_inline_type_fields_Type() {
+   // create input type (domain)
+   uint total = SharedRuntime::java_return_convention_max_int + SharedRuntime::java_return_convention_max_float*2;
+   const Type **fields = TypeTuple::fields(total);
+   // We don't know the number of returned values and their
+   // types. Assume all registers available to the return convention
+   // are used.
+   fields[TypeFunc::Parms] = TypePtr::BOTTOM;
+   uint i = 1;
+   for (; i < SharedRuntime::java_return_convention_max_int; i++) {
+     fields[TypeFunc::Parms+i] = TypeInt::INT;
+   }
+   for (; i < total; i+=2) {
+     fields[TypeFunc::Parms+i] = Type::DOUBLE;
+     fields[TypeFunc::Parms+i+1] = Type::HALF;
+   }
+   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + total, fields);
+ 
+   // create result type (range)
+   fields = TypeTuple::fields(1);
+   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;
+ 
+   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1,fields);
+ 
+   return TypeFunc::make(domain, range);
+ }
+ 
+ const TypeFunc *OptoRuntime::pack_inline_type_Type() {
+   // create input type (domain)
+   uint total = 1 + SharedRuntime::java_return_convention_max_int + SharedRuntime::java_return_convention_max_float*2;
+   const Type **fields = TypeTuple::fields(total);
+   // We don't know the number of returned values and their
+   // types. Assume all registers available to the return convention
+   // are used.
+   fields[TypeFunc::Parms] = TypeRawPtr::BOTTOM;
+   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;
+   uint i = 2;
+   for (; i < SharedRuntime::java_return_convention_max_int+1; i++) {
+     fields[TypeFunc::Parms+i] = TypeInt::INT;
+   }
+   for (; i < total; i+=2) {
+     fields[TypeFunc::Parms+i] = Type::DOUBLE;
+     fields[TypeFunc::Parms+i+1] = Type::HALF;
+   }
+   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + total, fields);
+ 
+   // create result type (range)
+   fields = TypeTuple::fields(1);
+   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;
+ 
+   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1,fields);
+ 
+   return TypeFunc::make(domain, range);
+ }
+ 
+ JRT_BLOCK_ENTRY(void, OptoRuntime::load_unknown_inline_C(flatArrayOopDesc* array, int index, JavaThread* current))
+   JRT_BLOCK;
+   oop buffer = array->read_value_from_flat_array(index, THREAD);
+   deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
+   current->set_vm_result(buffer);
+   JRT_BLOCK_END;
+ JRT_END
+ 
+ const TypeFunc* OptoRuntime::load_unknown_inline_Type() {
+   // create input type (domain)
+   const Type** fields = TypeTuple::fields(2);
+   fields[TypeFunc::Parms] = TypeOopPtr::NOTNULL;
+   fields[TypeFunc::Parms+1] = TypeInt::POS;
+ 
+   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+2, fields);
+ 
+   // create result type (range)
+   fields = TypeTuple::fields(1);
+   fields[TypeFunc::Parms] = TypeInstPtr::BOTTOM;
+ 
+   const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
+ 
+   return TypeFunc::make(domain, range);
+ }
+ 
+ JRT_BLOCK_ENTRY(void, OptoRuntime::store_unknown_inline_C(instanceOopDesc* buffer, flatArrayOopDesc* array, int index, JavaThread* current))
+   JRT_BLOCK;
+   array->write_value_to_flat_array(buffer, index, THREAD);
+   if (HAS_PENDING_EXCEPTION) {
+       fatal("This entry must be changed to be a non-leaf entry because writing to a flat array can now throw an exception");
+   }
+   JRT_BLOCK_END;
+ JRT_END
+ 
+ const TypeFunc* OptoRuntime::store_unknown_inline_Type() {
+   // create input type (domain)
+   const Type** fields = TypeTuple::fields(3);
+   fields[TypeFunc::Parms] = TypeInstPtr::NOTNULL;
+   fields[TypeFunc::Parms+1] = TypeOopPtr::NOTNULL;
+   fields[TypeFunc::Parms+2] = TypeInt::POS;
+ 
+   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+3, fields);
+ 
+   // create result type (range)
+   fields = TypeTuple::fields(0);
+   const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
+ 
+   return TypeFunc::make(domain, range);
+ }
< prev index next >