changeset 9619:40d499730aad

Don't do repeated write barrier on same object. Re-use the first that comes.
author rkennke
date Wed, 16 Sep 2015 17:21:00 +0200
parents 32062879e445
children 818dd82363ec
files src/share/vm/opto/graphKit.cpp src/share/vm/opto/phaseX.cpp src/share/vm/opto/shenandoahSupport.cpp
diffstat 3 files changed, 35 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/graphKit.cpp	Wed Sep 16 17:20:28 2015 +0200
+++ b/src/share/vm/opto/graphKit.cpp	Wed Sep 16 17:21:00 2015 +0200
@@ -4461,13 +4461,16 @@
     }
     const Type* obj_type = obj->bottom_type();
     const TypePtr* adr_type = obj_type->is_ptr()->add_offset(-8);
-    ShenandoahWriteBarrierNode* wb = new ShenandoahWriteBarrierNode(NULL, memory(adr_type), obj);
+    // tty->print("wb for: "); obj->dump();
+    ShenandoahWriteBarrierNode* wb = new ShenandoahWriteBarrierNode(NULL, immutable_memory(), obj);
+    // tty->print("........"); wb->dump();
     Node* n = _gvn.transform(wb);
     if (wb == n) {
       Node* proj = _gvn.transform(new ShenandoahWBMemProjNode(wb));
       set_memory(proj, adr_type);
     }
     record_for_igvn(n);
+    replace_in_map(obj, n);
     return n;
 
   } else {
--- a/src/share/vm/opto/phaseX.cpp	Wed Sep 16 17:20:28 2015 +0200
+++ b/src/share/vm/opto/phaseX.cpp	Wed Sep 16 17:21:00 2015 +0200
@@ -1241,7 +1241,7 @@
 
   // Global Value Numbering
   i = hash_find_insert(k);      // Check for pre-existing node
-  if (i && (i != k)) {
+  if (i && (i != k) && k->Opcode() != Op_ShenandoahWriteBarrier) {
     // Return the pre-existing node if it isn't dead
     NOT_PRODUCT(set_progress();)
     if (k->Opcode() == Op_ShenandoahWriteBarrier) {
--- a/src/share/vm/opto/shenandoahSupport.cpp	Wed Sep 16 17:20:28 2015 +0200
+++ b/src/share/vm/opto/shenandoahSupport.cpp	Wed Sep 16 17:21:00 2015 +0200
@@ -167,7 +167,7 @@
 
 Node* ShenandoahReadBarrierNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 
-  if (! can_reshape) {
+  if (true || ! can_reshape) {
     return NULL;
   }
 
@@ -208,7 +208,7 @@
 
 Node* ShenandoahWriteBarrierNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 
-  if (! can_reshape) return NULL;
+  if (true || ! can_reshape) return NULL;
 
   if (in(Memory) == phase->C->immutable_memory()) return NULL;
 
@@ -240,15 +240,27 @@
   // check_invariants();
 #endif
 
-  // if (true) return this;
+  if (Opcode() == Op_ShenandoahWriteBarrier) return this;
 
   Node* n = in(ValueIn);
   Node* rb_mem = Opcode() == Op_ShenandoahReadBarrier ? in(Memory) : NULL;
   if (! needs_barrier(phase, n, rb_mem)) {
-    return kill_mem_proj(phase, n);
+    if (Opcode() == Op_ShenandoahWriteBarrier) {
+      if (n->Opcode() == Op_ShenandoahWriteBarrier) {
+	return n;
+      } else {
+#ifdef ASSERT
+	tty->print("could not elide wb: "); dump();
+	tty->print("with..............: "); n->dump();
+#endif
+	return this;
+      }
+    } else {
+      return n;
+    }
   }
 
-  // if (true) return this;
+  if (Opcode() == Op_ShenandoahWriteBarrier) return this;
 
   // Try to find a write barrier sibling with identical inputs that we can fold into.
   for (DUIterator i = n->outs(); n->has_out(i); i++) {
@@ -256,6 +268,11 @@
     if (sibling == this) {
       continue;
     }
+    /*
+    assert(sibling->Opcode() != Op_ShenandoahWriteBarrier ||
+	   Opcode() != Op_ShenandoahWriteBarrier || hash() == sibling->hash(),
+	   "if this is a write barrier, then sibling can't be write barrier too");
+    */
     if (sibling->Opcode() != Op_ShenandoahWriteBarrier) {
       continue;
     }
@@ -375,13 +392,13 @@
 }
 
 void ShenandoahBarrierNode::check_invariants() {
-  if (Opcode() == Op_ShenandoahWriteBarrier) {
-    uint mem_projs = num_mem_projs();
-    if (mem_projs > 1) {
-      tty->print_cr("num_mem_proj: %u", mem_projs);
-      dump(2);
-    }
-    assert(mem_projs <= 1, "exactly 1 memory projection");
-  }
+  // if (Opcode() == Op_ShenandoahWriteBarrier) {
+  //   uint mem_projs = num_mem_projs();
+  //   if (mem_projs > 1) {
+  //     tty->print_cr("num_mem_proj: %u", mem_projs);
+  //     dump(2);
+  //   }
+  //   assert(mem_projs <= 1, "exactly 1 memory projection");
+  // }
 }
 #endif