Mercurial > hg > truffle
comparison src/share/vm/graal/graalCompilerToVM.cpp @ 9023:f94bb5d20e5d
Rename MethodInvalidatedException to InvalidInstalledCodeException (and make it a checked exception). Make sure that a compiled code object can always be directly called without first doing a check on the native method pointer.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 11 Apr 2013 17:36:46 +0200 |
parents | 6d86ce1297bc |
children | 2b840ae76df1 |
comparison
equal
deleted
inserted
replaced
9002:7844a36d0216 | 9023:f94bb5d20e5d |
---|---|
909 | 909 |
910 JavaArgumentUnboxer jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static()); | 910 JavaArgumentUnboxer jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static()); |
911 JavaValue result(jap.get_ret_type()); | 911 JavaValue result(jap.get_ret_type()); |
912 | 912 |
913 nmethod* nm = (nmethod*) (address) metaspace_nmethod; | 913 nmethod* nm = (nmethod*) (address) metaspace_nmethod; |
914 if (nm == NULL || !nm->is_alive()) { | |
915 THROW_0(vmSymbols::MethodInvalidatedException()); | |
916 } | |
917 | |
918 jca.set_alternative_target(nm); | 914 jca.set_alternative_target(nm); |
919 JavaCalls::call(&result, mh, &jca, CHECK_NULL); | 915 JavaCalls::call(&result, mh, &jca, CHECK_NULL); |
920 | 916 |
921 if (jap.get_ret_type() == T_VOID) { | 917 if (jap.get_ret_type() == T_VOID) { |
922 return NULL; | 918 return NULL; |
939 args.push_oop(JNIHandles::resolve(arg1)); | 935 args.push_oop(JNIHandles::resolve(arg1)); |
940 args.push_oop(JNIHandles::resolve(arg2)); | 936 args.push_oop(JNIHandles::resolve(arg2)); |
941 args.push_oop(JNIHandles::resolve(arg3)); | 937 args.push_oop(JNIHandles::resolve(arg3)); |
942 | 938 |
943 nmethod* nm = (nmethod*) (address) metaspace_nmethod; | 939 nmethod* nm = (nmethod*) (address) metaspace_nmethod; |
944 if (nm == NULL || !nm->is_alive()) { | |
945 THROW_0(vmSymbols::MethodInvalidatedException()); | |
946 } | |
947 | |
948 args.set_alternative_target(nm); | 940 args.set_alternative_target(nm); |
949 JavaCalls::call(&result, method, &args, CHECK_NULL); | 941 JavaCalls::call(&result, method, &args, CHECK_NULL); |
950 | 942 |
951 return JNIHandles::make_local((oop) result.get_jobject()); | 943 return JNIHandles::make_local((oop) result.get_jobject()); |
952 C2V_END | 944 C2V_END |
1067 method_data->initialize(); | 1059 method_data->initialize(); |
1068 } | 1060 } |
1069 C2V_END | 1061 C2V_END |
1070 | 1062 |
1071 | 1063 |
1064 C2V_VMENTRY(void, invalidateInstalledCode, (JNIEnv *env, jobject, jlong nativeMethod)) | |
1065 nmethod* m = (nmethod*)nativeMethod; | |
1066 m->mark_for_deoptimization(); | |
1067 VM_Deoptimize op; | |
1068 VMThread::execute(&op); | |
1069 C2V_END | |
1070 | |
1071 | |
1072 C2V_VMENTRY(jboolean, isInstalledCodeValid, (JNIEnv *env, jobject, jlong nativeMethod)) | |
1073 nmethod* m = (nmethod*)nativeMethod; | |
1074 return m->is_alive(); | |
1075 C2V_END | |
1072 | 1076 |
1073 #define CC (char*) /*cast a literal from (const char*)*/ | 1077 #define CC (char*) /*cast a literal from (const char*)*/ |
1074 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f)) | 1078 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f)) |
1075 | 1079 |
1076 #define RESOLVED_TYPE "Lcom/oracle/graal/api/meta/ResolvedJavaType;" | 1080 #define RESOLVED_TYPE "Lcom/oracle/graal/api/meta/ResolvedJavaType;" |
1144 {CC"getLineNumberTable", CC"("HS_RESOLVED_METHOD")[J", FN_PTR(getLineNumberTable)}, | 1148 {CC"getLineNumberTable", CC"("HS_RESOLVED_METHOD")[J", FN_PTR(getLineNumberTable)}, |
1145 {CC"getLocalVariableTable", CC"("HS_RESOLVED_METHOD")["LOCAL, FN_PTR(getLocalVariableTable)}, | 1149 {CC"getLocalVariableTable", CC"("HS_RESOLVED_METHOD")["LOCAL, FN_PTR(getLocalVariableTable)}, |
1146 {CC"getFileName", CC"("HS_RESOLVED_JAVA_TYPE")"STRING, FN_PTR(getFileName)}, | 1150 {CC"getFileName", CC"("HS_RESOLVED_JAVA_TYPE")"STRING, FN_PTR(getFileName)}, |
1147 {CC"clearQueuedForCompilation", CC"("HS_RESOLVED_METHOD")V", FN_PTR(clearQueuedForCompilation)}, | 1151 {CC"clearQueuedForCompilation", CC"("HS_RESOLVED_METHOD")V", FN_PTR(clearQueuedForCompilation)}, |
1148 {CC"reprofile", CC"("METASPACE_METHOD")V", FN_PTR(reprofile)}, | 1152 {CC"reprofile", CC"("METASPACE_METHOD")V", FN_PTR(reprofile)}, |
1153 {CC"invalidateInstalledCode", CC"(J)V", FN_PTR(invalidateInstalledCode)}, | |
1154 {CC"isInstalledCodeValid", CC"(J)Z", FN_PTR(isInstalledCodeValid)}, | |
1149 }; | 1155 }; |
1150 | 1156 |
1151 int CompilerToVM_methods_count() { | 1157 int CompilerToVM_methods_count() { |
1152 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod); | 1158 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod); |
1153 } | 1159 } |