src/share/vm/runtime/sharedRuntime.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/runtime

src/share/vm/runtime/sharedRuntime.cpp

Print this page
rev 12400 : 8168503: JEP 297: Unified arm32/arm64 Port
Reviewed-by: kvn, enevill, ihse, dholmes, erik, coleenp, cjplummer


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "aot/aotLoader.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "code/codeCache.hpp"
  31 #include "code/compiledIC.hpp"
  32 #include "code/codeCacheExtensions.hpp"
  33 #include "code/scopeDesc.hpp"
  34 #include "code/vtableStubs.hpp"
  35 #include "compiler/abstractCompiler.hpp"
  36 #include "compiler/compileBroker.hpp"
  37 #include "compiler/disassembler.hpp"
  38 #include "gc/shared/gcLocker.inline.hpp"
  39 #include "interpreter/interpreter.hpp"
  40 #include "interpreter/interpreterRuntime.hpp"
  41 #include "logging/log.hpp"
  42 #include "memory/metaspaceShared.hpp"
  43 #include "memory/resourceArea.hpp"
  44 #include "memory/universe.inline.hpp"
  45 #include "oops/klass.hpp"
  46 #include "oops/objArrayKlass.hpp"
  47 #include "oops/oop.inline.hpp"
  48 #include "prims/forte.hpp"
  49 #include "prims/jvmtiExport.hpp"
  50 #include "prims/methodHandles.hpp"
  51 #include "prims/nativeLookup.hpp"
  52 #include "runtime/arguments.hpp"


