< 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/atomicAccess.hpp"
  65 #include "runtime/frame.inline.hpp"
  66 #include "runtime/handles.inline.hpp"

 171 
 172   C2_STUBS_DO(GEN_C2_BLOB, GEN_C2_STUB, GEN_C2_JVMTI_STUB)
 173 
 174   return true;
 175 }
 176 
 177 #undef GEN_C2_BLOB
 178 
 179 #undef C2_STUB_FIELD_NAME
 180 #undef C2_STUB_TYPEFUNC
 181 #undef C2_STUB_C_FUNC
 182 #undef C2_STUB_NAME
 183 #undef GEN_C2_STUB
 184 
 185 #undef C2_JVMTI_STUB_C_FUNC
 186 #undef GEN_C2_JVMTI_STUB
 187 // #undef gen
 188 
 189 const TypeFunc* OptoRuntime::_new_instance_Type                   = nullptr;
 190 const TypeFunc* OptoRuntime::_new_array_Type                      = nullptr;

 191 const TypeFunc* OptoRuntime::_multianewarray2_Type                = nullptr;
 192 const TypeFunc* OptoRuntime::_multianewarray3_Type                = nullptr;
 193 const TypeFunc* OptoRuntime::_multianewarray4_Type                = nullptr;
 194 const TypeFunc* OptoRuntime::_multianewarray5_Type                = nullptr;
 195 const TypeFunc* OptoRuntime::_multianewarrayN_Type                = nullptr;
 196 const TypeFunc* OptoRuntime::_complete_monitor_enter_Type         = nullptr;
 197 const TypeFunc* OptoRuntime::_complete_monitor_exit_Type          = nullptr;
 198 const TypeFunc* OptoRuntime::_monitor_notify_Type                 = nullptr;
 199 const TypeFunc* OptoRuntime::_uncommon_trap_Type                  = nullptr;
 200 const TypeFunc* OptoRuntime::_athrow_Type                         = nullptr;
 201 const TypeFunc* OptoRuntime::_rethrow_Type                        = nullptr;
 202 const TypeFunc* OptoRuntime::_Math_D_D_Type                       = nullptr;
 203 const TypeFunc* OptoRuntime::_Math_DD_D_Type                      = nullptr;
 204 const TypeFunc* OptoRuntime::_modf_Type                           = nullptr;
 205 const TypeFunc* OptoRuntime::_l2f_Type                            = nullptr;
 206 const TypeFunc* OptoRuntime::_void_long_Type                      = nullptr;
 207 const TypeFunc* OptoRuntime::_void_void_Type                      = nullptr;
 208 const TypeFunc* OptoRuntime::_jfr_write_checkpoint_Type           = nullptr;
 209 const TypeFunc* OptoRuntime::_flush_windows_Type                  = nullptr;
 210 const TypeFunc* OptoRuntime::_fast_arraycopy_Type                 = nullptr;

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




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

 368 
 369   if (array_type->is_typeArray_klass()) {












 370     // The oopFactory likes to work with the element type.
 371     // (We could bypass the oopFactory, since it doesn't add much value.)
 372     BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
 373     result = oopFactory::new_typeArray(elem_type, len, THREAD);
 374   } else {
 375     // Although the oopFactory likes to work with the elem_type,
 376     // the compiler prefers the array_type, since it must already have
 377     // that latter value in hand for the fast path.
 378     Handle holder(current, array_type->klass_holder()); // keep the array klass alive
 379     Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
 380     result = oopFactory::new_objArray(elem_type, len, THREAD);





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

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

 580 
 581   // create result type (range)
 582   fields = TypeTuple::fields(1);
 583   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
 584 
 585   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
 586 
 587   return TypeFunc::make(domain, range);
 588 }
 589 
 590 #if INCLUDE_JVMTI
 591 static const TypeFunc* make_notify_jvmti_vthread_Type() {
 592   // create input type (domain)
 593   const Type **fields = TypeTuple::fields(2);
 594   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // VirtualThread oop
 595   fields[TypeFunc::Parms+1] = TypeInt::BOOL;        // jboolean
 596   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
 597 
 598   // no result type needed
 599   fields = TypeTuple::fields(1);

 602 
 603   return TypeFunc::make(domain,range);
 604 }
 605 #endif
 606 
 607 static const TypeFunc* make_athrow_Type() {
 608   // create input type (domain)
 609   const Type **fields = TypeTuple::fields(1);
 610   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
 611   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
 612 
 613   // create result type (range)
 614   fields = TypeTuple::fields(0);
 615 
 616   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 617 
 618   return TypeFunc::make(domain, range);
 619 }
 620 
 621 static const TypeFunc* make_new_array_Type() {

















 622   // create input type (domain)
 623   const Type **fields = TypeTuple::fields(2);
 624   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass
 625   fields[TypeFunc::Parms+1] = TypeInt::INT;       // array size
 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 const TypeFunc* OptoRuntime::multianewarray_Type(int ndim) {
 638   // create input type (domain)
 639   const int nargs = ndim + 1;
 640   const Type **fields = TypeTuple::fields(nargs);
 641   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;   // element klass

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

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

2250     }
2251     st.print("@%d", bci);
2252     // To print linenumbers instead of bci use: m->line_number_from_bci(bci)
2253   }
2254   NamedCounter* c = new NamedCounter(st.freeze(), tag);
2255 
2256   // atomically add the new counter to the head of the list.  We only
2257   // add counters so this is safe.
2258   NamedCounter* head;
2259   do {
2260     c->set_next(nullptr);
2261     head = _named_counters;
2262     c->set_next(head);
2263   } while (AtomicAccess::cmpxchg(&_named_counters, head, c) != head);
2264   return c;
2265 }
2266 
2267 void OptoRuntime::initialize_types() {
2268   _new_instance_Type                  = make_new_instance_Type();
2269   _new_array_Type                     = make_new_array_Type();

2270   _multianewarray2_Type               = multianewarray_Type(2);
2271   _multianewarray3_Type               = multianewarray_Type(3);
2272   _multianewarray4_Type               = multianewarray_Type(4);
2273   _multianewarray5_Type               = multianewarray_Type(5);
2274   _multianewarrayN_Type               = make_multianewarrayN_Type();
2275   _complete_monitor_enter_Type        = make_complete_monitor_enter_Type();
2276   _complete_monitor_exit_Type         = make_complete_monitor_exit_Type();
2277   _monitor_notify_Type                = make_monitor_notify_Type();
2278   _uncommon_trap_Type                 = make_uncommon_trap_Type();
2279   _athrow_Type                        = make_athrow_Type();
2280   _rethrow_Type                       = make_rethrow_Type();
2281   _Math_D_D_Type                      = make_Math_D_D_Type();
2282   _Math_DD_D_Type                     = make_Math_DD_D_Type();
2283   _modf_Type                          = make_modf_Type();
2284   _l2f_Type                           = make_l2f_Type();
2285   _void_long_Type                     = make_void_long_Type();
2286   _void_void_Type                     = make_void_void_Type();
2287   _jfr_write_checkpoint_Type          = make_jfr_write_checkpoint_Type();
2288   _flush_windows_Type                 = make_flush_windows_Type();
2289   _fast_arraycopy_Type                = make_arraycopy_Type(ac_fast);

2350 static void trace_exception(outputStream* st, oop exception_oop, address exception_pc, const char* msg) {
2351   trace_exception_counter++;
2352   stringStream tempst;
2353 
2354   tempst.print("%d [Exception (%s): ", trace_exception_counter, msg);
2355   exception_oop->print_value_on(&tempst);
2356   tempst.print(" in ");
2357   CodeBlob* blob = CodeCache::find_blob(exception_pc);
2358   if (blob->is_nmethod()) {
2359     blob->as_nmethod()->method()->print_value_on(&tempst);
2360   } else if (blob->is_runtime_stub()) {
2361     tempst.print("<runtime-stub>");
2362   } else {
2363     tempst.print("<unknown>");
2364   }
2365   tempst.print(" at " INTPTR_FORMAT,  p2i(exception_pc));
2366   tempst.print("]");
2367 
2368   st->print_raw_cr(tempst.freeze());
2369 }










































































































  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/atomicAccess.hpp"
  67 #include "runtime/frame.inline.hpp"
  68 #include "runtime/handles.inline.hpp"

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

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



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

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

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

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

2151                       RegisterMap::WalkContinuation::skip);
2152   frame stub_frame = thread->last_frame();
2153   assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
2154   frame caller_frame = stub_frame.sender(&reg_map);
2155   return caller_frame.is_deoptimized_frame();
2156 }
2157 
2158 static const TypeFunc* make_register_finalizer_Type() {
2159   // create input type (domain)
2160   const Type **fields = TypeTuple::fields(1);
2161   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // oop;          Receiver
2162   // // The JavaThread* is passed to each routine as the last argument
2163   // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL;  // JavaThread *; Executing thread
2164   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
2165 
2166   // create result type (range)
2167   fields = TypeTuple::fields(0);
2168 
2169   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2170 
2171   return TypeFunc::make(domain, range);
2172 }
2173 
2174 #if INCLUDE_JFR
2175 static const TypeFunc* make_class_id_load_barrier_Type() {
2176   // create input type (domain)
2177   const Type **fields = TypeTuple::fields(1);
2178   fields[TypeFunc::Parms+0] = TypeInstPtr::KLASS;
2179   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms + 1, fields);
2180 
2181   // create result type (range)
2182   fields = TypeTuple::fields(0);
2183 
2184   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms + 0, fields);
2185 
2186   return TypeFunc::make(domain,range);
2187 }
2188 #endif // INCLUDE_JFR
2189 
2190 //-----------------------------------------------------------------------------
2191 static const TypeFunc* make_dtrace_method_entry_exit_Type() {
2192   // create input type (domain)
2193   const Type **fields = TypeTuple::fields(2);
2194   fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
2195   fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM;  // Method*;    Method we are entering
2196   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
2197 
2198   // create result type (range)
2199   fields = TypeTuple::fields(0);
2200 
2201   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2202 
2203   return TypeFunc::make(domain, range);
2204 }
2205 
2206 static const TypeFunc* make_dtrace_object_alloc_Type() {
2207   // create input type (domain)
2208   const Type **fields = TypeTuple::fields(2);
2209   fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
2210   fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL;  // oop;    newly allocated object
2211 
2212   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
2213 
2214   // create result type (range)
2215   fields = TypeTuple::fields(0);
2216 
2217   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2218 
2219   return TypeFunc::make(domain, range);
2220 }
2221 
2222 JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer_C(oopDesc* obj, JavaThread* current))
2223   assert(oopDesc::is_oop(obj), "must be a valid oop");
2224   assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
2225   InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
2226 JRT_END
2227 
2228 //-----------------------------------------------------------------------------
2229 
2230 NamedCounter * volatile OptoRuntime::_named_counters = nullptr;
2231 
2232 //
2233 // dump the collected NamedCounters.
2234 //
2235 void OptoRuntime::print_named_counters() {
2236   int total_lock_count = 0;
2237   int eliminated_lock_count = 0;
2238 
2239   NamedCounter* c = _named_counters;

2290     }
2291     st.print("@%d", bci);
2292     // To print linenumbers instead of bci use: m->line_number_from_bci(bci)
2293   }
2294   NamedCounter* c = new NamedCounter(st.freeze(), tag);
2295 
2296   // atomically add the new counter to the head of the list.  We only
2297   // add counters so this is safe.
2298   NamedCounter* head;
2299   do {
2300     c->set_next(nullptr);
2301     head = _named_counters;
2302     c->set_next(head);
2303   } while (AtomicAccess::cmpxchg(&_named_counters, head, c) != head);
2304   return c;
2305 }
2306 
2307 void OptoRuntime::initialize_types() {
2308   _new_instance_Type                  = make_new_instance_Type();
2309   _new_array_Type                     = make_new_array_Type();
2310   _new_array_nozero_Type              = make_new_array_nozero_Type();
2311   _multianewarray2_Type               = multianewarray_Type(2);
2312   _multianewarray3_Type               = multianewarray_Type(3);
2313   _multianewarray4_Type               = multianewarray_Type(4);
2314   _multianewarray5_Type               = multianewarray_Type(5);
2315   _multianewarrayN_Type               = make_multianewarrayN_Type();
2316   _complete_monitor_enter_Type        = make_complete_monitor_enter_Type();
2317   _complete_monitor_exit_Type         = make_complete_monitor_exit_Type();
2318   _monitor_notify_Type                = make_monitor_notify_Type();
2319   _uncommon_trap_Type                 = make_uncommon_trap_Type();
2320   _athrow_Type                        = make_athrow_Type();
2321   _rethrow_Type                       = make_rethrow_Type();
2322   _Math_D_D_Type                      = make_Math_D_D_Type();
2323   _Math_DD_D_Type                     = make_Math_DD_D_Type();
2324   _modf_Type                          = make_modf_Type();
2325   _l2f_Type                           = make_l2f_Type();
2326   _void_long_Type                     = make_void_long_Type();
2327   _void_void_Type                     = make_void_void_Type();
2328   _jfr_write_checkpoint_Type          = make_jfr_write_checkpoint_Type();
2329   _flush_windows_Type                 = make_flush_windows_Type();
2330   _fast_arraycopy_Type                = make_arraycopy_Type(ac_fast);

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