< 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/objArrayKlass.hpp"
  48 #include "oops/klass.inline.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/objArrayKlass.hpp"
  50 #include "oops/klass.inline.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     result = oopFactory::new_flatArray(vk, len, fak->layout_kind(), THREAD);
 392     if (array_type->is_null_free_array_klass() && !h_init_val.is_null()) {
 393       // Null-free arrays need to be initialized
 394       for (int i = 0; i < len; i++) {
 395         vk->write_value_to_addr(h_init_val(), ((flatArrayOop)result)->value_at_addr(i, fak->layout_helper()), fak->layout_kind(), true, CHECK);
 396       }
 397     }
 398   } else if (array_type->is_typeArray_klass()) {
 399     // The oopFactory likes to work with the element type.
 400     // (We could bypass the oopFactory, since it doesn't add much value.)
 401     BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
 402     result = oopFactory::new_typeArray(elem_type, len, THREAD);
 403   } else {



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

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

 635 
 636   return TypeFunc::make(domain,range);
 637 }
 638 #endif
 639 
 640 static const TypeFunc* make_athrow_Type() {
 641   // create input type (domain)
 642   const Type **fields = TypeTuple::fields(1);
 643   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
 644   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
 645 
 646   // create result type (range)
 647   fields = TypeTuple::fields(0);
 648 
 649   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 650 
 651   return TypeFunc::make(domain, range);
 652 }
 653 
 654 static const TypeFunc* make_new_array_Type() {
 655   // create input type (domain)
 656   const Type **fields = TypeTuple::fields(3);
 657   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass
 658   fields[TypeFunc::Parms+1] = TypeInt::INT;       // array size
 659   fields[TypeFunc::Parms+2] = TypeInstPtr::NOTNULL;       // init value
 660   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields);
 661 
 662   // create result type (range)
 663   fields = TypeTuple::fields(1);
 664   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
 665 
 666   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
 667 
 668   return TypeFunc::make(domain, range);
 669 }
 670 
 671 static const TypeFunc* make_new_array_nozero_Type() {
 672   // create input type (domain)
 673   const Type **fields = TypeTuple::fields(2);
 674   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass
 675   fields[TypeFunc::Parms+1] = TypeInt::INT;       // array size
 676   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
 677 
 678   // create result type (range)
 679   fields = TypeTuple::fields(1);
 680   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
 681 
 682   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
 683 
 684   return TypeFunc::make(domain, range);
 685 }
 686 
 687 const TypeFunc* OptoRuntime::multianewarray_Type(int ndim) {
 688   // create input type (domain)
 689   const int nargs = ndim + 1;
 690   const Type **fields = TypeTuple::fields(nargs);
 691   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass

 727   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 728 
 729   return TypeFunc::make(domain, range);
 730 }
 731 
 732 //-----------------------------------------------------------------------------
 733 // Monitor Handling
 734 
 735 static const TypeFunc* make_complete_monitor_enter_Type() {
 736   // create input type (domain)
 737   const Type **fields = TypeTuple::fields(2);
 738   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 739   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;   // Address of stack location for lock
 740   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
 741 
 742   // create result type (range)
 743   fields = TypeTuple::fields(0);
 744 
 745   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
 746 
 747   return TypeFunc::make(domain, range);
 748 }
 749 
 750 //-----------------------------------------------------------------------------
 751 
 752 static const TypeFunc* make_complete_monitor_exit_Type() {
 753   // create input type (domain)
 754   const Type **fields = TypeTuple::fields(3);
 755   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 756   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;    // Address of stack location for lock - BasicLock
 757   fields[TypeFunc::Parms+2] = TypeRawPtr::BOTTOM;    // Thread pointer (Self)
 758   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields);
 759 
 760   // create result type (range)
 761   fields = TypeTuple::fields(0);
 762 
 763   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 764 
 765   return TypeFunc::make(domain, range);
 766 }
 767 

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

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

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