src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp
author jwilhelm
Tue, 20 Mar 2018 04:36:44 +0100
changeset 49412 2c3b9dbba7bc
parent 49164 src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.inline.hpp@7e958a8ebcd3
parent 49347 src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.inline.hpp@edb65305d3ac
child 49595 e3e2fb5cc799
permissions -rw-r--r--
Merge
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"
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    31
#include "oops/oop.inline.hpp"
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    32
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    33
template <DecoratorSet decorators, typename T>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    34
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
    35
  if (HasDecorator<decorators, AS_DEST_NOT_INITIALIZED>::value ||
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    36
      HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    37
    return;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    38
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    39
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    40
  T heap_oop = RawAccess<MO_VOLATILE>::oop_load(field);
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    41
  if (!oopDesc::is_null(heap_oop)) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    42
    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
    43
  }
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    44
}
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    45
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    46
template <DecoratorSet decorators, typename T>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    47
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
    48
  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
    49
  if (*byte != G1CardTable::g1_young_card_val()) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    50
    // Take a slow path for cards in old
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    51
    write_ref_field_post_slow(byte);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    52
  }
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    53
}
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
diff changeset
    54
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    55
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
    56
  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
    57
  // 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
    58
  // 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
    59
  // 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
    60
  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
    61
  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
    62
  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
    63
  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
    64
48784
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 48628
diff changeset
    65
  if (needs_enqueue && value != NULL) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    66
    enqueue(value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    67
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    68
}
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
template <DecoratorSet decorators, typename BarrierSetT>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    71
template <typename T>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    72
inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    73
oop_load_not_in_heap(T* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    74
  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
    75
  enqueue_if_weak_or_archive(decorators, value);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    76
  return value;
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
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    79
template <DecoratorSet decorators, typename BarrierSetT>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    80
template <typename T>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    81
inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    82
oop_load_in_heap(T* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    83
  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
    84
  enqueue_if_weak_or_archive(decorators, value);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    85
  return value;
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
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    88
template <DecoratorSet decorators, typename BarrierSetT>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    89
inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    90
oop_load_in_heap_at(oop base, ptrdiff_t offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    91
  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
    92
  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
    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
template <typename T>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    98
inline void G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    99
oop_store_not_in_heap(T* addr, oop new_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   100
  if (HasDecorator<decorators, IN_CONCURRENT_ROOT>::value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   101
    // 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
   102
    // even for roots.
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   103
    G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   104
    bs->write_ref_field_pre<decorators>(addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   105
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
   106
  Raw::oop_store(addr, new_value);
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
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   109
#endif // SHARE_VM_GC_G1_G1BARRIERSET_INLINE_HPP