src/hotspot/share/runtime/sharedRuntime.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54752 3fbaea4b1f1c
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    55 #include "prims/methodHandles.hpp"
    55 #include "prims/methodHandles.hpp"
    56 #include "prims/nativeLookup.hpp"
    56 #include "prims/nativeLookup.hpp"
    57 #include "runtime/arguments.hpp"
    57 #include "runtime/arguments.hpp"
    58 #include "runtime/atomic.hpp"
    58 #include "runtime/atomic.hpp"
    59 #include "runtime/biasedLocking.hpp"
    59 #include "runtime/biasedLocking.hpp"
    60 #include "runtime/compilationPolicy.hpp"
       
    61 #include "runtime/frame.inline.hpp"
    60 #include "runtime/frame.inline.hpp"
    62 #include "runtime/handles.inline.hpp"
    61 #include "runtime/handles.inline.hpp"
    63 #include "runtime/init.hpp"
    62 #include "runtime/init.hpp"
    64 #include "runtime/interfaceSupport.inline.hpp"
    63 #include "runtime/interfaceSupport.inline.hpp"
    65 #include "runtime/java.hpp"
    64 #include "runtime/java.hpp"
   762   // Increment counter for hs_err file reporting
   761   // Increment counter for hs_err file reporting
   763   Atomic::inc(&Exceptions::_stack_overflow_errors);
   762   Atomic::inc(&Exceptions::_stack_overflow_errors);
   764   throw_and_post_jvmti_exception(thread, exception);
   763   throw_and_post_jvmti_exception(thread, exception);
   765 }
   764 }
   766 
   765 
   767 #if INCLUDE_JVMCI
       
   768 address SharedRuntime::deoptimize_for_implicit_exception(JavaThread* thread, address pc, CompiledMethod* nm, int deopt_reason) {
       
   769   assert(deopt_reason > Deoptimization::Reason_none && deopt_reason < Deoptimization::Reason_LIMIT, "invalid deopt reason");
       
   770   thread->set_jvmci_implicit_exception_pc(pc);
       
   771   thread->set_pending_deoptimization(Deoptimization::make_trap_request((Deoptimization::DeoptReason)deopt_reason, Deoptimization::Action_reinterpret));
       
   772   return (SharedRuntime::deopt_blob()->implicit_exception_uncommon_trap());
       
   773 }
       
   774 #endif // INCLUDE_JVMCI
       
   775 
       
   776 address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread,
   766 address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread,
   777                                                            address pc,
   767                                                            address pc,
   778                                                            SharedRuntime::ImplicitExceptionKind exception_kind)
   768                                                            ImplicitExceptionKind exception_kind)
   779 {
   769 {
   780   address target_pc = NULL;
   770   address target_pc = NULL;
   781 
   771 
   782   if (Interpreter::contains(pc)) {
   772   if (Interpreter::contains(pc)) {
   783 #ifdef CC_INTERP
   773 #ifdef CC_INTERP
   874           }
   864           }
   875 
   865 
   876 #ifndef PRODUCT
   866 #ifndef PRODUCT
   877           _implicit_null_throws++;
   867           _implicit_null_throws++;
   878 #endif
   868 #endif
   879 #if INCLUDE_JVMCI
   869           target_pc = cm->continuation_for_implicit_null_exception(pc);
   880           if (cm->is_compiled_by_jvmci() && cm->pc_desc_at(pc) != NULL) {
       
   881             // If there's no PcDesc then we'll die way down inside of
       
   882             // deopt instead of just getting normal error reporting,
       
   883             // so only go there if it will succeed.
       
   884             return deoptimize_for_implicit_exception(thread, pc, cm, Deoptimization::Reason_null_check);
       
   885           } else {
       
   886 #endif // INCLUDE_JVMCI
       
   887           assert (cm->is_nmethod(), "Expect nmethod");
       
   888           target_pc = ((nmethod*)cm)->continuation_for_implicit_exception(pc);
       
   889 #if INCLUDE_JVMCI
       
   890           }
       
   891 #endif // INCLUDE_JVMCI
       
   892           // If there's an unexpected fault, target_pc might be NULL,
   870           // If there's an unexpected fault, target_pc might be NULL,
   893           // in which case we want to fall through into the normal
   871           // in which case we want to fall through into the normal
   894           // error handling code.
   872           // error handling code.
   895         }
   873         }
   896 
   874 
   902         CompiledMethod* cm = CodeCache::find_compiled(pc);
   880         CompiledMethod* cm = CodeCache::find_compiled(pc);
   903         guarantee(cm != NULL, "must have containing compiled method for implicit division-by-zero exceptions");
   881         guarantee(cm != NULL, "must have containing compiled method for implicit division-by-zero exceptions");
   904 #ifndef PRODUCT
   882 #ifndef PRODUCT
   905         _implicit_div0_throws++;
   883         _implicit_div0_throws++;
   906 #endif
   884 #endif
   907 #if INCLUDE_JVMCI
   885         target_pc = cm->continuation_for_implicit_div0_exception(pc);
   908         if (cm->is_compiled_by_jvmci() && cm->pc_desc_at(pc) != NULL) {
       
   909           return deoptimize_for_implicit_exception(thread, pc, cm, Deoptimization::Reason_div0_check);
       
   910         } else {
       
   911 #endif // INCLUDE_JVMCI
       
   912         target_pc = cm->continuation_for_implicit_exception(pc);
       
   913 #if INCLUDE_JVMCI
       
   914         }
       
   915 #endif // INCLUDE_JVMCI
       
   916         // If there's an unexpected fault, target_pc might be NULL,
   886         // If there's an unexpected fault, target_pc might be NULL,
   917         // in which case we want to fall through into the normal
   887         // in which case we want to fall through into the normal
   918         // error handling code.
   888         // error handling code.
   919         break; // fall through
   889         break; // fall through
   920       }
   890       }
  1296     // Don't update call site if callee nmethod was replaced by an other nmethod
  1266     // Don't update call site if callee nmethod was replaced by an other nmethod
  1297     // which may happen when multiply alive nmethod (tiered compilation)
  1267     // which may happen when multiply alive nmethod (tiered compilation)
  1298     // will be supported.
  1268     // will be supported.
  1299     if (!callee_method->is_old() &&
  1269     if (!callee_method->is_old() &&
  1300         (callee == NULL || (callee->is_in_use() && callee_method->code() == callee))) {
  1270         (callee == NULL || (callee->is_in_use() && callee_method->code() == callee))) {
       
  1271       NoSafepointVerifier nsv;
  1301 #ifdef ASSERT
  1272 #ifdef ASSERT
  1302       // We must not try to patch to jump to an already unloaded method.
  1273       // We must not try to patch to jump to an already unloaded method.
  1303       if (dest_entry_point != 0) {
  1274       if (dest_entry_point != 0) {
  1304         CodeBlob* cb = CodeCache::find_blob(dest_entry_point);
  1275         CodeBlob* cb = CodeCache::find_blob(dest_entry_point);
  1305         assert((cb != NULL) && cb->is_compiled() && (((CompiledMethod*)cb) == callee),
  1276         assert((cb != NULL) && cb->is_compiled() && (((CompiledMethod*)cb) == callee),
  1312           if (!inline_cache->set_to_monomorphic(virtual_call_info)) {
  1283           if (!inline_cache->set_to_monomorphic(virtual_call_info)) {
  1313             return false;
  1284             return false;
  1314           }
  1285           }
  1315         }
  1286         }
  1316       } else {
  1287       } else {
       
  1288         if (VM_Version::supports_fast_class_init_checks() &&
       
  1289             invoke_code == Bytecodes::_invokestatic &&
       
  1290             callee_method->needs_clinit_barrier() &&
       
  1291             callee != NULL && (callee->is_compiled_by_jvmci() || callee->is_aot())) {
       
  1292           return true; // skip patching for JVMCI or AOT code
       
  1293         }
  1317         CompiledStaticCall* ssc = caller_nm->compiledStaticCall_before(caller_frame.pc());
  1294         CompiledStaticCall* ssc = caller_nm->compiledStaticCall_before(caller_frame.pc());
  1318         if (ssc->is_clean()) ssc->set(static_call_info);
  1295         if (ssc->is_clean()) ssc->set(static_call_info);
  1319       }
  1296       }
  1320     }
  1297     }
  1321   } // unlock CompiledICLocker
  1298   } // unlock CompiledICLocker
  1374     tty->print_cr(" at pc: " INTPTR_FORMAT " to code: " INTPTR_FORMAT,
  1351     tty->print_cr(" at pc: " INTPTR_FORMAT " to code: " INTPTR_FORMAT,
  1375                   p2i(caller_frame.pc()), p2i(callee_method->code()));
  1352                   p2i(caller_frame.pc()), p2i(callee_method->code()));
  1376   }
  1353   }
  1377 #endif
  1354 #endif
  1378 
  1355 
  1379   // Do not patch call site for static call when the class is not
  1356   if (invoke_code == Bytecodes::_invokestatic) {
  1380   // fully initialized.
  1357     assert(callee_method->method_holder()->is_initialized() ||
  1381   if (invoke_code == Bytecodes::_invokestatic &&
  1358            callee_method->method_holder()->is_reentrant_initialization(thread),
  1382       !callee_method->method_holder()->is_initialized()) {
  1359            "invalid class initialization state for invoke_static");
  1383     assert(callee_method->method_holder()->is_linked(), "must be");
  1360     if (!VM_Version::supports_fast_class_init_checks() && callee_method->needs_clinit_barrier()) {
  1384     return callee_method;
  1361       // In order to keep class initialization check, do not patch call
       
  1362       // site for static call when the class is not fully initialized.
       
  1363       // Proper check is enforced by call site re-resolution on every invocation.
       
  1364       //
       
  1365       // When fast class initialization checks are supported (VM_Version::supports_fast_class_init_checks() == true),
       
  1366       // explicit class initialization check is put in nmethod entry (VEP).
       
  1367       assert(callee_method->method_holder()->is_linked(), "must be");
       
  1368       return callee_method;
       
  1369     }
  1385   }
  1370   }
  1386 
  1371 
  1387   // JSR 292 key invariant:
  1372   // JSR 292 key invariant:
  1388   // If the resolved method is a MethodHandle invoke target, the call
  1373   // If the resolved method is a MethodHandle invoke target, the call
  1389   // site must be a MethodHandle call site, because the lambda form might tail-call
  1374   // site must be a MethodHandle call site, because the lambda form might tail-call
  1459       caller_frame.is_entry_frame()) {
  1444       caller_frame.is_entry_frame()) {
  1460     Method* callee = thread->callee_target();
  1445     Method* callee = thread->callee_target();
  1461     guarantee(callee != NULL && callee->is_method(), "bad handshake");
  1446     guarantee(callee != NULL && callee->is_method(), "bad handshake");
  1462     thread->set_vm_result_2(callee);
  1447     thread->set_vm_result_2(callee);
  1463     thread->set_callee_target(NULL);
  1448     thread->set_callee_target(NULL);
  1464     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     }
  1465   }
  1462   }
  1466 
  1463 
  1467   // Must be compiled to compiled path which is safe to stackwalk
  1464   // Must be compiled to compiled path which is safe to stackwalk
  1468   methodHandle callee_method;
  1465   methodHandle callee_method;
  1469   JRT_BLOCK
  1466   JRT_BLOCK
  2033 char* SharedRuntime::generate_class_cast_message(
  2030 char* SharedRuntime::generate_class_cast_message(
  2034     Klass* caster_klass, Klass* target_klass, Symbol* target_klass_name) {
  2031     Klass* caster_klass, Klass* target_klass, Symbol* target_klass_name) {
  2035   const char* caster_name = caster_klass->external_name();
  2032   const char* caster_name = caster_klass->external_name();
  2036 
  2033 
  2037   assert(target_klass != NULL || target_klass_name != NULL, "one must be provided");
  2034   assert(target_klass != NULL || target_klass_name != NULL, "one must be provided");
  2038   const char* target_name = target_klass == NULL ? target_klass_name->as_C_string() :
  2035   const char* target_name = target_klass == NULL ? target_klass_name->as_klass_external_name() :
  2039                                                    target_klass->external_name();
  2036                                                    target_klass->external_name();
  2040 
  2037 
  2041   size_t msglen = strlen(caster_name) + strlen("class ") + strlen(" cannot be cast to class ") + strlen(target_name) + 1;
  2038   size_t msglen = strlen(caster_name) + strlen("class ") + strlen(" cannot be cast to class ") + strlen(target_name) + 1;
  2042 
  2039 
  2043   const char* caster_klass_description = "";
  2040   const char* caster_klass_description = "";
  2092   oop obj(_obj);
  2089   oop obj(_obj);
  2093   if (PrintBiasedLockingStatistics) {
  2090   if (PrintBiasedLockingStatistics) {
  2094     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
  2091     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
  2095   }
  2092   }
  2096   Handle h_obj(THREAD, obj);
  2093   Handle h_obj(THREAD, obj);
  2097   if (UseBiasedLocking) {
  2094   ObjectSynchronizer::enter(h_obj, lock, CHECK);
  2098     // Retry fast entry if bias is revoked to avoid unnecessary inflation
       
  2099     ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK);
       
  2100   } else {
       
  2101     ObjectSynchronizer::slow_enter(h_obj, lock, CHECK);
       
  2102   }
       
  2103   assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
  2095   assert(!HAS_PENDING_EXCEPTION, "Should have no exception here");
  2104   JRT_BLOCK_END
  2096   JRT_BLOCK_END
  2105 JRT_END
  2097 JRT_END
  2106 
  2098 
  2107 // Handles the uncommon cases of monitor unlocking in compiled code
  2099 // Handles the uncommon cases of monitor unlocking in compiled code
  2128 #endif /* MIGHT_HAVE_PENDING */
  2120 #endif /* MIGHT_HAVE_PENDING */
  2129 
  2121 
  2130   {
  2122   {
  2131     // Exit must be non-blocking, and therefore no exceptions can be thrown.
  2123     // Exit must be non-blocking, and therefore no exceptions can be thrown.
  2132     EXCEPTION_MARK;
  2124     EXCEPTION_MARK;
  2133     ObjectSynchronizer::slow_exit(obj, lock, THREAD);
  2125     ObjectSynchronizer::exit(obj, lock, THREAD);
  2134   }
  2126   }
  2135 
  2127 
  2136 #ifdef MIGHT_HAVE_PENDING
  2128 #ifdef MIGHT_HAVE_PENDING
  2137   if (pending_excep != NULL) {
  2129   if (pending_excep != NULL) {
  2138     THREAD->set_pending_exception(pending_excep, pending_file, pending_line);
  2130     THREAD->set_pending_exception(pending_excep, pending_file, pending_line);
  2463  public:
  2455  public:
  2464   AdapterHandlerTable()
  2456   AdapterHandlerTable()
  2465     : BasicHashtable<mtCode>(293, (DumpSharedSpaces ? sizeof(CDSAdapterHandlerEntry) : sizeof(AdapterHandlerEntry))) { }
  2457     : BasicHashtable<mtCode>(293, (DumpSharedSpaces ? sizeof(CDSAdapterHandlerEntry) : sizeof(AdapterHandlerEntry))) { }
  2466 
  2458 
  2467   // Create a new entry suitable for insertion in the table
  2459   // Create a new entry suitable for insertion in the table
  2468   AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) {
  2460   AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry, address c2i_no_clinit_check_entry) {
  2469     AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable<mtCode>::new_entry(fingerprint->compute_hash());
  2461     AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable<mtCode>::new_entry(fingerprint->compute_hash());
  2470     entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
  2462     entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
  2471     if (DumpSharedSpaces) {
  2463     if (DumpSharedSpaces) {
  2472       ((CDSAdapterHandlerEntry*)entry)->init();
  2464       ((CDSAdapterHandlerEntry*)entry)->init();
  2473     }
  2465     }
  2474     return entry;
  2466     return entry;
  2475   }
  2467   }
  2614 }
  2606 }
  2615 
  2607 
  2616 AdapterHandlerEntry* AdapterHandlerLibrary::new_entry(AdapterFingerPrint* fingerprint,
  2608 AdapterHandlerEntry* AdapterHandlerLibrary::new_entry(AdapterFingerPrint* fingerprint,
  2617                                                       address i2c_entry,
  2609                                                       address i2c_entry,
  2618                                                       address c2i_entry,
  2610                                                       address c2i_entry,
  2619                                                       address c2i_unverified_entry) {
  2611                                                       address c2i_unverified_entry,
  2620   return _adapters->new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
  2612                                                       address c2i_no_clinit_check_entry) {
       
  2613   return _adapters->new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
  2621 }
  2614 }
  2622 
  2615 
  2623 AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter(const methodHandle& method) {
  2616 AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter(const methodHandle& method) {
  2624   AdapterHandlerEntry* entry = get_adapter0(method);
  2617   AdapterHandlerEntry* entry = get_adapter0(method);
  2625   if (method->is_shared()) {
  2618   if (method->is_shared()) {
  2791 address AdapterHandlerEntry::base_address() {
  2784 address AdapterHandlerEntry::base_address() {
  2792   address base = _i2c_entry;
  2785   address base = _i2c_entry;
  2793   if (base == NULL)  base = _c2i_entry;
  2786   if (base == NULL)  base = _c2i_entry;
  2794   assert(base <= _c2i_entry || _c2i_entry == NULL, "");
  2787   assert(base <= _c2i_entry || _c2i_entry == NULL, "");
  2795   assert(base <= _c2i_unverified_entry || _c2i_unverified_entry == NULL, "");
  2788   assert(base <= _c2i_unverified_entry || _c2i_unverified_entry == NULL, "");
       
  2789   assert(base <= _c2i_no_clinit_check_entry || _c2i_no_clinit_check_entry == NULL, "");
  2796   return base;
  2790   return base;
  2797 }
  2791 }
  2798 
  2792 
  2799 void AdapterHandlerEntry::relocate(address new_base) {
  2793 void AdapterHandlerEntry::relocate(address new_base) {
  2800   address old_base = base_address();
  2794   address old_base = base_address();
  2804     _i2c_entry += delta;
  2798     _i2c_entry += delta;
  2805   if (_c2i_entry != NULL)
  2799   if (_c2i_entry != NULL)
  2806     _c2i_entry += delta;
  2800     _c2i_entry += delta;
  2807   if (_c2i_unverified_entry != NULL)
  2801   if (_c2i_unverified_entry != NULL)
  2808     _c2i_unverified_entry += delta;
  2802     _c2i_unverified_entry += delta;
       
  2803   if (_c2i_no_clinit_check_entry != NULL)
       
  2804     _c2i_no_clinit_check_entry += delta;
  2809   assert(base_address() == new_base, "");
  2805   assert(base_address() == new_base, "");
  2810 }
  2806 }
  2811 
  2807 
  2812 
  2808 
  2813 void AdapterHandlerEntry::deallocate() {
  2809 void AdapterHandlerEntry::deallocate() {
  2814   delete _fingerprint;
  2810   delete _fingerprint;
  2815 #ifdef ASSERT
  2811 #ifdef ASSERT
  2816   if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code);
  2812   FREE_C_HEAP_ARRAY(unsigned char, _saved_code);
  2817 #endif
  2813 #endif
  2818 }
  2814 }
  2819 
  2815 
  2820 
  2816 
  2821 #ifdef ASSERT
  2817 #ifdef ASSERT
  2846  * back to java blocking if a safepoint is in progress.
  2842  * back to java blocking if a safepoint is in progress.
  2847  */
  2843  */
  2848 void AdapterHandlerLibrary::create_native_wrapper(const methodHandle& method) {
  2844 void AdapterHandlerLibrary::create_native_wrapper(const methodHandle& method) {
  2849   ResourceMark rm;
  2845   ResourceMark rm;
  2850   nmethod* nm = NULL;
  2846   nmethod* nm = NULL;
       
  2847   address critical_entry = NULL;
  2851 
  2848 
  2852   assert(method->is_native(), "must be native");
  2849   assert(method->is_native(), "must be native");
  2853   assert(method->is_method_handle_intrinsic() ||
  2850   assert(method->is_method_handle_intrinsic() ||
  2854          method->has_native_function(), "must have something valid to call!");
  2851          method->has_native_function(), "must have something valid to call!");
       
  2852 
       
  2853   if (CriticalJNINatives && !method->is_method_handle_intrinsic()) {
       
  2854     // We perform the I/O with transition to native before acquiring AdapterHandlerLibrary_lock.
       
  2855     critical_entry = NativeLookup::lookup_critical_entry(method);
       
  2856   }
  2855 
  2857 
  2856   {
  2858   {
  2857     // Perform the work while holding the lock, but perform any printing outside the lock
  2859     // Perform the work while holding the lock, but perform any printing outside the lock
  2858     MutexLocker mu(AdapterHandlerLibrary_lock);
  2860     MutexLocker mu(AdapterHandlerLibrary_lock);
  2859     // See if somebody beat us to it
  2861     // See if somebody beat us to it
  2895       // are just trampolines so the argument registers must be outgoing ones.
  2897       // are just trampolines so the argument registers must be outgoing ones.
  2896       const bool is_outgoing = method->is_method_handle_intrinsic();
  2898       const bool is_outgoing = method->is_method_handle_intrinsic();
  2897       int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing);
  2899       int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing);
  2898 
  2900 
  2899       // Generate the compiled-to-native wrapper code
  2901       // Generate the compiled-to-native wrapper code
  2900       nm = SharedRuntime::generate_native_wrapper(&_masm, method, compile_id, sig_bt, regs, ret_type);
  2902       nm = SharedRuntime::generate_native_wrapper(&_masm, method, compile_id, sig_bt, regs, ret_type, critical_entry);
  2901 
  2903 
  2902       if (nm != NULL) {
  2904       if (nm != NULL) {
  2903         method->set_code(method, nm);
  2905         {
       
  2906           MutexLocker pl(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
       
  2907           if (nm->make_in_use()) {
       
  2908             method->set_code(method, nm);
       
  2909           }
       
  2910         }
  2904 
  2911 
  2905         DirectiveSet* directive = DirectivesStack::getDefaultDirective(CompileBroker::compiler(CompLevel_simple));
  2912         DirectiveSet* directive = DirectivesStack::getDefaultDirective(CompileBroker::compiler(CompLevel_simple));
  2906         if (directive->PrintAssemblyOption) {
  2913         if (directive->PrintAssemblyOption) {
  2907           nm->print_code();
  2914           nm->print_code();
  2908         }
  2915         }
  3103        kptr2 < fr.interpreter_frame_monitor_begin();
  3110        kptr2 < fr.interpreter_frame_monitor_begin();
  3104        kptr2 = fr.next_monitor_in_interpreter_frame(kptr2) ) {
  3111        kptr2 = fr.next_monitor_in_interpreter_frame(kptr2) ) {
  3105     if (kptr2->obj() != NULL) {         // Avoid 'holes' in the monitor array
  3112     if (kptr2->obj() != NULL) {         // Avoid 'holes' in the monitor array
  3106       BasicLock *lock = kptr2->lock();
  3113       BasicLock *lock = kptr2->lock();
  3107       // Inflate so the displaced header becomes position-independent
  3114       // Inflate so the displaced header becomes position-independent
  3108       if (lock->displaced_header()->is_unlocked())
  3115       if (lock->displaced_header().is_unlocked())
  3109         ObjectSynchronizer::inflate_helper(kptr2->obj());
  3116         ObjectSynchronizer::inflate_helper(kptr2->obj());
  3110       // Now the displaced header is free to move
  3117       // Now the displaced header is free to move
  3111       buf[i++] = (intptr_t)lock->displaced_header();
  3118       buf[i++] = (intptr_t)lock->displaced_header().value();
  3112       buf[i++] = cast_from_oop<intptr_t>(kptr2->obj());
  3119       buf[i++] = cast_from_oop<intptr_t>(kptr2->obj());
  3113     }
  3120     }
  3114   }
  3121   }
  3115   assert(i - max_locals == active_monitor_count*2, "found the expected number of monitors");
  3122   assert(i - max_locals == active_monitor_count*2, "found the expected number of monitors");
  3116 
  3123 
  3142   }
  3149   }
  3143   assert(false, "Should have found handler");
  3150   assert(false, "Should have found handler");
  3144 }
  3151 }
  3145 
  3152 
  3146 void AdapterHandlerEntry::print_adapter_on(outputStream* st) const {
  3153 void AdapterHandlerEntry::print_adapter_on(outputStream* st) const {
  3147   st->print_cr("AHE@" INTPTR_FORMAT ": %s i2c: " INTPTR_FORMAT " c2i: " INTPTR_FORMAT " c2iUV: " INTPTR_FORMAT,
  3154   st->print("AHE@" INTPTR_FORMAT ": %s", p2i(this), fingerprint()->as_string());
  3148                p2i(this), fingerprint()->as_string(),
  3155   if (get_i2c_entry() != NULL) {
  3149                p2i(get_i2c_entry()), p2i(get_c2i_entry()), p2i(get_c2i_unverified_entry()));
  3156     st->print(" i2c: " INTPTR_FORMAT, p2i(get_i2c_entry()));
  3150 
  3157   }
       
  3158   if (get_c2i_entry() != NULL) {
       
  3159     st->print(" c2i: " INTPTR_FORMAT, p2i(get_c2i_entry()));
       
  3160   }
       
  3161   if (get_c2i_unverified_entry() != NULL) {
       
  3162     st->print(" c2iUV: " INTPTR_FORMAT, p2i(get_c2i_unverified_entry()));
       
  3163   }
       
  3164   if (get_c2i_no_clinit_check_entry() != NULL) {
       
  3165     st->print(" c2iNCI: " INTPTR_FORMAT, p2i(get_c2i_no_clinit_check_entry()));
       
  3166   }
       
  3167   st->cr();
  3151 }
  3168 }
  3152 
  3169 
  3153 #if INCLUDE_CDS
  3170 #if INCLUDE_CDS
  3154 
  3171 
  3155 void CDSAdapterHandlerEntry::init() {
  3172 void CDSAdapterHandlerEntry::init() {