src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.inline.hpp
author stefank
Thu, 22 Feb 2018 18:36:32 +0100
changeset 49048 4e8c86b75428
parent 48966 e6eb66d2e765
child 49164 7e958a8ebcd3
permissions -rw-r--r--
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap Reviewed-by: pliden, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
     1
/*
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 47998
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
     4
 *
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
     7
 * published by the Free Software Foundation.
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
     8
 *
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    13
 * accompanied this code).
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    14
 *
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    18
 *
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    21
 * questions.
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    22
 *
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    23
 */
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    24
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    26
#define SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    27
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    28
#include "gc/shared/accessBarrierSupport.inline.hpp"
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    29
#include "gc/g1/g1SATBCardTableModRefBS.hpp"
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    30
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    31
template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    32
inline void G1SATBCardTableModRefBS::write_ref_field_pre(T* field) {
48966
e6eb66d2e765 8197454: Need Access decorator for storing oop into uninitialized location
kbarrett
parents: 48784
diff changeset
    33
  if (HasDecorator<decorators, AS_DEST_NOT_INITIALIZED>::value ||
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    34
      HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    35
    return;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    36
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    37
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    38
  T heap_oop = oopDesc::load_heap_oop(field);
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    39
  if (!oopDesc::is_null(heap_oop)) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    40
    enqueue(oopDesc::decode_heap_oop_not_null(heap_oop));
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    41
  }
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    42
}
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    43
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    44
template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    45
inline void G1SATBCardTableLoggingModRefBS::write_ref_field_post(T* field, oop new_val) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    46
  volatile jbyte* byte = byte_for(field);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    47
  if (*byte != g1_young_gen) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    48
    // Take a slow path for cards in old
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    49
    write_ref_field_post_slow(byte);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    50
  }
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    51
}
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    52
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    53
void G1SATBCardTableModRefBS::set_card_claimed(size_t card_index) {
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    54
  jbyte val = _byte_map[card_index];
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    55
  if (val == clean_card_val()) {
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    56
    val = (jbyte)claimed_card_val();
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    57
  } else {
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    58
    val |= (jbyte)claimed_card_val();
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    59
  }
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    60
  _byte_map[card_index] = val;
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    61
}
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    62
48784
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
    63
inline void G1SATBCardTableModRefBS::enqueue_if_weak_or_archive(DecoratorSet decorators, oop value) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    64
  assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
48784
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
    65
  // Archive roots need to be enqueued since they add subgraphs to the
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
    66
  // Java heap that were not there at the snapshot when marking started.
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
    67
  // Weak and phantom references also need enqueueing for similar reasons.
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
    68
  const bool in_archive_root   = (decorators & IN_ARCHIVE_ROOT) != 0;
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    69
  const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    70
  const bool peek              = (decorators & AS_NO_KEEPALIVE) != 0;
48784
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
    71
  const bool needs_enqueue     = in_archive_root || (!peek && !on_strong_oop_ref);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    72
48784
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
    73
  if (needs_enqueue && value != NULL) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    74
    enqueue(value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    75
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    76
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    77
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    78
template <DecoratorSet decorators, typename BarrierSetT>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    79
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    80
inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    81
oop_load_not_in_heap(T* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    82
  oop value = ModRef::oop_load_not_in_heap(addr);
48784
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
    83
  enqueue_if_weak_or_archive(decorators, value);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    84
  return value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    85
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    86
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    87
template <DecoratorSet decorators, typename BarrierSetT>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    88
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    89
inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    90
oop_load_in_heap(T* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    91
  oop value = ModRef::oop_load_in_heap(addr);
48784
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
    92
  enqueue_if_weak_or_archive(decorators, value);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    93
  return value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    94
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    95
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    96
template <DecoratorSet decorators, typename BarrierSetT>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    97
inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    98
oop_load_in_heap_at(oop base, ptrdiff_t offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    99
  oop value = ModRef::oop_load_in_heap_at(base, offset);
48784
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
   100
  enqueue_if_weak_or_archive(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), value);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   101
  return value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   102
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   103
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   104
template <DecoratorSet decorators, typename BarrierSetT>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   105
template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   106
inline void G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   107
oop_store_not_in_heap(T* addr, oop new_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   108
  if (HasDecorator<decorators, IN_CONCURRENT_ROOT>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   109
    // For roots not scanned in a safepoint, we have to apply SATB barriers
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   110
    // even for roots.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   111
    G1SATBCardTableLoggingModRefBS *bs = barrier_set_cast<G1SATBCardTableLoggingModRefBS>(BarrierSet::barrier_set());
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   112
    bs->write_ref_field_pre<decorators>(addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   113
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   114
  Raw::oop_store(addr, new_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   115
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   116
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
   117
#endif // SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP