Skip to content

Commit

Permalink
8329191: JVMCI compiler warning is truncated
Browse files Browse the repository at this point in the history
Reviewed-by: never
  • Loading branch information
Doug Simon committed Mar 28, 2024
1 parent 2b79c22 commit 7c7b961
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/hotspot/share/jvmci/jvmciCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,12 @@ void JVMCICompiler::on_upcall(const char* error, JVMCICompileState* compile_stat
if (err > 10 && err * 10 > ok && !_disabled) {
_disabled = true;
int total = err + ok;
const char* disable_msg = err_msg("JVMCI compiler disabled "
"after %d of %d upcalls had errors (Last error: \"%s\"). "
"Use -Xlog:jit+compilation for more detail.", err, total, error);
// Using stringStream instead of err_msg to avoid truncation
stringStream st;
st.print("JVMCI compiler disabled "
"after %d of %d upcalls had errors (Last error: \"%s\"). "
"Use -Xlog:jit+compilation for more detail.", err, total, error);
const char* disable_msg = st.freeze();
log_warning(jit,compilation)("%s", disable_msg);
if (compile_state != nullptr) {
const char* disable_error = os::strdup(disable_msg);
Expand Down
12 changes: 8 additions & 4 deletions src/hotspot/share/jvmci/jvmciEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ void JVMCIEnv::check_init(JVMCI_TRAPS) {
if (_init_error == JNI_ENOMEM) {
JVMCI_THROW_MSG(OutOfMemoryError, "JNI_ENOMEM creating or attaching to libjvmci");
}
JVMCI_THROW_MSG(InternalError, err_msg("Error creating or attaching to libjvmci (err: %d, description: %s)",
_init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg));
stringStream st;
st.print("Error creating or attaching to libjvmci (err: %d, description: %s)",
_init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg);
JVMCI_THROW_MSG(InternalError, st.freeze());
}

void JVMCIEnv::check_init(TRAPS) {
Expand All @@ -250,8 +252,10 @@ void JVMCIEnv::check_init(TRAPS) {
if (_init_error == JNI_ENOMEM) {
THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "JNI_ENOMEM creating or attaching to libjvmci");
}
THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), err_msg("Error creating or attaching to libjvmci (err: %d, description: %s)",
_init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg));
stringStream st;
st.print("Error creating or attaching to libjvmci (err: %d, description: %s)",
_init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg);
THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), st.freeze());
}

// Prints a pending exception (if any) and its stack trace to st.
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/share/jvmci/jvmciRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,10 @@ static bool after_compiler_upcall(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, c
const char* pending_stack_trace = nullptr;
JVMCIENV->pending_exception_as_string(&pending_string, &pending_stack_trace);
if (pending_string == nullptr) pending_string = "null";
const char* failure_reason = os::strdup(err_msg("uncaught exception in %s [%s]", function, pending_string), mtJVMCI);
// Using stringStream instead of err_msg to avoid truncation
stringStream st;
st.print("uncaught exception in %s [%s]", function, pending_string);
const char* failure_reason = os::strdup(st.freeze(), mtJVMCI);
if (failure_reason == nullptr) {
failure_reason = "uncaught exception";
reason_on_C_heap = false;
Expand Down

0 comments on commit 7c7b961

Please sign in to comment.