comparison src/share/vm/interpreter/interpreterRuntime.cpp @ 1660:083fde3b838e

6964498: JSR 292 invokedynamic sites need local bootstrap methods Summary: Add JVM_CONSTANT_InvokeDynamic records to constant pool to determine per-instruction BSMs. Reviewed-by: twisti
author jrose
date Thu, 15 Jul 2010 18:40:45 -0700
parents d93949c5bdcc
children 3e8fbc61cee8
comparison
equal deleted inserted replaced
1649:a528509c992b 1660:083fde3b838e
700 700
701 const Bytecodes::Code bytecode = Bytecodes::_invokedynamic; 701 const Bytecodes::Code bytecode = Bytecodes::_invokedynamic;
702 702
703 methodHandle caller_method(thread, method(thread)); 703 methodHandle caller_method(thread, method(thread));
704 704
705 // first find the bootstrap method
706 KlassHandle caller_klass(thread, caller_method->method_holder());
707 Handle bootm = SystemDictionary::find_bootstrap_method(caller_klass, CHECK);
708
709 constantPoolHandle pool(thread, caller_method->constants()); 705 constantPoolHandle pool(thread, caller_method->constants());
710 pool->set_invokedynamic(); // mark header to flag active call sites 706 pool->set_invokedynamic(); // mark header to flag active call sites
711 707
712 int caller_bci = 0; 708 int caller_bci = 0;
713 int site_index = 0; 709 int site_index = 0;
724 if (!pool->cache()->entry_at(main_index)->is_resolved(bytecode)) { 720 if (!pool->cache()->entry_at(main_index)->is_resolved(bytecode)) {
725 JvmtiHideSingleStepping jhss(thread); 721 JvmtiHideSingleStepping jhss(thread);
726 CallInfo info; 722 CallInfo info;
727 LinkResolver::resolve_invoke(info, Handle(), pool, 723 LinkResolver::resolve_invoke(info, Handle(), pool,
728 site_index, bytecode, CHECK); 724 site_index, bytecode, CHECK);
729 // The main entry corresponds to a JVM_CONSTANT_NameAndType, and serves 725 // The main entry corresponds to a JVM_CONSTANT_InvokeDynamic, and serves
730 // as a common reference point for all invokedynamic call sites with 726 // as a common reference point for all invokedynamic call sites with
731 // that exact call descriptor. We will link it in the CP cache exactly 727 // that exact call descriptor. We will link it in the CP cache exactly
732 // as if it were an invokevirtual of MethodHandle.invoke. 728 // as if it were an invokevirtual of MethodHandle.invoke.
733 pool->cache()->entry_at(main_index)->set_method( 729 pool->cache()->entry_at(main_index)->set_method(
734 bytecode, 730 bytecode,
735 info.resolved_method(), 731 info.resolved_method(),
736 info.vtable_index()); 732 info.vtable_index());
737 assert(pool->cache()->entry_at(main_index)->is_vfinal(), "f2 must be a methodOop");
738 } 733 }
739 734
740 // The method (f2 entry) of the main entry is the MH.invoke for the 735 // The method (f2 entry) of the main entry is the MH.invoke for the
741 // invokedynamic target call signature. 736 // invokedynamic target call signature.
742 intptr_t f2_value = pool->cache()->entry_at(main_index)->f2(); 737 oop f1_value = pool->cache()->entry_at(main_index)->f1();
743 methodHandle signature_invoker(THREAD, (methodOop) f2_value); 738 methodHandle signature_invoker(THREAD, (methodOop) f1_value);
744 assert(signature_invoker.not_null() && signature_invoker->is_method() && signature_invoker->is_method_handle_invoke(), 739 assert(signature_invoker.not_null() && signature_invoker->is_method() && signature_invoker->is_method_handle_invoke(),
745 "correct result from LinkResolver::resolve_invokedynamic"); 740 "correct result from LinkResolver::resolve_invokedynamic");
746 741
742 Handle bootm = SystemDictionary::find_bootstrap_method(caller_method, caller_bci,
743 main_index, CHECK);
744 if (bootm.is_null()) {
745 THROW_MSG(vmSymbols::java_lang_IllegalStateException(),
746 "no bootstrap method found for invokedynamic");
747 }
748
749 // Short circuit if CallSite has been bound already:
750 if (!pool->cache()->secondary_entry_at(site_index)->is_f1_null())
751 return;
752
747 symbolHandle call_site_name(THREAD, pool->name_ref_at(site_index)); 753 symbolHandle call_site_name(THREAD, pool->name_ref_at(site_index));
748 754
749 Handle info; // NYI: Other metadata from a new kind of CP entry. (Annotations?) 755 Handle info; // NYI: Other metadata from a new kind of CP entry. (Annotations?)
750
751 // this is the index which gets stored on the CallSite object (as "callerPosition"):
752 int call_site_position = constantPoolCacheOopDesc::decode_secondary_index(site_index);
753 756
754 Handle call_site 757 Handle call_site
755 = SystemDictionary::make_dynamic_call_site(bootm, 758 = SystemDictionary::make_dynamic_call_site(bootm,
756 // Callee information: 759 // Callee information:
757 call_site_name, 760 call_site_name,