< prev index next >

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

Print this page
rev 56771 : 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet


  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "gc/shenandoah/shenandoahAsserts.hpp"
  26 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
  27 #include "gc/shenandoah/shenandoahBarrierSetClone.inline.hpp"
  28 #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
  29 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"

  30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  31 #include "gc/shenandoah/shenandoahHeuristics.hpp"
  32 #include "gc/shenandoah/shenandoahTraversalGC.hpp"
  33 #include "memory/iterator.inline.hpp"
  34 #include "runtime/interfaceSupport.inline.hpp"
  35 #ifdef COMPILER1
  36 #include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp"
  37 #endif
  38 #ifdef COMPILER2
  39 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
  40 #endif
  41 
  42 class ShenandoahBarrierSetC1;
  43 class ShenandoahBarrierSetC2;
  44 
  45 ShenandoahBarrierSet::ShenandoahBarrierSet(ShenandoahHeap* heap) :
  46   BarrierSet(make_barrier_set_assembler<ShenandoahBarrierSetAssembler>(),
  47              make_barrier_set_c1<ShenandoahBarrierSetC1>(),
  48              make_barrier_set_c2<ShenandoahBarrierSetC2>(),
  49              NULL /* barrier_set_nmethod */,


  52   _satb_mark_queue_buffer_allocator("SATB Buffer Allocator", ShenandoahSATBBufferSize),
  53   _satb_mark_queue_set(&_satb_mark_queue_buffer_allocator)
  54 {
  55 }
  56 
  57 ShenandoahBarrierSetAssembler* ShenandoahBarrierSet::assembler() {
  58   BarrierSetAssembler* const bsa = BarrierSet::barrier_set()->barrier_set_assembler();
  59   return reinterpret_cast<ShenandoahBarrierSetAssembler*>(bsa);
  60 }
  61 
  62 void ShenandoahBarrierSet::print_on(outputStream* st) const {
  63   st->print("ShenandoahBarrierSet");
  64 }
  65 
  66 bool ShenandoahBarrierSet::is_a(BarrierSet::Name bsn) {
  67   return bsn == BarrierSet::ShenandoahBarrierSet;
  68 }
  69 
  70 bool ShenandoahBarrierSet::is_aligned(HeapWord* hw) {
  71   return true;






























  72 }
  73 
  74 template <class T>
  75 inline void ShenandoahBarrierSet::inline_write_ref_field_pre(T* field, oop new_val) {
  76   shenandoah_assert_not_in_cset_loc_except(field, _heap->cancelled_gc());
  77   if (_heap->is_concurrent_mark_in_progress()) {
  78     T heap_oop = RawAccess<>::oop_load(field);
  79     if (!CompressedOops::is_null(heap_oop)) {
  80       enqueue(CompressedOops::decode(heap_oop));
  81     }
  82   }
  83 }
  84 
  85 // These are the more general virtual versions.
  86 void ShenandoahBarrierSet::write_ref_field_pre_work(oop* field, oop new_val) {
  87   inline_write_ref_field_pre(field, new_val);
  88 }
  89 
  90 void ShenandoahBarrierSet::write_ref_field_pre_work(narrowOop* field, oop new_val) {
  91   inline_write_ref_field_pre(field, new_val);




  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "gc/shenandoah/shenandoahAsserts.hpp"
  26 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
  27 #include "gc/shenandoah/shenandoahBarrierSetClone.inline.hpp"
  28 #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
  29 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
  30 #include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
  31 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  32 #include "gc/shenandoah/shenandoahHeuristics.hpp"
  33 #include "gc/shenandoah/shenandoahTraversalGC.hpp"
  34 #include "memory/iterator.inline.hpp"
  35 #include "runtime/interfaceSupport.inline.hpp"
  36 #ifdef COMPILER1
  37 #include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp"
  38 #endif
  39 #ifdef COMPILER2
  40 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
  41 #endif
  42 
  43 class ShenandoahBarrierSetC1;
  44 class ShenandoahBarrierSetC2;
  45 
  46 ShenandoahBarrierSet::ShenandoahBarrierSet(ShenandoahHeap* heap) :
  47   BarrierSet(make_barrier_set_assembler<ShenandoahBarrierSetAssembler>(),
  48              make_barrier_set_c1<ShenandoahBarrierSetC1>(),
  49              make_barrier_set_c2<ShenandoahBarrierSetC2>(),
  50              NULL /* barrier_set_nmethod */,


  53   _satb_mark_queue_buffer_allocator("SATB Buffer Allocator", ShenandoahSATBBufferSize),
  54   _satb_mark_queue_set(&_satb_mark_queue_buffer_allocator)
  55 {
  56 }
  57 
  58 ShenandoahBarrierSetAssembler* ShenandoahBarrierSet::assembler() {
  59   BarrierSetAssembler* const bsa = BarrierSet::barrier_set()->barrier_set_assembler();
  60   return reinterpret_cast<ShenandoahBarrierSetAssembler*>(bsa);
  61 }
  62 
  63 void ShenandoahBarrierSet::print_on(outputStream* st) const {
  64   st->print("ShenandoahBarrierSet");
  65 }
  66 
  67 bool ShenandoahBarrierSet::is_a(BarrierSet::Name bsn) {
  68   return bsn == BarrierSet::ShenandoahBarrierSet;
  69 }
  70 
  71 bool ShenandoahBarrierSet::is_aligned(HeapWord* hw) {
  72   return true;
  73 }
  74 
  75 bool ShenandoahBarrierSet::need_load_reference_barrier(DecoratorSet decorators, BasicType type) {
  76   if (!ShenandoahLoadRefBarrier) return false;
  77   // Only needed for references
  78   if (!is_reference_type(type)) return false;
  79   return true;
  80 }
  81 
  82 bool ShenandoahBarrierSet::use_native_load_reference_barrier(DecoratorSet decorators, BasicType type) {
  83   assert(need_load_reference_barrier(decorators, type), "Why ask?");
  84   assert(is_reference_type(type), "Why we here?");
  85   // Native load reference barrier is only needed for concurrent root processing
  86   if (!ShenandoahConcurrentRoots::can_do_concurrent_roots()) {
  87     return false;
  88   }
  89 
  90   return (decorators & IN_NATIVE) != 0;
  91 }
  92 
  93 bool ShenandoahBarrierSet::need_keep_alive_barrier(DecoratorSet decorators,BasicType type) {
  94   if (!ShenandoahKeepAliveBarrier) return false;
  95   // Only needed for references
  96   if (!is_reference_type(type)) return false;
  97 
  98   bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0;
  99   bool unknown = (decorators & ON_UNKNOWN_OOP_REF) != 0;
 100   bool is_traversal_mode = ShenandoahHeap::heap()->is_traversal_mode();
 101   bool on_weak_ref = (decorators & (ON_WEAK_OOP_REF | ON_PHANTOM_OOP_REF)) != 0;
 102   return (on_weak_ref || unknown) && (keep_alive || is_traversal_mode);
 103 }
 104 
 105 template <class T>
 106 inline void ShenandoahBarrierSet::inline_write_ref_field_pre(T* field, oop new_val) {
 107   shenandoah_assert_not_in_cset_loc_except(field, _heap->cancelled_gc());
 108   if (_heap->is_concurrent_mark_in_progress()) {
 109     T heap_oop = RawAccess<>::oop_load(field);
 110     if (!CompressedOops::is_null(heap_oop)) {
 111       enqueue(CompressedOops::decode(heap_oop));
 112     }
 113   }
 114 }
 115 
 116 // These are the more general virtual versions.
 117 void ShenandoahBarrierSet::write_ref_field_pre_work(oop* field, oop new_val) {
 118   inline_write_ref_field_pre(field, new_val);
 119 }
 120 
 121 void ShenandoahBarrierSet::write_ref_field_pre_work(narrowOop* field, oop new_val) {
 122   inline_write_ref_field_pre(field, new_val);


< prev index next >