729 |
729 |
730 // ------------------------------------------------------------------ |
730 // ------------------------------------------------------------------ |
731 // ciEnv::get_fake_invokedynamic_method_impl |
731 // ciEnv::get_fake_invokedynamic_method_impl |
732 ciMethod* ciEnv::get_fake_invokedynamic_method_impl(constantPoolHandle cpool, |
732 ciMethod* ciEnv::get_fake_invokedynamic_method_impl(constantPoolHandle cpool, |
733 int index, Bytecodes::Code bc) { |
733 int index, Bytecodes::Code bc) { |
|
734 // Compare the following logic with InterpreterRuntime::resolve_invokedynamic. |
734 assert(bc == Bytecodes::_invokedynamic, "must be invokedynamic"); |
735 assert(bc == Bytecodes::_invokedynamic, "must be invokedynamic"); |
735 |
736 |
736 // Get the CallSite from the constant pool cache. |
737 bool is_resolved = cpool->cache()->main_entry_at(index)->is_resolved(bc); |
737 ConstantPoolCacheEntry* cpc_entry = cpool->cache()->secondary_entry_at(index); |
738 if (is_resolved && (oop) cpool->cache()->secondary_entry_at(index)->f1() == NULL) |
738 assert(cpc_entry != NULL && cpc_entry->is_secondary_entry(), "sanity"); |
739 // FIXME: code generation could allow for null (unlinked) call site |
739 Handle call_site = cpc_entry->f1(); |
740 is_resolved = false; |
740 |
741 |
741 // Call site might not be linked yet. |
742 // Call site might not be resolved yet. We could create a real invoker method from the |
742 if (call_site.is_null()) { |
743 // compiler, but it is simpler to stop the code path here with an unlinked method. |
|
744 if (!is_resolved) { |
743 ciInstanceKlass* mh_klass = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass(); |
745 ciInstanceKlass* mh_klass = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass(); |
744 ciSymbol* sig_sym = get_object(cpool->signature_ref_at(index))->as_symbol(); |
746 ciSymbol* sig_sym = get_object(cpool->signature_ref_at(index))->as_symbol(); |
745 return get_unloaded_method(mh_klass, ciSymbol::invoke_name(), sig_sym); |
747 return get_unloaded_method(mh_klass, ciSymbol::invokeExact_name(), sig_sym); |
746 } |
748 } |
747 |
749 |
748 // Get the methodOop from the CallSite. |
750 // Get the invoker methodOop from the constant pool. |
749 methodOop method_oop = (methodOop) java_dyn_CallSite::vmmethod(call_site()); |
751 intptr_t f2_value = cpool->cache()->main_entry_at(index)->f2(); |
750 assert(method_oop != NULL, "sanity"); |
752 methodOop signature_invoker = methodOop(f2_value); |
751 assert(method_oop->is_method_handle_invoke(), "consistent"); |
753 assert(signature_invoker != NULL && signature_invoker->is_method() && signature_invoker->is_method_handle_invoke(), |
752 |
754 "correct result from LinkResolver::resolve_invokedynamic"); |
753 return get_object(method_oop)->as_method(); |
755 |
|
756 return get_object(signature_invoker)->as_method(); |
754 } |
757 } |
755 |
758 |
756 |
759 |
757 // ------------------------------------------------------------------ |
760 // ------------------------------------------------------------------ |
758 // ciEnv::get_instance_klass_for_declared_method_holder |
761 // ciEnv::get_instance_klass_for_declared_method_holder |