36 #include "compiler/disassembler.hpp" |
36 #include "compiler/disassembler.hpp" |
37 #include "gc/shared/gcLocker.inline.hpp" |
37 #include "gc/shared/gcLocker.inline.hpp" |
38 #include "interpreter/interpreter.hpp" |
38 #include "interpreter/interpreter.hpp" |
39 #include "interpreter/interpreterRuntime.hpp" |
39 #include "interpreter/interpreterRuntime.hpp" |
40 #include "logging/log.hpp" |
40 #include "logging/log.hpp" |
|
41 #include "memory/metaspaceShared.hpp" |
41 #include "memory/resourceArea.hpp" |
42 #include "memory/resourceArea.hpp" |
42 #include "memory/universe.inline.hpp" |
43 #include "memory/universe.inline.hpp" |
43 #include "oops/klass.hpp" |
44 #include "oops/klass.hpp" |
44 #include "oops/objArrayKlass.hpp" |
45 #include "oops/objArrayKlass.hpp" |
45 #include "oops/oop.inline.hpp" |
46 #include "oops/oop.inline.hpp" |
1786 // interpreted. If the caller is compiled we attempt to patch the caller |
1787 // interpreted. If the caller is compiled we attempt to patch the caller |
1787 // so he no longer calls into the interpreter. |
1788 // so he no longer calls into the interpreter. |
1788 IRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address caller_pc)) |
1789 IRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address caller_pc)) |
1789 Method* moop(method); |
1790 Method* moop(method); |
1790 |
1791 |
1791 address entry_point = moop->from_compiled_entry(); |
1792 address entry_point = moop->from_compiled_entry_no_trampoline(); |
1792 |
1793 |
1793 // It's possible that deoptimization can occur at a call site which hasn't |
1794 // It's possible that deoptimization can occur at a call site which hasn't |
1794 // been resolved yet, in which case this function will be called from |
1795 // been resolved yet, in which case this function will be called from |
1795 // an nmethod that has been patched for deopt and we can ignore the |
1796 // an nmethod that has been patched for deopt and we can ignore the |
1796 // request for a fixup. |
1797 // request for a fixup. |
2349 return (AdapterHandlerEntry*)BasicHashtable<mtCode>::bucket(i); |
2350 return (AdapterHandlerEntry*)BasicHashtable<mtCode>::bucket(i); |
2350 } |
2351 } |
2351 |
2352 |
2352 public: |
2353 public: |
2353 AdapterHandlerTable() |
2354 AdapterHandlerTable() |
2354 : BasicHashtable<mtCode>(293, sizeof(AdapterHandlerEntry)) { } |
2355 : BasicHashtable<mtCode>(293, (DumpSharedSpaces ? sizeof(CDSAdapterHandlerEntry) : sizeof(AdapterHandlerEntry))) { } |
2355 |
2356 |
2356 // Create a new entry suitable for insertion in the table |
2357 // Create a new entry suitable for insertion in the table |
2357 AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) { |
2358 AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) { |
2358 AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable<mtCode>::new_entry(fingerprint->compute_hash()); |
2359 AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable<mtCode>::new_entry(fingerprint->compute_hash()); |
2359 entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry); |
2360 entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry); |
|
2361 if (DumpSharedSpaces) { |
|
2362 ((CDSAdapterHandlerEntry*)entry)->init(); |
|
2363 } |
2360 return entry; |
2364 return entry; |
2361 } |
2365 } |
2362 |
2366 |
2363 // Insert an entry into the table |
2367 // Insert an entry into the table |
2364 void add(AdapterHandlerEntry* entry) { |
2368 void add(AdapterHandlerEntry* entry) { |
2517 address c2i_unverified_entry) { |
2521 address c2i_unverified_entry) { |
2518 return _adapters->new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry); |
2522 return _adapters->new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry); |
2519 } |
2523 } |
2520 |
2524 |
2521 AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter(const methodHandle& method) { |
2525 AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter(const methodHandle& method) { |
|
2526 AdapterHandlerEntry* entry = get_adapter0(method); |
|
2527 if (method->is_shared()) { |
|
2528 MutexLocker mu(AdapterHandlerLibrary_lock); |
|
2529 if (method->adapter() == NULL) { |
|
2530 method->update_adapter_trampoline(entry); |
|
2531 } |
|
2532 address trampoline = method->from_compiled_entry(); |
|
2533 if (*(int*)trampoline == 0) { |
|
2534 CodeBuffer buffer(trampoline, (int)SharedRuntime::trampoline_size()); |
|
2535 MacroAssembler _masm(&buffer); |
|
2536 SharedRuntime::generate_trampoline(&_masm, entry->get_c2i_entry()); |
|
2537 |
|
2538 if (PrintInterpreter) { |
|
2539 Disassembler::decode(buffer.insts_begin(), buffer.insts_end()); |
|
2540 } |
|
2541 } |
|
2542 } |
|
2543 |
|
2544 return entry; |
|
2545 } |
|
2546 |
|
2547 AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter0(const methodHandle& method) { |
2522 // Use customized signature handler. Need to lock around updates to |
2548 // Use customized signature handler. Need to lock around updates to |
2523 // the AdapterHandlerTable (it is not safe for concurrent readers |
2549 // the AdapterHandlerTable (it is not safe for concurrent readers |
2524 // and a single writer: this could be fixed if it becomes a |
2550 // and a single writer: this could be fixed if it becomes a |
2525 // problem). |
2551 // problem). |
2526 |
2552 |
2533 { |
2559 { |
2534 MutexLocker mu(AdapterHandlerLibrary_lock); |
2560 MutexLocker mu(AdapterHandlerLibrary_lock); |
2535 // make sure data structure is initialized |
2561 // make sure data structure is initialized |
2536 initialize(); |
2562 initialize(); |
2537 |
2563 |
2538 if (CodeCacheExtensions::skip_compiler_support()) { |
2564 // during dump time, always generate adapters, even if the |
|
2565 // compiler has been turned off. |
|
2566 if (!DumpSharedSpaces && CodeCacheExtensions::skip_compiler_support()) { |
2539 // adapters are useless and should not be used, including the |
2567 // adapters are useless and should not be used, including the |
2540 // abstract_method_handler. However, some callers check that |
2568 // abstract_method_handler. However, some callers check that |
2541 // an adapter was installed. |
2569 // an adapter was installed. |
2542 // Return the singleton adapter, stored into _abstract_method_handler |
2570 // Return the singleton adapter, stored into _abstract_method_handler |
2543 // and modified to cause an error if we ever call it. |
2571 // and modified to cause an error if we ever call it. |
3014 st->print_cr("AHE@" INTPTR_FORMAT ": %s i2c: " INTPTR_FORMAT " c2i: " INTPTR_FORMAT " c2iUV: " INTPTR_FORMAT, |
3042 st->print_cr("AHE@" INTPTR_FORMAT ": %s i2c: " INTPTR_FORMAT " c2i: " INTPTR_FORMAT " c2iUV: " INTPTR_FORMAT, |
3015 p2i(this), fingerprint()->as_string(), |
3043 p2i(this), fingerprint()->as_string(), |
3016 p2i(get_i2c_entry()), p2i(get_c2i_entry()), p2i(get_c2i_unverified_entry())); |
3044 p2i(get_i2c_entry()), p2i(get_c2i_entry()), p2i(get_c2i_unverified_entry())); |
3017 |
3045 |
3018 } |
3046 } |
|
3047 |
|
3048 #if INCLUDE_CDS |
|
3049 |
|
3050 void CDSAdapterHandlerEntry::init() { |
|
3051 assert(DumpSharedSpaces, "used during dump time only"); |
|
3052 _c2i_entry_trampoline = (address)MetaspaceShared::misc_data_space_alloc(SharedRuntime::trampoline_size()); |
|
3053 _adapter_trampoline = (AdapterHandlerEntry**)MetaspaceShared::misc_data_space_alloc(sizeof(AdapterHandlerEntry*)); |
|
3054 }; |
|
3055 |
|
3056 #endif // INCLUDE_CDS |
|
3057 |
3019 |
3058 |
3020 #ifndef PRODUCT |
3059 #ifndef PRODUCT |
3021 |
3060 |
3022 void AdapterHandlerLibrary::print_statistics() { |
3061 void AdapterHandlerLibrary::print_statistics() { |
3023 _adapters->print_statistics(); |
3062 _adapters->print_statistics(); |