changeset 16683:4d0d1dc5db00

introduce extra field to record when HotSpotGraalRuntime has been initialized to avoid spurious errors during VM shutdown for short lived applications
author Doug Simon <doug.simon@oracle.com>
date Mon, 04 Aug 2014 23:25:14 +0200
parents 63706366f6c5
children 6fdfe46660a1
files src/share/vm/graal/graalRuntime.cpp src/share/vm/graal/graalRuntime.hpp
diffstat 2 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/graal/graalRuntime.cpp	Mon Aug 04 16:50:50 2014 +0200
+++ b/src/share/vm/graal/graalRuntime.cpp	Mon Aug 04 23:25:14 2014 +0200
@@ -39,6 +39,7 @@
 
 address GraalRuntime::_external_deopt_i2c_entry = NULL;
 jobject GraalRuntime::_HotSpotGraalRuntime_instance = NULL;
+bool GraalRuntime::_HotSpotGraalRuntime_initialized = false;
 
 void GraalRuntime::initialize_natives(JNIEnv *env, jclass c2vmClass) {
   uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end();
@@ -681,6 +682,7 @@
 
 Handle GraalRuntime::get_HotSpotGraalRuntime() {
   if (JNIHandles::resolve(_HotSpotGraalRuntime_instance) == NULL) {
+    guarantee(!_HotSpotGraalRuntime_initialized, "cannot reinitialize HotSpotGraalRuntime");
     Thread* THREAD = Thread::current();
     check_generated_sources_sha1(CHECK_ABORT_(Handle()));
     TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", CHECK_ABORT_(Handle()));
@@ -690,6 +692,7 @@
     JavaValue result(T_OBJECT);
     JavaCalls::call_static(&result, klass, runtime, sig, CHECK_ABORT_(Handle()));
     _HotSpotGraalRuntime_instance = JNIHandles::make_global((oop) result.get_jobject());
+    _HotSpotGraalRuntime_initialized = true;
   }
   return Handle(JNIHandles::resolve_non_null(_HotSpotGraalRuntime_instance));
 }
--- a/src/share/vm/graal/graalRuntime.hpp	Mon Aug 04 16:50:50 2014 +0200
+++ b/src/share/vm/graal/graalRuntime.hpp	Mon Aug 04 23:25:14 2014 +0200
@@ -32,6 +32,7 @@
  private:
 
   static jobject _HotSpotGraalRuntime_instance;
+  static bool _HotSpotGraalRuntime_initialized;
   static address _external_deopt_i2c_entry;
   static const char* _generated_sources_sha1;
 
@@ -111,7 +112,7 @@
 
   static void initialize_natives(JNIEnv *env, jclass c2vmClass);
 
-  static bool is_HotSpotGraalRuntime_initialized() { return _HotSpotGraalRuntime_instance != NULL; }
+  static bool is_HotSpotGraalRuntime_initialized() { return _HotSpotGraalRuntime_initialized; }
 
   /**
    * Gets the singleton HotSpotGraalRuntime instance, initializing it if necessary