8204524: Unnecessary memory barriers in G1ParScanThreadState::copy_to_survivor_space
authormhorie
Mon, 25 Jun 2018 10:41:03 +0200
changeset 50748 d46700d64e9c
parent 50747 66aa2e3ffcbc
child 50749 41a5b2de5ad3
8204524: Unnecessary memory barriers in G1ParScanThreadState::copy_to_survivor_space Reviewed-by: kbarrett, mdoerr, drwhite, tschatzl
src/hotspot/share/gc/g1/g1ParScanThreadState.cpp
src/hotspot/share/oops/oop.hpp
src/hotspot/share/oops/oop.inline.hpp
--- a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp	Mon Jun 25 11:51:04 2018 +0530
+++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp	Mon Jun 25 10:41:03 2018 +0200
@@ -266,7 +266,7 @@
   Prefetch::write(obj_ptr, PrefetchCopyIntervalInBytes);
 
   const oop obj = oop(obj_ptr);
-  const oop forward_ptr = old->forward_to_atomic(obj);
+  const oop forward_ptr = old->forward_to_atomic(obj, memory_order_relaxed);
   if (forward_ptr == NULL) {
     Copy::aligned_disjoint_words((HeapWord*) old, obj_ptr, word_sz);
 
@@ -356,7 +356,7 @@
 oop G1ParScanThreadState::handle_evacuation_failure_par(oop old, markOop m) {
   assert(_g1h->is_in_cset(old), "Object " PTR_FORMAT " should be in the CSet", p2i(old));
 
-  oop forward_ptr = old->forward_to_atomic(old);
+  oop forward_ptr = old->forward_to_atomic(old, memory_order_relaxed);
   if (forward_ptr == NULL) {
     // Forward-to-self succeeded. We are the "owner" of the object.
     HeapRegion* r = _g1h->heap_region_containing(old);
--- a/src/hotspot/share/oops/oop.hpp	Mon Jun 25 11:51:04 2018 +0530
+++ b/src/hotspot/share/oops/oop.hpp	Mon Jun 25 10:41:03 2018 +0200
@@ -266,7 +266,7 @@
   // Exactly one thread succeeds in inserting the forwarding pointer, and
   // this call returns "NULL" for that thread; any other thread has the
   // value of the forwarding pointer returned and does not modify "this".
-  inline oop forward_to_atomic(oop p);
+  inline oop forward_to_atomic(oop p, atomic_memory_order order = memory_order_conservative);
 
   inline oop forwardee() const;
   inline oop forwardee_acquire() const;
--- a/src/hotspot/share/oops/oop.inline.hpp	Mon Jun 25 11:51:04 2018 +0530
+++ b/src/hotspot/share/oops/oop.inline.hpp	Mon Jun 25 10:41:03 2018 +0200
@@ -352,7 +352,7 @@
   return cas_set_mark_raw(m, compare, order) == compare;
 }
 
-oop oopDesc::forward_to_atomic(oop p) {
+oop oopDesc::forward_to_atomic(oop p, atomic_memory_order order) {
   markOop oldMark = mark_raw();
   markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
   markOop curMark;
@@ -361,7 +361,7 @@
   assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
 
   while (!oldMark->is_marked()) {
-    curMark = cas_set_mark_raw(forwardPtrMark, oldMark);
+    curMark = cas_set_mark_raw(forwardPtrMark, oldMark, order);
     assert(is_forwarded(), "object should have been forwarded");
     if (curMark == oldMark) {
       return NULL;