Mercurial > hg > graal-jvmci-8
changeset 22770:1fbfcc0334d3
JVMCI PrintCompilation support should reuse CompileBroker logic
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 14 Jan 2016 11:36:05 -0800 |
parents | d57508b1bcb5 |
children | 994b87797b9d 6f6220ad4454 |
files | jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationRequestFailure.java jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationRequestResult.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java jvmci/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/JVMCICompiler.java src/share/vm/compiler/compileBroker.cpp src/share/vm/jvmci/jvmciCompiler.cpp src/share/vm/jvmci/jvmciEnv.cpp src/share/vm/jvmci/jvmciEnv.hpp src/share/vm/jvmci/jvmciJavaClasses.hpp src/share/vm/jvmci/systemDictionary_jvmci.hpp src/share/vm/jvmci/vmSymbols_jvmci.hpp |
diffstat | 12 files changed, 149 insertions(+), 117 deletions(-) [+] |
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationRequestFailure.java Thu Jan 14 11:32:37 2016 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * 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; - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationRequestResult.java Thu Jan 14 11:36:05 2016 -0800 @@ -0,0 +1,72 @@ +/* + * 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 the result of a compile request. + */ +public final class CompilationRequestResult { + + /** + * A user readable description of the failure. + */ + private final String failureMessage; + + /** + * Whether this is a transient failure where retrying would help. + */ + private final boolean retry; + + /** + * Number of bytecodes inlined into the compilation, exclusive of the bytecodes in the root + * method. + */ + private final int inlinedBytecodes; + + private CompilationRequestResult(String failureMessage, boolean retry, int inlinedBytecodes) { + assert retry == (failureMessage != null) : "must be a message if retryable"; + this.failureMessage = failureMessage; + this.retry = retry; + this.inlinedBytecodes = inlinedBytecodes; + } + + public static CompilationRequestResult success(int inlinedBytecodes) { + return new CompilationRequestResult(null, true, inlinedBytecodes); + } + + public static CompilationRequestResult failure(String failureMessage, boolean retry) { + return new CompilationRequestResult(failureMessage, retry, 0); + } + + public String getFailureMessgae() { + return failureMessage; + } + + public boolean getRetry() { + return retry; + } + + public int getInlinedBytecodes() { + return inlinedBytecodes; + } +}
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Thu Jan 14 11:32:37 2016 -0800 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Thu Jan 14 11:36:05 2016 -0800 @@ -23,7 +23,7 @@ package jdk.vm.ci.hotspot; import jdk.vm.ci.code.CompilationRequest; -import jdk.vm.ci.code.CompilationRequestFailure; +import jdk.vm.ci.code.CompilationRequestResult; import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.runtime.JVMCICompiler; import jdk.vm.ci.runtime.JVMCICompilerFactory; @@ -34,7 +34,7 @@ private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCICompiler { - public CompilationRequestFailure compileMethod(CompilationRequest request) { + public CompilationRequestResult compileMethod(CompilationRequest request) { throw new JVMCIError("no JVMCI compiler selected"); }
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Thu Jan 14 11:32:37 2016 -0800 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Thu Jan 14 11:36:05 2016 -0800 @@ -37,7 +37,7 @@ import java.util.TreeMap; import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CompilationRequestFailure; +import jdk.vm.ci.code.CompilationRequestResult; import jdk.vm.ci.code.CompilationResult; import jdk.vm.ci.code.InstalledCode; import jdk.vm.ci.common.JVMCIError; @@ -242,7 +242,7 @@ * Called from the VM. */ @SuppressWarnings({"unused"}) - private CompilationRequestFailure compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { + private CompilationRequestResult compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { return getCompiler().compileMethod(new HotSpotCompilationRequest(method, entryBCI, jvmciEnv, id)); }
--- a/jvmci/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/JVMCICompiler.java Thu Jan 14 11:32:37 2016 -0800 +++ b/jvmci/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/JVMCICompiler.java Thu Jan 14 11:36:05 2016 -0800 @@ -23,7 +23,7 @@ package jdk.vm.ci.runtime; import jdk.vm.ci.code.CompilationRequest; -import jdk.vm.ci.code.CompilationRequestFailure; +import jdk.vm.ci.code.CompilationRequestResult; public interface JVMCICompiler { int INVOCATION_ENTRY_BCI = -1; @@ -32,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. */ - CompilationRequestFailure compileMethod(CompilationRequest request); + CompilationRequestResult compileMethod(CompilationRequest request); }
--- a/src/share/vm/compiler/compileBroker.cpp Thu Jan 14 11:32:37 2016 -0800 +++ b/src/share/vm/compiler/compileBroker.cpp Thu Jan 14 11:36:05 2016 -0800 @@ -2152,10 +2152,10 @@ DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, compiler_name(task_level)); } - // Allocate a new set of JNI handles. - push_jni_handle_block(); Method* target_handle = task->method(); int compilable = ciEnv::MethodCompilable; + const char* failure_reason = NULL; + const char* retry_message = NULL; AbstractCompiler *comp = compiler(task_level); int system_dictionary_modification_counter; @@ -2175,10 +2175,19 @@ jvmci->compile_method(method, osr_bci, &env); post_compile(thread, task, event, task->code() != NULL, NULL); + + failure_reason = env.failure_reason(); + if (!env.retryable()) { + retry_message = "not retryable"; + compilable = ciEnv::MethodCompilable_not_at_tier; + } + } else #endif // COMPILERJVMCI { - + // Allocate a new set of JNI handles. + push_jni_handle_block(); + NoHandleMark nhm; ThreadToNativeFromVM ttn(thread); @@ -2220,22 +2229,27 @@ compilable = ci_env.compilable(); if (ci_env.failing()) { - task->set_failure_reason(ci_env.failure_reason()); - const char* retry_message = ci_env.retry_message(); - if (_compilation_log != NULL) { - _compilation_log->log_failure(thread, task, ci_env.failure_reason(), retry_message); - } - if (PrintCompilation) { - FormatBufferResource msg = retry_message != NULL ? - err_msg_res("COMPILE SKIPPED: %s (%s)", ci_env.failure_reason(), retry_message) : - err_msg_res("COMPILE SKIPPED: %s", ci_env.failure_reason()); - task->print_compilation(tty, msg); - } + failure_reason = ci_env.failure_reason(); + retry_message = ci_env.retry_message(); } post_compile(thread, task, event, !ci_env.failing(), &ci_env); + + pop_jni_handle_block(); } - pop_jni_handle_block(); + + if (failure_reason != NULL) { + if (_compilation_log != NULL) { + _compilation_log->log_failure(thread, task, failure_reason, retry_message); + } + if (PrintCompilation) { + FormatBufferResource msg = retry_message != NULL ? + err_msg_res("COMPILE SKIPPED: %s (%s)", failure_reason, retry_message) : + err_msg_res("COMPILE SKIPPED: %s", failure_reason); + task->print_compilation(tty, msg); + } + } + methodHandle method(thread, task->method());
--- a/src/share/vm/jvmci/jvmciCompiler.cpp Thu Jan 14 11:32:37 2016 -0800 +++ b/src/share/vm/jvmci/jvmciCompiler.cpp Thu Jan 14 11:36:05 2016 -0800 @@ -129,7 +129,6 @@ JVMCIRuntime::ensure_jvmci_class_loader_is_initialized(); JVMCIJavaClasses::compute_offsets(THREAD); HandleMark hm; - ResourceMark rm; Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_ABORT); JavaValue method_result(T_OBJECT); @@ -161,37 +160,22 @@ if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; } - if (PrintCompilation) { - env->task()->print_compilation(tty, "COMPILE SKIPPED: exception thrown"); - } + env->set_failure("exception throw", false); } else { - 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: %s (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); + oop result_object = (oop) result.get_jobject(); + if (result_object != NULL) { + oop failure_message = CompilationRequestResult::failureMessage(result_object); + if (failure_message != NULL) { + const char* failure_reason = failure_message != NULL ? java_lang_String::as_utf8_string(failure_message) : "unknown reason"; + env->set_failure(failure_reason, CompilationRequestResult::retry(result_object)); + } else { + if (env->task()->code() == NULL) { + env->set_failure("no nmethod produced", true); } else { - method->set_not_osr_compilable(CompLevel_full_optimization); + env->task()->set_num_inlined_bytecodes(CompilationRequestResult::inlinedBytecodes(result_object)); + _methodsCompiled++; } } - } else { - if (env->task()->code() == NULL) { - if (PrintCompilation) { - env->task()->print_compilation(tty, "COMPILE SKIPPED: no nmethod produced"); - } - } else { - _methodsCompiled++; - } } } }
--- a/src/share/vm/jvmci/jvmciEnv.cpp Thu Jan 14 11:32:37 2016 -0800 +++ b/src/share/vm/jvmci/jvmciEnv.cpp Thu Jan 14 11:36:05 2016 -0800 @@ -48,16 +48,17 @@ #include "jvmci/jvmciRuntime.hpp" #include "jvmci/jvmciJavaClasses.hpp" -JVMCIEnv::JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter) { - _task = task; - _system_dictionary_modification_counter = system_dictionary_modification_counter; - { - // Get Jvmti capabilities under lock to get consistent values. - MutexLocker mu(JvmtiThreadState_lock); - _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint(); - _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables(); - _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions(); - } +JVMCIEnv::JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter): + _task(task), + _system_dictionary_modification_counter(system_dictionary_modification_counter), + _failure_reason(NULL), + _retryable(true) +{ + // Get Jvmti capabilities under lock to get consistent values. + MutexLocker mu(JvmtiThreadState_lock); + _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint(); + _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables(); + _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions(); } // ------------------------------------------------------------------
--- a/src/share/vm/jvmci/jvmciEnv.hpp Thu Jan 14 11:32:37 2016 -0800 +++ b/src/share/vm/jvmci/jvmciEnv.hpp Thu Jan 14 11:36:05 2016 -0800 @@ -99,6 +99,10 @@ CompileTask* _task; int _system_dictionary_modification_counter; + // Compilation result values + const char* _failure_reason; + bool _retryable; + // Cache JVMTI state bool _jvmti_can_hotswap_or_post_breakpoint; bool _jvmti_can_access_local_variables; @@ -140,6 +144,14 @@ public: CompileTask* task() { return _task; } + const char* failure_reason() { return _failure_reason; } + bool retryable() { return _retryable; } + + void set_failure(const char* reason, bool retryable) { + _failure_reason = reason; + _retryable = retryable; + } + // Register the result of a compilation. static JVMCIEnv::CodeInstallResult register_method( const methodHandle& target,
--- a/src/share/vm/jvmci/jvmciJavaClasses.hpp Thu Jan 14 11:32:37 2016 -0800 +++ b/src/share/vm/jvmci/jvmciJavaClasses.hpp Thu Jan 14 11:36:05 2016 -0800 @@ -161,9 +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) \ + start_class(CompilationRequestResult) \ + oop_field(CompilationRequestResult, failureMessage, "Ljava/lang/String;") \ + boolean_field(CompilationRequestResult, retry) \ + int_field(CompilationRequestResult, inlinedBytecodes) \ end_class \ start_class(DebugInfo) \ oop_field(DebugInfo, bytecodePosition, "Ljdk/vm/ci/code/BytecodePosition;") \
--- a/src/share/vm/jvmci/systemDictionary_jvmci.hpp Thu Jan 14 11:32:37 2016 -0800 +++ b/src/share/vm/jvmci/systemDictionary_jvmci.hpp Thu Jan 14 11:36:05 2016 -0800 @@ -65,7 +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(CompilationRequestResult_klass, jdk_vm_ci_code_CompilationRequestResult, 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) \
--- a/src/share/vm/jvmci/vmSymbols_jvmci.hpp Thu Jan 14 11:32:37 2016 -0800 +++ b/src/share/vm/jvmci/vmSymbols_jvmci.hpp Thu Jan 14 11:36:05 2016 -0800 @@ -70,7 +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_CompilationRequestResult, "jdk/vm/ci/code/CompilationRequestResult") \ 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") \ @@ -87,7 +87,7 @@ 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)Ljdk/vm/ci/code/CompilationRequestFailure;") \ + template(compileMethod_signature, "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;IJI)Ljdk/vm/ci/code/CompilationRequestResult;") \ template(fromMetaspace_name, "fromMetaspace") \ template(method_fromMetaspace_signature, "(J)Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;") \ template(constantPool_fromMetaspace_signature, "(J)Ljdk/vm/ci/hotspot/HotSpotConstantPool;") \