src/share/vm/prims/methodHandles.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
7085860 Cdiff src/share/vm/prims/methodHandles.cpp
src/share/vm/prims/methodHandles.cpp
Print this page
*** 3079,3088 ****
--- 3079,3112 ----
// TO DO: expand at least some of the MemberNames, to avoid massive callbacks
return res;
}
JVM_END
+ JVM_ENTRY(void, MHN_setCallSiteTargetNormal(JNIEnv* env, jobject igcls, jobject call_site_jh, jobject target_jh)) {
+ oop call_site = JNIHandles::resolve_non_null(call_site_jh);
+ oop target = JNIHandles::resolve(target_jh);
+ {
+ // Walk all nmethods depending on this call site.
+ MutexLocker mu(Compile_lock, thread);
+ Universe::flush_dependents_on(call_site, target);
+ }
+ java_lang_invoke_CallSite::set_target(call_site, target);
+ }
+ JVM_END
+
+ JVM_ENTRY(void, MHN_setCallSiteTargetVolatile(JNIEnv* env, jobject igcls, jobject call_site_jh, jobject target_jh)) {
+ oop call_site = JNIHandles::resolve_non_null(call_site_jh);
+ oop target = JNIHandles::resolve(target_jh);
+ {
+ // Walk all nmethods depending on this call site.
+ MutexLocker mu(Compile_lock, thread);
+ Universe::flush_dependents_on(call_site, target);
+ }
+ java_lang_invoke_CallSite::set_target_volatile(call_site, target);
+ }
+ JVM_END
+
methodOop MethodHandles::resolve_raise_exception_method(TRAPS) {
if (_raise_exception_method != NULL) {
// no need to do it twice
return raise_exception_method();
}
*** 3135,3161 ****
JVM_END
/// JVM_RegisterMethodHandleMethods
#define LANG "Ljava/lang/"
#define JLINV "Ljava/lang/invoke/"
#define OBJ LANG"Object;"
#define CLS LANG"Class;"
#define STRG LANG"String;"
#define MT JLINV"MethodType;"
#define MH JLINV"MethodHandle;"
#define MEM JLINV"MemberName;"
#define AMH JLINV"AdapterMethodHandle;"
#define BMH JLINV"BoundMethodHandle;"
#define DMH JLINV"DirectMethodHandle;"
#define CC (char*) /*cast a literal from (const char*)*/
#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
! // These are the native methods on sun.invoke.MethodHandleNatives.
static JNINativeMethod methods[] = {
// void init(MemberName self, AccessibleObject ref)
{CC"init", CC"("AMH""MH"I)V", FN_PTR(MHN_init_AMH)},
{CC"init", CC"("BMH""OBJ"I)V", FN_PTR(MHN_init_BMH)},
{CC"init", CC"("DMH""OBJ"Z"CLS")V", FN_PTR(MHN_init_DMH)},
--- 3159,3188 ----
JVM_END
/// JVM_RegisterMethodHandleMethods
+ #undef CS // Solaris builds complain
+
#define LANG "Ljava/lang/"
#define JLINV "Ljava/lang/invoke/"
#define OBJ LANG"Object;"
#define CLS LANG"Class;"
#define STRG LANG"String;"
+ #define CS JLINV"CallSite;"
#define MT JLINV"MethodType;"
#define MH JLINV"MethodHandle;"
#define MEM JLINV"MemberName;"
#define AMH JLINV"AdapterMethodHandle;"
#define BMH JLINV"BoundMethodHandle;"
#define DMH JLINV"DirectMethodHandle;"
#define CC (char*) /*cast a literal from (const char*)*/
#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
! // These are the native methods on java.lang.invoke.MethodHandleNatives.
static JNINativeMethod methods[] = {
// void init(MemberName self, AccessibleObject ref)
{CC"init", CC"("AMH""MH"I)V", FN_PTR(MHN_init_AMH)},
{CC"init", CC"("BMH""OBJ"I)V", FN_PTR(MHN_init_BMH)},
{CC"init", CC"("DMH""OBJ"Z"CLS")V", FN_PTR(MHN_init_DMH)},
*** 3170,3179 ****
--- 3197,3211 ----
// static native int getMembers(Class<?> defc, String matchName, String matchSig,
// int matchFlags, Class<?> caller, int skip, MemberName[] results);
{CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)}
};
+ static JNINativeMethod call_site_methods[] = {
+ {CC"setCallSiteTargetNormal", CC"("CS""MH")V", FN_PTR(MHN_setCallSiteTargetNormal)},
+ {CC"setCallSiteTargetVolatile", CC"("CS""MH")V", FN_PTR(MHN_setCallSiteTargetVolatile)}
+ };
+
static JNINativeMethod invoke_methods[] = {
// void init(MemberName self, AccessibleObject ref)
{CC"invoke", CC"(["OBJ")"OBJ, FN_PTR(MH_invoke_UOE)},
{CC"invokeExact", CC"(["OBJ")"OBJ, FN_PTR(MH_invokeExact_UOE)}
};
*** 3186,3213 ****
if (!EnableInvokeDynamic) {
warning("JSR 292 is disabled in this JVM. Use -XX:+UnlockDiagnosticVMOptions -XX:+EnableInvokeDynamic to enable.");
return; // bind nothing
}
bool enable_MH = true;
{
ThreadToNativeFromVM ttnfv(thread);
-
int status = env->RegisterNatives(MHN_class, methods, sizeof(methods)/sizeof(JNINativeMethod));
if (!env->ExceptionOccurred()) {
const char* L_MH_name = (JLINV "MethodHandle");
const char* MH_name = L_MH_name+1;
jclass MH_class = env->FindClass(MH_name);
status = env->RegisterNatives(MH_class, invoke_methods, sizeof(invoke_methods)/sizeof(JNINativeMethod));
}
if (env->ExceptionOccurred()) {
- MethodHandles::set_enabled(false);
warning("JSR 292 method handle code is mismatched to this JVM. Disabling support.");
enable_MH = false;
env->ExceptionClear();
}
}
if (enable_MH) {
methodOop raiseException_method = MethodHandles::resolve_raise_exception_method(CHECK);
if (raiseException_method != NULL) {
--- 3218,3250 ----
if (!EnableInvokeDynamic) {
warning("JSR 292 is disabled in this JVM. Use -XX:+UnlockDiagnosticVMOptions -XX:+EnableInvokeDynamic to enable.");
return; // bind nothing
}
+ assert(!MethodHandles::enabled(), "must not be enabled");
bool enable_MH = true;
{
ThreadToNativeFromVM ttnfv(thread);
int status = env->RegisterNatives(MHN_class, methods, sizeof(methods)/sizeof(JNINativeMethod));
if (!env->ExceptionOccurred()) {
const char* L_MH_name = (JLINV "MethodHandle");
const char* MH_name = L_MH_name+1;
jclass MH_class = env->FindClass(MH_name);
status = env->RegisterNatives(MH_class, invoke_methods, sizeof(invoke_methods)/sizeof(JNINativeMethod));
}
if (env->ExceptionOccurred()) {
warning("JSR 292 method handle code is mismatched to this JVM. Disabling support.");
enable_MH = false;
env->ExceptionClear();
}
+
+ status = env->RegisterNatives(MHN_class, call_site_methods, sizeof(call_site_methods)/sizeof(JNINativeMethod));
+ if (env->ExceptionOccurred()) {
+ // Exception is okay until 7087357
+ env->ExceptionClear();
+ }
}
if (enable_MH) {
methodOop raiseException_method = MethodHandles::resolve_raise_exception_method(CHECK);
if (raiseException_method != NULL) {
src/share/vm/prims/methodHandles.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File