7009600: JSR 292 Server compiler crashes in Compile::find_intrinsic(ciMethod*, bool)

Catch errors during the compile-time processing of method handles; back out cleanly

Reviewed-by: twisti
This commit is contained in:
John R Rose 2011-04-07 17:12:23 -07:00
parent b95f04efbf
commit f8fe3457a5
2 changed files with 21 additions and 7 deletions

View file

@ -42,10 +42,21 @@ ciMethod* ciMethodHandle::get_adapter(bool is_invokedynamic) const {
methodHandle callee(_callee->get_methodOop()); methodHandle callee(_callee->get_methodOop());
// We catch all exceptions here that could happen in the method // We catch all exceptions here that could happen in the method
// handle compiler and stop the VM. // handle compiler and stop the VM.
MethodHandleCompiler mhc(h, callee, is_invokedynamic, CATCH); MethodHandleCompiler mhc(h, callee, is_invokedynamic, THREAD);
methodHandle m = mhc.compile(CATCH); if (!HAS_PENDING_EXCEPTION) {
methodHandle m = mhc.compile(THREAD);
if (!HAS_PENDING_EXCEPTION) {
return CURRENT_ENV->get_object(m())->as_method(); return CURRENT_ENV->get_object(m())->as_method();
} }
}
if (PrintMiscellaneous && (Verbose || WizardMode)) {
tty->print("*** ciMethodHandle::get_adapter => ");
PENDING_EXCEPTION->print();
tty->print("*** get_adapter (%s): ", is_invokedynamic ? "indy" : "mh"); ((ciObject*)this)->print(); //@@
}
CLEAR_PENDING_EXCEPTION;
return NULL;
}
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View file

@ -63,6 +63,7 @@ CallGenerator* Compile::call_generator(ciMethod* call_method, int vtable_index,
JVMState* jvms, bool allow_inline, JVMState* jvms, bool allow_inline,
float prof_factor) { float prof_factor) {
CallGenerator* cg; CallGenerator* cg;
guarantee(call_method != NULL, "failed method resolution");
// Dtrace currently doesn't work unless all calls are vanilla // Dtrace currently doesn't work unless all calls are vanilla
if (env()->dtrace_method_probes()) { if (env()->dtrace_method_probes()) {
@ -130,8 +131,9 @@ CallGenerator* Compile::call_generator(ciMethod* call_method, int vtable_index,
// Get an adapter for the MethodHandle. // Get an adapter for the MethodHandle.
ciMethod* target_method = method_handle->get_method_handle_adapter(); ciMethod* target_method = method_handle->get_method_handle_adapter();
CallGenerator* hit_cg = NULL;
CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor); if (target_method != NULL)
hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor);
if (hit_cg != NULL && hit_cg->is_inline()) if (hit_cg != NULL && hit_cg->is_inline())
return hit_cg; return hit_cg;
} }
@ -152,8 +154,9 @@ CallGenerator* Compile::call_generator(ciMethod* call_method, int vtable_index,
// Get an adapter for the MethodHandle. // Get an adapter for the MethodHandle.
ciMethod* target_method = method_handle->get_invokedynamic_adapter(); ciMethod* target_method = method_handle->get_invokedynamic_adapter();
CallGenerator* hit_cg = NULL;
CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor); if (target_method != NULL)
hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor);
if (hit_cg != NULL && hit_cg->is_inline()) { if (hit_cg != NULL && hit_cg->is_inline()) {
CallGenerator* miss_cg = CallGenerator::for_dynamic_call(call_method); CallGenerator* miss_cg = CallGenerator::for_dynamic_call(call_method);
return CallGenerator::for_predicted_dynamic_call(method_handle, miss_cg, hit_cg, prof_factor); return CallGenerator::for_predicted_dynamic_call(method_handle, miss_cg, hit_cg, prof_factor);