# HG changeset patch # User Tom Rodriguez # Date 1445538390 25200 # Node ID f190cf6fb28e95fb0311cda5003004f75787be9f # Parent 15013021dbfa7c7cce4ff7fdbfabd5e118e0b0f6 Don't abort if exceptions occur during JVMCI compilation diff -r 15013021dbfa -r f190cf6fb28e src/share/vm/jvmci/jvmciCompiler.cpp --- a/src/share/vm/jvmci/jvmciCompiler.cpp Thu Oct 22 12:43:42 2015 +0200 +++ b/src/share/vm/jvmci/jvmciCompiler.cpp Thu Oct 22 11:26:30 2015 -0700 @@ -133,22 +133,40 @@ Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_ABORT); JavaValue method_result(T_OBJECT); - { + JavaCallArguments args; + args.push_long((jlong) (address) method()); + JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(), + vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, THREAD); + + if (!HAS_PENDING_EXCEPTION) { + JavaValue result(T_VOID); JavaCallArguments args; - args.push_long((jlong) (address) method()); - JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, CHECK_ABORT); + args.push_oop(receiver); + args.push_oop((oop)method_result.get_jobject()); + args.push_int(entry_bci); + args.push_long((jlong) (address) env); + args.push_int(env->task()->compile_id()); + JavaCalls::call_special(&result, receiver->klass(), + vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD); } - JavaValue result(T_VOID); - JavaCallArguments args; - args.push_oop(receiver); - args.push_oop((oop)method_result.get_jobject()); - args.push_int(entry_bci); - args.push_long((jlong) (address) env); - args.push_int(env->task()->compile_id()); - JavaCalls::call_special(&result, receiver->klass(), vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, CHECK_ABORT); + // An uncaught exception was thrown during compilation. Generally these + // should be handled by the Java code in some useful way but if they leak + // through to here report them instead of dying or silently ignoring them. + if (HAS_PENDING_EXCEPTION) { + Handle throwable = PENDING_EXCEPTION; + CLEAR_PENDING_EXCEPTION; - _methodsCompiled++; + JVMCIRuntime::call_printStackTrace(throwable, THREAD); + if (HAS_PENDING_EXCEPTION) { + CLEAR_PENDING_EXCEPTION; + } + + // Something went wrong so disable compilation at this level + method->set_not_compilable(CompLevel_full_optimization); + } else { + _methodsCompiled++; + } }