src/hotspot/share/gc/g1/g1BarrierSet.hpp
author kbarrett
Thu, 15 Nov 2018 19:59:10 -0500
changeset 52582 6df094be7f58
parent 51390 135285dfc551
child 53244 9807daeb47c4
permissions -rw-r--r--
8213352: Separate BufferNode allocation from PtrQueueSet Summary: Move free-list management and allocation to new class. Reviewed-by: tschatzl, sjohanss
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
/*
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48784
diff changeset
     2
 * Copyright (c) 2001, 2018, 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
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1BARRIERSET_HPP
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    26
#define SHARE_VM_GC_G1_G1BARRIERSET_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
49751
c3a10df652c0 8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents: 49488
diff changeset
    28
#include "gc/g1/dirtyCardQueue.hpp"
51368
adcb0bb3d1e9 8209118: Abstract SATBMarkQueueSet's ThreadLocalData access
rkennke
parents: 50532
diff changeset
    29
#include "gc/g1/g1SATBMarkQueueSet.hpp"
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49347
diff changeset
    30
#include "gc/shared/cardTableBarrierSet.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    32
class DirtyCardQueueSet;
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    33
class CardTable;
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;
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    45
  DirtyCardQueueSet _dirty_card_queue_set;
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    46
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    47
  static G1BarrierSet* g1_barrier_set() {
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    48
    return barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    49
  }
28830
a252e278c3d9 8064947: Clean up BarrierSet ctor/dtor
jprovino
parents: 28217
diff changeset
    50
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    51
 public:
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    52
  G1BarrierSet(G1CardTable* table);
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    53
  ~G1BarrierSet() { }
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    54
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    55
  // 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
    56
  // pre-marking object graph.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    57
  static void enqueue(oop pre_val);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    58
50532
a18c60527166 8204585: Remove IN_ARCHIVE_ROOT from Access API
kbarrett
parents: 50375
diff changeset
    59
  static void enqueue_if_weak(DecoratorSet decorators, oop value);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    60
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    61
  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
    62
  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
    63
  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
    64
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    65
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    66
  void write_ref_field_pre(T* field);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25480
diff changeset
    67
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
  // 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
    69
  // above no longer applies.
42598
45562c0473fb 8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents: 35862
diff changeset
    70
  void invalidate(MemRegion mr);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    71
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48784
diff changeset
    72
  void write_region(MemRegion mr)         { invalidate(mr); }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    73
  void write_ref_array_work(MemRegion mr) { invalidate(mr); }
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    74
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    75
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    76
  void write_ref_field_post(T* field, oop new_val);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    77
  void write_ref_field_post_slow(volatile jbyte* byte);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    78
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49751
diff changeset
    79
  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
    80
  virtual void on_thread_destroy(Thread* thread);
49007
82d9d5744e5f 8197994: Move JavaThread::initialize_queues() logic to G1SATBCardTableLoggingModRefBS
pliden
parents: 48961
diff changeset
    81
  virtual void on_thread_attach(JavaThread* thread);
82d9d5744e5f 8197994: Move JavaThread::initialize_queues() logic to G1SATBCardTableLoggingModRefBS
pliden
parents: 48961
diff changeset
    82
  virtual void on_thread_detach(JavaThread* thread);
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48784
diff changeset
    83
52582
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51390
diff changeset
    84
  BufferNode::Allocator& satb_mark_queue_buffer_allocator();
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51390
diff changeset
    85
  BufferNode::Allocator& dirty_card_queue_buffer_allocator();
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51390
diff changeset
    86
51390
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    87
  static G1SATBMarkQueueSet& satb_mark_queue_set() {
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    88
    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
    89
  }
c3a10df652c0 8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents: 49488
diff changeset
    90
c3a10df652c0 8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents: 49488
diff changeset
    91
  static DirtyCardQueueSet& dirty_card_queue_set() {
51390
135285dfc551 8209396: Make PtrQueueSets not statically allocated
kbarrett
parents: 51368
diff changeset
    92
    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
    93
  }
c3a10df652c0 8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents: 49488
diff changeset
    94
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    95
  // Callbacks for runtime accesses.
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    96
  template <DecoratorSet decorators, typename BarrierSetT = G1BarrierSet>
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    97
  class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    98
    typedef ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> ModRef;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    99
    typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   100
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   101
  public:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   102
    // Needed for loads on non-heap weak references
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   103
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   104
    static oop oop_load_not_in_heap(T* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   105
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   106
    // Needed for non-heap stores
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   107
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   108
    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
   109
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   110
    // Needed for weak references
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   111
    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
   112
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   113
    // Defensive: will catch weak oops at addresses in heap
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   114
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   115
    static oop oop_load_in_heap(T* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   116
  };
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   117
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   118
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   119
template<>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   120
struct BarrierSet::GetName<G1BarrierSet> {
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   121
  static const BarrierSet::Name value = BarrierSet::G1BarrierSet;
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   122
};
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   123
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   124
template<>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   125
struct BarrierSet::GetType<BarrierSet::G1BarrierSet> {
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   126
  typedef ::G1BarrierSet type;
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   127
};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   128
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   129
#endif // SHARE_VM_GC_G1_G1BARRIERSET_HPP