src/hotspot/share/jvmci/jvmciRuntime.cpp
changeset 55317 b76aee290002
parent 55293 d19dc5b10fbb
child 55454 8892555795cd
equal deleted inserted replaced
55316:218f5a414379 55317:b76aee290002
  1337   // without any intervening modification of the system
  1337   // without any intervening modification of the system
  1338   // dictionary.  That means they were invalidly constructed.
  1338   // dictionary.  That means they were invalidly constructed.
  1339   return JVMCI::dependencies_invalid;
  1339   return JVMCI::dependencies_invalid;
  1340 }
  1340 }
  1341 
  1341 
       
  1342 // Reports a pending exception and exits the VM.
       
  1343 static void fatal_exception_in_compile(JVMCIEnv* JVMCIENV, JavaThread* thread, const char* msg) {
       
  1344   // Only report a fatal JVMCI compilation exception once
       
  1345   static volatile int report_init_failure = 0;
       
  1346   if (!report_init_failure && Atomic::cmpxchg(1, &report_init_failure, 0) == 0) {
       
  1347       tty->print_cr("%s:", msg);
       
  1348       JVMCIENV->describe_pending_exception(true);
       
  1349   }
       
  1350   JVMCIENV->clear_pending_exception();
       
  1351   before_exit(thread);
       
  1352   vm_exit(-1);
       
  1353 }
  1342 
  1354 
  1343 void JVMCIRuntime::compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, const methodHandle& method, int entry_bci) {
  1355 void JVMCIRuntime::compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, const methodHandle& method, int entry_bci) {
  1344   JVMCI_EXCEPTION_CONTEXT
  1356   JVMCI_EXCEPTION_CONTEXT
  1345 
  1357 
  1346   JVMCICompileState* compile_state = JVMCIENV->compile_state();
  1358   JVMCICompileState* compile_state = JVMCIENV->compile_state();
  1358   }
  1370   }
  1359 
  1371 
  1360   HandleMark hm;
  1372   HandleMark hm;
  1361   JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV);
  1373   JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV);
  1362   if (JVMCIENV->has_pending_exception()) {
  1374   if (JVMCIENV->has_pending_exception()) {
  1363     JVMCIENV->describe_pending_exception(true);
  1375     fatal_exception_in_compile(JVMCIENV, thread, "Exception during HotSpotJVMCIRuntime initialization");
  1364     compile_state->set_failure(false, "exception getting HotSpotJVMCIRuntime object");
       
  1365     return;
       
  1366   }
  1376   }
  1367   JVMCIObject jvmci_method = JVMCIENV->get_jvmci_method(method, JVMCIENV);
  1377   JVMCIObject jvmci_method = JVMCIENV->get_jvmci_method(method, JVMCIENV);
  1368   if (JVMCIENV->has_pending_exception()) {
  1378   if (JVMCIENV->has_pending_exception()) {
  1369     JVMCIENV->describe_pending_exception(true);
  1379     JVMCIENV->describe_pending_exception(true);
  1370     compile_state->set_failure(false, "exception getting JVMCI wrapper method");
  1380     compile_state->set_failure(false, "exception getting JVMCI wrapper method");
  1395       assert(false, "JVMCICompiler.compileMethod should always return non-null");
  1405       assert(false, "JVMCICompiler.compileMethod should always return non-null");
  1396     }
  1406     }
  1397   } else {
  1407   } else {
  1398     // An uncaught exception here implies failure during compiler initialization.
  1408     // An uncaught exception here implies failure during compiler initialization.
  1399     // The only sensible thing to do here is to exit the VM.
  1409     // The only sensible thing to do here is to exit the VM.
  1400 
  1410     fatal_exception_in_compile(JVMCIENV, thread, "Exception during JVMCI compiler initialization");
  1401     // Only report initialization failure once
       
  1402     static volatile int report_init_failure = 0;
       
  1403     if (!report_init_failure && Atomic::cmpxchg(1, &report_init_failure, 0) == 0) {
       
  1404         tty->print_cr("Exception during JVMCI compiler initialization:");
       
  1405         JVMCIENV->describe_pending_exception(true);
       
  1406     }
       
  1407     JVMCIENV->clear_pending_exception();
       
  1408     before_exit((JavaThread*) THREAD);
       
  1409     vm_exit(-1);
       
  1410   }
  1411   }
  1411   if (compiler->is_bootstrapping()) {
  1412   if (compiler->is_bootstrapping()) {
  1412     compiler->set_bootstrap_compilation_request_handled();
  1413     compiler->set_bootstrap_compilation_request_handled();
  1413   }
  1414   }
  1414 }
  1415 }