src/hotspot/share/runtime/sharedRuntime.cpp
changeset 57574 6a159c6c23cc
parent 55293 d19dc5b10fbb
child 57584 9d82a35b6ff7
equal deleted inserted replaced
57573:7e8f6c56c285 57574:6a159c6c23cc
  1444       caller_frame.is_entry_frame()) {
  1444       caller_frame.is_entry_frame()) {
  1445     Method* callee = thread->callee_target();
  1445     Method* callee = thread->callee_target();
  1446     guarantee(callee != NULL && callee->is_method(), "bad handshake");
  1446     guarantee(callee != NULL && callee->is_method(), "bad handshake");
  1447     thread->set_vm_result_2(callee);
  1447     thread->set_vm_result_2(callee);
  1448     thread->set_callee_target(NULL);
  1448     thread->set_callee_target(NULL);
  1449     return callee->get_c2i_entry();
  1449     if (caller_frame.is_entry_frame() && VM_Version::supports_fast_class_init_checks()) {
       
  1450       // Bypass class initialization checks in c2i when caller is in native.
       
  1451       // JNI calls to static methods don't have class initialization checks.
       
  1452       // Fast class initialization checks are present in c2i adapters and call into
       
  1453       // SharedRuntime::handle_wrong_method() on the slow path.
       
  1454       //
       
  1455       // JVM upcalls may land here as well, but there's a proper check present in
       
  1456       // LinkResolver::resolve_static_call (called from JavaCalls::call_static),
       
  1457       // so bypassing it in c2i adapter is benign.
       
  1458       return callee->get_c2i_no_clinit_check_entry();
       
  1459     } else {
       
  1460       return callee->get_c2i_entry();
       
  1461     }
  1450   }
  1462   }
  1451 
  1463 
  1452   // Must be compiled to compiled path which is safe to stackwalk
  1464   // Must be compiled to compiled path which is safe to stackwalk
  1453   methodHandle callee_method;
  1465   methodHandle callee_method;
  1454   JRT_BLOCK
  1466   JRT_BLOCK
  2448  public:
  2460  public:
  2449   AdapterHandlerTable()
  2461   AdapterHandlerTable()
  2450     : BasicHashtable<mtCode>(293, (DumpSharedSpaces ? sizeof(CDSAdapterHandlerEntry) : sizeof(AdapterHandlerEntry))) { }
  2462     : BasicHashtable<mtCode>(293, (DumpSharedSpaces ? sizeof(CDSAdapterHandlerEntry) : sizeof(AdapterHandlerEntry))) { }
  2451 
  2463 
  2452   // Create a new entry suitable for insertion in the table
  2464   // Create a new entry suitable for insertion in the table
  2453   AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) {
  2465   AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry, address c2i_no_clinit_check_entry) {
  2454     AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable<mtCode>::new_entry(fingerprint->compute_hash());
  2466     AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable<mtCode>::new_entry(fingerprint->compute_hash());
  2455     entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
  2467     entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
  2456     if (DumpSharedSpaces) {
  2468     if (DumpSharedSpaces) {
  2457       ((CDSAdapterHandlerEntry*)entry)->init();
  2469       ((CDSAdapterHandlerEntry*)entry)->init();
  2458     }
  2470     }
  2459     return entry;
  2471     return entry;
  2460   }
  2472   }
  2599 }
  2611 }
  2600 
  2612 
  2601 AdapterHandlerEntry* AdapterHandlerLibrary::new_entry(AdapterFingerPrint* fingerprint,
  2613 AdapterHandlerEntry* AdapterHandlerLibrary::new_entry(AdapterFingerPrint* fingerprint,
  2602                                                       address i2c_entry,
  2614                                                       address i2c_entry,
  2603                                                       address c2i_entry,
  2615                                                       address c2i_entry,
  2604                                                       address c2i_unverified_entry) {
  2616                                                       address c2i_unverified_entry,
  2605   return _adapters->new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
  2617                                                       address c2i_no_clinit_check_entry) {
       
  2618   return _adapters->new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
  2606 }
  2619 }
  2607 
  2620 
  2608 AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter(const methodHandle& method) {
  2621 AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter(const methodHandle& method) {
  2609   AdapterHandlerEntry* entry = get_adapter0(method);
  2622   AdapterHandlerEntry* entry = get_adapter0(method);
  2610   if (method->is_shared()) {
  2623   if (method->is_shared()) {
  2776 address AdapterHandlerEntry::base_address() {
  2789 address AdapterHandlerEntry::base_address() {
  2777   address base = _i2c_entry;
  2790   address base = _i2c_entry;
  2778   if (base == NULL)  base = _c2i_entry;
  2791   if (base == NULL)  base = _c2i_entry;
  2779   assert(base <= _c2i_entry || _c2i_entry == NULL, "");
  2792   assert(base <= _c2i_entry || _c2i_entry == NULL, "");
  2780   assert(base <= _c2i_unverified_entry || _c2i_unverified_entry == NULL, "");
  2793   assert(base <= _c2i_unverified_entry || _c2i_unverified_entry == NULL, "");
       
  2794   assert(base <= _c2i_no_clinit_check_entry || _c2i_no_clinit_check_entry == NULL, "");
  2781   return base;
  2795   return base;
  2782 }
  2796 }
  2783 
  2797 
  2784 void AdapterHandlerEntry::relocate(address new_base) {
  2798 void AdapterHandlerEntry::relocate(address new_base) {
  2785   address old_base = base_address();
  2799   address old_base = base_address();
  2789     _i2c_entry += delta;
  2803     _i2c_entry += delta;
  2790   if (_c2i_entry != NULL)
  2804   if (_c2i_entry != NULL)
  2791     _c2i_entry += delta;
  2805     _c2i_entry += delta;
  2792   if (_c2i_unverified_entry != NULL)
  2806   if (_c2i_unverified_entry != NULL)
  2793     _c2i_unverified_entry += delta;
  2807     _c2i_unverified_entry += delta;
       
  2808   if (_c2i_no_clinit_check_entry != NULL)
       
  2809     _c2i_no_clinit_check_entry += delta;
  2794   assert(base_address() == new_base, "");
  2810   assert(base_address() == new_base, "");
  2795 }
  2811 }
  2796 
  2812 
  2797 
  2813 
  2798 void AdapterHandlerEntry::deallocate() {
  2814 void AdapterHandlerEntry::deallocate() {
  3127   }
  3143   }
  3128   assert(false, "Should have found handler");
  3144   assert(false, "Should have found handler");
  3129 }
  3145 }
  3130 
  3146 
  3131 void AdapterHandlerEntry::print_adapter_on(outputStream* st) const {
  3147 void AdapterHandlerEntry::print_adapter_on(outputStream* st) const {
  3132   st->print_cr("AHE@" INTPTR_FORMAT ": %s i2c: " INTPTR_FORMAT " c2i: " INTPTR_FORMAT " c2iUV: " INTPTR_FORMAT,
  3148   st->print("AHE@" INTPTR_FORMAT ": %s", p2i(this), fingerprint()->as_string());
  3133                p2i(this), fingerprint()->as_string(),
  3149   if (get_i2c_entry() != NULL) {
  3134                p2i(get_i2c_entry()), p2i(get_c2i_entry()), p2i(get_c2i_unverified_entry()));
  3150     st->print(" i2c: " INTPTR_FORMAT, p2i(get_i2c_entry()));
  3135 
  3151   }
       
  3152   if (get_c2i_entry() != NULL) {
       
  3153     st->print(" c2i: " INTPTR_FORMAT, p2i(get_c2i_entry()));
       
  3154   }
       
  3155   if (get_c2i_unverified_entry() != NULL) {
       
  3156     st->print(" c2iUV: " INTPTR_FORMAT, p2i(get_c2i_unverified_entry()));
       
  3157   }
       
  3158   if (get_c2i_no_clinit_check_entry() != NULL) {
       
  3159     st->print(" c2iNCI: " INTPTR_FORMAT, p2i(get_c2i_no_clinit_check_entry()));
       
  3160   }
       
  3161   st->cr();
  3136 }
  3162 }
  3137 
  3163 
  3138 #if INCLUDE_CDS
  3164 #if INCLUDE_CDS
  3139 
  3165 
  3140 void CDSAdapterHandlerEntry::init() {
  3166 void CDSAdapterHandlerEntry::init() {