< prev index next >

src/hotspot/share/opto/runtime.cpp

Print this page




  32 #include "code/nmethod.hpp"
  33 #include "code/pcDesc.hpp"
  34 #include "code/scopeDesc.hpp"
  35 #include "code/vtableStubs.hpp"
  36 #include "compiler/compileBroker.hpp"
  37 #include "compiler/oopMap.hpp"
  38 #include "gc/g1/heapRegion.hpp"
  39 #include "gc/shared/barrierSet.hpp"
  40 #include "gc/shared/collectedHeap.hpp"
  41 #include "gc/shared/gcLocker.hpp"
  42 #include "interpreter/bytecode.hpp"
  43 #include "interpreter/interpreter.hpp"
  44 #include "interpreter/linkResolver.hpp"
  45 #include "logging/log.hpp"
  46 #include "logging/logStream.hpp"
  47 #include "memory/oopFactory.hpp"
  48 #include "memory/resourceArea.hpp"
  49 #include "oops/objArrayKlass.hpp"
  50 #include "oops/oop.inline.hpp"
  51 #include "oops/typeArrayOop.inline.hpp"


  52 #include "opto/ad.hpp"
  53 #include "opto/addnode.hpp"
  54 #include "opto/callnode.hpp"
  55 #include "opto/cfgnode.hpp"
  56 #include "opto/graphKit.hpp"
  57 #include "opto/machnode.hpp"
  58 #include "opto/matcher.hpp"
  59 #include "opto/memnode.hpp"
  60 #include "opto/mulnode.hpp"
  61 #include "opto/runtime.hpp"
  62 #include "opto/subnode.hpp"
  63 #include "runtime/atomic.hpp"
  64 #include "runtime/frame.inline.hpp"
  65 #include "runtime/handles.inline.hpp"
  66 #include "runtime/interfaceSupport.inline.hpp"
  67 #include "runtime/javaCalls.hpp"
  68 #include "runtime/sharedRuntime.hpp"
  69 #include "runtime/signature.hpp"
  70 #include "runtime/threadCritical.hpp"
  71 #include "runtime/vframe.hpp"


 223 
 224   deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
 225   JRT_BLOCK_END;
 226 
 227   // inform GC that we won't do card marks for initializing writes.
 228   SharedRuntime::on_slowpath_allocation_exit(thread);
 229 JRT_END
 230 
 231 
 232 // array allocation
 233 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, JavaThread *thread))
 234   JRT_BLOCK;
 235 #ifndef PRODUCT
 236   SharedRuntime::_new_array_ctr++;            // new array requires GC
 237 #endif
 238   assert(check_compiled_frame(thread), "incorrect caller");
 239 
 240   // Scavenge and allocate an instance.
 241   oop result;
 242 
 243   if (array_type->is_typeArray_klass()) {



 244     // The oopFactory likes to work with the element type.
 245     // (We could bypass the oopFactory, since it doesn't add much value.)
 246     BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
 247     result = oopFactory::new_typeArray(elem_type, len, THREAD);
 248   } else {
 249     // Although the oopFactory likes to work with the elem_type,
 250     // the compiler prefers the array_type, since it must already have
 251     // that latter value in hand for the fast path.
 252     Handle holder(THREAD, array_type->klass_holder()); // keep the array klass alive
 253     Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
 254     result = oopFactory::new_objArray(elem_type, len, THREAD);
 255   }
 256 
 257   // Pass oops back through thread local storage.  Our apparent type to Java
 258   // is that we return an oop, but we can block on exit from this routine and
 259   // a GC can trash the oop in C's return register.  The generated stub will
 260   // fetch the oop from TLS after any possible GC.
 261   deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
 262   thread->set_vm_result(result);
 263   JRT_BLOCK_END;
 264 
 265   // inform GC that we won't do card marks for initializing writes.
 266   SharedRuntime::on_slowpath_allocation_exit(thread);
 267 JRT_END
 268 
 269 // array allocation without zeroing
 270 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread *thread))
 271   JRT_BLOCK;
 272 #ifndef PRODUCT
 273   SharedRuntime::_new_array_ctr++;            // new array requires GC
 274 #endif


 548   fields = TypeTuple::fields(0);
 549   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 550 
 551   return TypeFunc::make(domain, range);
 552 }
 553 
 554 //-----------------------------------------------------------------------------
 555 // Monitor Handling
 556 const TypeFunc *OptoRuntime::complete_monitor_enter_Type() {
 557   // create input type (domain)
 558   const Type **fields = TypeTuple::fields(2);
 559   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 560   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;   // Address of stack location for lock
 561   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
 562 
 563   // create result type (range)
 564   fields = TypeTuple::fields(0);
 565 
 566   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
 567 
 568   return TypeFunc::make(domain,range);
 569 }
 570 
 571 
 572 //-----------------------------------------------------------------------------
 573 const TypeFunc *OptoRuntime::complete_monitor_exit_Type() {
 574   // create input type (domain)
 575   const Type **fields = TypeTuple::fields(3);
 576   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 577   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;    // Address of stack location for lock - BasicLock
 578   fields[TypeFunc::Parms+2] = TypeRawPtr::BOTTOM;    // Thread pointer (Self)
 579   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields);
 580 
 581   // create result type (range)
 582   fields = TypeTuple::fields(0);
 583 
 584   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 585 
 586   return TypeFunc::make(domain, range);
 587 }
 588 


