< prev index next >

src/share/vm/runtime/sharedRuntime.cpp

Print this page




 532     tty->print_cr("b) other problem");
 533   }
 534 #endif // PRODUCT
 535 
 536   ShouldNotReachHere();
 537   return NULL;
 538 }
 539 
 540 
 541 JRT_LEAF(address, SharedRuntime::exception_handler_for_return_address(JavaThread* thread, address return_address))
 542   return raw_exception_handler_for_return_address(thread, return_address);
 543 JRT_END
 544 
 545 
 546 address SharedRuntime::get_poll_stub(address pc) {
 547   address stub;
 548   // Look up the code blob
 549   CodeBlob *cb = CodeCache::find_blob(pc);
 550 
 551   // Should be an nmethod
 552   assert(cb && cb->is_compiled(), "safepoint polling: pc must refer to an nmethod");
 553 
 554   // Look up the relocation information
 555   assert(((CompiledMethod*)cb)->is_at_poll_or_poll_return(pc),
 556     "safepoint polling: type must be poll");
 557 
 558 #ifdef ASSERT
 559   if (!((NativeInstruction*)pc)->is_safepoint_poll()) {
 560     tty->print_cr("bad pc: " PTR_FORMAT, p2i(pc));
 561     Disassembler::decode(cb);
 562     fatal("Only polling locations are used for safepoint");
 563   }
 564 #endif
 565 
 566   bool at_poll_return = ((CompiledMethod*)cb)->is_at_poll_return(pc);
 567   bool has_wide_vectors = ((CompiledMethod*)cb)->has_wide_vectors();
 568   if (at_poll_return) {
 569     assert(SharedRuntime::polling_page_return_handler_blob() != NULL,
 570            "polling page return stub not created yet");
 571     stub = SharedRuntime::polling_page_return_handler_blob()->entry_point();
 572   } else if (has_wide_vectors) {


1785   const int member_arg_pos = total_args_passed - 1;
1786   assert(member_arg_pos >= 0 && member_arg_pos < total_args_passed, "oob");
1787   assert(sig_bt[member_arg_pos] == T_OBJECT, "dispatch argument must be an object");
1788 
1789   const bool is_outgoing = method->is_method_handle_intrinsic();
1790   int comp_args_on_stack = java_calling_convention(sig_bt, regs_without_member_name, total_args_passed - 1, is_outgoing);
1791 
1792   for (int i = 0; i < member_arg_pos; i++) {
1793     VMReg a =    regs_with_member_name[i].first();
1794     VMReg b = regs_without_member_name[i].first();
1795     assert(a->value() == b->value(), "register allocation mismatch: a=" INTX_FORMAT ", b=" INTX_FORMAT, a->value(), b->value());
1796   }
1797   assert(regs_with_member_name[member_arg_pos].first()->is_valid(), "bad member arg");
1798 }
1799 #endif
1800 
1801 bool SharedRuntime::should_fixup_call_destination(address destination, address entry_point, address caller_pc, Method* moop, CodeBlob* cb) {
1802   if (destination != entry_point) {
1803     CodeBlob* callee = CodeCache::find_blob(destination);
1804     // callee == cb seems weird. It means calling interpreter thru stub.
1805     if (callee == cb || callee->is_adapter_blob()) {
1806       // static call or optimized virtual
1807       if (TraceCallFixup) {
1808         tty->print("fixup callsite           at " INTPTR_FORMAT " to compiled code for", p2i(caller_pc));
1809         moop->print_short_name(tty);
1810         tty->print_cr(" to " INTPTR_FORMAT, p2i(entry_point));
1811       }
1812       return true;
1813     } else {
1814       if (TraceCallFixup) {
1815         tty->print("failed to fixup callsite at " INTPTR_FORMAT " to compiled code for", p2i(caller_pc));
1816         moop->print_short_name(tty);
1817         tty->print_cr(" to " INTPTR_FORMAT, p2i(entry_point));
1818       }
1819       // assert is too strong could also be resolve destinations.
1820       // assert(InlineCacheBuffer::contains(destination) || VtableStubs::contains(destination), "must be");
1821     }
1822   } else {
1823     if (TraceCallFixup) {
1824       tty->print("already patched callsite at " INTPTR_FORMAT " to compiled code for", p2i(caller_pc));
1825       moop->print_short_name(tty);


1834 // we were called by a compiled method. However we could have lost a race
1835 // where we went int -> i2c -> c2i and so the caller could in fact be
1836 // interpreted. If the caller is compiled we attempt to patch the caller
1837 // so he no longer calls into the interpreter.
1838 IRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address caller_pc))
1839   Method* moop(method);
1840 
1841   address entry_point = moop->from_compiled_entry_no_trampoline();
1842 
1843   // It's possible that deoptimization can occur at a call site which hasn't
1844   // been resolved yet, in which case this function will be called from
1845   // an nmethod that has been patched for deopt and we can ignore the
1846   // request for a fixup.
1847   // Also it is possible that we lost a race in that from_compiled_entry
1848   // is now back to the i2c in that case we don't need to patch and if
1849   // we did we'd leap into space because the callsite needs to use
1850   // "to interpreter" stub in order to load up the Method*. Don't
1851   // ask me how I know this...
1852 
1853   CodeBlob* cb = CodeCache::find_blob(caller_pc);
1854   if (!cb->is_compiled() || entry_point == moop->get_c2i_entry()) {
1855     return;
1856   }
1857 
1858   // The check above makes sure this is a nmethod.
1859   CompiledMethod* nm = cb->as_compiled_method_or_null();
1860   assert(nm, "must be");
1861 
1862   // Get the return PC for the passed caller PC.
1863   address return_pc = caller_pc + frame::pc_return_offset;
1864 
1865   // There is a benign race here. We could be attempting to patch to a compiled
1866   // entry point at the same time the callee is being deoptimized. If that is
1867   // the case then entry_point may in fact point to a c2i and we'd patch the
1868   // call site with the same old data. clear_code will set code() to NULL
1869   // at the end of it. If we happen to see that NULL then we can skip trying
1870   // to patch. If we hit the window where the callee has a c2i in the
1871   // from_compiled_entry and the NULL isn't present yet then we lose the race
1872   // and patch the code with the same old data. Asi es la vida.
1873 
1874   if (moop->code() == NULL) return;




 532     tty->print_cr("b) other problem");
 533   }
 534 #endif // PRODUCT
 535 
 536   ShouldNotReachHere();
 537   return NULL;
 538 }
 539 
 540 
 541 JRT_LEAF(address, SharedRuntime::exception_handler_for_return_address(JavaThread* thread, address return_address))
 542   return raw_exception_handler_for_return_address(thread, return_address);
 543 JRT_END
 544 
 545 
 546 address SharedRuntime::get_poll_stub(address pc) {
 547   address stub;
 548   // Look up the code blob
 549   CodeBlob *cb = CodeCache::find_blob(pc);
 550 
 551   // Should be an nmethod
 552   guarantee(cb != NULL && cb->is_compiled(), "safepoint polling: pc must refer to an nmethod");
 553 
 554   // Look up the relocation information
 555   assert(((CompiledMethod*)cb)->is_at_poll_or_poll_return(pc),
 556     "safepoint polling: type must be poll");
 557 
 558 #ifdef ASSERT
 559   if (!((NativeInstruction*)pc)->is_safepoint_poll()) {
 560     tty->print_cr("bad pc: " PTR_FORMAT, p2i(pc));
 561     Disassembler::decode(cb);
 562     fatal("Only polling locations are used for safepoint");
 563   }
 564 #endif
 565 
 566   bool at_poll_return = ((CompiledMethod*)cb)->is_at_poll_return(pc);
 567   bool has_wide_vectors = ((CompiledMethod*)cb)->has_wide_vectors();
 568   if (at_poll_return) {
 569     assert(SharedRuntime::polling_page_return_handler_blob() != NULL,
 570            "polling page return stub not created yet");
 571     stub = SharedRuntime::polling_page_return_handler_blob()->entry_point();
 572   } else if (has_wide_vectors) {


1785   const int member_arg_pos = total_args_passed - 1;
1786   assert(member_arg_pos >= 0 && member_arg_pos < total_args_passed, "oob");
1787   assert(sig_bt[member_arg_pos] == T_OBJECT, "dispatch argument must be an object");
1788 
1789   const bool is_outgoing = method->is_method_handle_intrinsic();
1790   int comp_args_on_stack = java_calling_convention(sig_bt, regs_without_member_name, total_args_passed - 1, is_outgoing);
1791 
1792   for (int i = 0; i < member_arg_pos; i++) {
1793     VMReg a =    regs_with_member_name[i].first();
1794     VMReg b = regs_without_member_name[i].first();
1795     assert(a->value() == b->value(), "register allocation mismatch: a=" INTX_FORMAT ", b=" INTX_FORMAT, a->value(), b->value());
1796   }
1797   assert(regs_with_member_name[member_arg_pos].first()->is_valid(), "bad member arg");
1798 }
1799 #endif
1800 
1801 bool SharedRuntime::should_fixup_call_destination(address destination, address entry_point, address caller_pc, Method* moop, CodeBlob* cb) {
1802   if (destination != entry_point) {
1803     CodeBlob* callee = CodeCache::find_blob(destination);
1804     // callee == cb seems weird. It means calling interpreter thru stub.
1805     if (callee != NULL && (callee == cb || callee->is_adapter_blob())) {
1806       // static call or optimized virtual
1807       if (TraceCallFixup) {
1808         tty->print("fixup callsite           at " INTPTR_FORMAT " to compiled code for", p2i(caller_pc));
1809         moop->print_short_name(tty);
1810         tty->print_cr(" to " INTPTR_FORMAT, p2i(entry_point));
1811       }
1812       return true;
1813     } else {
1814       if (TraceCallFixup) {
1815         tty->print("failed to fixup callsite at " INTPTR_FORMAT " to compiled code for", p2i(caller_pc));
1816         moop->print_short_name(tty);
1817         tty->print_cr(" to " INTPTR_FORMAT, p2i(entry_point));
1818       }
1819       // assert is too strong could also be resolve destinations.
1820       // assert(InlineCacheBuffer::contains(destination) || VtableStubs::contains(destination), "must be");
1821     }
1822   } else {
1823     if (TraceCallFixup) {
1824       tty->print("already patched callsite at " INTPTR_FORMAT " to compiled code for", p2i(caller_pc));
1825       moop->print_short_name(tty);


1834 // we were called by a compiled method. However we could have lost a race
1835 // where we went int -> i2c -> c2i and so the caller could in fact be
1836 // interpreted. If the caller is compiled we attempt to patch the caller
1837 // so he no longer calls into the interpreter.
1838 IRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address caller_pc))
1839   Method* moop(method);
1840 
1841   address entry_point = moop->from_compiled_entry_no_trampoline();
1842 
1843   // It's possible that deoptimization can occur at a call site which hasn't
1844   // been resolved yet, in which case this function will be called from
1845   // an nmethod that has been patched for deopt and we can ignore the
1846   // request for a fixup.
1847   // Also it is possible that we lost a race in that from_compiled_entry
1848   // is now back to the i2c in that case we don't need to patch and if
1849   // we did we'd leap into space because the callsite needs to use
1850   // "to interpreter" stub in order to load up the Method*. Don't
1851   // ask me how I know this...
1852 
1853   CodeBlob* cb = CodeCache::find_blob(caller_pc);
1854   if (cb == NULL || !cb->is_compiled() || entry_point == moop->get_c2i_entry()) {
1855     return;
1856   }
1857 
1858   // The check above makes sure this is a nmethod.
1859   CompiledMethod* nm = cb->as_compiled_method_or_null();
1860   assert(nm, "must be");
1861 
1862   // Get the return PC for the passed caller PC.
1863   address return_pc = caller_pc + frame::pc_return_offset;
1864 
1865   // There is a benign race here. We could be attempting to patch to a compiled
1866   // entry point at the same time the callee is being deoptimized. If that is
1867   // the case then entry_point may in fact point to a c2i and we'd patch the
1868   // call site with the same old data. clear_code will set code() to NULL
1869   // at the end of it. If we happen to see that NULL then we can skip trying
1870   // to patch. If we hit the window where the callee has a c2i in the
1871   // from_compiled_entry and the NULL isn't present yet then we lose the race
1872   // and patch the code with the same old data. Asi es la vida.
1873 
1874   if (moop->code() == NULL) return;


< prev index next >