src/share/vm/c1/c1_GraphBuilder.cpp

Print this page

        

@@ -1434,11 +1434,11 @@
     call_register_finalizer();
   }
 
   bool need_mem_bar = false;
   if (method()->name() == ciSymbol::object_initializer_name() &&
-      scope()->wrote_final()) {
+      (scope()->wrote_final() || (AlwaysSafeConstructors && scope()->wrote_fields()))) {
     need_mem_bar = true;
   }
 
   // Check to see whether we are inlining. If so, Return
   // instructions become Gotos to the continuation point.

@@ -1548,10 +1548,14 @@
 
   if (field->is_final() && (code == Bytecodes::_putfield)) {
     scope()->set_wrote_final();
   }
 
+  if (code == Bytecodes::_putfield) {
+    scope()->set_wrote_fields();
+  }
+
   const int offset = !needs_patching ? field->offset() : -1;
   switch (code) {
     case Bytecodes::_getstatic: {
       // check for compile-time constants, i.e., initialized static final fields
       Instruction* constant = NULL;