src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp
author tschatzl
Wed, 18 Apr 2018 11:36:48 +0200
changeset 49806 2d62570a615c
parent 49595 e3e2fb5cc799
child 50532 a18c60527166
permissions -rw-r--r--
8200426: Make G1 code use _g1h members Summary: Consistently use _g1h member names for cached G1CollectedHeap* variables. Reviewed-by: sangheki, 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
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1BARRIERSET_INLINE_HPP
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    26
#define SHARE_VM_GC_G1_G1BARRIERSET_INLINE_HPP
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    27
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    28
#include "gc/g1/g1BarrierSet.hpp"
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48966
diff changeset
    29
#include "gc/g1/g1CardTable.hpp"
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    30
#include "gc/shared/accessBarrierSupport.inline.hpp"
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49347
diff changeset
    31
#include "oops/access.inline.hpp"
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49347
diff changeset
    32
#include "oops/compressedOops.inline.hpp"
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49347
diff changeset
    33
#include "oops/oop.hpp"
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    34
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    35
template <DecoratorSet decorators, typename T>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    36
inline void G1BarrierSet::write_ref_field_pre(T* field) {
48966
e6eb66d2e765 8197454: Need Access decorator for storing oop into uninitialized location
kbarrett
parents: 48784
diff changeset
    37
  if (HasDecorator<decorators, AS_DEST_NOT_INITIALIZED>::value ||
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    38
      HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    39
    return;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    40
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    41
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    42
  T heap_oop = RawAccess<MO_VOLATILE>::oop_load(field);
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49347
diff changeset
    43
  if (!CompressedOops::is_null(heap_oop)) {
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49347
diff changeset
    44
    enqueue(CompressedOops::decode_not_null(heap_oop));
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    45
  }
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    46
}
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    47
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    48
template <DecoratorSet decorators, typename T>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    49
inline void G1BarrierSet::write_ref_field_post(T* field, oop new_val) {
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48966
diff changeset
    50
  volatile jbyte* byte = _card_table->byte_for(field);
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48966
diff changeset
    51
  if (*byte != G1CardTable::g1_young_card_val()) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    52
    // Take a slow path for cards in old
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    53
    write_ref_field_post_slow(byte);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    54
  }
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    55
}
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    56
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    57
inline void G1BarrierSet::enqueue_if_weak_or_archive(DecoratorSet decorators, oop value) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    58
  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
    59
  // 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
    60
  // 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
    61
  // 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
    62
  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
    63
  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
    64
  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
    65
  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
    66
48784
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
    67
  if (needs_enqueue && value != NULL) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    68
    enqueue(value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    69
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    70
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    71
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    72
template <DecoratorSet decorators, typename BarrierSetT>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    73
template <typename T>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    74
inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    75
oop_load_not_in_heap(T* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    76
  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
    77
  enqueue_if_weak_or_archive(decorators, value);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    78
  return value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    79
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    80
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    81
template <DecoratorSet decorators, typename BarrierSetT>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    82
template <typename T>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    83
inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    84
oop_load_in_heap(T* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    85
  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
    86
  enqueue_if_weak_or_archive(decorators, value);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    87
  return value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    88
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    89
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    90
template <DecoratorSet decorators, typename BarrierSetT>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    91
inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    92
oop_load_in_heap_at(oop base, ptrdiff_t offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    93
  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
    94
  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
    95
  return value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    96
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    97
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    98
template <DecoratorSet decorators, typename BarrierSetT>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    99
template <typename T>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   100
inline void G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   101
oop_store_not_in_heap(T* addr, oop new_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   102
  if (HasDecorator<decorators, IN_CONCURRENT_ROOT>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   103
    // 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
   104
    // even for roots.
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   105
    G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   106
    bs->write_ref_field_pre<decorators>(addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   107
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   108
  Raw::oop_store(addr, new_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   109
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   110
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   111
#endif // SHARE_VM_GC_G1_G1BARRIERSET_INLINE_HPP