src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.inline.hpp
changeset 47998 fb0275c320a0
parent 47216 71c04702a3d5
child 48628 69d65d9dcadb
equal deleted inserted replaced
47997:55c43e677ded 47998:fb0275c320a0
     1 /*
     1 /*
     2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    23  */
    23  */
    24 
    24 
    25 #ifndef SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP
    25 #ifndef SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP
    26 #define SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP
    26 #define SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP
    27 
    27 
       
    28 #include "gc/shared/accessBarrierSupport.inline.hpp"
    28 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
    29 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
    29 #include "oops/oop.inline.hpp"
    30 #include "oops/oop.inline.hpp"
    30 
    31 
    31 // We export this to make it available in cases where the static
    32 template <DecoratorSet decorators, typename T>
    32 // type of the barrier set is known.  Note that it is non-virtual.
    33 inline void G1SATBCardTableModRefBS::write_ref_field_pre(T* field) {
    33 template <class T> void G1SATBCardTableModRefBS::inline_write_ref_field_pre(T* field, oop newVal) {
    34   if (HasDecorator<decorators, ARRAYCOPY_DEST_NOT_INITIALIZED>::value ||
       
    35       HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
       
    36     return;
       
    37   }
       
    38 
    34   T heap_oop = oopDesc::load_heap_oop(field);
    39   T heap_oop = oopDesc::load_heap_oop(field);
    35   if (!oopDesc::is_null(heap_oop)) {
    40   if (!oopDesc::is_null(heap_oop)) {
    36     enqueue(oopDesc::decode_heap_oop(heap_oop));
    41     enqueue(oopDesc::decode_heap_oop_not_null(heap_oop));
    37   }
    42   }
    38 }
    43 }
    39 
    44 
    40 // These are the more general virtual versions.
    45 template <DecoratorSet decorators, typename T>
    41 void G1SATBCardTableModRefBS::write_ref_field_pre_work(oop* field, oop new_val) {
    46 inline void G1SATBCardTableLoggingModRefBS::write_ref_field_post(T* field, oop new_val) {
    42   inline_write_ref_field_pre(field, new_val);
    47   volatile jbyte* byte = byte_for(field);
    43 }
    48   if (*byte != g1_young_gen) {
    44 void G1SATBCardTableModRefBS::write_ref_field_pre_work(narrowOop* field, oop new_val) {
    49     // Take a slow path for cards in old
    45   inline_write_ref_field_pre(field, new_val);
    50     write_ref_field_post_slow(byte);
       
    51   }
    46 }
    52 }
    47 
    53 
    48 void G1SATBCardTableModRefBS::set_card_claimed(size_t card_index) {
    54 void G1SATBCardTableModRefBS::set_card_claimed(size_t card_index) {
    49   jbyte val = _byte_map[card_index];
    55   jbyte val = _byte_map[card_index];
    50   if (val == clean_card_val()) {
    56   if (val == clean_card_val()) {
    53     val |= (jbyte)claimed_card_val();
    59     val |= (jbyte)claimed_card_val();
    54   }
    60   }
    55   _byte_map[card_index] = val;
    61   _byte_map[card_index] = val;
    56 }
    62 }
    57 
    63 
       
    64 inline void G1SATBCardTableModRefBS::enqueue_if_weak(DecoratorSet decorators, oop value) {
       
    65   assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
       
    66   const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;
       
    67   const bool peek              = (decorators & AS_NO_KEEPALIVE) != 0;
       
    68 
       
    69   if (!peek && !on_strong_oop_ref && value != NULL) {
       
    70     enqueue(value);
       
    71   }
       
    72 }
       
    73 
       
    74 template <DecoratorSet decorators, typename BarrierSetT>
       
    75 template <typename T>
       
    76 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
       
    77 oop_load_not_in_heap(T* addr) {
       
    78   oop value = ModRef::oop_load_not_in_heap(addr);
       
    79   enqueue_if_weak(decorators, value);
       
    80   return value;
       
    81 }
       
    82 
       
    83 template <DecoratorSet decorators, typename BarrierSetT>
       
    84 template <typename T>
       
    85 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
       
    86 oop_load_in_heap(T* addr) {
       
    87   oop value = ModRef::oop_load_in_heap(addr);
       
    88   enqueue_if_weak(decorators, value);
       
    89   return value;
       
    90 }
       
    91 
       
    92 template <DecoratorSet decorators, typename BarrierSetT>
       
    93 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
       
    94 oop_load_in_heap_at(oop base, ptrdiff_t offset) {
       
    95   oop value = ModRef::oop_load_in_heap_at(base, offset);
       
    96   enqueue_if_weak(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), value);
       
    97   return value;
       
    98 }
       
    99 
       
   100 template <DecoratorSet decorators, typename BarrierSetT>
       
   101 template <typename T>
       
   102 inline void G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
       
   103 oop_store_not_in_heap(T* addr, oop new_value) {
       
   104   if (HasDecorator<decorators, IN_CONCURRENT_ROOT>::value) {
       
   105     // For roots not scanned in a safepoint, we have to apply SATB barriers
       
   106     // even for roots.
       
   107     G1SATBCardTableLoggingModRefBS *bs = barrier_set_cast<G1SATBCardTableLoggingModRefBS>(BarrierSet::barrier_set());
       
   108     bs->write_ref_field_pre<decorators>(addr);
       
   109   }
       
   110   Raw::oop_store(addr, new_value);
       
   111 }
       
   112 
    58 #endif // SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP
   113 #endif // SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP