< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2013, 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
  *

@@ -20,11 +20,10 @@
  * questions.
  *
  */
 
 #include "precompiled.hpp"
-#include "gc/g1/g1BarrierSet.hpp"
 #include "gc/shenandoah/shenandoahAsserts.hpp"
 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
 #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
 #include "gc/shenandoah/shenandoahHeap.inline.hpp"

@@ -206,35 +205,29 @@
     ShenandoahUpdateRefsForOopClosure</* wb = */ false> cl;
     obj->oop_iterate(&cl);
   }
 }
 
-oop ShenandoahBarrierSet::read_barrier(oop src) {
-  // Check for forwarded objects, because on Full GC path we might deal with
-  // non-trivial fwdptrs that contain Full GC specific metadata. We could check
-  // for is_full_gc_in_progress(), but this also covers the case of stable heap,
-  // which provides a bit of performance improvement.
-  if (ShenandoahReadBarrier && _heap->has_forwarded_objects()) {
-    return ShenandoahBarrierSet::resolve_forwarded(src);
+oop ShenandoahBarrierSet::load_reference_barrier_not_null(oop obj) {
+  if (ShenandoahLoadRefBarrier && _heap->has_forwarded_objects()) {
+    return load_reference_barrier_impl(obj);
   } else {
-    return src;
+    return obj;
   }
 }
 
-bool ShenandoahBarrierSet::obj_equals(oop obj1, oop obj2) {
-  bool eq = oopDesc::equals_raw(obj1, obj2);
-  if (! eq && ShenandoahAcmpBarrier) {
-    OrderAccess::loadload();
-    obj1 = resolve_forwarded(obj1);
-    obj2 = resolve_forwarded(obj2);
-    eq = oopDesc::equals_raw(obj1, obj2);
+oop ShenandoahBarrierSet::load_reference_barrier(oop obj) {
+  if (obj != NULL) {
+    return load_reference_barrier_not_null(obj);
+  } else {
+    return obj;
   }
-  return eq;
 }
 
-oop ShenandoahBarrierSet::write_barrier_mutator(oop obj) {
-  assert(UseShenandoahGC && ShenandoahWriteBarrier, "should be enabled");
+
+oop ShenandoahBarrierSet::load_reference_barrier_mutator(oop obj) {
+  assert(ShenandoahLoadRefBarrier, "should be enabled");
   assert(_heap->is_gc_in_progress_mask(ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL), "evac should be in progress");
   shenandoah_assert_in_cset(NULL, obj);
 
   oop fwd = resolve_forwarded_not_null(obj);
   if (oopDesc::equals_raw(obj, fwd)) {

@@ -276,12 +269,12 @@
     return res_oop;
   }
   return fwd;
 }
 
-oop ShenandoahBarrierSet::write_barrier_impl(oop obj) {
-  assert(UseShenandoahGC && ShenandoahWriteBarrier, "should be enabled");
+oop ShenandoahBarrierSet::load_reference_barrier_impl(oop obj) {
+  assert(ShenandoahLoadRefBarrier, "should be enabled");
   if (!CompressedOops::is_null(obj)) {
     bool evac_in_progress = _heap->is_gc_in_progress_mask(ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL);
     oop fwd = resolve_forwarded_not_null(obj);
     if (evac_in_progress &&
         _heap->in_collection_set(obj) &&

@@ -299,29 +292,14 @@
   } else {
     return obj;
   }
 }
 
-oop ShenandoahBarrierSet::write_barrier(oop obj) {
-  if (ShenandoahWriteBarrier && _heap->has_forwarded_objects()) {
-    return write_barrier_impl(obj);
-  } else {
-    return obj;
-  }
-}
-
-oop ShenandoahBarrierSet::storeval_barrier(oop obj) {
-  if (ShenandoahStoreValEnqueueBarrier) {
-    if (!CompressedOops::is_null(obj)) {
-      obj = write_barrier(obj);
-      enqueue(obj);
-    }
-  }
-  if (ShenandoahStoreValReadBarrier) {
-    obj = resolve_forwarded(obj);
+void ShenandoahBarrierSet::storeval_barrier(oop obj) {
+  if (ShenandoahStoreValEnqueueBarrier && !CompressedOops::is_null(obj)) {
+    enqueue(obj);
   }
-  return obj;
 }
 
 void ShenandoahBarrierSet::keep_alive_barrier(oop obj) {
   if (ShenandoahKeepAliveBarrier && _heap->is_concurrent_mark_in_progress()) {
     enqueue(obj);

@@ -333,19 +311,13 @@
   if (!_satb_mark_queue_set.is_active()) return;
 
   // Filter marked objects before hitting the SATB queues. The same predicate would
   // be used by SATBMQ::filter to eliminate already marked objects downstream, but
   // filtering here helps to avoid wasteful SATB queueing work to begin with.
-  if (!_heap->requires_marking(obj)) return;
+  if (!_heap->requires_marking<false>(obj)) return;
 
-  Thread* thr = Thread::current();
-  if (thr->is_Java_thread()) {
-    ShenandoahThreadLocalData::satb_mark_queue(thr).enqueue(obj);
-  } else {
-    MutexLockerEx x(Shared_SATB_Q_lock, Mutex::_no_safepoint_check_flag);
-    _satb_mark_queue_set.shared_satb_queue()->enqueue(obj);
-  }
+  ShenandoahThreadLocalData::satb_mark_queue(Thread::current()).enqueue(obj);
 }
 
 void ShenandoahBarrierSet::on_thread_create(Thread* thread) {
   // Create thread local data
   ShenandoahThreadLocalData::create(thread);

@@ -354,23 +326,28 @@
 void ShenandoahBarrierSet::on_thread_destroy(Thread* thread) {
   // Destroy thread local data
   ShenandoahThreadLocalData::destroy(thread);
 }
 
-void ShenandoahBarrierSet::on_thread_attach(JavaThread* thread) {
-  assert(!SafepointSynchronize::is_at_safepoint(), "We should not be at a safepoint");
-  assert(!ShenandoahThreadLocalData::satb_mark_queue(thread).is_active(), "SATB queue should not be active");
-  assert(ShenandoahThreadLocalData::satb_mark_queue(thread).is_empty(), "SATB queue should be empty");
-  if (ShenandoahBarrierSet::satb_mark_queue_set().is_active()) {
-    ShenandoahThreadLocalData::satb_mark_queue(thread).set_active(true);
-  }
-  ShenandoahThreadLocalData::set_gc_state(thread, _heap->gc_state());
-  ShenandoahThreadLocalData::initialize_gclab(thread);
-}
-
-void ShenandoahBarrierSet::on_thread_detach(JavaThread* thread) {
-  ShenandoahThreadLocalData::satb_mark_queue(thread).flush();
-  PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
-  if (gclab != NULL) {
-    gclab->retire();
+void ShenandoahBarrierSet::on_thread_attach(Thread *thread) {
+  assert(!thread->is_Java_thread() || !SafepointSynchronize::is_at_safepoint(),
+         "We should not be at a safepoint");
+  SATBMarkQueue& queue = ShenandoahThreadLocalData::satb_mark_queue(thread);
+  assert(!queue.is_active(), "SATB queue should not be active");
+  assert( queue.is_empty(),  "SATB queue should be empty");
+  queue.set_active(_satb_mark_queue_set.is_active());
+  if (thread->is_Java_thread()) {
+    ShenandoahThreadLocalData::set_gc_state(thread, _heap->gc_state());
+    ShenandoahThreadLocalData::initialize_gclab(thread);
+  }
+}
+
+void ShenandoahBarrierSet::on_thread_detach(Thread *thread) {
+  SATBMarkQueue& queue = ShenandoahThreadLocalData::satb_mark_queue(thread);
+  queue.flush();
+  if (thread->is_Java_thread()) {
+    PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
+    if (gclab != NULL) {
+      gclab->retire();
+    }
   }
 }
< prev index next >