2563 AdapterHandlerTable* AdapterHandlerLibrary::_adapters = NULL;
2564 AdapterHandlerEntry* AdapterHandlerLibrary::_abstract_method_handler = NULL;
2565 const int AdapterHandlerLibrary_size = 16*K;
2566 BufferBlob* AdapterHandlerLibrary::_buffer = NULL;
2567 
2568 BufferBlob* AdapterHandlerLibrary::buffer_blob() {
2569   // Should be called only when AdapterHandlerLibrary_lock is active.
2570   if (_buffer == NULL) // Initialize lazily
2571       _buffer = BufferBlob::create("adapters", AdapterHandlerLibrary_size);
2572   return _buffer;
2573 }
2574 
2575 extern "C" void unexpected_adapter_call() {
2576   ShouldNotCallThis();
2577 }
2578 
2579 void AdapterHandlerLibrary::initialize() {
2580   if (_adapters != NULL) return;
2581   _adapters = new AdapterHandlerTable();
2582 
2583   if (!CodeCacheExtensions::skip_compiler_support()) {
2584     // Create a special handler for abstract methods.  Abstract methods
2585     // are never compiled so an i2c entry is somewhat meaningless, but
2586     // throw AbstractMethodError just in case.
2587     // Pass wrong_method_abstract for the c2i transitions to return
2588     // AbstractMethodError for invalid invocations.
2589     address wrong_method_abstract = SharedRuntime::get_handle_wrong_method_abstract_stub();
2590     _abstract_method_handler = AdapterHandlerLibrary::new_entry(new AdapterFingerPrint(0, NULL),
2591                                                                 StubRoutines::throw_AbstractMethodError_entry(),
2592                                                                 wrong_method_abstract, wrong_method_abstract);
2593   } else {
2594     // Adapters are not supposed to be used.
2595     // Generate a special one to cause an error if used (and store this
2596     // singleton in place of the useless _abstract_method_error adapter).
2597     address entry = (address) &unexpected_adapter_call;
2598     _abstract_method_handler = AdapterHandlerLibrary::new_entry(new AdapterFingerPrint(0, NULL),
2599                                                                 entry,
2600                                                                 entry,
2601                                                                 entry);
2602 
2603   }
2604 }
2605 
2606 AdapterHandlerEntry* AdapterHandlerLibrary::new_entry(AdapterFingerPrint* fingerprint,
2607                                                       address i2c_entry,
2608                                                       address c2i_entry,
2609                                                       address c2i_unverified_entry) {
2610   return _adapters->new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
2611 }
2612 
2613 AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter(const methodHandle& method) {
2614   AdapterHandlerEntry* entry = get_adapter0(method);
2615   if (method->is_shared()) {
2616     // See comments around Method::link_method()
2617     MutexLocker mu(AdapterHandlerLibrary_lock);
2618     if (method->adapter() == NULL) {
2619       method->update_adapter_trampoline(entry);
2620     }
2621     address trampoline = method->from_compiled_entry();
2622     if (*(int*)trampoline == 0) {
2623       CodeBuffer buffer(trampoline, (int)SharedRuntime::trampoline_size());


2633 
2634   return entry;
2635 }
2636 
2637 AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter0(const methodHandle& method) {
2638   // Use customized signature handler.  Need to lock around updates to
2639   // the AdapterHandlerTable (it is not safe for concurrent readers
2640   // and a single writer: this could be fixed if it becomes a
2641   // problem).
2642 
2643   ResourceMark rm;
2644 
2645   NOT_PRODUCT(int insts_size);
2646   AdapterBlob* new_adapter = NULL;
2647   AdapterHandlerEntry* entry = NULL;
2648   AdapterFingerPrint* fingerprint = NULL;
2649   {
2650     MutexLocker mu(AdapterHandlerLibrary_lock);
2651     // make sure data structure is initialized
2652     initialize();
2653 
2654     // during dump time, always generate adapters, even if the
2655     // compiler has been turned off.
2656     if (!DumpSharedSpaces && CodeCacheExtensions::skip_compiler_support()) {
2657       // adapters are useless and should not be used, including the
2658       // abstract_method_handler. However, some callers check that
2659       // an adapter was installed.
2660       // Return the singleton adapter, stored into _abstract_method_handler
2661       // and modified to cause an error if we ever call it.
2662       return _abstract_method_handler;
2663     }
2664 
2665     if (method->is_abstract()) {
2666       return _abstract_method_handler;
2667     }
2668 
2669     // Fill in the signature array, for the calling-convention call.
2670     int total_args_passed = method->size_of_parameters(); // All args on stack
2671 
2672     BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
2673     VMRegPair* regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
2674     int i = 0;
2675     if (!method->is_static())  // Pass in receiver first
2676       sig_bt[i++] = T_OBJECT;
2677     for (SignatureStream ss(method->signature()); !ss.at_return_type(); ss.next()) {
2678       sig_bt[i++] = ss.type();  // Collect remaining bits of signature
2679       if (ss.type() == T_LONG || ss.type() == T_DOUBLE)
2680         sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
2681     }
2682     assert(i == total_args_passed, "");
2683 




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "aot/aotLoader.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "code/codeCache.hpp"
  31 #include "code/compiledIC.hpp"

  32 #include "code/scopeDesc.hpp"
  33 #include "code/vtableStubs.hpp"
  34 #include "compiler/abstractCompiler.hpp"
  35 #include "compiler/compileBroker.hpp"
  36 #include "compiler/disassembler.hpp"
  37 #include "gc/shared/gcLocker.inline.hpp"
  38 #include "interpreter/interpreter.hpp"
  39 #include "interpreter/interpreterRuntime.hpp"
  40 #include "logging/log.hpp"
  41 #include "memory/metaspaceShared.hpp"
  42 #include "memory/resourceArea.hpp"
  43 #include "memory/universe.inline.hpp"
  44 #include "oops/klass.hpp"
  45 #include "oops/objArrayKlass.hpp"
  46 #include "oops/oop.inline.hpp"
  47 #include "prims/forte.hpp"
  48 #include "prims/jvmtiExport.hpp"
  49 #include "prims/methodHandles.hpp"
  50 #include "prims/nativeLookup.hpp"
  51 #include "runtime/arguments.hpp"


2562 AdapterHandlerTable* AdapterHandlerLibrary::_adapters = NULL;
2563 AdapterHandlerEntry* AdapterHandlerLibrary::_abstract_method_handler = NULL;
2564 const int AdapterHandlerLibrary_size = 16*K;
2565 BufferBlob* AdapterHandlerLibrary::_buffer = NULL;
2566 
2567 BufferBlob* AdapterHandlerLibrary::buffer_blob() {
2568   // Should be called only when AdapterHandlerLibrary_lock is active.
2569   if (_buffer == NULL) // Initialize lazily
2570       _buffer = BufferBlob::create("adapters", AdapterHandlerLibrary_size);
2571   return _buffer;
2572 }
2573 
2574 extern "C" void unexpected_adapter_call() {
2575   ShouldNotCallThis();
2576 }
2577 
2578 void AdapterHandlerLibrary::initialize() {
2579   if (_adapters != NULL) return;
2580   _adapters = new AdapterHandlerTable();
2581 

2582   // Create a special handler for abstract methods.  Abstract methods
2583   // are never compiled so an i2c entry is somewhat meaningless, but
2584   // throw AbstractMethodError just in case.
2585   // Pass wrong_method_abstract for the c2i transitions to return
2586   // AbstractMethodError for invalid invocations.
2587   address wrong_method_abstract = SharedRuntime::get_handle_wrong_method_abstract_stub();
2588   _abstract_method_handler = AdapterHandlerLibrary::new_entry(new AdapterFingerPrint(0, NULL),
2589                                                               StubRoutines::throw_AbstractMethodError_entry(),
2590                                                               wrong_method_abstract, wrong_method_abstract);











2591 }
2592 
2593 AdapterHandlerEntry* AdapterHandlerLibrary::new_entry(AdapterFingerPrint* fingerprint,
2594                                                       address i2c_entry,
2595                                                       address c2i_entry,
2596                                                       address c2i_unverified_entry) {
2597   return _adapters->new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
2598 }
2599 
2600 AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter(const methodHandle& method) {
2601   AdapterHandlerEntry* entry = get_adapter0(method);
2602   if (method->is_shared()) {
2603     // See comments around Method::link_method()
2604     MutexLocker mu(AdapterHandlerLibrary_lock);
2605     if (method->adapter() == NULL) {
2606       method->update_adapter_trampoline(entry);
2607     }
2608     address trampoline = method->from_compiled_entry();
2609     if (*(int*)trampoline == 0) {
2610       CodeBuffer buffer(trampoline, (int)SharedRuntime::trampoline_size());


2620 
2621   return entry;
2622 }
2623 
2624 AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter0(const methodHandle& method) {
2625   // Use customized signature handler.  Need to lock around updates to
2626   // the AdapterHandlerTable (it is not safe for concurrent readers
2627   // and a single writer: this could be fixed if it becomes a
2628   // problem).
2629 
2630   ResourceMark rm;
2631 
2632   NOT_PRODUCT(int insts_size);
2633   AdapterBlob* new_adapter = NULL;
2634   AdapterHandlerEntry* entry = NULL;
2635   AdapterFingerPrint* fingerprint = NULL;
2636   {
2637     MutexLocker mu(AdapterHandlerLibrary_lock);
2638     // make sure data structure is initialized
2639     initialize();











2640 
2641     if (method->is_abstract()) {
2642       return _abstract_method_handler;
2643     }
2644 
2645     // Fill in the signature array, for the calling-convention call.
2646     int total_args_passed = method->size_of_parameters(); // All args on stack
2647 
2648     BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
2649     VMRegPair* regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
2650     int i = 0;
2651     if (!method->is_static())  // Pass in receiver first
2652       sig_bt[i++] = T_OBJECT;
2653     for (SignatureStream ss(method->signature()); !ss.at_return_type(); ss.next()) {
2654       sig_bt[i++] = ss.type();  // Collect remaining bits of signature
2655       if (ss.type() == T_LONG || ss.type() == T_DOUBLE)
2656         sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
2657     }
2658     assert(i == total_args_passed, "");
2659 


src/share/vm/runtime/sharedRuntime.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File