Mercurial > hg > truffle
comparison src/share/vm/oops/methodOop.cpp @ 1507:cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
Summary: split MethodHandle.invoke into invokeExact and invokeGeneric; also clean up JVM-to-Java interfaces
Reviewed-by: twisti
author | jrose |
---|---|
date | Sat, 01 May 2010 02:42:18 -0700 |
parents | 2338d41fbd81 |
children | ef1a1d051971 |
comparison
equal
deleted
inserted
replaced
1506:2338d41fbd81 | 1507:cd5dbf694d45 |
---|---|
805 | 805 |
806 // caching this method should be just fine | 806 // caching this method should be just fine |
807 return false; | 807 return false; |
808 } | 808 } |
809 | 809 |
810 bool methodOopDesc::is_method_handle_invoke_name(vmSymbols::SID name_sid) { | |
811 switch (name_sid) { | |
812 case vmSymbols::VM_SYMBOL_ENUM_NAME(invoke_name): // FIXME: remove this transitional form | |
813 case vmSymbols::VM_SYMBOL_ENUM_NAME(invokeExact_name): | |
814 case vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name): | |
815 return true; | |
816 } | |
817 return false; | |
818 } | |
819 | |
810 // Constant pool structure for invoke methods: | 820 // Constant pool structure for invoke methods: |
811 enum { | 821 enum { |
812 _imcp_invoke_name = 1, // utf8: 'invoke' | 822 _imcp_invoke_name = 1, // utf8: 'invokeExact' or 'invokeGeneric' |
813 _imcp_invoke_signature, // utf8: (variable symbolOop) | 823 _imcp_invoke_signature, // utf8: (variable symbolOop) |
814 _imcp_method_type_value, // string: (variable java/dyn/MethodType, sic) | 824 _imcp_method_type_value, // string: (variable java/dyn/MethodType, sic) |
815 _imcp_limit | 825 _imcp_limit |
816 }; | 826 }; |
817 | 827 |
837 //------------------------------------------------------------------------------ | 847 //------------------------------------------------------------------------------ |
838 // methodOopDesc::is_method_handle_adapter | 848 // methodOopDesc::is_method_handle_adapter |
839 // | 849 // |
840 // Tests if this method is an internal adapter frame from the | 850 // Tests if this method is an internal adapter frame from the |
841 // MethodHandleCompiler. | 851 // MethodHandleCompiler. |
852 // Must be consistent with MethodHandleCompiler::get_method_oop(). | |
842 bool methodOopDesc::is_method_handle_adapter() const { | 853 bool methodOopDesc::is_method_handle_adapter() const { |
843 return ((name() == vmSymbols::invoke_name() && | 854 return (is_method_handle_invoke_name(name()) && |
844 method_holder() == SystemDictionary::MethodHandle_klass()) | 855 is_synthetic() && |
845 || | 856 MethodHandleCompiler::klass_is_method_handle_adapter_holder(method_holder())); |
846 method_holder() == SystemDictionary::InvokeDynamic_klass()); | |
847 } | 857 } |
848 | 858 |
849 methodHandle methodOopDesc::make_invoke_method(KlassHandle holder, | 859 methodHandle methodOopDesc::make_invoke_method(KlassHandle holder, |
860 symbolHandle name, | |
850 symbolHandle signature, | 861 symbolHandle signature, |
851 Handle method_type, TRAPS) { | 862 Handle method_type, TRAPS) { |
852 methodHandle empty; | 863 methodHandle empty; |
853 | 864 |
854 assert(holder() == SystemDictionary::MethodHandle_klass(), | 865 assert(holder() == SystemDictionary::MethodHandle_klass(), |
863 constantPoolHandle cp; | 874 constantPoolHandle cp; |
864 { | 875 { |
865 constantPoolOop cp_oop = oopFactory::new_constantPool(_imcp_limit, IsSafeConc, CHECK_(empty)); | 876 constantPoolOop cp_oop = oopFactory::new_constantPool(_imcp_limit, IsSafeConc, CHECK_(empty)); |
866 cp = constantPoolHandle(THREAD, cp_oop); | 877 cp = constantPoolHandle(THREAD, cp_oop); |
867 } | 878 } |
868 cp->symbol_at_put(_imcp_invoke_name, vmSymbols::invoke_name()); | 879 cp->symbol_at_put(_imcp_invoke_name, name()); |
869 cp->symbol_at_put(_imcp_invoke_signature, signature()); | 880 cp->symbol_at_put(_imcp_invoke_signature, signature()); |
870 cp->string_at_put(_imcp_method_type_value, vmSymbols::void_signature()); | 881 cp->string_at_put(_imcp_method_type_value, vmSymbols::void_signature()); |
871 cp->set_pool_holder(holder()); | 882 cp->set_pool_holder(holder()); |
872 | 883 |
873 // set up the fancy stuff: | 884 // set up the fancy stuff: |
880 m = methodHandle(THREAD, m_oop); | 891 m = methodHandle(THREAD, m_oop); |
881 } | 892 } |
882 m->set_constants(cp()); | 893 m->set_constants(cp()); |
883 m->set_name_index(_imcp_invoke_name); | 894 m->set_name_index(_imcp_invoke_name); |
884 m->set_signature_index(_imcp_invoke_signature); | 895 m->set_signature_index(_imcp_invoke_signature); |
885 assert(m->name() == vmSymbols::invoke_name(), ""); | 896 assert(is_method_handle_invoke_name(m->name()), ""); |
886 assert(m->signature() == signature(), ""); | 897 assert(m->signature() == signature(), ""); |
887 #ifdef CC_INTERP | 898 #ifdef CC_INTERP |
888 ResultTypeFinder rtf(signature()); | 899 ResultTypeFinder rtf(signature()); |
889 m->set_result_index(rtf.type()); | 900 m->set_result_index(rtf.type()); |
890 #endif | 901 #endif |
1031 // pretend it is the corresponding method in the non-strict class: | 1042 // pretend it is the corresponding method in the non-strict class: |
1032 klass_id = vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_Math); | 1043 klass_id = vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_Math); |
1033 id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags); | 1044 id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags); |
1034 break; | 1045 break; |
1035 } | 1046 } |
1047 break; | |
1048 | |
1049 // Signature-polymorphic methods: MethodHandle.invoke*, InvokeDynamic.*. | |
1050 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_MethodHandle): | |
1051 if (is_static() || !is_native()) break; | |
1052 switch (name_id) { | |
1053 case vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name): | |
1054 id = vmIntrinsics::_invokeGeneric; break; | |
1055 default: | |
1056 if (is_method_handle_invoke_name(name())) | |
1057 id = vmIntrinsics::_invokeExact; | |
1058 break; | |
1059 } | |
1060 break; | |
1061 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_InvokeDynamic): | |
1062 if (!is_static() || !is_native()) break; | |
1063 id = vmIntrinsics::_invokeDynamic; | |
1064 break; | |
1036 } | 1065 } |
1037 | 1066 |
1038 if (id != vmIntrinsics::_none) { | 1067 if (id != vmIntrinsics::_none) { |
1039 // Set up its iid. It is an alias method. | 1068 // Set up its iid. It is an alias method. |
1040 set_intrinsic_id(id); | 1069 set_intrinsic_id(id); |