< prev index next >

src/hotspot/share/opto/runtime.cpp

Print this page

  27 #include "code/codeCache.hpp"
  28 #include "code/compiledIC.hpp"
  29 #include "code/nmethod.hpp"
  30 #include "code/pcDesc.hpp"
  31 #include "code/scopeDesc.hpp"
  32 #include "code/vtableStubs.hpp"
  33 #include "compiler/compilationMemoryStatistic.hpp"
  34 #include "compiler/compileBroker.hpp"
  35 #include "compiler/oopMap.hpp"
  36 #include "gc/g1/g1HeapRegion.hpp"
  37 #include "gc/shared/barrierSet.hpp"
  38 #include "gc/shared/collectedHeap.hpp"
  39 #include "gc/shared/gcLocker.hpp"
  40 #include "interpreter/bytecode.hpp"
  41 #include "interpreter/interpreter.hpp"
  42 #include "interpreter/linkResolver.hpp"
  43 #include "logging/log.hpp"
  44 #include "logging/logStream.hpp"
  45 #include "memory/oopFactory.hpp"
  46 #include "memory/resourceArea.hpp"


  47 #include "oops/klass.inline.hpp"
  48 #include "oops/objArrayKlass.hpp"
  49 #include "oops/oop.inline.hpp"
  50 #include "oops/typeArrayOop.inline.hpp"
  51 #include "opto/ad.hpp"
  52 #include "opto/addnode.hpp"
  53 #include "opto/callnode.hpp"
  54 #include "opto/cfgnode.hpp"
  55 #include "opto/graphKit.hpp"
  56 #include "opto/machnode.hpp"
  57 #include "opto/matcher.hpp"
  58 #include "opto/memnode.hpp"
  59 #include "opto/mulnode.hpp"
  60 #include "opto/output.hpp"
  61 #include "opto/runtime.hpp"
  62 #include "opto/subnode.hpp"
  63 #include "prims/jvmtiExport.hpp"
  64 #include "runtime/atomic.hpp"
  65 #include "runtime/frame.inline.hpp"
  66 #include "runtime/handles.inline.hpp"

 181 
 182   C2_STUBS_DO(GEN_C2_BLOB, GEN_C2_STUB, GEN_C2_JVMTI_STUB)
 183 
 184   return true;
 185 }
 186 
 187 #undef GEN_C2_BLOB
 188 
 189 #undef C2_STUB_FIELD_NAME
 190 #undef C2_STUB_TYPEFUNC
 191 #undef C2_STUB_C_FUNC
 192 #undef C2_STUB_NAME
 193 #undef GEN_C2_STUB
 194 
 195 #undef C2_JVMTI_STUB_C_FUNC
 196 #undef GEN_C2_JVMTI_STUB
 197 // #undef gen
 198 
 199 const TypeFunc* OptoRuntime::_new_instance_Type                   = nullptr;
 200 const TypeFunc* OptoRuntime::_new_array_Type                      = nullptr;

 201 const TypeFunc* OptoRuntime::_multianewarray2_Type                = nullptr;
 202 const TypeFunc* OptoRuntime::_multianewarray3_Type                = nullptr;
 203 const TypeFunc* OptoRuntime::_multianewarray4_Type                = nullptr;
 204 const TypeFunc* OptoRuntime::_multianewarray5_Type                = nullptr;
 205 const TypeFunc* OptoRuntime::_multianewarrayN_Type                = nullptr;
 206 const TypeFunc* OptoRuntime::_complete_monitor_enter_Type         = nullptr;
 207 const TypeFunc* OptoRuntime::_complete_monitor_exit_Type          = nullptr;
 208 const TypeFunc* OptoRuntime::_monitor_notify_Type                 = nullptr;
 209 const TypeFunc* OptoRuntime::_uncommon_trap_Type                  = nullptr;
 210 const TypeFunc* OptoRuntime::_athrow_Type                         = nullptr;
 211 const TypeFunc* OptoRuntime::_rethrow_Type                        = nullptr;
 212 const TypeFunc* OptoRuntime::_Math_D_D_Type                       = nullptr;
 213 const TypeFunc* OptoRuntime::_Math_DD_D_Type                      = nullptr;
 214 const TypeFunc* OptoRuntime::_modf_Type                           = nullptr;
 215 const TypeFunc* OptoRuntime::_l2f_Type                            = nullptr;
 216 const TypeFunc* OptoRuntime::_void_long_Type                      = nullptr;
 217 const TypeFunc* OptoRuntime::_void_void_Type                      = nullptr;
 218 const TypeFunc* OptoRuntime::_jfr_write_checkpoint_Type           = nullptr;
 219 const TypeFunc* OptoRuntime::_flush_windows_Type                  = nullptr;
 220 const TypeFunc* OptoRuntime::_fast_arraycopy_Type                 = nullptr;

 311                                    oopDesc* dest, jint dest_pos,
 312                                    jint length, JavaThread* thread) {
 313   SharedRuntime::slow_arraycopy_C(src,  src_pos, dest, dest_pos, length, thread);
 314 }
 315 
 316 void OptoRuntime::complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current) {
 317   SharedRuntime::complete_monitor_locking_C(obj, lock, current);
 318 }
 319 
 320 
 321 //=============================================================================
 322 // Opto compiler runtime routines
 323 //=============================================================================
 324 
 325 
 326 //=============================allocation======================================
 327 // We failed the fast-path allocation.  Now we need to do a scavenge or GC
 328 // and try allocation again.
 329 
 330 // object allocation
 331 JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, JavaThread* current))
 332   JRT_BLOCK;
 333 #ifndef PRODUCT
 334   SharedRuntime::_new_instance_ctr++;         // new instance requires GC
 335 #endif
 336   assert(check_compiled_frame(current), "incorrect caller");
 337 
 338   // These checks are cheap to make and support reflective allocation.
 339   int lh = klass->layout_helper();
 340   if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) {
 341     Handle holder(current, klass->klass_holder()); // keep the klass alive
 342     klass->check_valid_for_instantiation(false, THREAD);
 343     if (!HAS_PENDING_EXCEPTION) {
 344       InstanceKlass::cast(klass)->initialize(THREAD);
 345     }
 346   }
 347 
 348   if (!HAS_PENDING_EXCEPTION) {
 349     // Scavenge and allocate an instance.
 350     Handle holder(current, klass->klass_holder()); // keep the klass alive
 351     oop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);




 352     current->set_vm_result_oop(result);
 353 
 354     // Pass oops back through thread local storage.  Our apparent type to Java
 355     // is that we return an oop, but we can block on exit from this routine and
 356     // a GC can trash the oop in C's return register.  The generated stub will
 357     // fetch the oop from TLS after any possible GC.
 358   }
 359 
 360   deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
 361   JRT_BLOCK_END;
 362 
 363   // inform GC that we won't do card marks for initializing writes.
 364   SharedRuntime::on_slowpath_allocation_exit(current);
 365 JRT_END
 366 
 367 
 368 // array allocation
 369 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, JavaThread* current))
 370   JRT_BLOCK;
 371 #ifndef PRODUCT
 372   SharedRuntime::_new_array_ctr++;            // new array requires GC
 373 #endif
 374   assert(check_compiled_frame(current), "incorrect caller");
 375 
 376   // Scavenge and allocate an instance.
 377   oop result;

 378 
 379   if (array_type->is_typeArray_klass()) {

























 380     // The oopFactory likes to work with the element type.
 381     // (We could bypass the oopFactory, since it doesn't add much value.)
 382     BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
 383     result = oopFactory::new_typeArray(elem_type, len, THREAD);
 384   } else {
 385     // Although the oopFactory likes to work with the elem_type,
 386     // the compiler prefers the array_type, since it must already have
 387     // that latter value in hand for the fast path.
 388     Handle holder(current, array_type->klass_holder()); // keep the array klass alive
 389     Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
 390     result = oopFactory::new_objArray(elem_type, len, THREAD);






 391   }
 392 
 393   // Pass oops back through thread local storage.  Our apparent type to Java
 394   // is that we return an oop, but we can block on exit from this routine and
 395   // a GC can trash the oop in C's return register.  The generated stub will
 396   // fetch the oop from TLS after any possible GC.
 397   deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
 398   current->set_vm_result_oop(result);
 399   JRT_BLOCK_END;
 400 
 401   // inform GC that we won't do card marks for initializing writes.
 402   SharedRuntime::on_slowpath_allocation_exit(current);
 403 JRT_END
 404 
 405 // array allocation without zeroing
 406 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread* current))
 407   JRT_BLOCK;
 408 #ifndef PRODUCT
 409   SharedRuntime::_new_array_ctr++;            // new array requires GC
 410 #endif

 567 JRT_BLOCK_ENTRY(void, OptoRuntime::monitor_notifyAll_C(oopDesc* obj, JavaThread* current))
 568 
 569   if (!SafepointSynchronize::is_synchronizing() ) {
 570     if (ObjectSynchronizer::quick_notify(obj, current, true)) {
 571       return;
 572     }
 573   }
 574 
 575   // This is the case the fast-path above isn't provisioned to handle.
 576   // The fast-path is designed to handle frequently arising cases in an efficient manner.
 577   // (The fast-path is just a degenerate variant of the slow-path).
 578   // Perform the dreaded state transition and pass control into the slow-path.
 579   JRT_BLOCK;
 580   Handle h_obj(current, obj);
 581   ObjectSynchronizer::notifyall(h_obj, CHECK);
 582   JRT_BLOCK_END;
 583 JRT_END
 584 
 585 static const TypeFunc* make_new_instance_Type() {
 586   // create input type (domain)
 587   const Type **fields = TypeTuple::fields(1);
 588   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
 589   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);

 590 
 591   // create result type (range)
 592   fields = TypeTuple::fields(1);
 593   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
 594 
 595   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
 596 
 597   return TypeFunc::make(domain, range);
 598 }
 599 
 600 #if INCLUDE_JVMTI
 601 static const TypeFunc* make_notify_jvmti_vthread_Type() {
 602   // create input type (domain)
 603   const Type **fields = TypeTuple::fields(2);
 604   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // VirtualThread oop
 605   fields[TypeFunc::Parms+1] = TypeInt::BOOL;        // jboolean
 606   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
 607 
 608   // no result type needed
 609   fields = TypeTuple::fields(1);

 612 
 613   return TypeFunc::make(domain,range);
 614 }
 615 #endif
 616 
 617 static const TypeFunc* make_athrow_Type() {
 618   // create input type (domain)
 619   const Type **fields = TypeTuple::fields(1);
 620   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
 621   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
 622 
 623   // create result type (range)
 624   fields = TypeTuple::fields(0);
 625 
 626   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 627 
 628   return TypeFunc::make(domain, range);
 629 }
 630 
 631 static const TypeFunc* make_new_array_Type() {

















 632   // create input type (domain)
 633   const Type **fields = TypeTuple::fields(2);
 634   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass
 635   fields[TypeFunc::Parms+1] = TypeInt::INT;       // array size
 636   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
 637 
 638   // create result type (range)
 639   fields = TypeTuple::fields(1);
 640   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
 641 
 642   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
 643 
 644   return TypeFunc::make(domain, range);
 645 }
 646 
 647 const TypeFunc* OptoRuntime::multianewarray_Type(int ndim) {
 648   // create input type (domain)
 649   const int nargs = ndim + 1;
 650   const Type **fields = TypeTuple::fields(nargs);
 651   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass

 687   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 688 
 689   return TypeFunc::make(domain, range);
 690 }
 691 
 692 //-----------------------------------------------------------------------------
 693 // Monitor Handling
 694 
 695 static const TypeFunc* make_complete_monitor_enter_Type() {
 696   // create input type (domain)
 697   const Type **fields = TypeTuple::fields(2);
 698   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 699   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;   // Address of stack location for lock
 700   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
 701 
 702   // create result type (range)
 703   fields = TypeTuple::fields(0);
 704 
 705   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
 706 
 707   return TypeFunc::make(domain,range);
 708 }
 709 
 710 //-----------------------------------------------------------------------------
 711 
 712 static const TypeFunc* make_complete_monitor_exit_Type() {
 713   // create input type (domain)
 714   const Type **fields = TypeTuple::fields(3);
 715   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 716   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;    // Address of stack location for lock - BasicLock
 717   fields[TypeFunc::Parms+2] = TypeRawPtr::BOTTOM;    // Thread pointer (Self)
 718   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields);
 719 
 720   // create result type (range)
 721   fields = TypeTuple::fields(0);
 722 
 723   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 724 
 725   return TypeFunc::make(domain, range);
 726 }
 727 

