101 |
101 |
102 { |
102 { |
103 MutexLockerEx pl(SafepointSynchronize::is_at_safepoint() ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag); |
103 MutexLockerEx pl(SafepointSynchronize::is_at_safepoint() ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag); |
104 #ifdef ASSERT |
104 #ifdef ASSERT |
105 CodeBlob* cb = CodeCache::find_blob_unsafe(_ic_call); |
105 CodeBlob* cb = CodeCache::find_blob_unsafe(_ic_call); |
106 assert(cb != NULL && cb->is_nmethod(), "must be nmethod"); |
106 assert(cb != NULL && cb->is_compiled(), "must be compiled"); |
107 #endif |
107 #endif |
108 _ic_call->set_destination_mt_safe(entry_point); |
108 _ic_call->set_destination_mt_safe(entry_point); |
109 } |
109 } |
110 |
110 |
111 if (is_optimized() || is_icstub) { |
111 if (is_optimized() || is_icstub) { |
180 _is_optimized = true; |
180 _is_optimized = true; |
181 _value = NULL; |
181 _value = NULL; |
182 } |
182 } |
183 } |
183 } |
184 |
184 |
185 CompiledIC::CompiledIC(nmethod* nm, NativeCall* call) |
185 CompiledIC::CompiledIC(CompiledMethod* cm, NativeCall* call) |
186 : _ic_call(call) |
186 : _ic_call(call) |
187 { |
187 { |
188 address ic_call = _ic_call->instruction_address(); |
188 address ic_call = _ic_call->instruction_address(); |
189 |
189 |
190 assert(ic_call != NULL, "ic_call address must be set"); |
190 assert(ic_call != NULL, "ic_call address must be set"); |
191 assert(nm != NULL, "must pass nmethod"); |
191 assert(cm != NULL, "must pass compiled method"); |
192 assert(nm->contains(ic_call), "must be in nmethod"); |
192 assert(cm->contains(ic_call), "must be in compiled method"); |
193 |
193 |
194 // Search for the ic_call at the given address. |
194 // Search for the ic_call at the given address. |
195 RelocIterator iter(nm, ic_call, ic_call+1); |
195 RelocIterator iter(cm, ic_call, ic_call+1); |
196 bool ret = iter.next(); |
196 bool ret = iter.next(); |
197 assert(ret == true, "relocInfo must exist at this address"); |
197 assert(ret == true, "relocInfo must exist at this address"); |
198 assert(iter.addr() == ic_call, "must find ic_call"); |
198 assert(iter.addr() == ic_call, "must find ic_call"); |
199 |
199 |
200 initialize_from_iter(&iter); |
200 initialize_from_iter(&iter); |
203 CompiledIC::CompiledIC(RelocIterator* iter) |
203 CompiledIC::CompiledIC(RelocIterator* iter) |
204 : _ic_call(nativeCall_at(iter->addr())) |
204 : _ic_call(nativeCall_at(iter->addr())) |
205 { |
205 { |
206 address ic_call = _ic_call->instruction_address(); |
206 address ic_call = _ic_call->instruction_address(); |
207 |
207 |
208 nmethod* nm = iter->code(); |
208 CompiledMethod* nm = iter->code(); |
209 assert(ic_call != NULL, "ic_call address must be set"); |
209 assert(ic_call != NULL, "ic_call address must be set"); |
210 assert(nm != NULL, "must pass nmethod"); |
210 assert(nm != NULL, "must pass compiled method"); |
211 assert(nm->contains(ic_call), "must be in nmethod"); |
211 assert(nm->contains(ic_call), "must be in compiled method"); |
212 |
212 |
213 initialize_from_iter(iter); |
213 initialize_from_iter(iter); |
214 } |
214 } |
215 |
215 |
216 bool CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) { |
216 bool CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) { |
276 |
276 |
277 // Use unsafe, since an inline cache might point to a zombie method. However, the zombie |
277 // Use unsafe, since an inline cache might point to a zombie method. However, the zombie |
278 // method is guaranteed to still exist, since we only remove methods after all inline caches |
278 // method is guaranteed to still exist, since we only remove methods after all inline caches |
279 // has been cleaned up |
279 // has been cleaned up |
280 CodeBlob* cb = CodeCache::find_blob_unsafe(ic_destination()); |
280 CodeBlob* cb = CodeCache::find_blob_unsafe(ic_destination()); |
281 bool is_monomorphic = (cb != NULL && cb->is_nmethod()); |
281 bool is_monomorphic = (cb != NULL && cb->is_compiled()); |
282 // Check that the cached_value is a klass for non-optimized monomorphic calls |
282 // Check that the cached_value is a klass for non-optimized monomorphic calls |
283 // This assertion is invalid for compiler1: a call that does not look optimized (no static stub) can be used |
283 // This assertion is invalid for compiler1: a call that does not look optimized (no static stub) can be used |
284 // for calling directly to vep without using the inline cache (i.e., cached_value == NULL). |
284 // for calling directly to vep without using the inline cache (i.e., cached_value == NULL). |
285 // For JVMCI this occurs because CHA is only used to improve inlining so call sites which could be optimized |
285 // For JVMCI this occurs because CHA is only used to improve inlining so call sites which could be optimized |
286 // virtuals because there are no currently loaded subclasses of a type are left as virtual call sites. |
286 // virtuals because there are no currently loaded subclasses of a type are left as virtual call sites. |
421 } else { |
421 } else { |
422 // Call to compiled code |
422 // Call to compiled code |
423 bool static_bound = info.is_optimized() || (info.cached_metadata() == NULL); |
423 bool static_bound = info.is_optimized() || (info.cached_metadata() == NULL); |
424 #ifdef ASSERT |
424 #ifdef ASSERT |
425 CodeBlob* cb = CodeCache::find_blob_unsafe(info.entry()); |
425 CodeBlob* cb = CodeCache::find_blob_unsafe(info.entry()); |
426 assert (cb->is_nmethod(), "must be compiled!"); |
426 assert (cb->is_compiled(), "must be compiled!"); |
427 #endif /* ASSERT */ |
427 #endif /* ASSERT */ |
428 |
428 |
429 // This is MT safe if we come from a clean-cache and go through a |
429 // This is MT safe if we come from a clean-cache and go through a |
430 // non-verified entry point |
430 // non-verified entry point |
431 bool safe = SafepointSynchronize::is_at_safepoint() || |
431 bool safe = SafepointSynchronize::is_at_safepoint() || |
467 KlassHandle receiver_klass, |
467 KlassHandle receiver_klass, |
468 bool is_optimized, |
468 bool is_optimized, |
469 bool static_bound, |
469 bool static_bound, |
470 CompiledICInfo& info, |
470 CompiledICInfo& info, |
471 TRAPS) { |
471 TRAPS) { |
472 nmethod* method_code = method->code(); |
472 CompiledMethod* method_code = method->code(); |
|
473 |
473 address entry = NULL; |
474 address entry = NULL; |
474 if (method_code != NULL && method_code->is_in_use()) { |
475 if (method_code != NULL && method_code->is_in_use()) { |
|
476 assert(method_code->is_compiled(), "must be compiled"); |
475 // Call to compiled code |
477 // Call to compiled code |
476 if (static_bound || is_optimized) { |
478 if (static_bound || is_optimized) { |
477 entry = method_code->verified_entry_point(); |
479 entry = method_code->verified_entry_point(); |
478 } else { |
480 } else { |
479 entry = method_code->entry_point(); |
481 entry = method_code->entry_point(); |
518 if (is_optimized) { |
520 if (is_optimized) { |
519 // Use stub entry |
521 // Use stub entry |
520 info.set_interpreter_entry(method()->get_c2i_entry(), method()); |
522 info.set_interpreter_entry(method()->get_c2i_entry(), method()); |
521 } else { |
523 } else { |
522 // Use icholder entry |
524 // Use icholder entry |
|
525 assert(method_code == NULL || method_code->is_compiled(), "must be compiled"); |
523 CompiledICHolder* holder = new CompiledICHolder(method(), receiver_klass()); |
526 CompiledICHolder* holder = new CompiledICHolder(method(), receiver_klass()); |
524 info.set_icholder_entry(method()->get_c2i_unverified_entry(), holder); |
527 info.set_icholder_entry(method()->get_c2i_unverified_entry(), holder); |
525 } |
528 } |
526 } |
529 } |
527 assert(info.is_optimized() == is_optimized, "must agree"); |
530 assert(info.is_optimized() == is_optimized, "must agree"); |
555 assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call"); |
558 assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call"); |
556 // Reset call site |
559 // Reset call site |
557 MutexLockerEx pl(SafepointSynchronize::is_at_safepoint() ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag); |
560 MutexLockerEx pl(SafepointSynchronize::is_at_safepoint() ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag); |
558 #ifdef ASSERT |
561 #ifdef ASSERT |
559 CodeBlob* cb = CodeCache::find_blob_unsafe(this); |
562 CodeBlob* cb = CodeCache::find_blob_unsafe(this); |
560 assert(cb != NULL && cb->is_nmethod(), "must be nmethod"); |
563 assert(cb != NULL && cb->is_compiled(), "must be compiled"); |
561 #endif |
564 #endif |
562 set_destination_mt_safe(SharedRuntime::get_resolve_static_call_stub()); |
565 set_destination_mt_safe(SharedRuntime::get_resolve_static_call_stub()); |
563 |
566 |
564 // Do not reset stub here: It is too expensive to call find_stub. |
567 // Do not reset stub here: It is too expensive to call find_stub. |
565 // Instead, rely on caller (nmethod::clear_inline_caches) to clear |
568 // Instead, rely on caller (nmethod::clear_inline_caches) to clear |
577 |
580 |
578 |
581 |
579 bool CompiledStaticCall::is_call_to_interpreted() const { |
582 bool CompiledStaticCall::is_call_to_interpreted() const { |
580 // It is a call to interpreted, if it calls to a stub. Hence, the destination |
583 // It is a call to interpreted, if it calls to a stub. Hence, the destination |
581 // must be in the stub part of the nmethod that contains the call |
584 // must be in the stub part of the nmethod that contains the call |
582 nmethod* nm = CodeCache::find_nmethod(instruction_address()); |
585 CompiledMethod* cm = CodeCache::find_compiled(instruction_address()); |
583 return nm->stub_contains(destination()); |
586 return cm->stub_contains(destination()); |
584 } |
587 } |
585 |
588 |
586 void CompiledStaticCall::set(const StaticCallInfo& info) { |
589 void CompiledStaticCall::set(const StaticCallInfo& info) { |
587 assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call"); |
590 assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call"); |
588 MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); |
591 MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); |
610 |
613 |
611 |
614 |
612 // Compute settings for a CompiledStaticCall. Since we might have to set |
615 // Compute settings for a CompiledStaticCall. Since we might have to set |
613 // the stub when calling to the interpreter, we need to return arguments. |
616 // the stub when calling to the interpreter, we need to return arguments. |
614 void CompiledStaticCall::compute_entry(const methodHandle& m, StaticCallInfo& info) { |
617 void CompiledStaticCall::compute_entry(const methodHandle& m, StaticCallInfo& info) { |
615 nmethod* m_code = m->code(); |
618 CompiledMethod* m_code = m->code(); |
616 info._callee = m; |
619 info._callee = m; |
617 if (m_code != NULL && m_code->is_in_use()) { |
620 if (m_code != NULL && m_code->is_in_use()) { |
618 info._to_interpreter = false; |
621 info._to_interpreter = false; |
619 info._entry = m_code->verified_entry_point(); |
622 info._entry = m_code->verified_entry_point(); |
620 } else { |
623 } else { |