1156   fields = TypeTuple::fields(1);
1157   // fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // locked oop
1158   fields[TypeFunc::Parms+0] = NULL; // void
1159   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
1160   return TypeFunc::make(domain, range);
1161 }
1162 
1163 //-------------- methodData update helpers
1164 
1165 const TypeFunc* OptoRuntime::profile_receiver_type_Type() {
1166   // create input type (domain)
1167   const Type **fields = TypeTuple::fields(2);
1168   fields[TypeFunc::Parms+0] = TypeAryPtr::NOTNULL;    // methodData pointer
1169   fields[TypeFunc::Parms+1] = TypeInstPtr::BOTTOM;    // receiver oop
1170   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
1171 
1172   // create result type
1173   fields = TypeTuple::fields(1);
1174   fields[TypeFunc::Parms+0] = NULL; // void
1175   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
1176   return TypeFunc::make(domain,range);
1177 }
1178 
1179 JRT_LEAF(void, OptoRuntime::profile_receiver_type_C(DataLayout* data, oopDesc* receiver))
1180   if (receiver == NULL) return;
1181   Klass* receiver_klass = receiver->klass();
1182 
1183   intptr_t* mdp = ((intptr_t*)(data)) + DataLayout::header_size_in_cells();
1184   int empty_row = -1;           // free row, if any is encountered
1185 
1186   // ReceiverTypeData* vc = new ReceiverTypeData(mdp);
1187   for (uint row = 0; row < ReceiverTypeData::row_limit(); row++) {
1188     // if (vc->receiver(row) == receiver_klass)
1189     int receiver_off = ReceiverTypeData::receiver_cell_index(row);
1190     intptr_t row_recv = *(mdp + receiver_off);
1191     if (row_recv == (intptr_t) receiver_klass) {
1192       // vc->set_receiver_count(row, vc->receiver_count(row) + DataLayout::counter_increment);
1193       int count_off = ReceiverTypeData::receiver_count_cell_index(row);
1194       *(mdp + count_off) += DataLayout::counter_increment;
1195       return;
1196     } else if (row_recv == 0) {


1475   frame stub_frame = thread->last_frame();
1476   assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
1477   frame caller_frame = stub_frame.sender(&reg_map);
1478   return caller_frame.is_deoptimized_frame();
1479 }
1480 
1481 
1482 const TypeFunc *OptoRuntime::register_finalizer_Type() {
1483   // create input type (domain)
1484   const Type **fields = TypeTuple::fields(1);
1485   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // oop;          Receiver
1486   // // The JavaThread* is passed to each routine as the last argument
1487   // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL;  // JavaThread *; Executing thread
1488   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
1489 
1490   // create result type (range)
1491   fields = TypeTuple::fields(0);
1492 
1493   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1494 
1495   return TypeFunc::make(domain,range);
1496 }
1497 
1498 
1499 //-----------------------------------------------------------------------------
1500 // Dtrace support.  entry and exit probes have the same signature
1501 const TypeFunc *OptoRuntime::dtrace_method_entry_exit_Type() {
1502   // create input type (domain)
1503   const Type **fields = TypeTuple::fields(2);
1504   fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
1505   fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM;  // Method*;    Method we are entering
1506   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
1507 
1508   // create result type (range)
1509   fields = TypeTuple::fields(0);
1510 
1511   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1512 
1513   return TypeFunc::make(domain,range);
1514 }
1515 
1516 const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() {
1517   // create input type (domain)
1518   const Type **fields = TypeTuple::fields(2);
1519   fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
1520   fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL;  // oop;    newly allocated object
1521 
1522   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
1523 
1524   // create result type (range)
1525   fields = TypeTuple::fields(0);
1526 
1527   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1528 
1529   return TypeFunc::make(domain,range);
1530 }
1531 
1532 
1533 JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer(oopDesc* obj, JavaThread* thread))
1534   assert(oopDesc::is_oop(obj), "must be a valid oop");
1535   assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
1536   InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
1537 JRT_END
1538 
1539 //-----------------------------------------------------------------------------
1540 
1541 NamedCounter * volatile OptoRuntime::_named_counters = NULL;
1542 
1543 //
1544 // dump the collected NamedCounters.
1545 //
1546 void OptoRuntime::print_named_counters() {
1547   int total_lock_count = 0;
1548   int eliminated_lock_count = 0;
1549 


1640 static void trace_exception(outputStream* st, oop exception_oop, address exception_pc, const char* msg) {
1641   trace_exception_counter++;
1642   stringStream tempst;
1643 
1644   tempst.print("%d [Exception (%s): ", trace_exception_counter, msg);
1645   exception_oop->print_value_on(&tempst);
1646   tempst.print(" in ");
1647   CodeBlob* blob = CodeCache::find_blob(exception_pc);
1648   if (blob->is_compiled()) {
1649     CompiledMethod* cm = blob->as_compiled_method_or_null();
1650     cm->method()->print_value_on(&tempst);
1651   } else if (blob->is_runtime_stub()) {
1652     tempst.print("<runtime-stub>");
1653   } else {
1654     tempst.print("<unknown>");
1655   }
1656   tempst.print(" at " INTPTR_FORMAT,  p2i(exception_pc));
1657   tempst.print("]");
1658 
1659   st->print_raw_cr(tempst.as_string());

























































































































1660 }


  32 #include "code/nmethod.hpp"
  33 #include "code/pcDesc.hpp"
  34 #include "code/scopeDesc.hpp"
  35 #include "code/vtableStubs.hpp"
  36 #include "compiler/compileBroker.hpp"
  37 #include "compiler/oopMap.hpp"
  38 #include "gc/g1/heapRegion.hpp"
  39 #include "gc/shared/barrierSet.hpp"
  40 #include "gc/shared/collectedHeap.hpp"
  41 #include "gc/shared/gcLocker.hpp"
  42 #include "interpreter/bytecode.hpp"
  43 #include "interpreter/interpreter.hpp"
  44 #include "interpreter/linkResolver.hpp"
  45 #include "logging/log.hpp"
  46 #include "logging/logStream.hpp"
  47 #include "memory/oopFactory.hpp"
  48 #include "memory/resourceArea.hpp"
  49 #include "oops/objArrayKlass.hpp"
  50 #include "oops/oop.inline.hpp"
  51 #include "oops/typeArrayOop.inline.hpp"
  52 #include "oops/valueArrayKlass.hpp"
  53 #include "oops/valueArrayOop.inline.hpp"
  54 #include "opto/ad.hpp"
  55 #include "opto/addnode.hpp"
  56 #include "opto/callnode.hpp"
  57 #include "opto/cfgnode.hpp"
  58 #include "opto/graphKit.hpp"
  59 #include "opto/machnode.hpp"
  60 #include "opto/matcher.hpp"
  61 #include "opto/memnode.hpp"
  62 #include "opto/mulnode.hpp"
  63 #include "opto/runtime.hpp"
  64 #include "opto/subnode.hpp"
  65 #include "runtime/atomic.hpp"
  66 #include "runtime/frame.inline.hpp"
  67 #include "runtime/handles.inline.hpp"
  68 #include "runtime/interfaceSupport.inline.hpp"
  69 #include "runtime/javaCalls.hpp"
  70 #include "runtime/sharedRuntime.hpp"
  71 #include "runtime/signature.hpp"
  72 #include "runtime/threadCritical.hpp"
  73 #include "runtime/vframe.hpp"


 225 
 226   deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
 227   JRT_BLOCK_END;
 228 
 229   // inform GC that we won't do card marks for initializing writes.
 230   SharedRuntime::on_slowpath_allocation_exit(thread);
 231 JRT_END
 232 
 233 
 234 // array allocation
 235 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, JavaThread *thread))
 236   JRT_BLOCK;
 237 #ifndef PRODUCT
 238   SharedRuntime::_new_array_ctr++;            // new array requires GC
 239 #endif
 240   assert(check_compiled_frame(thread), "incorrect caller");
 241 
 242   // Scavenge and allocate an instance.
 243   oop result;
 244 
 245   if (array_type->is_valueArray_klass()) {
 246     Klass* elem_type = ValueArrayKlass::cast(array_type)->element_klass();
 247     result = oopFactory::new_valueArray(elem_type, len, THREAD);
 248   } else if (array_type->is_typeArray_klass()) {
 249     // The oopFactory likes to work with the element type.
 250     // (We could bypass the oopFactory, since it doesn't add much value.)
 251     BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
 252     result = oopFactory::new_typeArray(elem_type, len, THREAD);
 253   } else {



 254     Handle holder(THREAD, array_type->klass_holder()); // keep the array klass alive
 255     result = ObjArrayKlass::cast(array_type)->allocate(len, THREAD);

 256   }
 257 
 258   // Pass oops back through thread local storage.  Our apparent type to Java
 259   // is that we return an oop, but we can block on exit from this routine and
 260   // a GC can trash the oop in C's return register.  The generated stub will
 261   // fetch the oop from TLS after any possible GC.
 262   deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
 263   thread->set_vm_result(result);
 264   JRT_BLOCK_END;
 265 
 266   // inform GC that we won't do card marks for initializing writes.
 267   SharedRuntime::on_slowpath_allocation_exit(thread);
 268 JRT_END
 269 
 270 // array allocation without zeroing
 271 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread *thread))
 272   JRT_BLOCK;
 273 #ifndef PRODUCT
 274   SharedRuntime::_new_array_ctr++;            // new array requires GC
 275 #endif


 549   fields = TypeTuple::fields(0);
 550   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 551 
 552   return TypeFunc::make(domain, range);
 553 }
 554 
 555 //-----------------------------------------------------------------------------
 556 // Monitor Handling
 557 const TypeFunc *OptoRuntime::complete_monitor_enter_Type() {
 558   // create input type (domain)
 559   const Type **fields = TypeTuple::fields(2);
 560   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 561   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;   // Address of stack location for lock
 562   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
 563 
 564   // create result type (range)
 565   fields = TypeTuple::fields(0);
 566 
 567   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
 568 
 569   return TypeFunc::make(domain, range);
 570 }
 571 
 572 
 573 //-----------------------------------------------------------------------------
 574 const TypeFunc *OptoRuntime::complete_monitor_exit_Type() {
 575   // create input type (domain)
 576   const Type **fields = TypeTuple::fields(3);
 577   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 578   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;    // Address of stack location for lock - BasicLock
 579   fields[TypeFunc::Parms+2] = TypeRawPtr::BOTTOM;    // Thread pointer (Self)
 580   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields);
 581 
 582   // create result type (range)
 583   fields = TypeTuple::fields(0);
 584 
 585   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 586 
 587   return TypeFunc::make(domain, range);
 588 }
 589 


