Mercurial > hg > graal-compiler
comparison src/share/vm/classfile/systemDictionary.cpp @ 1602:136b78722a08
6939203: JSR 292 needs method handle constants
Summary: Add new CP types CONSTANT_MethodHandle, CONSTANT_MethodType; extend 'ldc' bytecode.
Reviewed-by: twisti, never
author | jrose |
---|---|
date | Wed, 09 Jun 2010 18:50:45 -0700 |
parents | c18cbe5936b8 |
children | 083fde3b838e |
comparison
equal
deleted
inserted
replaced
1585:49fac4acd688 | 1602:136b78722a08 |
---|---|
2452 // report back to the caller with the MethodType and the "on_bcp" flag | 2452 // report back to the caller with the MethodType and the "on_bcp" flag |
2453 return_bcp_flag = is_on_bcp; | 2453 return_bcp_flag = is_on_bcp; |
2454 return Handle(THREAD, (oop) result.get_jobject()); | 2454 return Handle(THREAD, (oop) result.get_jobject()); |
2455 } | 2455 } |
2456 | 2456 |
2457 // Ask Java code to find or construct a method handle constant. | |
2458 Handle SystemDictionary::link_method_handle_constant(KlassHandle caller, | |
2459 int ref_kind, //e.g., JVM_REF_invokeVirtual | |
2460 KlassHandle callee, | |
2461 symbolHandle name_sym, | |
2462 symbolHandle signature, | |
2463 TRAPS) { | |
2464 Handle empty; | |
2465 Handle name = java_lang_String::create_from_symbol(name_sym(), CHECK_(empty)); | |
2466 Handle type; | |
2467 if (signature->utf8_length() > 0 && signature->byte_at(0) == '(') { | |
2468 bool ignore_is_on_bcp = false; | |
2469 type = find_method_handle_type(signature, caller, ignore_is_on_bcp, CHECK_(empty)); | |
2470 } else { | |
2471 SignatureStream ss(signature(), false); | |
2472 if (!ss.is_done()) { | |
2473 oop mirror = ss.as_java_mirror(caller->class_loader(), caller->protection_domain(), | |
2474 SignatureStream::NCDFError, CHECK_(empty)); | |
2475 type = Handle(THREAD, mirror); | |
2476 ss.next(); | |
2477 if (!ss.is_done()) type = Handle(); // error! | |
2478 } | |
2479 } | |
2480 if (type.is_null()) { | |
2481 THROW_MSG_(vmSymbols::java_lang_LinkageError(), "bad signature", empty); | |
2482 } | |
2483 | |
2484 // call sun.dyn.MethodHandleNatives::linkMethodHandleConstant(Class caller, int refKind, Class callee, String name, Object type) -> MethodHandle | |
2485 JavaCallArguments args; | |
2486 args.push_oop(caller->java_mirror()); // the referring class | |
2487 args.push_int(ref_kind); | |
2488 args.push_oop(callee->java_mirror()); // the target class | |
2489 args.push_oop(name()); | |
2490 args.push_oop(type()); | |
2491 JavaValue result(T_OBJECT); | |
2492 JavaCalls::call_static(&result, | |
2493 SystemDictionary::MethodHandleNatives_klass(), | |
2494 vmSymbols::linkMethodHandleConstant_name(), | |
2495 vmSymbols::linkMethodHandleConstant_signature(), | |
2496 &args, CHECK_(empty)); | |
2497 return Handle(THREAD, (oop) result.get_jobject()); | |
2498 } | |
2457 | 2499 |
2458 // Ask Java code to find or construct a java.dyn.CallSite for the given | 2500 // Ask Java code to find or construct a java.dyn.CallSite for the given |
2459 // name and signature, as interpreted relative to the given class loader. | 2501 // name and signature, as interpreted relative to the given class loader. |
2460 Handle SystemDictionary::make_dynamic_call_site(Handle bootstrap_method, | 2502 Handle SystemDictionary::make_dynamic_call_site(Handle bootstrap_method, |
2461 symbolHandle name, | 2503 symbolHandle name, |