2067                       RegisterMap::WalkContinuation::skip);
2068   frame stub_frame = thread->last_frame();
2069   assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
2070   frame caller_frame = stub_frame.sender(&reg_map);
2071   return caller_frame.is_deoptimized_frame();
2072 }
2073 
2074 static const TypeFunc* make_register_finalizer_Type() {
2075   // create input type (domain)
2076   const Type **fields = TypeTuple::fields(1);
2077   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // oop;          Receiver
2078   // // The JavaThread* is passed to each routine as the last argument
2079   // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL;  // JavaThread *; Executing thread
2080   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
2081 
2082   // create result type (range)
2083   fields = TypeTuple::fields(0);
2084 
2085   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2086 
2087   return TypeFunc::make(domain,range);
2088 }
2089 
2090 #if INCLUDE_JFR
2091 static const TypeFunc* make_class_id_load_barrier_Type() {
2092   // create input type (domain)
2093   const Type **fields = TypeTuple::fields(1);
2094   fields[TypeFunc::Parms+0] = TypeInstPtr::KLASS;
2095   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms + 1, fields);
2096 
2097   // create result type (range)
2098   fields = TypeTuple::fields(0);
2099 
2100   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms + 0, fields);
2101 
2102   return TypeFunc::make(domain,range);
2103 }
2104 #endif // INCLUDE_JFR
2105 
2106 //-----------------------------------------------------------------------------
2107 static const TypeFunc* make_dtrace_method_entry_exit_Type() {
2108   // create input type (domain)
2109   const Type **fields = TypeTuple::fields(2);
2110   fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
2111   fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM;  // Method*;    Method we are entering
2112   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
2113 
2114   // create result type (range)
2115   fields = TypeTuple::fields(0);
2116 
2117   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2118 
2119   return TypeFunc::make(domain,range);
2120 }
2121 
2122 static const TypeFunc* make_dtrace_object_alloc_Type() {
2123   // create input type (domain)
2124   const Type **fields = TypeTuple::fields(2);
2125   fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
2126   fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL;  // oop;    newly allocated object
2127 
2128   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
2129 
2130   // create result type (range)
2131   fields = TypeTuple::fields(0);
2132 
2133   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2134 
2135   return TypeFunc::make(domain,range);
2136 }
2137 
2138 JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer_C(oopDesc* obj, JavaThread* current))
2139   assert(oopDesc::is_oop(obj), "must be a valid oop");
2140   assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
2141   InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
2142 JRT_END
2143 
2144 //-----------------------------------------------------------------------------
2145 
2146 NamedCounter * volatile OptoRuntime::_named_counters = nullptr;
2147 
2148 //
2149 // dump the collected NamedCounters.
2150 //
2151 void OptoRuntime::print_named_counters() {
2152   int total_lock_count = 0;
2153   int eliminated_lock_count = 0;
2154 
2155   NamedCounter* c = _named_counters;

2206     }
2207     st.print("@%d", bci);
2208     // To print linenumbers instead of bci use: m->line_number_from_bci(bci)
2209   }
2210   NamedCounter* c = new NamedCounter(st.freeze(), tag);
2211 
2212   // atomically add the new counter to the head of the list.  We only
2213   // add counters so this is safe.
2214   NamedCounter* head;
2215   do {
2216     c->set_next(nullptr);
2217     head = _named_counters;
2218     c->set_next(head);
2219   } while (Atomic::cmpxchg(&_named_counters, head, c) != head);
2220   return c;
2221 }
2222 
2223 void OptoRuntime::initialize_types() {
2224   _new_instance_Type                  = make_new_instance_Type();
2225   _new_array_Type                     = make_new_array_Type();

2226   _multianewarray2_Type               = multianewarray_Type(2);
2227   _multianewarray3_Type               = multianewarray_Type(3);
2228   _multianewarray4_Type               = multianewarray_Type(4);
2229   _multianewarray5_Type               = multianewarray_Type(5);
2230   _multianewarrayN_Type               = make_multianewarrayN_Type();
2231   _complete_monitor_enter_Type        = make_complete_monitor_enter_Type();
2232   _complete_monitor_exit_Type         = make_complete_monitor_exit_Type();
2233   _monitor_notify_Type                = make_monitor_notify_Type();
2234   _uncommon_trap_Type                 = make_uncommon_trap_Type();
2235   _athrow_Type                        = make_athrow_Type();
2236   _rethrow_Type                       = make_rethrow_Type();
2237   _Math_D_D_Type                      = make_Math_D_D_Type();
2238   _Math_DD_D_Type                     = make_Math_DD_D_Type();
2239   _modf_Type                          = make_modf_Type();
2240   _l2f_Type                           = make_l2f_Type();
2241   _void_long_Type                     = make_void_long_Type();
2242   _void_void_Type                     = make_void_void_Type();
2243   _jfr_write_checkpoint_Type          = make_jfr_write_checkpoint_Type();
2244   _flush_windows_Type                 = make_flush_windows_Type();
2245   _fast_arraycopy_Type                = make_arraycopy_Type(ac_fast);

2306 static void trace_exception(outputStream* st, oop exception_oop, address exception_pc, const char* msg) {
2307   trace_exception_counter++;
2308   stringStream tempst;
2309 
2310   tempst.print("%d [Exception (%s): ", trace_exception_counter, msg);
2311   exception_oop->print_value_on(&tempst);
2312   tempst.print(" in ");
2313   CodeBlob* blob = CodeCache::find_blob(exception_pc);
2314   if (blob->is_nmethod()) {
2315     blob->as_nmethod()->method()->print_value_on(&tempst);
2316   } else if (blob->is_runtime_stub()) {
2317     tempst.print("<runtime-stub>");
2318   } else {
2319     tempst.print("<unknown>");
2320   }
2321   tempst.print(" at " INTPTR_FORMAT,  p2i(exception_pc));
2322   tempst.print("]");
2323 
2324   st->print_raw_cr(tempst.freeze());
2325 }










































































































  27 #include "code/codeCache.hpp"
  28 #include "code/compiledIC.hpp"
  29 #include "code/nmethod.hpp"
  30 #include "code/pcDesc.hpp"
  31 #include "code/scopeDesc.hpp"
  32 #include "code/vtableStubs.hpp"
  33 #include "compiler/compilationMemoryStatistic.hpp"
  34 #include "compiler/compileBroker.hpp"
  35 #include "compiler/oopMap.hpp"
  36 #include "gc/g1/g1HeapRegion.hpp"
  37 #include "gc/shared/barrierSet.hpp"
  38 #include "gc/shared/collectedHeap.hpp"
  39 #include "gc/shared/gcLocker.hpp"
  40 #include "interpreter/bytecode.hpp"
  41 #include "interpreter/interpreter.hpp"
  42 #include "interpreter/linkResolver.hpp"
  43 #include "logging/log.hpp"
  44 #include "logging/logStream.hpp"
  45 #include "memory/oopFactory.hpp"
  46 #include "memory/resourceArea.hpp"
  47 #include "oops/flatArrayKlass.hpp"
  48 #include "oops/flatArrayOop.inline.hpp"
  49 #include "oops/klass.inline.hpp"
  50 #include "oops/objArrayKlass.hpp"
  51 #include "oops/oop.inline.hpp"
  52 #include "oops/typeArrayOop.inline.hpp"
  53 #include "opto/ad.hpp"
  54 #include "opto/addnode.hpp"
  55 #include "opto/callnode.hpp"
  56 #include "opto/cfgnode.hpp"
  57 #include "opto/graphKit.hpp"
  58 #include "opto/machnode.hpp"
  59 #include "opto/matcher.hpp"
  60 #include "opto/memnode.hpp"
  61 #include "opto/mulnode.hpp"
  62 #include "opto/output.hpp"
  63 #include "opto/runtime.hpp"
  64 #include "opto/subnode.hpp"
  65 #include "prims/jvmtiExport.hpp"
  66 #include "runtime/atomic.hpp"
  67 #include "runtime/frame.inline.hpp"
  68 #include "runtime/handles.inline.hpp"

 183 
 184   C2_STUBS_DO(GEN_C2_BLOB, GEN_C2_STUB, GEN_C2_JVMTI_STUB)
 185 
 186   return true;
 187 }
 188 
 189 #undef GEN_C2_BLOB
 190 
 191 #undef C2_STUB_FIELD_NAME
 192 #undef C2_STUB_TYPEFUNC
 193 #undef C2_STUB_C_FUNC
 194 #undef C2_STUB_NAME
 195 #undef GEN_C2_STUB
 196 
 197 #undef C2_JVMTI_STUB_C_FUNC
 198 #undef GEN_C2_JVMTI_STUB
 199 // #undef gen
 200 
 201 const TypeFunc* OptoRuntime::_new_instance_Type                   = nullptr;
 202 const TypeFunc* OptoRuntime::_new_array_Type                      = nullptr;
 203 const TypeFunc* OptoRuntime::_new_array_nozero_Type               = nullptr;
 204 const TypeFunc* OptoRuntime::_multianewarray2_Type                = nullptr;
 205 const TypeFunc* OptoRuntime::_multianewarray3_Type                = nullptr;
 206 const TypeFunc* OptoRuntime::_multianewarray4_Type                = nullptr;
 207 const TypeFunc* OptoRuntime::_multianewarray5_Type                = nullptr;
 208 const TypeFunc* OptoRuntime::_multianewarrayN_Type                = nullptr;
 209 const TypeFunc* OptoRuntime::_complete_monitor_enter_Type         = nullptr;
 210 const TypeFunc* OptoRuntime::_complete_monitor_exit_Type          = nullptr;
 211 const TypeFunc* OptoRuntime::_monitor_notify_Type                 = nullptr;
 212 const TypeFunc* OptoRuntime::_uncommon_trap_Type                  = nullptr;
 213 const TypeFunc* OptoRuntime::_athrow_Type                         = nullptr;
 214 const TypeFunc* OptoRuntime::_rethrow_Type                        = nullptr;
 215 const TypeFunc* OptoRuntime::_Math_D_D_Type                       = nullptr;
 216 const TypeFunc* OptoRuntime::_Math_DD_D_Type                      = nullptr;
 217 const TypeFunc* OptoRuntime::_modf_Type                           = nullptr;
 218 const TypeFunc* OptoRuntime::_l2f_Type                            = nullptr;
 219 const TypeFunc* OptoRuntime::_void_long_Type                      = nullptr;
 220 const TypeFunc* OptoRuntime::_void_void_Type                      = nullptr;
 221 const TypeFunc* OptoRuntime::_jfr_write_checkpoint_Type           = nullptr;
 222 const TypeFunc* OptoRuntime::_flush_windows_Type                  = nullptr;
 223 const TypeFunc* OptoRuntime::_fast_arraycopy_Type                 = nullptr;

 314                                    oopDesc* dest, jint dest_pos,
 315                                    jint length, JavaThread* thread) {
 316   SharedRuntime::slow_arraycopy_C(src,  src_pos, dest, dest_pos, length, thread);
 317 }
 318 
 319 void OptoRuntime::complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current) {
 320   SharedRuntime::complete_monitor_locking_C(obj, lock, current);
 321 }
 322 
 323 
 324 //=============================================================================
 325 // Opto compiler runtime routines
 326 //=============================================================================
 327 
 328 
 329 //=============================allocation======================================
 330 // We failed the fast-path allocation.  Now we need to do a scavenge or GC
 331 // and try allocation again.
 332 
 333 // object allocation
 334 JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, bool is_larval, JavaThread* current))
 335   JRT_BLOCK;
 336 #ifndef PRODUCT
 337   SharedRuntime::_new_instance_ctr++;         // new instance requires GC
 338 #endif
 339   assert(check_compiled_frame(current), "incorrect caller");
 340 
 341   // These checks are cheap to make and support reflective allocation.
 342   int lh = klass->layout_helper();
 343   if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) {
 344     Handle holder(current, klass->klass_holder()); // keep the klass alive
 345     klass->check_valid_for_instantiation(false, THREAD);
 346     if (!HAS_PENDING_EXCEPTION) {
 347       InstanceKlass::cast(klass)->initialize(THREAD);
 348     }
 349   }
 350 
 351   if (!HAS_PENDING_EXCEPTION) {
 352     // Scavenge and allocate an instance.
 353     Handle holder(current, klass->klass_holder()); // keep the klass alive
 354     instanceOop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);
 355     if (is_larval) {
 356       // Check if this is a larval buffer allocation
 357       result->set_mark(result->mark().enter_larval_state());
 358     }
 359     current->set_vm_result_oop(result);
 360 
 361     // Pass oops back through thread local storage.  Our apparent type to Java
 362     // is that we return an oop, but we can block on exit from this routine and
 363     // a GC can trash the oop in C's return register.  The generated stub will
 364     // fetch the oop from TLS after any possible GC.
 365   }
 366 
 367   deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
 368   JRT_BLOCK_END;
 369 
 370   // inform GC that we won't do card marks for initializing writes.
 371   SharedRuntime::on_slowpath_allocation_exit(current);
 372 JRT_END
 373 
 374 
 375 // array allocation
 376 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, oopDesc* init_val, JavaThread* current))
 377   JRT_BLOCK;
 378 #ifndef PRODUCT
 379   SharedRuntime::_new_array_ctr++;            // new array requires GC
 380 #endif
 381   assert(check_compiled_frame(current), "incorrect caller");
 382 
 383   // Scavenge and allocate an instance.
 384   oop result;
 385   Handle h_init_val(current, init_val); // keep the init_val object alive
 386 
 387   if (array_type->is_flatArray_klass()) {
 388     Handle holder(current, array_type->klass_holder()); // keep the array klass alive
 389     FlatArrayKlass* fak = FlatArrayKlass::cast(array_type);
 390     InlineKlass* vk = fak->element_klass();
 391     ArrayKlass::ArrayProperties props = ArrayKlass::ArrayProperties::DEFAULT;
 392     switch(fak->layout_kind()) {
 393       case LayoutKind::ATOMIC_FLAT:
 394         props = ArrayKlass::ArrayProperties::NULL_RESTRICTED;
 395       break;
 396       case LayoutKind::NON_ATOMIC_FLAT:
 397         props = (ArrayKlass::ArrayProperties)(ArrayKlass::ArrayProperties::NULL_RESTRICTED | ArrayKlass::ArrayProperties::NON_ATOMIC);
 398       break;
 399       case LayoutKind::NULLABLE_ATOMIC_FLAT:
 400       props = ArrayKlass::ArrayProperties::NON_ATOMIC;
 401       break;
 402       default:
 403         ShouldNotReachHere();
 404     }
 405     result = oopFactory::new_flatArray(vk, len, props, fak->layout_kind(), THREAD);
 406     if (array_type->is_null_free_array_klass() && !h_init_val.is_null()) {
 407       // Null-free arrays need to be initialized
 408       for (int i = 0; i < len; i++) {
 409         vk->write_value_to_addr(h_init_val(), ((flatArrayOop)result)->value_at_addr(i, fak->layout_helper()), fak->layout_kind(), true, CHECK);
 410       }
 411     }
 412   } else if (array_type->is_typeArray_klass()) {
 413     // The oopFactory likes to work with the element type.
 414     // (We could bypass the oopFactory, since it doesn't add much value.)
 415     BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
 416     result = oopFactory::new_typeArray(elem_type, len, THREAD);
 417   } else {



 418     Handle holder(current, array_type->klass_holder()); // keep the array klass alive
 419     RefArrayKlass* array_klass = RefArrayKlass::cast(array_type);
 420     result = array_klass->allocate_instance(len, RefArrayKlass::cast(array_type)->properties(), THREAD);
 421     if (array_type->is_null_free_array_klass() && !h_init_val.is_null()) {
 422       // Null-free arrays need to be initialized
 423       for (int i = 0; i < len; i++) {
 424         ((objArrayOop)result)->obj_at_put(i, h_init_val());
 425       }
 426     }
 427   }
 428 
 429   // Pass oops back through thread local storage.  Our apparent type to Java
 430   // is that we return an oop, but we can block on exit from this routine and
 431   // a GC can trash the oop in C's return register.  The generated stub will
 432   // fetch the oop from TLS after any possible GC.
 433   deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
 434   current->set_vm_result_oop(result);
 435   JRT_BLOCK_END;
 436 
 437   // inform GC that we won't do card marks for initializing writes.
 438   SharedRuntime::on_slowpath_allocation_exit(current);
 439 JRT_END
 440 
 441 // array allocation without zeroing
 442 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread* current))
 443   JRT_BLOCK;
 444 #ifndef PRODUCT
 445   SharedRuntime::_new_array_ctr++;            // new array requires GC
 446 #endif

 603 JRT_BLOCK_ENTRY(void, OptoRuntime::monitor_notifyAll_C(oopDesc* obj, JavaThread* current))
 604 
 605   if (!SafepointSynchronize::is_synchronizing() ) {
 606     if (ObjectSynchronizer::quick_notify(obj, current, true)) {
 607       return;
 608     }
 609   }
 610 
 611   // This is the case the fast-path above isn't provisioned to handle.
 612   // The fast-path is designed to handle frequently arising cases in an efficient manner.
 613   // (The fast-path is just a degenerate variant of the slow-path).
 614   // Perform the dreaded state transition and pass control into the slow-path.
 615   JRT_BLOCK;
 616   Handle h_obj(current, obj);
 617   ObjectSynchronizer::notifyall(h_obj, CHECK);
 618   JRT_BLOCK_END;
 619 JRT_END
 620 
 621 static const TypeFunc* make_new_instance_Type() {
 622   // create input type (domain)
 623   const Type **fields = TypeTuple::fields(2);
 624   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
 625   fields[TypeFunc::Parms+1] = TypeInt::BOOL;        // is_larval
 626   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
 627 
 628   // create result type (range)
 629   fields = TypeTuple::fields(1);
 630   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
 631 
 632   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
 633 
 634   return TypeFunc::make(domain, range);
 635 }
 636 
 637 #if INCLUDE_JVMTI
 638 static const TypeFunc* make_notify_jvmti_vthread_Type() {
 639   // create input type (domain)
 640   const Type **fields = TypeTuple::fields(2);
 641   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // VirtualThread oop
 642   fields[TypeFunc::Parms+1] = TypeInt::BOOL;        // jboolean
 643   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
 644 
 645   // no result type needed
 646   fields = TypeTuple::fields(1);

 649 
 650   return TypeFunc::make(domain,range);
 651 }
 652 #endif
 653 
 654 static const TypeFunc* make_athrow_Type() {
 655   // create input type (domain)
 656   const Type **fields = TypeTuple::fields(1);
 657   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
 658   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
 659 
 660   // create result type (range)
 661   fields = TypeTuple::fields(0);
 662 
 663   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 664 
 665   return TypeFunc::make(domain, range);
 666 }
 667 
 668 static const TypeFunc* make_new_array_Type() {
 669   // create input type (domain)
 670   const Type **fields = TypeTuple::fields(3);
 671   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass
 672   fields[TypeFunc::Parms+1] = TypeInt::INT;       // array size
 673   fields[TypeFunc::Parms+2] = TypeInstPtr::NOTNULL;       // init value
 674   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields);
 675 
 676   // create result type (range)
 677   fields = TypeTuple::fields(1);
 678   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
 679 
 680   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
 681 
 682   return TypeFunc::make(domain, range);
 683 }
 684 
 685 static const TypeFunc* make_new_array_nozero_Type() {
 686   // create input type (domain)
 687   const Type **fields = TypeTuple::fields(2);
 688   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass
 689   fields[TypeFunc::Parms+1] = TypeInt::INT;       // array size
 690   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
 691 
 692   // create result type (range)
 693   fields = TypeTuple::fields(1);
 694   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
 695 
 696   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
 697 
 698   return TypeFunc::make(domain, range);
 699 }
 700 
 701 const TypeFunc* OptoRuntime::multianewarray_Type(int ndim) {
 702   // create input type (domain)
 703   const int nargs = ndim + 1;
 704   const Type **fields = TypeTuple::fields(nargs);
 705   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass

 741   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 742 
 743   return TypeFunc::make(domain, range);
 744 }
 745 
 746 //-----------------------------------------------------------------------------
 747 // Monitor Handling
 748 
 749 static const TypeFunc* make_complete_monitor_enter_Type() {
 750   // create input type (domain)
 751   const Type **fields = TypeTuple::fields(2);
 752   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 753   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;   // Address of stack location for lock
 754   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
 755 
 756   // create result type (range)
 757   fields = TypeTuple::fields(0);
 758 
 759   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
 760 
 761   return TypeFunc::make(domain, range);
 762 }
 763 
 764 //-----------------------------------------------------------------------------
 765 
 766 static const TypeFunc* make_complete_monitor_exit_Type() {
 767   // create input type (domain)
 768   const Type **fields = TypeTuple::fields(3);
 769   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 770   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;    // Address of stack location for lock - BasicLock
 771   fields[TypeFunc::Parms+2] = TypeRawPtr::BOTTOM;    // Thread pointer (Self)
 772   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields);
 773 
 774   // create result type (range)
 775   fields = TypeTuple::fields(0);
 776 
 777   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 778 
 779   return TypeFunc::make(domain, range);
 780 }
 781 

