changeset 7822:ce7613869df3

8071821: Assert failed in UnexpectedDeoptimizationTest.java Summary: assert fires in case of concurrent initialization of ciInstanceKlass::_has_injected_fields Reviewed-by: kvn
author roland
date Mon, 09 Feb 2015 13:45:59 +0100
parents e9291d20ecaa
children d0b3b6f5a445
files src/share/vm/ci/ciInstanceKlass.cpp src/share/vm/ci/ciInstanceKlass.hpp
diffstat 2 files changed, 16 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/ci/ciInstanceKlass.cpp	Mon Feb 09 15:10:58 2015 +0100
+++ b/src/share/vm/ci/ciInstanceKlass.cpp	Mon Feb 09 13:45:59 2015 +0100
@@ -501,32 +501,31 @@
   return fields;
 }
 
-void ciInstanceKlass::compute_injected_fields_helper() {
+bool ciInstanceKlass::compute_injected_fields_helper() {
   ASSERT_IN_VM;
   InstanceKlass* k = get_instanceKlass();
 
   for (InternalFieldStream fs(k); !fs.done(); fs.next()) {
     if (fs.access_flags().is_static())  continue;
-    _has_injected_fields++;
-    break;
+    return true;
   }
+  return false;
 }
 
-bool ciInstanceKlass::compute_injected_fields() {
-  assert(_has_injected_fields == -1, "shouldn't be initialized yet");
+void ciInstanceKlass::compute_injected_fields() {
   assert(is_loaded(), "must be loaded");
 
+  int has_injected_fields = 0;
   if (super() != NULL && super()->has_injected_fields()) {
-    _has_injected_fields = 1;
-    return true;
+    has_injected_fields = 1;
+  } else {
+    GUARDED_VM_ENTRY({
+        has_injected_fields = compute_injected_fields_helper() ? 1 : 0;
+      });
   }
-
-  _has_injected_fields = 0;
-  GUARDED_VM_ENTRY({
-      compute_injected_fields_helper();
-    });
-
-  return _has_injected_fields > 0 ? true : false;
+  // may be concurrently initialized for shared ciInstanceKlass objects
+  assert(_has_injected_fields == -1 || _has_injected_fields == has_injected_fields, "broken concurrent initialization");
+  _has_injected_fields = has_injected_fields;
 }
 
 // ------------------------------------------------------------------
--- a/src/share/vm/ci/ciInstanceKlass.hpp	Mon Feb 09 15:10:58 2015 +0100
+++ b/src/share/vm/ci/ciInstanceKlass.hpp	Mon Feb 09 13:45:59 2015 +0100
@@ -72,8 +72,8 @@
   //   Itsef: more than one implementors.
   ciInstanceKlass*       _implementor;
 
-  bool compute_injected_fields();
-  void compute_injected_fields_helper();
+  void compute_injected_fields();
+  bool compute_injected_fields_helper();
 
 protected:
   ciInstanceKlass(KlassHandle h_k);
@@ -193,7 +193,7 @@
 
   bool has_injected_fields() {
     if (_has_injected_fields == -1) {
-      return compute_injected_fields();
+      compute_injected_fields();
     }
     return _has_injected_fields > 0 ? true : false;
   }