src/hotspot/share/code/compiledIC.cpp
changeset 52858 dad45affbdaa
parent 52857 7e268f863ff0
child 53415 698ee6095c76
child 53651 0331b08811ad
equal deleted inserted replaced
52857:7e268f863ff0 52858:dad45affbdaa
   124     tty->cr();
   124     tty->cr();
   125   }
   125   }
   126 
   126 
   127   {
   127   {
   128     CodeBlob* cb = CodeCache::find_blob_unsafe(_call->instruction_address());
   128     CodeBlob* cb = CodeCache::find_blob_unsafe(_call->instruction_address());
   129     MutexLockerEx pl(CompiledICLocker::is_safe(cb->as_compiled_method()) ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag);
       
   130     assert(cb != NULL && cb->is_compiled(), "must be compiled");
   129     assert(cb != NULL && cb->is_compiled(), "must be compiled");
   131     _call->set_destination_mt_safe(entry_point);
   130     _call->set_destination_mt_safe(entry_point);
   132   }
   131   }
   133 
   132 
   134   if (is_optimized() || is_icstub) {
   133   if (is_optimized() || is_icstub) {
   372 
   371 
   373   address entry = _call->get_resolve_call_stub(is_optimized());
   372   address entry = _call->get_resolve_call_stub(is_optimized());
   374 
   373 
   375   // A zombie transition will always be safe, since the metadata has already been set to NULL, so
   374   // A zombie transition will always be safe, since the metadata has already been set to NULL, so
   376   // we only need to patch the destination
   375   // we only need to patch the destination
   377   bool safe_transition = _call->is_safe_for_patching() || !in_use || is_optimized() || CompiledICLocker::is_safe(_method);
   376   bool safe_transition = _call->is_safe_for_patching() || !in_use || is_optimized() || SafepointSynchronize::is_at_safepoint();
   378 
   377 
   379   if (safe_transition) {
   378   if (safe_transition) {
   380     // Kill any leftover stub we might have too
   379     // Kill any leftover stub we might have too
   381     clear_ic_stub();
   380     clear_ic_stub();
   382     if (is_optimized()) {
   381     if (is_optimized()) {
   425 
   424 
   426   Thread *thread = Thread::current();
   425   Thread *thread = Thread::current();
   427   if (info.to_interpreter() || info.to_aot()) {
   426   if (info.to_interpreter() || info.to_aot()) {
   428     // Call to interpreter
   427     // Call to interpreter
   429     if (info.is_optimized() && is_optimized()) {
   428     if (info.is_optimized() && is_optimized()) {
   430        assert(is_clean(), "unsafe IC path");
   429       assert(is_clean(), "unsafe IC path");
   431        MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
       
   432       // the call analysis (callee structure) specifies that the call is optimized
   430       // the call analysis (callee structure) specifies that the call is optimized
   433       // (either because of CHA or the static target is final)
   431       // (either because of CHA or the static target is final)
   434       // At code generation time, this call has been emitted as static call
   432       // At code generation time, this call has been emitted as static call
   435       // Call via stub
   433       // Call via stub
   436       assert(info.cached_metadata() != NULL && info.cached_metadata()->is_method(), "sanity check");
   434       assert(info.cached_metadata() != NULL && info.cached_metadata()->is_method(), "sanity check");
   600 
   598 
   601 bool CompiledStaticCall::set_to_clean(bool in_use) {
   599 bool CompiledStaticCall::set_to_clean(bool in_use) {
   602   // in_use is unused but needed to match template function in CompiledMethod
   600   // in_use is unused but needed to match template function in CompiledMethod
   603   assert(CompiledICLocker::is_safe(instruction_address()), "mt unsafe call");
   601   assert(CompiledICLocker::is_safe(instruction_address()), "mt unsafe call");
   604   // Reset call site
   602   // Reset call site
   605   MutexLockerEx pl(SafepointSynchronize::is_at_safepoint() ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag);
       
   606   set_destination_mt_safe(resolve_call_stub());
   603   set_destination_mt_safe(resolve_call_stub());
   607 
   604 
   608   // Do not reset stub here:  It is too expensive to call find_stub.
   605   // Do not reset stub here:  It is too expensive to call find_stub.
   609   // Instead, rely on caller (nmethod::clear_inline_caches) to clear
   606   // Instead, rely on caller (nmethod::clear_inline_caches) to clear
   610   // both the call and its stub.
   607   // both the call and its stub.
   646   set_destination_mt_safe(entry);
   643   set_destination_mt_safe(entry);
   647 }
   644 }
   648 
   645 
   649 void CompiledStaticCall::set(const StaticCallInfo& info) {
   646 void CompiledStaticCall::set(const StaticCallInfo& info) {
   650   assert(CompiledICLocker::is_safe(instruction_address()), "mt unsafe call");
   647   assert(CompiledICLocker::is_safe(instruction_address()), "mt unsafe call");
   651   MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
       
   652   // Updating a cache to the wrong entry can cause bugs that are very hard
   648   // Updating a cache to the wrong entry can cause bugs that are very hard
   653   // to track down - if cache entry gets invalid - we just clean it. In
   649   // to track down - if cache entry gets invalid - we just clean it. In
   654   // this way it is always the same code path that is responsible for
   650   // this way it is always the same code path that is responsible for
   655   // updating and resolving an inline cache
   651   // updating and resolving an inline cache
   656   assert(is_clean(), "do not update a call entry - use clean");
   652   assert(is_clean(), "do not update a call entry - use clean");