2121                       RegisterMap::WalkContinuation::skip);
2122   frame stub_frame = thread->last_frame();
2123   assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
2124   frame caller_frame = stub_frame.sender(&reg_map);
2125   return caller_frame.is_deoptimized_frame();
2126 }
2127 
2128 static const TypeFunc* make_register_finalizer_Type() {
2129   // create input type (domain)
2130   const Type **fields = TypeTuple::fields(1);
2131   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // oop;          Receiver
2132   // // The JavaThread* is passed to each routine as the last argument
2133   // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL;  // JavaThread *; Executing thread
2134   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
2135 
2136   // create result type (range)
2137   fields = TypeTuple::fields(0);
2138 
2139   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2140 
2141   return TypeFunc::make(domain, range);
2142 }
2143 
2144 #if INCLUDE_JFR
2145 static const TypeFunc* make_class_id_load_barrier_Type() {
2146   // create input type (domain)
2147   const Type **fields = TypeTuple::fields(1);
2148   fields[TypeFunc::Parms+0] = TypeInstPtr::KLASS;
2149   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms + 1, fields);
2150 
2151   // create result type (range)
2152   fields = TypeTuple::fields(0);
2153 
2154   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms + 0, fields);
2155 
2156   return TypeFunc::make(domain,range);
2157 }
2158 #endif // INCLUDE_JFR
2159 
2160 //-----------------------------------------------------------------------------
2161 static const TypeFunc* make_dtrace_method_entry_exit_Type() {
2162   // create input type (domain)
2163   const Type **fields = TypeTuple::fields(2);
2164   fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
2165   fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM;  // Method*;    Method we are entering
2166   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
2167 
2168   // create result type (range)
2169   fields = TypeTuple::fields(0);
2170 
2171   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2172 
2173   return TypeFunc::make(domain, range);
2174 }
2175 
2176 static const TypeFunc* make_dtrace_object_alloc_Type() {
2177   // create input type (domain)
2178   const Type **fields = TypeTuple::fields(2);
2179   fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
2180   fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL;  // oop;    newly allocated object
2181 
2182   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
2183 
2184   // create result type (range)
2185   fields = TypeTuple::fields(0);
2186 
2187   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2188 
2189   return TypeFunc::make(domain, range);
2190 }
2191 
2192 JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer_C(oopDesc* obj, JavaThread* current))
2193   assert(oopDesc::is_oop(obj), "must be a valid oop");
2194   assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
2195   InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
2196 JRT_END
2197 
2198 //-----------------------------------------------------------------------------
2199 
2200 NamedCounter * volatile OptoRuntime::_named_counters = nullptr;
2201 
2202 //
2203 // dump the collected NamedCounters.
2204 //
2205 void OptoRuntime::print_named_counters() {
2206   int total_lock_count = 0;
2207   int eliminated_lock_count = 0;
2208 
2209   NamedCounter* c = _named_counters;

2260     }
2261     st.print("@%d", bci);
2262     // To print linenumbers instead of bci use: m->line_number_from_bci(bci)
2263   }
2264   NamedCounter* c = new NamedCounter(st.freeze(), tag);
2265 
2266   // atomically add the new counter to the head of the list.  We only
2267   // add counters so this is safe.
2268   NamedCounter* head;
2269   do {
2270     c->set_next(nullptr);
2271     head = _named_counters;
2272     c->set_next(head);
2273   } while (Atomic::cmpxchg(&_named_counters, head, c) != head);
2274   return c;
2275 }
2276 
2277 void OptoRuntime::initialize_types() {
2278   _new_instance_Type                  = make_new_instance_Type();
2279   _new_array_Type                     = make_new_array_Type();
2280   _new_array_nozero_Type              = make_new_array_nozero_Type();
2281   _multianewarray2_Type               = multianewarray_Type(2);
2282   _multianewarray3_Type               = multianewarray_Type(3);
2283   _multianewarray4_Type               = multianewarray_Type(4);
2284   _multianewarray5_Type               = multianewarray_Type(5);
2285   _multianewarrayN_Type               = make_multianewarrayN_Type();
2286   _complete_monitor_enter_Type        = make_complete_monitor_enter_Type();
2287   _complete_monitor_exit_Type         = make_complete_monitor_exit_Type();
2288   _monitor_notify_Type                = make_monitor_notify_Type();
2289   _uncommon_trap_Type                 = make_uncommon_trap_Type();
2290   _athrow_Type                        = make_athrow_Type();
2291   _rethrow_Type                       = make_rethrow_Type();
2292   _Math_D_D_Type                      = make_Math_D_D_Type();
2293   _Math_DD_D_Type                     = make_Math_DD_D_Type();
2294   _modf_Type                          = make_modf_Type();
2295   _l2f_Type                           = make_l2f_Type();
2296   _void_long_Type                     = make_void_long_Type();
2297   _void_void_Type                     = make_void_void_Type();
2298   _jfr_write_checkpoint_Type          = make_jfr_write_checkpoint_Type();
2299   _flush_windows_Type                 = make_flush_windows_Type();
2300   _fast_arraycopy_Type                = make_arraycopy_Type(ac_fast);

2361 static void trace_exception(outputStream* st, oop exception_oop, address exception_pc, const char* msg) {
2362   trace_exception_counter++;
2363   stringStream tempst;
2364 
2365   tempst.print("%d [Exception (%s): ", trace_exception_counter, msg);
2366   exception_oop->print_value_on(&tempst);
2367   tempst.print(" in ");
2368   CodeBlob* blob = CodeCache::find_blob(exception_pc);
2369   if (blob->is_nmethod()) {
2370     blob->as_nmethod()->method()->print_value_on(&tempst);
2371   } else if (blob->is_runtime_stub()) {
2372     tempst.print("<runtime-stub>");
2373   } else {
2374     tempst.print("<unknown>");
2375   }
2376   tempst.print(" at " INTPTR_FORMAT,  p2i(exception_pc));
2377   tempst.print("]");
2378 
2379   st->print_raw_cr(tempst.freeze());
2380 }
2381 
2382 const TypeFunc *OptoRuntime::store_inline_type_fields_Type() {
2383   // create input type (domain)
2384   uint total = SharedRuntime::java_return_convention_max_int + SharedRuntime::java_return_convention_max_float*2;
2385   const Type **fields = TypeTuple::fields(total);
2386   // We don't know the number of returned values and their
2387   // types. Assume all registers available to the return convention
2388   // are used.
2389   fields[TypeFunc::Parms] = TypePtr::BOTTOM;
2390   uint i = 1;
2391   for (; i < SharedRuntime::java_return_convention_max_int; i++) {
2392     fields[TypeFunc::Parms+i] = TypeInt::INT;
2393   }
2394   for (; i < total; i+=2) {
2395     fields[TypeFunc::Parms+i] = Type::DOUBLE;
2396     fields[TypeFunc::Parms+i+1] = Type::HALF;
2397   }
2398   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + total, fields);
2399 
2400   // create result type (range)
2401   fields = TypeTuple::fields(1);
2402   fields[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM;
2403 
2404   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1,fields);
2405 
2406   return TypeFunc::make(domain, range);
2407 }
2408 
2409 const TypeFunc *OptoRuntime::pack_inline_type_Type() {
2410   // create input type (domain)
2411   uint total = 1 + SharedRuntime::java_return_convention_max_int + SharedRuntime::java_return_convention_max_float*2;
2412   const Type **fields = TypeTuple::fields(total);
2413   // We don't know the number of returned values and their
2414   // types. Assume all registers available to the return convention
2415   // are used.
2416   fields[TypeFunc::Parms] = TypeRawPtr::BOTTOM;
2417   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;
2418   uint i = 2;
2419   for (; i < SharedRuntime::java_return_convention_max_int+1; i++) {
2420     fields[TypeFunc::Parms+i] = TypeInt::INT;
2421   }
2422   for (; i < total; i+=2) {
2423     fields[TypeFunc::Parms+i] = Type::DOUBLE;
2424     fields[TypeFunc::Parms+i+1] = Type::HALF;
2425   }
2426   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + total, fields);
2427 
2428   // create result type (range)
2429   fields = TypeTuple::fields(1);
2430   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;
2431 
2432   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1,fields);
2433 
2434   return TypeFunc::make(domain, range);
2435 }
2436 
2437 JRT_BLOCK_ENTRY(void, OptoRuntime::load_unknown_inline_C(flatArrayOopDesc* array, int index, JavaThread* current))
2438   JRT_BLOCK;
2439   oop buffer = array->obj_at(index, THREAD);
2440   deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
2441   current->set_vm_result_oop(buffer);
2442   JRT_BLOCK_END;
2443 JRT_END
2444 
2445 const TypeFunc* OptoRuntime::load_unknown_inline_Type() {
2446   // create input type (domain)
2447   const Type** fields = TypeTuple::fields(2);
2448   fields[TypeFunc::Parms] = TypeOopPtr::NOTNULL;
2449   fields[TypeFunc::Parms+1] = TypeInt::POS;
2450 
2451   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+2, fields);
2452 
2453   // create result type (range)
2454   fields = TypeTuple::fields(1);
2455   fields[TypeFunc::Parms] = TypeInstPtr::BOTTOM;
2456 
2457   const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
2458 
2459   return TypeFunc::make(domain, range);
2460 }
2461 
2462 JRT_BLOCK_ENTRY(void, OptoRuntime::store_unknown_inline_C(instanceOopDesc* buffer, flatArrayOopDesc* array, int index, JavaThread* current))
2463   JRT_BLOCK;
2464   array->obj_at_put(index, buffer, THREAD);
2465   if (HAS_PENDING_EXCEPTION) {
2466       fatal("This entry must be changed to be a non-leaf entry because writing to a flat array can now throw an exception");
2467   }
2468   JRT_BLOCK_END;
2469 JRT_END
2470 
2471 const TypeFunc* OptoRuntime::store_unknown_inline_Type() {
2472   // create input type (domain)
2473   const Type** fields = TypeTuple::fields(3);
2474   fields[TypeFunc::Parms] = TypeInstPtr::NOTNULL;
2475   fields[TypeFunc::Parms+1] = TypeOopPtr::NOTNULL;
2476   fields[TypeFunc::Parms+2] = TypeInt::POS;
2477 
2478   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+3, fields);
2479 
2480   // create result type (range)
2481   fields = TypeTuple::fields(0);
2482   const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
2483 
2484   return TypeFunc::make(domain, range);
2485 }
< prev index next >