977 for (int idx = 0; idx < length(); idx++) {
978 oop mem_name = JNIHandles::resolve(this->at(idx));
979 if (mem_name != NULL) {
980 java_lang_invoke_MemberName::adjust_vmtarget(mem_name, old_method, new_method,
981 trace_name_printed);
982 }
983 }
984 }
985 }
986 #endif // INCLUDE_JVMTI
987
988 //
989 // Here are the native methods in java.lang.invoke.MethodHandleNatives
990 // They are the private interface between this JVM and the HotSpot-specific
991 // Java code that implements JSR 292 method handles.
992 //
993 // Note: We use a JVM_ENTRY macro to define each of these, for this is the way
994 // that intrinsic (non-JNI) native methods are defined in HotSpot.
995 //
996
997 JVM_ENTRY(jint, MHN_getConstant(JNIEnv *env, jobject igcls, jint which)) {
998 switch (which) {
999 case MethodHandles::GC_COUNT_GWT:
1000 #ifdef COMPILER2
1001 return true;
1002 #else
1003 return false;
1004 #endif
1005 }
1006 return 0;
1007 }
1008 JVM_END
1009
1010 #ifndef PRODUCT
1011 #define EACH_NAMED_CON(template, requirement) \
1012 template(MethodHandles,GC_COUNT_GWT) \
1013 template(java_lang_invoke_MemberName,MN_IS_METHOD) \
1014 template(java_lang_invoke_MemberName,MN_IS_CONSTRUCTOR) \
1015 template(java_lang_invoke_MemberName,MN_IS_FIELD) \
1016 template(java_lang_invoke_MemberName,MN_IS_TYPE) \
1017 template(java_lang_invoke_MemberName,MN_CALLER_SENSITIVE) \
1018 template(java_lang_invoke_MemberName,MN_SEARCH_SUPERCLASSES) \
1019 template(java_lang_invoke_MemberName,MN_SEARCH_INTERFACES) \
1020 template(java_lang_invoke_MemberName,MN_REFERENCE_KIND_SHIFT) \
1021 template(java_lang_invoke_MemberName,MN_REFERENCE_KIND_MASK) \
1022 template(MethodHandles,GC_LAMBDA_SUPPORT) \
1023 /*end*/
1024
1025 #define IGNORE_REQ(req_expr) /* req_expr */
1026 #define ONE_PLUS(scope,value) 1+
1027 static const int con_value_count = EACH_NAMED_CON(ONE_PLUS, IGNORE_REQ) 0;
1028 #define VALUE_COMMA(scope,value) scope::value,
1029 static const int con_values[con_value_count+1] = { EACH_NAMED_CON(VALUE_COMMA, IGNORE_REQ) 0 };
1030 #define STRING_NULL(scope,value) #value "\0"
1031 static const char con_names[] = { EACH_NAMED_CON(STRING_NULL, IGNORE_REQ) };
1032
1033 static bool advertise_con_value(int which) {
1034 if (which < 0) return false;
1035 bool ok = true;
1036 int count = 0;
1037 #define INC_COUNT(scope,value) \
1038 ++count;
1039 #define CHECK_REQ(req_expr) \
1040 if (which < count) return ok; \
1041 ok = (req_expr);
1042 EACH_NAMED_CON(INC_COUNT, CHECK_REQ);
1296
1297 #define LANG "Ljava/lang/"
1298 #define JLINV "Ljava/lang/invoke/"
1299
1300 #define OBJ LANG"Object;"
1301 #define CLS LANG"Class;"
1302 #define STRG LANG"String;"
1303 #define CS JLINV"CallSite;"
1304 #define MT JLINV"MethodType;"
1305 #define MH JLINV"MethodHandle;"
1306 #define MEM JLINV"MemberName;"
1307
1308 #define CC (char*) /*cast a literal from (const char*)*/
1309 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
1310
1311 // These are the native methods on java.lang.invoke.MethodHandleNatives.
1312 static JNINativeMethod MHN_methods[] = {
1313 {CC"init", CC"("MEM""OBJ")V", FN_PTR(MHN_init_Mem)},
1314 {CC"expand", CC"("MEM")V", FN_PTR(MHN_expand_Mem)},
1315 {CC"resolve", CC"("MEM""CLS")"MEM, FN_PTR(MHN_resolve_Mem)},
1316 {CC"getConstant", CC"(I)I", FN_PTR(MHN_getConstant)},
1317 // static native int getNamedCon(int which, Object[] name)
1318 {CC"getNamedCon", CC"(I["OBJ")I", FN_PTR(MHN_getNamedCon)},
1319 // static native int getMembers(Class<?> defc, String matchName, String matchSig,
1320 // int matchFlags, Class<?> caller, int skip, MemberName[] results);
1321 {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)},
1322 {CC"objectFieldOffset", CC"("MEM")J", FN_PTR(MHN_objectFieldOffset)},
1323 {CC"setCallSiteTargetNormal", CC"("CS""MH")V", FN_PTR(MHN_setCallSiteTargetNormal)},
1324 {CC"setCallSiteTargetVolatile", CC"("CS""MH")V", FN_PTR(MHN_setCallSiteTargetVolatile)},
1325 {CC"staticFieldOffset", CC"("MEM")J", FN_PTR(MHN_staticFieldOffset)},
1326 {CC"staticFieldBase", CC"("MEM")"OBJ, FN_PTR(MHN_staticFieldBase)},
1327 {CC"getMemberVMInfo", CC"("MEM")"OBJ, FN_PTR(MHN_getMemberVMInfo)}
1328 };
1329
1330 static JNINativeMethod MH_methods[] = {
1331 // UnsupportedOperationException throwers
1332 {CC"invoke", CC"(["OBJ")"OBJ, FN_PTR(MH_invoke_UOE)},
1333 {CC"invokeExact", CC"(["OBJ")"OBJ, FN_PTR(MH_invokeExact_UOE)}
1334 };
1335
1336 /**
|
977 for (int idx = 0; idx < length(); idx++) {
978 oop mem_name = JNIHandles::resolve(this->at(idx));
979 if (mem_name != NULL) {
980 java_lang_invoke_MemberName::adjust_vmtarget(mem_name, old_method, new_method,
981 trace_name_printed);
982 }
983 }
984 }
985 }
986 #endif // INCLUDE_JVMTI
987
988 //
989 // Here are the native methods in java.lang.invoke.MethodHandleNatives
990 // They are the private interface between this JVM and the HotSpot-specific
991 // Java code that implements JSR 292 method handles.
992 //
993 // Note: We use a JVM_ENTRY macro to define each of these, for this is the way
994 // that intrinsic (non-JNI) native methods are defined in HotSpot.
995 //
996
997 #ifndef PRODUCT
998 #define EACH_NAMED_CON(template, requirement) \
999 template(java_lang_invoke_MemberName,MN_IS_METHOD) \
1000 template(java_lang_invoke_MemberName,MN_IS_CONSTRUCTOR) \
1001 template(java_lang_invoke_MemberName,MN_IS_FIELD) \
1002 template(java_lang_invoke_MemberName,MN_IS_TYPE) \
1003 template(java_lang_invoke_MemberName,MN_CALLER_SENSITIVE) \
1004 template(java_lang_invoke_MemberName,MN_SEARCH_SUPERCLASSES) \
1005 template(java_lang_invoke_MemberName,MN_SEARCH_INTERFACES) \
1006 template(java_lang_invoke_MemberName,MN_REFERENCE_KIND_SHIFT) \
1007 template(java_lang_invoke_MemberName,MN_REFERENCE_KIND_MASK) \
1008 /*end*/
1009
1010 #define IGNORE_REQ(req_expr) /* req_expr */
1011 #define ONE_PLUS(scope,value) 1+
1012 static const int con_value_count = EACH_NAMED_CON(ONE_PLUS, IGNORE_REQ) 0;
1013 #define VALUE_COMMA(scope,value) scope::value,
1014 static const int con_values[con_value_count+1] = { EACH_NAMED_CON(VALUE_COMMA, IGNORE_REQ) 0 };
1015 #define STRING_NULL(scope,value) #value "\0"
1016 static const char con_names[] = { EACH_NAMED_CON(STRING_NULL, IGNORE_REQ) };
1017
1018 static bool advertise_con_value(int which) {
1019 if (which < 0) return false;
1020 bool ok = true;
1021 int count = 0;
1022 #define INC_COUNT(scope,value) \
1023 ++count;
1024 #define CHECK_REQ(req_expr) \
1025 if (which < count) return ok; \
1026 ok = (req_expr);
1027 EACH_NAMED_CON(INC_COUNT, CHECK_REQ);
1281
1282 #define LANG "Ljava/lang/"
1283 #define JLINV "Ljava/lang/invoke/"
1284
1285 #define OBJ LANG"Object;"
1286 #define CLS LANG"Class;"
1287 #define STRG LANG"String;"
1288 #define CS JLINV"CallSite;"
1289 #define MT JLINV"MethodType;"
1290 #define MH JLINV"MethodHandle;"
1291 #define MEM JLINV"MemberName;"
1292
1293 #define CC (char*) /*cast a literal from (const char*)*/
1294 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
1295
1296 // These are the native methods on java.lang.invoke.MethodHandleNatives.
1297 static JNINativeMethod MHN_methods[] = {
1298 {CC"init", CC"("MEM""OBJ")V", FN_PTR(MHN_init_Mem)},
1299 {CC"expand", CC"("MEM")V", FN_PTR(MHN_expand_Mem)},
1300 {CC"resolve", CC"("MEM""CLS")"MEM, FN_PTR(MHN_resolve_Mem)},
1301 // static native int getNamedCon(int which, Object[] name)
1302 {CC"getNamedCon", CC"(I["OBJ")I", FN_PTR(MHN_getNamedCon)},
1303 // static native int getMembers(Class<?> defc, String matchName, String matchSig,
1304 // int matchFlags, Class<?> caller, int skip, MemberName[] results);
1305 {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)},
1306 {CC"objectFieldOffset", CC"("MEM")J", FN_PTR(MHN_objectFieldOffset)},
1307 {CC"setCallSiteTargetNormal", CC"("CS""MH")V", FN_PTR(MHN_setCallSiteTargetNormal)},
1308 {CC"setCallSiteTargetVolatile", CC"("CS""MH")V", FN_PTR(MHN_setCallSiteTargetVolatile)},
1309 {CC"staticFieldOffset", CC"("MEM")J", FN_PTR(MHN_staticFieldOffset)},
1310 {CC"staticFieldBase", CC"("MEM")"OBJ, FN_PTR(MHN_staticFieldBase)},
1311 {CC"getMemberVMInfo", CC"("MEM")"OBJ, FN_PTR(MHN_getMemberVMInfo)}
1312 };
1313
1314 static JNINativeMethod MH_methods[] = {
1315 // UnsupportedOperationException throwers
1316 {CC"invoke", CC"(["OBJ")"OBJ, FN_PTR(MH_invoke_UOE)},
1317 {CC"invokeExact", CC"(["OBJ")"OBJ, FN_PTR(MH_invokeExact_UOE)}
1318 };
1319
1320 /**
|