changeset 22543:97ca867d3622

Fix assertion failure in JVMCIRuntime::metadata_do
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Wed, 09 Sep 2015 11:17:58 -0700
parents 15579668ec3a
children b87d1bf3cd9a
files src/share/vm/jvmci/jvmciRuntime.cpp
diffstat 1 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/jvmci/jvmciRuntime.cpp	Wed Sep 09 15:27:45 2015 +0200
+++ b/src/share/vm/jvmci/jvmciRuntime.cpp	Wed Sep 09 11:17:58 2015 -0700
@@ -724,10 +724,20 @@
 }
 
 void JVMCIRuntime::metadata_do(void f(Metadata*)) {
-  if (!is_HotSpotJVMCIRuntime_initialized()) {
-    assert(HotSpotJVMCIMetaAccessContext::klass() == NULL ||
-           !HotSpotJVMCIMetaAccessContext::klass()->is_linked() ||
-           HotSpotJVMCIMetaAccessContext::allContexts() == NULL, "shouldn't be anything registered yet");
+  // For simplicity, the existence of HotSpotJVMCIMetaAccessContext in
+  // the SystemDictionary well known classes should ensure the other
+  // classes have already been loaded, so make sure their order in the
+  // table enforces that.
+  assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_internal_jvmci_hotspot_HotSpotResolvedJavaMethodImpl) <
+         SystemDictionary::WK_KLASS_ENUM_NAME(jdk_internal_jvmci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
+  assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_internal_jvmci_hotspot_HotSpotConstantPool) <
+         SystemDictionary::WK_KLASS_ENUM_NAME(jdk_internal_jvmci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
+  assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_internal_jvmci_hotspot_HotSpotResolvedObjectTypeImpl) <
+         SystemDictionary::WK_KLASS_ENUM_NAME(jdk_internal_jvmci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
+
+  if (HotSpotJVMCIMetaAccessContext::klass() == NULL ||
+      !HotSpotJVMCIMetaAccessContext::klass()->is_linked()) {
+    // Nothing could be registered yet
     return;
   }
 
@@ -736,6 +746,12 @@
   if (allContexts == NULL) {
     return;
   }
+
+  // These must be loaded at this point but the linking state doesn't matter.
+  assert(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass() != NULL, "must be loaded");
+  assert(SystemDictionary::HotSpotConstantPool_klass() != NULL, "must be loaded");
+  assert(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass() != NULL, "must be loaded");
+  
   for (int i = 0; i < allContexts->length(); i++) {
     oop ref = allContexts->obj_at(i);
     if (ref != NULL) {