< prev index next >

src/cpu/x86/vm/macroAssembler_x86.cpp

Print this page
rev 13055 : Implement barriers for maintaining connection matrix.

@@ -43,10 +43,11 @@
 #include "utilities/macros.hpp"
 #if INCLUDE_ALL_GCS
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
 #include "gc/g1/heapRegion.hpp"
+#include "gc/shenandoah/shenandoahConnectionMatrix.hpp"
 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
 #endif // INCLUDE_ALL_GCS
 #include "crc32c.h"
 #ifdef COMPILER2

@@ -5347,24 +5348,55 @@
   if(tosca_live) pop(rax);
 
   bind(done);
 }
 
+void MacroAssembler::shenandoah_write_barrier_post(Register store_addr,
+                                                   Register new_val,
+                                                   Register thread,
+                                                   Register tmp,
+                                                   Register tmp2) {
+  assert(UseShenandoahGC, "why else should we be here?");
+
+  if (! UseShenandoahMatrix) {
+    // No need for that barrier if not using matrix.
+    return;
+  }
+
+  Label done;
+  testptr(new_val, new_val);
+  jcc(Assembler::zero, done);
+  ShenandoahConnectionMatrix* matrix = ShenandoahHeap::heap()->connection_matrix();
+  address matrix_addr = matrix->matrix_addr();
+  movptr(rscratch1, (intptr_t) ShenandoahHeap::heap()->first_region_bottom());
+  // Compute from-region index
+  movptr(tmp, store_addr);
+  subptr(tmp, rscratch1);
+  shrptr(tmp, ShenandoahHeapRegion::RegionSizeShift);
+  // Compute to-region index
+  movptr(tmp2, new_val);
+  subptr(tmp2, rscratch1);
+  shrptr(tmp2, ShenandoahHeapRegion::RegionSizeShift);
+  // Compute matrix index
+  imulq(tmp, tmp, matrix->stride());
+  addq(tmp, tmp2);
+  movptr(rscratch1, (intptr_t) matrix_addr);
+  // Store true at _matrix[from * stride + to]
+  //movb(Address(rscratch1, tmp, Address::times_1), 3 /*true*/);
+  movbool(Address(rscratch1, tmp, Address::times_1), true);
+  bind(done);
+}
+
 void MacroAssembler::g1_write_barrier_post(Register store_addr,
                                            Register new_val,
                                            Register thread,
                                            Register tmp,
                                            Register tmp2) {
 #ifdef _LP64
   assert(thread == r15_thread, "must be");
 #endif // _LP64
 
-  if (UseShenandoahGC) {
-    // No need for this in Shenandoah.
-    return;
-  }
-
   assert(UseG1GC, "expect G1 GC");
 
   Address queue_index(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
                                        DirtyCardQueue::byte_offset_of_index()));
   Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
< prev index next >