Skip to content

Commit adb8561

Browse files
author
Doug Simon
committed
8253228: [JVMCI] provide more info on fatal JVMCI errors
Reviewed-by: kvn, never
1 parent a7422ac commit adb8561

File tree

4 files changed

+19
-34
lines changed

4 files changed

+19
-34
lines changed

src/hotspot/share/jvmci/jvmci.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ void* JVMCI::get_shared_library(char*& path, bool load) {
7070
char ebuf[1024];
7171
if (JVMCILibPath != NULL) {
7272
if (!os::dll_locate_lib(path, sizeof(path), JVMCILibPath, JVMCI_SHARED_LIBRARY_NAME)) {
73-
vm_exit_during_initialization("Unable to locate JVMCI shared library in path specified by -XX:JVMCILibPath value", JVMCILibPath);
73+
fatal("Unable to create path to JVMCI shared library based on value of JVMCILibPath (%s)", JVMCILibPath);
7474
}
7575
} else {
7676
if (!os::dll_locate_lib(path, sizeof(path), Arguments::get_dll_dir(), JVMCI_SHARED_LIBRARY_NAME)) {
77-
vm_exit_during_initialization("Unable to create path to JVMCI shared library");
77+
fatal("Unable to create path to JVMCI shared library");
7878
}
7979
}
8080

8181
void* handle = os::dll_load(path, ebuf, sizeof ebuf);
8282
if (handle == NULL) {
83-
vm_exit_during_initialization("Unable to load JVMCI shared library", ebuf);
83+
fatal("Unable to load JVMCI shared library from %s: %s", path, ebuf);
8484
}
8585
_shared_library_handle = handle;
8686
_shared_library_path = strdup(path);

src/hotspot/share/jvmci/jvmciEnv.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ void JVMCIEnv::copy_saved_properties() {
101101

102102
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_vm_ci_services_Services(), Handle(), Handle(), true, THREAD);
103103
if (HAS_PENDING_EXCEPTION) {
104-
JVMCIRuntime::exit_on_pending_exception(NULL, "Error initializing jdk.vm.ci.services.Services");
104+
JVMCIRuntime::fatal_exception(NULL, "Error initializing jdk.vm.ci.services.Services");
105105
}
106106
InstanceKlass* ik = InstanceKlass::cast(k);
107107
if (ik->should_be_initialized()) {
108108
ik->initialize(THREAD);
109109
if (HAS_PENDING_EXCEPTION) {
110-
JVMCIRuntime::exit_on_pending_exception(NULL, "Error initializing jdk.vm.ci.services.Services");
110+
JVMCIRuntime::fatal_exception(NULL, "Error initializing jdk.vm.ci.services.Services");
111111
}
112112
}
113113

@@ -117,7 +117,7 @@ void JVMCIEnv::copy_saved_properties() {
117117
JavaCallArguments args;
118118
JavaCalls::call_static(&result, ik, serializeSavedProperties, vmSymbols::serializePropertiesToByteArray_signature(), &args, THREAD);
119119
if (HAS_PENDING_EXCEPTION) {
120-
JVMCIRuntime::exit_on_pending_exception(NULL, "Error calling jdk.vm.ci.services.Services.serializeSavedProperties");
120+
JVMCIRuntime::fatal_exception(NULL, "Error calling jdk.vm.ci.services.Services.serializeSavedProperties");
121121
}
122122
oop res = (oop) result.get_jobject();
123123
assert(res->is_typeArray(), "must be");
@@ -219,7 +219,7 @@ void JVMCIEnv::init_env_mode_runtime(JavaThread* thread, JNIEnv* parent_env) {
219219
if (result != JNI_OK) {
220220
char message[256];
221221
jio_snprintf(message, 256, "Uncaught exception pushing local frame for JVMCIEnv scope entered at %s:%d", _file, _line);
222-
JVMCIRuntime::exit_on_pending_exception(this, message);
222+
JVMCIRuntime::fatal_exception(this, message);
223223
}
224224
_pop_frame_on_close = true;
225225
}
@@ -288,7 +288,7 @@ void JVMCIEnv::translate_hotspot_exception_to_jni_exception(JavaThread* THREAD,
288288
vmSymbols::encodeThrowable_name(),
289289
vmSymbols::encodeThrowable_signature(), &jargs, THREAD);
290290
if (HAS_PENDING_EXCEPTION) {
291-
JVMCIRuntime::exit_on_pending_exception(this, "HotSpotJVMCIRuntime.encodeThrowable should not throw an exception");
291+
JVMCIRuntime::fatal_exception(this, "HotSpotJVMCIRuntime.encodeThrowable should not throw an exception");
292292
}
293293

294294
oop encoded_throwable_string = (oop) result.get_jobject();
@@ -329,7 +329,7 @@ JVMCIEnv::~JVMCIEnv() {
329329
if (has_pending_exception()) {
330330
char message[256];
331331
jio_snprintf(message, 256, "Uncaught exception exiting JVMCIEnv scope entered at %s:%d", _file, _line);
332-
JVMCIRuntime::exit_on_pending_exception(this, message);
332+
JVMCIRuntime::fatal_exception(this, message);
333333
}
334334

335335
if (_detach_on_close) {

src/hotspot/share/jvmci/jvmciRuntime.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ void JVMCIRuntime::describe_pending_hotspot_exception(JavaThread* THREAD, bool c
10831083
}
10841084

10851085

1086-
void JVMCIRuntime::exit_on_pending_exception(JVMCIEnv* JVMCIENV, const char* message) {
1086+
void JVMCIRuntime::fatal_exception(JVMCIEnv* JVMCIENV, const char* message) {
10871087
JavaThread* THREAD = JavaThread::current();
10881088

10891089
static volatile int report_error = 0;
@@ -1099,9 +1099,7 @@ void JVMCIRuntime::exit_on_pending_exception(JVMCIEnv* JVMCIENV, const char* mes
10991099
// Allow error reporting thread to print the stack trace.
11001100
THREAD->sleep(200);
11011101
}
1102-
1103-
before_exit(THREAD);
1104-
vm_exit(-1);
1102+
fatal("Fatal exception in JVMCI: %s", message);
11051103
}
11061104

11071105
// ------------------------------------------------------------------
@@ -1455,19 +1453,6 @@ JVMCI::CodeInstallResult JVMCIRuntime::validate_compile_task_dependencies(Depend
14551453
return JVMCI::dependencies_failed;
14561454
}
14571455

1458-
// Reports a pending exception and exits the VM.
1459-
static void fatal_exception_in_compile(JVMCIEnv* JVMCIENV, JavaThread* thread, const char* msg) {
1460-
// Only report a fatal JVMCI compilation exception once
1461-
static volatile int report_init_failure = 0;
1462-
if (!report_init_failure && Atomic::cmpxchg(&report_init_failure, 0, 1) == 0) {
1463-
tty->print_cr("%s:", msg);
1464-
JVMCIENV->describe_pending_exception(true);
1465-
}
1466-
JVMCIENV->clear_pending_exception();
1467-
before_exit(thread);
1468-
vm_exit(-1);
1469-
}
1470-
14711456
void JVMCIRuntime::compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, const methodHandle& method, int entry_bci) {
14721457
JVMCI_EXCEPTION_CONTEXT
14731458

@@ -1488,7 +1473,7 @@ void JVMCIRuntime::compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, c
14881473
HandleMark hm(thread);
14891474
JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV);
14901475
if (JVMCIENV->has_pending_exception()) {
1491-
fatal_exception_in_compile(JVMCIENV, thread, "Exception during HotSpotJVMCIRuntime initialization");
1476+
fatal_exception(JVMCIENV, "Exception during HotSpotJVMCIRuntime initialization");
14921477
}
14931478
JVMCIObject jvmci_method = JVMCIENV->get_jvmci_method(method, JVMCIENV);
14941479
if (JVMCIENV->has_pending_exception()) {
@@ -1523,7 +1508,7 @@ void JVMCIRuntime::compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, c
15231508
} else {
15241509
// An uncaught exception here implies failure during compiler initialization.
15251510
// The only sensible thing to do here is to exit the VM.
1526-
fatal_exception_in_compile(JVMCIENV, thread, "Exception during JVMCI compiler initialization");
1511+
fatal_exception(JVMCIENV, "Exception during JVMCI compiler initialization");
15271512
}
15281513
if (compiler->is_bootstrapping()) {
15291514
compiler->set_bootstrap_compilation_request_handled();

src/hotspot/share/jvmci/jvmciRuntime.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,16 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
303303
char* speculations,
304304
int speculations_len);
305305

306-
// Exits the VM due to an unexpected exception.
307-
static void exit_on_pending_exception(JVMCIEnv* JVMCIENV, const char* message);
306+
// Reports an unexpected exception and exits the VM with a fatal error.
307+
static void fatal_exception(JVMCIEnv* JVMCIENV, const char* message);
308308

309309
static void describe_pending_hotspot_exception(JavaThread* THREAD, bool clear);
310310

311311
#define CHECK_EXIT THREAD); \
312312
if (HAS_PENDING_EXCEPTION) { \
313313
char buf[256]; \
314314
jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
315-
JVMCIRuntime::exit_on_pending_exception(NULL, buf); \
315+
JVMCIRuntime::fatal_exception(NULL, buf); \
316316
return; \
317317
} \
318318
(void)(0
@@ -321,7 +321,7 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
321321
if (HAS_PENDING_EXCEPTION) { \
322322
char buf[256]; \
323323
jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
324-
JVMCIRuntime::exit_on_pending_exception(NULL, buf); \
324+
JVMCIRuntime::fatal_exception(NULL, buf); \
325325
return v; \
326326
} \
327327
(void)(0
@@ -330,7 +330,7 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
330330
if (JVMCIENV->has_pending_exception()) { \
331331
char buf[256]; \
332332
jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
333-
JVMCIRuntime::exit_on_pending_exception(JVMCIENV, buf); \
333+
JVMCIRuntime::fatal_exception(JVMCIENV, buf); \
334334
return; \
335335
} \
336336
(void)(0
@@ -339,7 +339,7 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
339339
if (JVMCIENV->has_pending_exception()) { \
340340
char buf[256]; \
341341
jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
342-
JVMCIRuntime::exit_on_pending_exception(JVMCIENV, buf); \
342+
JVMCIRuntime::fatal_exception(JVMCIENV, buf); \
343343
return result; \
344344
} \
345345
(void)(0

0 commit comments

Comments
 (0)