1157   fields = TypeTuple::fields(1);
1158   // fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // locked oop
1159   fields[TypeFunc::Parms+0] = NULL; // void
1160   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
1161   return TypeFunc::make(domain, range);
1162 }
1163 
1164 //-------------- methodData update helpers
1165 
1166 const TypeFunc* OptoRuntime::profile_receiver_type_Type() {
1167   // create input type (domain)
1168   const Type **fields = TypeTuple::fields(2);
1169   fields[TypeFunc::Parms+0] = TypeAryPtr::NOTNULL;    // methodData pointer
1170   fields[TypeFunc::Parms+1] = TypeInstPtr::BOTTOM;    // receiver oop
1171   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
1172 
1173   // create result type
1174   fields = TypeTuple::fields(1);
1175   fields[TypeFunc::Parms+0] = NULL; // void
1176   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
1177   return TypeFunc::make(domain, range);
1178 }
1179 
1180 JRT_LEAF(void, OptoRuntime::profile_receiver_type_C(DataLayout* data, oopDesc* receiver))
1181   if (receiver == NULL) return;
1182   Klass* receiver_klass = receiver->klass();
1183 
1184   intptr_t* mdp = ((intptr_t*)(data)) + DataLayout::header_size_in_cells();
1185   int empty_row = -1;           // free row, if any is encountered
1186 
1187   // ReceiverTypeData* vc = new ReceiverTypeData(mdp);
1188   for (uint row = 0; row < ReceiverTypeData::row_limit(); row++) {
1189     // if (vc->receiver(row) == receiver_klass)
1190     int receiver_off = ReceiverTypeData::receiver_cell_index(row);
1191     intptr_t row_recv = *(mdp + receiver_off);
1192     if (row_recv == (intptr_t) receiver_klass) {
1193       // vc->set_receiver_count(row, vc->receiver_count(row) + DataLayout::counter_increment);
1194       int count_off = ReceiverTypeData::receiver_count_cell_index(row);
1195       *(mdp + count_off) += DataLayout::counter_increment;
1196       return;
1197     } else if (row_recv == 0) {


1476   frame stub_frame = thread->last_frame();
1477   assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
1478   frame caller_frame = stub_frame.sender(&reg_map);
1479   return caller_frame.is_deoptimized_frame();
1480 }
1481 
1482 
1483 const TypeFunc *OptoRuntime::register_finalizer_Type() {
1484   // create input type (domain)
1485   const Type **fields = TypeTuple::fields(1);
1486   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // oop;          Receiver
1487   // // The JavaThread* is passed to each routine as the last argument
1488   // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL;  // JavaThread *; Executing thread
1489   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
1490 
1491   // create result type (range)
1492   fields = TypeTuple::fields(0);
1493 
1494   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1495 
1496   return TypeFunc::make(domain, range);
1497 }
1498 
1499 
1500 //-----------------------------------------------------------------------------
1501 // Dtrace support.  entry and exit probes have the same signature
1502 const TypeFunc *OptoRuntime::dtrace_method_entry_exit_Type() {
1503   // create input type (domain)
1504   const Type **fields = TypeTuple::fields(2);
1505   fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
1506   fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM;  // Method*;    Method we are entering
1507   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
1508 
1509   // create result type (range)
1510   fields = TypeTuple::fields(0);
1511 
1512   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1513 
1514   return TypeFunc::make(domain, range);
1515 }
1516 
1517 const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() {
1518   // create input type (domain)
1519   const Type **fields = TypeTuple::fields(2);
1520   fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
1521   fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL;  // oop;    newly allocated object
1522 
1523   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
1524 
1525   // create result type (range)
1526   fields = TypeTuple::fields(0);
1527 
1528   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1529 
1530   return TypeFunc::make(domain, range);
1531 }
1532 
1533 
1534 JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer(oopDesc* obj, JavaThread* thread))
1535   assert(oopDesc::is_oop(obj), "must be a valid oop");
1536   assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
1537   InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
1538 JRT_END
1539 
1540 //-----------------------------------------------------------------------------
1541 
1542 NamedCounter * volatile OptoRuntime::_named_counters = NULL;
1543 
1544 //
1545 // dump the collected NamedCounters.
1546 //
1547 void OptoRuntime::print_named_counters() {
1548   int total_lock_count = 0;
1549   int eliminated_lock_count = 0;
1550 


1641 static void trace_exception(outputStream* st, oop exception_oop, address exception_pc, const char* msg) {
1642   trace_exception_counter++;
1643   stringStream tempst;
1644 
1645   tempst.print("%d [Exception (%s): ", trace_exception_counter, msg);
1646   exception_oop->print_value_on(&tempst);
1647   tempst.print(" in ");
1648   CodeBlob* blob = CodeCache::find_blob(exception_pc);
1649   if (blob->is_compiled()) {
1650     CompiledMethod* cm = blob->as_compiled_method_or_null();
1651     cm->method()->print_value_on(&tempst);
1652   } else if (blob->is_runtime_stub()) {
1653     tempst.print("<runtime-stub>");
1654   } else {
1655     tempst.print("<unknown>");
1656   }
1657   tempst.print(" at " INTPTR_FORMAT,  p2i(exception_pc));
1658   tempst.print("]");
1659 
1660   st->print_raw_cr(tempst.as_string());
1661 }
1662 
1663 const TypeFunc *OptoRuntime::store_value_type_fields_Type() {
1664   // create input type (domain)
1665   uint total = SharedRuntime::java_return_convention_max_int + SharedRuntime::java_return_convention_max_float*2;
1666   const Type **fields = TypeTuple::fields(total);
1667   // We don't know the number of returned values and their
1668   // types. Assume all registers available to the return convention
1669   // are used.
1670   fields[TypeFunc::Parms] = TypePtr::BOTTOM;
1671   uint i = 1;
1672   for (; i < SharedRuntime::java_return_convention_max_int; i++) {
1673     fields[TypeFunc::Parms+i] = TypeInt::INT;
1674   }
1675   for (; i < total; i+=2) {
1676     fields[TypeFunc::Parms+i] = Type::DOUBLE;
1677     fields[TypeFunc::Parms+i+1] = Type::HALF;
1678   }
1679   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + total, fields);
1680 
1681   // create result type (range)
1682   fields = TypeTuple::fields(1);
1683   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;
1684 
1685   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1,fields);
1686 
1687   return TypeFunc::make(domain, range);
1688 }
1689 
1690 const TypeFunc *OptoRuntime::pack_value_type_Type() {
1691   // create input type (domain)
1692   uint total = 1 + SharedRuntime::java_return_convention_max_int + SharedRuntime::java_return_convention_max_float*2;
1693   const Type **fields = TypeTuple::fields(total);
1694   // We don't know the number of returned values and their
1695   // types. Assume all registers available to the return convention
1696   // are used.
1697   fields[TypeFunc::Parms] = TypeRawPtr::BOTTOM;
1698   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;
1699   uint i = 2;
1700   for (; i < SharedRuntime::java_return_convention_max_int+1; i++) {
1701     fields[TypeFunc::Parms+i] = TypeInt::INT;
1702   }
1703   for (; i < total; i+=2) {
1704     fields[TypeFunc::Parms+i] = Type::DOUBLE;
1705     fields[TypeFunc::Parms+i+1] = Type::HALF;
1706   }
1707   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + total, fields);
1708 
1709   // create result type (range)
1710   fields = TypeTuple::fields(1);
1711   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;
1712 
1713   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1,fields);
1714 
1715   return TypeFunc::make(domain, range);
1716 }
1717 
1718 JRT_LEAF(void, OptoRuntime::load_unknown_value(valueArrayOopDesc* array, int index, instanceOopDesc* buffer))
1719 {
1720   Klass* klass = array->klass();
1721   assert(klass->is_valueArray_klass(), "expected value array oop");
1722 
1723   ValueArrayKlass* vaklass = ValueArrayKlass::cast(klass);
1724   ValueKlass* vklass = vaklass->element_klass();
1725   void* src = array->value_at_addr(index, vaklass->layout_helper());
1726   vklass->value_store(src, vklass->data_for_oop(buffer),
1727                         vaklass->element_byte_size(), true, false);
1728 }
1729 JRT_END
1730 
1731 const TypeFunc *OptoRuntime::load_unknown_value_Type() {
1732   // create input type (domain)
1733   const Type **fields = TypeTuple::fields(3);
1734   // We don't know the number of returned values and their
1735   // types. Assume all registers available to the return convention
1736   // are used.
1737   fields[TypeFunc::Parms] = TypeOopPtr::NOTNULL;
1738   fields[TypeFunc::Parms+1] = TypeInt::POS;
1739   fields[TypeFunc::Parms+2] = TypeInstPtr::NOTNULL;
1740 
1741   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+3, fields);
1742 
1743   // create result type (range)
1744   fields = TypeTuple::fields(0);
1745   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
1746 
1747   return TypeFunc::make(domain, range);
1748 }
1749 
1750 JRT_LEAF(void, OptoRuntime::store_unknown_value(instanceOopDesc* buffer, valueArrayOopDesc* array, int index))
1751 {
1752   assert(buffer != NULL, "can't store null into flat array");
1753   Klass* klass = array->klass();
1754   assert(klass->is_valueArray_klass(), "expected value array");
1755   assert(ArrayKlass::cast(klass)->element_klass() == buffer->klass(), "Store type incorrect");
1756 
1757   ValueArrayKlass* vaklass = ValueArrayKlass::cast(klass);
1758   ValueKlass* vklass = vaklass->element_klass();
1759   const int lh = vaklass->layout_helper();
1760   vklass->value_store(vklass->data_for_oop(buffer), array->value_at_addr(index, lh),
1761                       vaklass->element_byte_size(), true, false);
1762 }
1763 JRT_END
1764 
1765 const TypeFunc *OptoRuntime::store_unknown_value_Type() {
1766   // create input type (domain)
1767   const Type **fields = TypeTuple::fields(3);
1768   // We don't know the number of returned values and their
1769   // types. Assume all registers available to the return convention
1770   // are used.
1771   fields[TypeFunc::Parms] = TypeInstPtr::NOTNULL;
1772   fields[TypeFunc::Parms+1] = TypeOopPtr::NOTNULL;
1773   fields[TypeFunc::Parms+2] = TypeInt::POS;
1774 
1775   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+3, fields);
1776 
1777   // create result type (range)
1778   fields = TypeTuple::fields(0);
1779   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
1780 
1781   return TypeFunc::make(domain, range);
1782 }
< prev index next >