Mercurial > hg > truffle
comparison src/share/vm/interpreter/linkResolver.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 | 4ce7240d622c |
children | 2ffde6cfe049 |
comparison
equal
deleted
inserted
replaced
1506:2338d41fbd81 | 1507:cd5dbf694d45 |
---|---|
136 // | 136 // |
137 // According to JVM spec. $5.4.3c & $5.4.3d | 137 // According to JVM spec. $5.4.3c & $5.4.3d |
138 | 138 |
139 void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) { | 139 void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) { |
140 methodOop result_oop = klass->uncached_lookup_method(name(), signature()); | 140 methodOop result_oop = klass->uncached_lookup_method(name(), signature()); |
141 if (EnableMethodHandles && result_oop != NULL) { | |
142 switch (result_oop->intrinsic_id()) { | |
143 case vmIntrinsics::_invokeExact: | |
144 case vmIntrinsics::_invokeGeneric: | |
145 case vmIntrinsics::_invokeDynamic: | |
146 // Do not link directly to these. The VM must produce a synthetic one using lookup_implicit_method. | |
147 return; | |
148 } | |
149 } | |
141 result = methodHandle(THREAD, result_oop); | 150 result = methodHandle(THREAD, result_oop); |
142 } | 151 } |
143 | 152 |
144 // returns first instance method | 153 // returns first instance method |
145 void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) { | 154 void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) { |
163 result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name(), signature())); | 172 result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name(), signature())); |
164 } | 173 } |
165 | 174 |
166 void LinkResolver::lookup_implicit_method(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) { | 175 void LinkResolver::lookup_implicit_method(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) { |
167 if (EnableMethodHandles && MethodHandles::enabled() && | 176 if (EnableMethodHandles && MethodHandles::enabled() && |
168 name == vmSymbolHandles::invoke_name() && klass() == SystemDictionary::MethodHandle_klass()) { | 177 klass() == SystemDictionary::MethodHandle_klass() && |
169 methodOop result_oop = SystemDictionary::find_method_handle_invoke(signature, | 178 methodOopDesc::is_method_handle_invoke_name(name())) { |
179 methodOop result_oop = SystemDictionary::find_method_handle_invoke(name, | |
180 signature, | |
170 Handle(), | 181 Handle(), |
171 Handle(), | 182 Handle(), |
172 CHECK); | 183 CHECK); |
173 if (result_oop != NULL) { | 184 if (result_oop != NULL) { |
174 assert(result_oop->is_method_handle_invoke() && result_oop->signature() == signature(), "consistent"); | 185 assert(result_oop->is_method_handle_invoke() && result_oop->signature() == signature(), "consistent"); |
237 | 248 |
238 void LinkResolver::resolve_dynamic_method(methodHandle& resolved_method, KlassHandle& resolved_klass, constantPoolHandle pool, int index, TRAPS) { | 249 void LinkResolver::resolve_dynamic_method(methodHandle& resolved_method, KlassHandle& resolved_klass, constantPoolHandle pool, int index, TRAPS) { |
239 // The class is java.dyn.MethodHandle | 250 // The class is java.dyn.MethodHandle |
240 resolved_klass = SystemDictionaryHandles::MethodHandle_klass(); | 251 resolved_klass = SystemDictionaryHandles::MethodHandle_klass(); |
241 | 252 |
242 symbolHandle method_name = vmSymbolHandles::invoke_name(); | 253 symbolHandle method_name = vmSymbolHandles::invokeExact_name(); |
243 | 254 |
244 symbolHandle method_signature(THREAD, pool->signature_ref_at(index)); | 255 symbolHandle method_signature(THREAD, pool->signature_ref_at(index)); |
245 KlassHandle current_klass (THREAD, pool->pool_holder()); | 256 KlassHandle current_klass (THREAD, pool->pool_holder()); |
246 | 257 |
247 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK); | 258 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK); |
1039 | 1050 |
1040 // This guy is reached from InterpreterRuntime::resolve_invokedynamic. | 1051 // This guy is reached from InterpreterRuntime::resolve_invokedynamic. |
1041 | 1052 |
1042 // At this point, we only need the signature, and can ignore the name. | 1053 // At this point, we only need the signature, and can ignore the name. |
1043 symbolHandle method_signature(THREAD, pool->signature_ref_at(raw_index)); // raw_index works directly | 1054 symbolHandle method_signature(THREAD, pool->signature_ref_at(raw_index)); // raw_index works directly |
1044 symbolHandle method_name = vmSymbolHandles::invoke_name(); | 1055 symbolHandle method_name = vmSymbolHandles::invokeExact_name(); |
1045 KlassHandle resolved_klass = SystemDictionaryHandles::MethodHandle_klass(); | 1056 KlassHandle resolved_klass = SystemDictionaryHandles::MethodHandle_klass(); |
1046 | 1057 |
1047 // JSR 292: this must be an implicitly generated method MethodHandle.invoke(*...) | 1058 // JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) |
1048 // The extra MH receiver will be inserted into the stack on every call. | 1059 // The extra MH receiver will be inserted into the stack on every call. |
1049 methodHandle resolved_method; | 1060 methodHandle resolved_method; |
1050 lookup_implicit_method(resolved_method, resolved_klass, method_name, method_signature, CHECK); | 1061 lookup_implicit_method(resolved_method, resolved_klass, method_name, method_signature, CHECK); |
1051 if (resolved_method.is_null()) { | 1062 if (resolved_method.is_null()) { |
1052 THROW(vmSymbols::java_lang_InternalError()); | 1063 THROW(vmSymbols::java_lang_InternalError()); |