# HG changeset patch # User Tom Rodriguez # Date 1452632071 28800 # Node ID d88299d598d6acd9197f9cea455ea40d1a2492aa # Parent 7d02b40973092b688f7d941ffb3a479b41f14bd7 Add support for passing back bailout messages diff -r 7d02b4097309 -r d88299d598d6 jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationRequestFailure.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationRequestFailure.java Tue Jan 12 12:54:31 2016 -0800 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.code; + +/** + * Simple class to provide information about a compilation failure. + */ +public class CompilationRequestFailure { + + /** + * A user readable description of the failure. + */ + private final String message; + + /** + * Whether this is a transient failure where retrying would help. + */ + private final boolean retry; + + public CompilationRequestFailure(String message, boolean retry) { + this.message = message; + this.retry = retry; + } + + public String getMessgae() { + return message; + } + + public boolean getRetry() { + return retry; + } +} diff -r 7d02b4097309 -r d88299d598d6 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Tue Jan 12 15:03:56 2016 +0100 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Tue Jan 12 12:54:31 2016 -0800 @@ -23,6 +23,7 @@ package jdk.vm.ci.hotspot; import jdk.vm.ci.code.CompilationRequest; +import jdk.vm.ci.code.CompilationRequestFailure; import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.runtime.JVMCICompiler; import jdk.vm.ci.runtime.JVMCICompilerFactory; @@ -33,7 +34,7 @@ private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCICompiler { - public void compileMethod(CompilationRequest request) { + public CompilationRequestFailure compileMethod(CompilationRequest request) { throw new JVMCIError("no JVMCI compiler selected"); } diff -r 7d02b4097309 -r d88299d598d6 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Tue Jan 12 15:03:56 2016 +0100 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Tue Jan 12 12:54:31 2016 -0800 @@ -36,8 +36,8 @@ import java.util.Objects; import java.util.TreeMap; -import sun.misc.VM; import jdk.vm.ci.code.Architecture; +import jdk.vm.ci.code.CompilationRequestFailure; import jdk.vm.ci.code.CompilationResult; import jdk.vm.ci.code.InstalledCode; import jdk.vm.ci.common.JVMCIError; @@ -50,6 +50,7 @@ import jdk.vm.ci.runtime.JVMCIBackend; import jdk.vm.ci.runtime.JVMCICompiler; import jdk.vm.ci.services.Services; +import sun.misc.VM; //JaCoCo Exclude @@ -241,8 +242,8 @@ * Called from the VM. */ @SuppressWarnings({"unused"}) - private void compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { - getCompiler().compileMethod(new HotSpotCompilationRequest(method, entryBCI, jvmciEnv, id)); + private CompilationRequestFailure compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { + return getCompiler().compileMethod(new HotSpotCompilationRequest(method, entryBCI, jvmciEnv, id)); } /** diff -r 7d02b4097309 -r d88299d598d6 jvmci/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/JVMCICompiler.java --- a/jvmci/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/JVMCICompiler.java Tue Jan 12 15:03:56 2016 +0100 +++ b/jvmci/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/JVMCICompiler.java Tue Jan 12 12:54:31 2016 -0800 @@ -23,6 +23,7 @@ package jdk.vm.ci.runtime; import jdk.vm.ci.code.CompilationRequest; +import jdk.vm.ci.code.CompilationRequestFailure; public interface JVMCICompiler { int INVOCATION_ENTRY_BCI = -1; @@ -31,5 +32,5 @@ * Services a compilation request. This object should compile the method to machine code and * install it in the code cache if the compilation is successful. */ - void compileMethod(CompilationRequest request); + CompilationRequestFailure compileMethod(CompilationRequest request); } diff -r 7d02b4097309 -r d88299d598d6 src/share/vm/jvmci/jvmciCompiler.cpp --- a/src/share/vm/jvmci/jvmciCompiler.cpp Tue Jan 12 15:03:56 2016 +0100 +++ b/src/share/vm/jvmci/jvmciCompiler.cpp Tue Jan 12 12:54:31 2016 -0800 @@ -138,8 +138,8 @@ JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, THREAD); + JavaValue result(T_OBJECT); if (!HAS_PENDING_EXCEPTION) { - JavaValue result(T_VOID); JavaCallArguments args; args.push_oop(receiver); args.push_oop((oop)method_result.get_jobject()); @@ -161,11 +161,38 @@ if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; } - - // Something went wrong so disable compilation at this level - method->set_not_compilable(CompLevel_full_optimization); + if (PrintCompilation) { + env->task()->print_compilation(tty, "COMPILE SKIPPED: exception thrown"); + } } else { - _methodsCompiled++; + oop request = (oop) result.get_jobject(); + if (request != NULL) { + oop failure = CompilationRequestFailure::message(request); + const char* failure_reason = failure != NULL ? java_lang_String::as_utf8_string(failure) : "unknown reason"; + + env->task()->set_failure_reason(failure_reason); + if (PrintCompilation) { + FormatBufferResource msg = CompilationRequestFailure::retry(request) ? + err_msg_res("COMPILE SKIPPED: (not_retryable)", failure_reason) : + err_msg_res("COMPILE SKIPPED: %s", failure_reason); + env->task()->print_compilation(tty, msg); + } + if (!CompilationRequestFailure::retry(request)) { + if (entry_bci == InvocationEntryBci) { + method->set_not_compilable(CompLevel_full_optimization); + } else { + method->set_not_osr_compilable(CompLevel_full_optimization); + } + } + } else { + if (env->task()->code() == NULL) { + if (PrintCompilation) { + env->task()->print_compilation(tty, "COMPILE SKIPPED: no nmethod produced"); + } + } else { + _methodsCompiled++; + } + } } } diff -r 7d02b4097309 -r d88299d598d6 src/share/vm/jvmci/jvmciEnv.cpp --- a/src/share/vm/jvmci/jvmciEnv.cpp Tue Jan 12 15:03:56 2016 +0100 +++ b/src/share/vm/jvmci/jvmciEnv.cpp Tue Jan 12 12:54:31 2016 -0800 @@ -536,7 +536,9 @@ // Record successful registration. // (Put nm into the task handle *before* publishing to the Java heap.) CompileTask* task = env == NULL ? NULL : env->task(); - if (task != NULL) task->set_code(nm); + if (task != NULL) { + task->set_code(nm); + } if (installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(installed_code())) { if (entry_bci == InvocationEntryBci) { diff -r 7d02b4097309 -r d88299d598d6 src/share/vm/jvmci/jvmciJavaClasses.hpp --- a/src/share/vm/jvmci/jvmciJavaClasses.hpp Tue Jan 12 15:03:56 2016 +0100 +++ b/src/share/vm/jvmci/jvmciJavaClasses.hpp Tue Jan 12 12:54:31 2016 -0800 @@ -161,6 +161,10 @@ start_class(CompilationResult_Mark) \ oop_field(CompilationResult_Mark, id, "Ljava/lang/Object;") \ end_class \ + start_class(CompilationRequestFailure) \ + oop_field(CompilationRequestFailure, message, "Ljava/lang/String;") \ + boolean_field(CompilationRequestFailure, retry) \ + end_class \ start_class(DebugInfo) \ oop_field(DebugInfo, bytecodePosition, "Ljdk/vm/ci/code/BytecodePosition;") \ oop_field(DebugInfo, referenceMap, "Ljdk/vm/ci/code/ReferenceMap;") \ @@ -272,7 +276,7 @@ long_field(HotSpotConstantPool, metaspaceConstantPool) \ end_class \ start_class(HotSpotJVMCIRuntime) \ - objArrayOop_field(HotSpotJVMCIRuntime, trivialPrefixes, "[Ljava/lang/String;") \ + objArrayOop_field(HotSpotJVMCIRuntime, trivialPrefixes, "[Ljava/lang/String;") \ end_class \ /* end*/ diff -r 7d02b4097309 -r d88299d598d6 src/share/vm/jvmci/systemDictionary_jvmci.hpp --- a/src/share/vm/jvmci/systemDictionary_jvmci.hpp Tue Jan 12 15:03:56 2016 +0100 +++ b/src/share/vm/jvmci/systemDictionary_jvmci.hpp Tue Jan 12 12:54:31 2016 -0800 @@ -65,6 +65,7 @@ do_klass(CompilationResult_Mark_klass, jdk_vm_ci_code_CompilationResult_Mark, Jvmci) \ do_klass(CompilationResult_Infopoint_klass, jdk_vm_ci_code_CompilationResult_Infopoint, Jvmci) \ do_klass(CompilationResult_Site_klass, jdk_vm_ci_code_CompilationResult_Site, Jvmci) \ + do_klass(CompilationRequestFailure_klass, jdk_vm_ci_code_CompilationRequestFailure, Jvmci) \ do_klass(InfopointReason_klass, jdk_vm_ci_code_InfopointReason, Jvmci) \ do_klass(InstalledCode_klass, jdk_vm_ci_code_InstalledCode, Jvmci) \ do_klass(code_Location_klass, jdk_vm_ci_code_Location, Jvmci) \ @@ -73,6 +74,7 @@ do_klass(StackSlot_klass, jdk_vm_ci_code_StackSlot, Jvmci) \ do_klass(StackLockValue_klass, jdk_vm_ci_code_StackLockValue, Jvmci) \ do_klass(VirtualObject_klass, jdk_vm_ci_code_VirtualObject, Jvmci) \ + do_klass(CompilationRequest_klass, jdk_vm_ci_code_CompilationRequest, Jvmci) \ do_klass(JavaConstant_klass, jdk_vm_ci_meta_JavaConstant, Jvmci) \ do_klass(PrimitiveConstant_klass, jdk_vm_ci_meta_PrimitiveConstant, Jvmci) \ do_klass(RawConstant_klass, jdk_vm_ci_meta_RawConstant, Jvmci) \ diff -r 7d02b4097309 -r d88299d598d6 src/share/vm/jvmci/vmSymbols_jvmci.hpp --- a/src/share/vm/jvmci/vmSymbols_jvmci.hpp Tue Jan 12 15:03:56 2016 +0100 +++ b/src/share/vm/jvmci/vmSymbols_jvmci.hpp Tue Jan 12 12:54:31 2016 -0800 @@ -70,6 +70,7 @@ template(jdk_vm_ci_code_CompilationResult_Mark, "jdk/vm/ci/code/CompilationResult$Mark") \ template(jdk_vm_ci_code_CompilationResult_Infopoint, "jdk/vm/ci/code/CompilationResult$Infopoint") \ template(jdk_vm_ci_code_CompilationResult_Site, "jdk/vm/ci/code/CompilationResult$Site") \ + template(jdk_vm_ci_code_CompilationRequestFailure, "jdk/vm/ci/code/CompilationRequestFailure") \ template(jdk_vm_ci_code_InfopointReason, "jdk/vm/ci/code/InfopointReason") \ template(jdk_vm_ci_code_InstalledCode, "jdk/vm/ci/code/InstalledCode") \ template(jdk_vm_ci_code_BytecodeFrame, "jdk/vm/ci/code/BytecodeFrame") \ @@ -83,9 +84,10 @@ template(jdk_vm_ci_code_VirtualObject, "jdk/vm/ci/code/VirtualObject") \ template(jdk_vm_ci_code_RegisterSaveLayout, "jdk/vm/ci/code/RegisterSaveLayout") \ template(jdk_vm_ci_code_InvalidInstalledCodeException, "jdk/vm/ci/code/InvalidInstalledCodeException") \ + template(jdk_vm_ci_code_CompilationRequest, "jdk/vm/ci/code/CompilationRequest") \ template(jdk_vm_ci_common_JVMCIError, "jdk/vm/ci/common/JVMCIError") \ template(compileMethod_name, "compileMethod") \ - template(compileMethod_signature, "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;IJI)V") \ + template(compileMethod_signature, "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;IJI)Ljdk/vm/ci/code/CompilationRequestFailure;") \ template(fromMetaspace_name, "fromMetaspace") \ template(method_fromMetaspace_signature, "(J)Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;") \ template(constantPool_fromMetaspace_signature, "(J)Ljdk/vm/ci/hotspot/HotSpotConstantPool;") \