comparison src/share/vm/graal/graalVMEntries.cpp @ 3683:345c3bbf9c3c

store RiCompiledMethod in nmethod and: * invalidate RiCompiledMethod when the nmethod is invalidated * invalidate the nmethod when the RiCompiledMethod object is GC'ed
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 18 Nov 2011 11:54:07 +0100
parents 136ea96eb7f8
children 5c8fc9f05960
comparison
equal deleted inserted replaced
3682:6c04a4f268e5 3683:345c3bbf9c3c
932 set_int(env, config, "runtimeCallStackSize", (jint)frame::arg_reg_save_area_bytes); 932 set_int(env, config, "runtimeCallStackSize", (jint)frame::arg_reg_save_area_bytes);
933 set_int(env, config, "klassModifierFlagsOffset", Klass::modifier_flags_offset_in_bytes() + sizeof(oopDesc)); 933 set_int(env, config, "klassModifierFlagsOffset", Klass::modifier_flags_offset_in_bytes() + sizeof(oopDesc));
934 set_int(env, config, "klassOopOffset", java_lang_Class::klass_offset_in_bytes()); 934 set_int(env, config, "klassOopOffset", java_lang_Class::klass_offset_in_bytes());
935 set_boolean(env, config, "isPollingPageFar", Assembler::is_polling_page_far()); 935 set_boolean(env, config, "isPollingPageFar", Assembler::is_polling_page_far());
936 936
937 set_int(env, config, "nmethodEntryOffset", nmethod::verified_entry_point_offset());
938
937 BarrierSet* bs = Universe::heap()->barrier_set(); 939 BarrierSet* bs = Universe::heap()->barrier_set();
938 switch (bs->kind()) { 940 switch (bs->kind()) {
939 case BarrierSet::CardTableModRef: 941 case BarrierSet::CardTableModRef:
940 case BarrierSet::CardTableExtension: { 942 case BarrierSet::CardTableExtension: {
941 jlong base = (jlong)((CardTableModRefBS*)bs)->byte_map_base; 943 jlong base = (jlong)((CardTableModRefBS*)bs)->byte_map_base;
967 set_int_array(env, config, "arrayOffsets", arrayOffsets); 969 set_int_array(env, config, "arrayOffsets", arrayOffsets);
968 set_int(env, config, "arrayClassElementOffset", objArrayKlass::element_klass_offset_in_bytes() + sizeof(oopDesc)); 970 set_int(env, config, "arrayClassElementOffset", objArrayKlass::element_klass_offset_in_bytes() + sizeof(oopDesc));
969 return config; 971 return config;
970 } 972 }
971 973
972 // public long installMethod(HotSpotTargetMethod targetMethod, boolean installCode); 974 // public HotSpotCompiledMethod installMethod(HotSpotTargetMethod targetMethod, boolean installCode);
973 JNIEXPORT jlong JNICALL Java_com_oracle_graal_hotspot_VMEntries_installMethod(JNIEnv *jniEnv, jobject, jobject targetMethod, jboolean install_code) { 975 JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_installMethod(JNIEnv *jniEnv, jobject, jobject targetMethod, jboolean install_code) {
974 VM_ENTRY_MARK; 976 VM_ENTRY_MARK;
975 nmethod* nm = NULL; 977 nmethod* nm = NULL;
976 if (CURRENT_ENV == NULL) { 978 if (CURRENT_ENV == NULL) {
977 Arena arena; 979 Arena arena;
978 ciEnv env(&arena); 980 ciEnv env(&arena);
979 ResourceMark rm; 981 ResourceMark rm;
980 CodeInstaller installer(JNIHandles::resolve(targetMethod), nm, install_code != 0); 982 CodeInstaller installer(JNIHandles::resolve(targetMethod), nm, install_code != 0);
981 } else { 983 } else {
982 ResourceMark rm; 984 ResourceMark rm;
983 CodeInstaller installer(JNIHandles::resolve(targetMethod), nm, install_code != 0); 985 CodeInstaller installer(JNIHandles::resolve(targetMethod), nm, install_code != 0);
984 } 986
985 return (jlong) nm; 987 if (CURRENT_ENV->failing()) {
988 tty->print_cr("failing: %s", CURRENT_ENV->failure_reason());
989 }
990 }
991
992 // if install_code is true then we installed the code into the given method, no need to return an RiCompiledMethod
993 if (!install_code && nm != NULL) {
994 instanceKlass::cast(HotSpotCompiledMethod::klass())->initialize(CHECK_NULL);
995 Handle obj = instanceKlass::cast(HotSpotCompiledMethod::klass())->allocate_permanent_instance(CHECK_NULL);
996 assert(obj() != NULL, "must succeed in allocating instance");
997 HotSpotCompiledMethod::set_nmethod(obj, (jlong) nm);
998 HotSpotCompiledMethod::set_method(obj, HotSpotTargetMethod::method(targetMethod));
999 nm->set_graal_compiled_method(obj());
1000 return JNIHandles::make_local(obj());
1001 } else {
1002 return NULL;
1003 }
986 } 1004 }
987 1005
988 // public HotSpotProxy installStub(HotSpotTargetMethod targetMethod, String name); 1006 // public HotSpotProxy installStub(HotSpotTargetMethod targetMethod, String name);
989 JNIEXPORT jlong JNICALL Java_com_oracle_graal_hotspot_VMEntries_installStub(JNIEnv *jniEnv, jobject, jobject targetMethod) { 1007 JNIEXPORT jlong JNICALL Java_com_oracle_graal_hotspot_VMEntries_installStub(JNIEnv *jniEnv, jobject, jobject targetMethod) {
990 VM_ENTRY_MARK; 1008 VM_ENTRY_MARK;
1035 #define CONSTANT_POOL "Lcom/sun/cri/ri/RiConstantPool;" 1053 #define CONSTANT_POOL "Lcom/sun/cri/ri/RiConstantPool;"
1036 #define EXCEPTION_HANDLERS "[Lcom/sun/cri/ri/RiExceptionHandler;" 1054 #define EXCEPTION_HANDLERS "[Lcom/sun/cri/ri/RiExceptionHandler;"
1037 #define TARGET_METHOD "Lcom/oracle/max/graal/hotspot/HotSpotTargetMethod;" 1055 #define TARGET_METHOD "Lcom/oracle/max/graal/hotspot/HotSpotTargetMethod;"
1038 #define CONFIG "Lcom/oracle/max/graal/hotspot/HotSpotVMConfig;" 1056 #define CONFIG "Lcom/oracle/max/graal/hotspot/HotSpotVMConfig;"
1039 #define HS_METHOD "Lcom/oracle/max/graal/hotspot/HotSpotMethod;" 1057 #define HS_METHOD "Lcom/oracle/max/graal/hotspot/HotSpotMethod;"
1058 #define HS_COMP_METHOD "Lcom/oracle/max/graal/hotspot/HotSpotCompiledMethod;"
1040 #define CI_CONSTANT "Lcom/sun/cri/ci/CiConstant;" 1059 #define CI_CONSTANT "Lcom/sun/cri/ci/CiConstant;"
1041 #define CI_KIND "Lcom/sun/cri/ci/CiKind;" 1060 #define CI_KIND "Lcom/sun/cri/ci/CiKind;"
1042 #define CI_RUNTIME_CALL "Lcom/sun/cri/ci/CiRuntimeCall;" 1061 #define CI_RUNTIME_CALL "Lcom/sun/cri/ci/CiRuntimeCall;"
1043 #define STRING "Ljava/lang/String;" 1062 #define STRING "Ljava/lang/String;"
1044 #define OBJECT "Ljava/lang/Object;" 1063 #define OBJECT "Ljava/lang/Object;"
1073 {CC"RiType_isInitialized", CC"("RESOLVED_TYPE")Z", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiType_1isInitialized)}, 1092 {CC"RiType_isInitialized", CC"("RESOLVED_TYPE")Z", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_RiType_1isInitialized)},
1074 {CC"getPrimitiveArrayType", CC"("CI_KIND")"TYPE, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_getPrimitiveArrayType)}, 1093 {CC"getPrimitiveArrayType", CC"("CI_KIND")"TYPE, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_getPrimitiveArrayType)},
1075 {CC"getMaxCallTargetOffset", CC"("CI_RUNTIME_CALL")J", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_getMaxCallTargetOffset)}, 1094 {CC"getMaxCallTargetOffset", CC"("CI_RUNTIME_CALL")J", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_getMaxCallTargetOffset)},
1076 {CC"getType", CC"("CLASS")"TYPE, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_getType)}, 1095 {CC"getType", CC"("CLASS")"TYPE, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_getType)},
1077 {CC"getConfiguration", CC"()"CONFIG, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_getConfiguration)}, 1096 {CC"getConfiguration", CC"()"CONFIG, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_getConfiguration)},
1078 {CC"installMethod", CC"("TARGET_METHOD"Z)J", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_installMethod)}, 1097 {CC"installMethod", CC"("TARGET_METHOD"Z)"HS_COMP_METHOD, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_installMethod)},
1079 {CC"installStub", CC"("TARGET_METHOD")"PROXY, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_installStub)}, 1098 {CC"installStub", CC"("TARGET_METHOD")"PROXY, FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_installStub)},
1080 {CC"recordBailout", CC"("STRING")V", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_recordBailout)}, 1099 {CC"recordBailout", CC"("STRING")V", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_recordBailout)},
1081 {CC"notifyJavaQueue", CC"()V", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_notifyJavaQueue)} 1100 {CC"notifyJavaQueue", CC"()V", FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_notifyJavaQueue)}
1082 }; 1101 };
1083 1102