Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/methodHandles.cpp @ 2416:38fea01eb669
6817525: turn on method handle functionality by default for JSR 292
Summary: After appropriate testing, we need to turn on EnableMethodHandles and EnableInvokeDynamic by default.
Reviewed-by: never, kvn, jrose, phh
author | twisti |
---|---|
date | Thu, 31 Mar 2011 02:31:57 -0700 |
parents | 8033953d67ff |
children | ed69575596ac |
comparison
equal
deleted
inserted
replaced
2415:09f96c3ff1ad | 2416:38fea01eb669 |
---|---|
110 | 110 |
111 //------------------------------------------------------------------------------ | 111 //------------------------------------------------------------------------------ |
112 // MethodHandles::generate_adapters | 112 // MethodHandles::generate_adapters |
113 // | 113 // |
114 void MethodHandles::generate_adapters() { | 114 void MethodHandles::generate_adapters() { |
115 if (!EnableMethodHandles || SystemDictionary::MethodHandle_klass() == NULL) return; | 115 if (!EnableInvokeDynamic || SystemDictionary::MethodHandle_klass() == NULL) return; |
116 | 116 |
117 assert(_adapter_code == NULL, "generate only once"); | 117 assert(_adapter_code == NULL, "generate only once"); |
118 | 118 |
119 ResourceMark rm; | 119 ResourceMark rm; |
120 TraceTime timer("MethodHandles adapters generation", TraceStartupTime); | 120 TraceTime timer("MethodHandles adapters generation", TraceStartupTime); |
141 } | 141 } |
142 | 142 |
143 | 143 |
144 void MethodHandles::set_enabled(bool z) { | 144 void MethodHandles::set_enabled(bool z) { |
145 if (_enabled != z) { | 145 if (_enabled != z) { |
146 guarantee(z && EnableMethodHandles, "can only enable once, and only if -XX:+EnableMethodHandles"); | 146 guarantee(z && EnableInvokeDynamic, "can only enable once, and only if -XX:+EnableInvokeDynamic"); |
147 _enabled = z; | 147 _enabled = z; |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 // Note: A method which does not have a TRAPS argument cannot block in the GC | 151 // Note: A method which does not have a TRAPS argument cannot block in the GC |
2577 // static native int getMembers(Class<?> defc, String matchName, String matchSig, | 2577 // static native int getMembers(Class<?> defc, String matchName, String matchSig, |
2578 // int matchFlags, Class<?> caller, int skip, MemberName[] results); | 2578 // int matchFlags, Class<?> caller, int skip, MemberName[] results); |
2579 {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)} | 2579 {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)} |
2580 }; | 2580 }; |
2581 | 2581 |
2582 // More entry points specifically for EnableInvokeDynamic. | |
2583 // FIXME: Remove methods2 after AllowTransitionalJSR292 is removed. | 2582 // FIXME: Remove methods2 after AllowTransitionalJSR292 is removed. |
2584 static JNINativeMethod methods2[] = { | 2583 static JNINativeMethod methods2[] = { |
2585 {CC"registerBootstrap", CC"("CLS MH")V", FN_PTR(MHN_registerBootstrap)}, | 2584 {CC"registerBootstrap", CC"("CLS MH")V", FN_PTR(MHN_registerBootstrap)}, |
2586 {CC"getBootstrap", CC"("CLS")"MH, FN_PTR(MHN_getBootstrap)}, | 2585 {CC"getBootstrap", CC"("CLS")"MH, FN_PTR(MHN_getBootstrap)}, |
2587 {CC"setCallSiteTarget", CC"("CST MH")V", FN_PTR(MHN_setCallSiteTarget)} | 2586 {CC"setCallSiteTarget", CC"("CST MH")V", FN_PTR(MHN_setCallSiteTarget)} |
2616 // This one function is exported, used by NativeLookup. | 2615 // This one function is exported, used by NativeLookup. |
2617 | 2616 |
2618 JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { | 2617 JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { |
2619 assert(MethodHandles::spot_check_entry_names(), "entry enum is OK"); | 2618 assert(MethodHandles::spot_check_entry_names(), "entry enum is OK"); |
2620 | 2619 |
2621 // note: this explicit warning-producing stuff will be replaced by auto-detection of the JSR 292 classes | 2620 if (!EnableInvokeDynamic) { |
2622 | 2621 warning("JSR 292 is disabled in this JVM. Use -XX:+UnlockDiagnosticVMOptions -XX:+EnableInvokeDynamic to enable."); |
2623 if (!EnableMethodHandles) { | |
2624 warning("JSR 292 method handles are disabled in this JVM. Use -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles to enable."); | |
2625 return; // bind nothing | 2622 return; // bind nothing |
2626 } | 2623 } |
2627 | 2624 |
2628 if (SystemDictionary::MethodHandleNatives_klass() != NULL && | 2625 if (SystemDictionary::MethodHandleNatives_klass() != NULL && |
2629 SystemDictionary::MethodHandleNatives_klass() != java_lang_Class::as_klassOop(JNIHandles::resolve(MHN_class))) { | 2626 SystemDictionary::MethodHandleNatives_klass() != java_lang_Class::as_klassOop(JNIHandles::resolve(MHN_class))) { |
2700 | 2697 |
2701 MethodHandles::generate_adapters(); | 2698 MethodHandles::generate_adapters(); |
2702 MethodHandles::set_enabled(true); | 2699 MethodHandles::set_enabled(true); |
2703 } | 2700 } |
2704 | 2701 |
2705 if (!EnableInvokeDynamic) { | |
2706 warning("JSR 292 invokedynamic is disabled in this JVM. Use -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic to enable."); | |
2707 return; // bind nothing | |
2708 } | |
2709 | |
2710 if (AllowTransitionalJSR292) { | 2702 if (AllowTransitionalJSR292) { |
2711 ThreadToNativeFromVM ttnfv(thread); | 2703 ThreadToNativeFromVM ttnfv(thread); |
2712 | 2704 |
2713 int status = env->RegisterNatives(MHN_class, methods2, sizeof(methods2)/sizeof(JNINativeMethod)); | 2705 int status = env->RegisterNatives(MHN_class, methods2, sizeof(methods2)/sizeof(JNINativeMethod)); |
2714 if (env->ExceptionOccurred()) { | 2706 if (env->ExceptionOccurred()) { |