< prev index next >

src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp

Print this page
rev 57544 : 8236485: Work-in-progress: Epoch synchronization protocol for G1 concurrent refinement
Reviewed-by:


  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_G1_G1BARRIERSET_INLINE_HPP
  26 #define SHARE_GC_G1_G1BARRIERSET_INLINE_HPP
  27 
  28 #include "gc/g1/g1BarrierSet.hpp"
  29 #include "gc/g1/g1CardTable.hpp"
  30 #include "gc/shared/accessBarrierSupport.inline.hpp"
  31 #include "oops/access.inline.hpp"
  32 #include "oops/compressedOops.inline.hpp"
  33 #include "oops/oop.hpp"



  34 
  35 template <DecoratorSet decorators, typename T>
  36 inline void G1BarrierSet::write_ref_field_pre(T* field) {
  37   if (HasDecorator<decorators, IS_DEST_UNINITIALIZED>::value ||
  38       HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
  39     return;
  40   }
  41 
  42   T heap_oop = RawAccess<MO_VOLATILE>::oop_load(field);
  43   if (!CompressedOops::is_null(heap_oop)) {
  44     enqueue(CompressedOops::decode_not_null(heap_oop));
  45   }
  46 }
  47 
  48 template <DecoratorSet decorators, typename T>
  49 inline void G1BarrierSet::write_ref_field_post(T* field, oop new_val) {




















  50   volatile CardValue* byte = _card_table->byte_for(field);
  51   if (*byte != G1CardTable::g1_young_card_val()) {
  52     // Take a slow path for cards in old
  53     write_ref_field_post_slow(byte);
  54   }
  55 }
  56 
  57 inline void G1BarrierSet::enqueue_if_weak(DecoratorSet decorators, oop value) {
  58   assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
  59   // Loading from a weak or phantom reference needs enqueueing, as
  60   // the object may not have been reachable (part of the snapshot)
  61   // when marking started.
  62   const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;
  63   const bool peek              = (decorators & AS_NO_KEEPALIVE) != 0;
  64   const bool needs_enqueue     = (!peek && !on_strong_oop_ref);
  65 
  66   if (needs_enqueue && value != NULL) {
  67     enqueue(value);
  68   }
  69 }




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_G1_G1BARRIERSET_INLINE_HPP
  26 #define SHARE_GC_G1_G1BARRIERSET_INLINE_HPP
  27 
  28 #include "gc/g1/g1BarrierSet.hpp"
  29 #include "gc/g1/g1CardTable.hpp"
  30 #include "gc/shared/accessBarrierSupport.inline.hpp"
  31 #include "oops/access.inline.hpp"
  32 #include "oops/compressedOops.inline.hpp"
  33 #include "oops/oop.hpp"
  34 #ifdef ASSERT
  35 #include "runtime/thread.inline.hpp"
  36 #endif
  37 
  38 template <DecoratorSet decorators, typename T>
  39 inline void G1BarrierSet::write_ref_field_pre(T* field) {
  40   if (HasDecorator<decorators, IS_DEST_UNINITIALIZED>::value ||
  41       HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
  42     return;
  43   }
  44 
  45   T heap_oop = RawAccess<MO_VOLATILE>::oop_load(field);
  46   if (!CompressedOops::is_null(heap_oop)) {
  47     enqueue(CompressedOops::decode_not_null(heap_oop));
  48   }
  49 }
  50 
  51 template <DecoratorSet decorators, typename T>
  52 inline void G1BarrierSet::write_ref_field_post(T* field, oop new_val) {
  53 /*
  54 #ifdef ASSERT
  55   if (Thread::current()->is_Java_thread()) {
  56     JavaThreadState s = ((JavaThread*)Thread::current())->thread_state();
  57     if (s != _thread_in_vm) {
  58       tty->print_cr("T(%s).state = %d", Thread::current()->name(), s);
  59       assert(false, "fail");
  60     }
  61   } else {
  62     tty->print_cr("T(%s) not JavaThread", Thread::current()->name());
  63     tty->print_cr("At safepoint? %d", SafepointSynchronize::is_at_safepoint());
  64     assert(false, "fail");
  65   }
  66 #endif
  67 */
  68 //  assert(SafepointSynchronize::is_at_safepoint() ||
  69 //         (Thread::current()->is_Java_thread() &&
  70 //             ((JavaThread*)Thread::current())->thread_state() == _thread_in_vm),
  71 //         "sanity");
  72 
  73   volatile CardValue* byte = _card_table->byte_for(field);
  74   if (*byte != G1CardTable::g1_young_card_val()) {
  75     // Take a slow path for cards in old
  76     write_ref_field_post_slow(byte);
  77   }
  78 }
  79 
  80 inline void G1BarrierSet::enqueue_if_weak(DecoratorSet decorators, oop value) {
  81   assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
  82   // Loading from a weak or phantom reference needs enqueueing, as
  83   // the object may not have been reachable (part of the snapshot)
  84   // when marking started.
  85   const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;
  86   const bool peek              = (decorators & AS_NO_KEEPALIVE) != 0;
  87   const bool needs_enqueue     = (!peek && !on_strong_oop_ref);
  88 
  89   if (needs_enqueue && value != NULL) {
  90     enqueue(value);
  91   }
  92 }


< prev index next >