src/hotspot/share/gc/g1/g1BarrierSet.hpp
author manc
Mon, 14 Oct 2019 18:48:10 -0700
changeset 58652 9b67dd88a931
parent 58059 baa4dd528de0
permissions -rw-r--r--
8232232: G1RemSetSummary::_rs_threads_vtimes is not initialized to zero Summary: Fix error in "Concurrent refinement threads times" in GC log and cleanup. Reviewed-by: tschatzl, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52582
diff changeset
     2
 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52582
diff changeset
    25
#ifndef SHARE_GC_G1_G1BARRIERSET_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52582
diff changeset
    26
#define SHARE_GC_G1_G1BARRIERSET_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
53747
13acc8e38a29 8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents: 53244
diff changeset
    28
#include "gc/g1/g1DirtyCardQueue.hpp"
51368
adcb0bb3d1e9 8209118: Abstract SATBMarkQueueSet's ThreadLocalData access
rkennke
parents: 50532
diff changeset
    29
#include "gc/g1/g1SATBMarkQueueSet.hpp"
54255
c81fbf340ceb 8220240: Refactor shared dirty card queue
kbarrett
parents: 54110
diff changeset
    30
#include "gc/g1/g1SharedDirtyCardQueue.hpp"
54110
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 54006
diff changeset
    31
#include "gc/shared/cardTable.hpp"
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49347
diff changeset
    32
#include "gc/shared/cardTableBarrierSet.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    34
class G1CardTable;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    35
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
// This barrier is specialized to use a logging barrier to support
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    37
// snapshot-at-the-beginning marking.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49347
diff changeset
    39
class G1BarrierSet: public CardTableBarrierSet {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32612
diff changeset
    40
  friend class VMStructs;
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    41
 private:
52582
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51390
diff changeset
    42
  BufferNode::Allocator _satb_mark_queue_buffer_allocator;
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51390
diff changeset
    43
  BufferNode::Allocator _dirty_card_queue_buffer_allocator;
51390
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    44
  G1SATBMarkQueueSet _satb_mark_queue_set;
53747
13acc8e38a29 8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents: 53244
diff changeset
    45
  G1DirtyCardQueueSet _dirty_card_queue_set;
54255
c81fbf340ceb 8220240: Refactor shared dirty card queue
kbarrett
parents: 54110
diff changeset
    46
  G1SharedDirtyCardQueue _shared_dirty_card_queue;
51390
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    47
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    48
  static G1BarrierSet* g1_barrier_set() {
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    49
    return barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    50
  }
28830
a252e278c3d9 8064947: Clean up BarrierSet ctor/dtor
jprovino
parents: 28217
diff changeset
    51
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    52
 public:
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    53
  G1BarrierSet(G1CardTable* table);
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    54
  ~G1BarrierSet() { }
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    55
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    56
  // Add "pre_val" to a set of objects that may have been disconnected from the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    57
  // pre-marking object graph.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    58
  static void enqueue(oop pre_val);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    59
50532
a18c60527166 8204585: Remove IN_ARCHIVE_ROOT from Access API
kbarrett
parents: 50375
diff changeset
    60
  static void enqueue_if_weak(DecoratorSet decorators, oop value);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    61
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    62
  template <class T> void write_ref_array_pre_work(T* dst, size_t count);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    63
  virtual void write_ref_array_pre(oop* dst, size_t count, bool dest_uninitialized);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    64
  virtual void write_ref_array_pre(narrowOop* dst, size_t count, bool dest_uninitialized);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    65
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    66
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    67
  void write_ref_field_pre(T* field);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25480
diff changeset
    68
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    69
  // NB: if you do a whole-heap invalidation, the "usual invariant" defined
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    70
  // above no longer applies.
42598
45562c0473fb 8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents: 35862
diff changeset
    71
  void invalidate(MemRegion mr);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    72
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48784
diff changeset
    73
  void write_region(MemRegion mr)         { invalidate(mr); }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    74
  void write_ref_array_work(MemRegion mr) { invalidate(mr); }
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    75
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    76
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    77
  void write_ref_field_post(T* field, oop new_val);
54110
f4f0dce5d0bb 8220301: Remove jbyte use in CardTable
tschatzl
parents: 54006
diff changeset
    78
  void write_ref_field_post_slow(volatile CardValue* byte);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    79
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49751
diff changeset
    80
  virtual void on_thread_create(Thread* thread);
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49751
diff changeset
    81
  virtual void on_thread_destroy(Thread* thread);
54006
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53747
diff changeset
    82
  virtual void on_thread_attach(Thread* thread);
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53747
diff changeset
    83
  virtual void on_thread_detach(Thread* thread);
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48784
diff changeset
    84
51390
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    85
  static G1SATBMarkQueueSet& satb_mark_queue_set() {
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    86
    return g1_barrier_set()->_satb_mark_queue_set;
49751
c3a10df652c0 8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents: 49488
diff changeset
    87
  }
c3a10df652c0 8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents: 49488
diff changeset
    88
53747
13acc8e38a29 8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents: 53244
diff changeset
    89
  static G1DirtyCardQueueSet& dirty_card_queue_set() {
51390
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    90
    return g1_barrier_set()->_dirty_card_queue_set;
49751
c3a10df652c0 8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents: 49488
diff changeset
    91
  }
c3a10df652c0 8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents: 49488
diff changeset
    92
54255
c81fbf340ceb 8220240: Refactor shared dirty card queue
kbarrett
parents: 54110
diff changeset
    93
  static G1SharedDirtyCardQueue& shared_dirty_card_queue() {
c81fbf340ceb 8220240: Refactor shared dirty card queue
kbarrett
parents: 54110
diff changeset
    94
    return g1_barrier_set()->_shared_dirty_card_queue;
c81fbf340ceb 8220240: Refactor shared dirty card queue
kbarrett
parents: 54110
diff changeset
    95
  }
c81fbf340ceb 8220240: Refactor shared dirty card queue
kbarrett
parents: 54110
diff changeset
    96
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    97
  // Callbacks for runtime accesses.
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    98
  template <DecoratorSet decorators, typename BarrierSetT = G1BarrierSet>
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    99
  class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   100
    typedef ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> ModRef;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   101
    typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   102
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   103
  public:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   104
    // Needed for loads on non-heap weak references
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   105
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   106
    static oop oop_load_not_in_heap(T* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   107
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   108
    // Needed for non-heap stores
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   109
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   110
    static void oop_store_not_in_heap(T* addr, oop new_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   111
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   112
    // Needed for weak references
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   113
    static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   114
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   115
    // Defensive: will catch weak oops at addresses in heap
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   116
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   117
    static oop oop_load_in_heap(T* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   118
  };
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   119
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   120
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   121
template<>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   122
struct BarrierSet::GetName<G1BarrierSet> {
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   123
  static const BarrierSet::Name value = BarrierSet::G1BarrierSet;
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   124
};
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   125
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   126
template<>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   127
struct BarrierSet::GetType<BarrierSet::G1BarrierSet> {
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   128
  typedef ::G1BarrierSet type;
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   129
};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   130
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52582
diff changeset
   131
#endif // SHARE_GC_G1_G1BARRIERSET_HPP