src/hotspot/share/gc/shared/cardTableBarrierSet.hpp
author kbarrett
Tue, 05 Mar 2019 19:54:33 -0500
changeset 54006 a421bdf22394
parent 53244 9807daeb47c4
child 54110 f4f0dce5d0bb
permissions -rw-r--r--
8219613: Use NonJavaThread PtrQueues Summary: Init and use NJT queues, remove shared SATB queue. Reviewed-by: shade, zgu, pliden, tschatzl Contributed-by: kim.barrett@oracle.com, shade@redhat.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50180
diff changeset
     2
 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4902
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4902
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: 4902
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50180
diff changeset
    25
#ifndef SHARE_GC_SHARED_CARDTABLEBARRIERSET_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50180
diff changeset
    26
#define SHARE_GC_SHARED_CARDTABLEBARRIERSET_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29805
diff changeset
    28
#include "gc/shared/modRefBarrierSet.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    29
#include "utilities/align.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    30
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    31
class CardTable;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    32
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// This kind of "BarrierSet" allows a "CollectedHeap" to detect and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// enumerate ref fields that have been modified (since the last
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// enumeration.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// As it currently stands, this barrier is *imprecise*: when a ref field in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// an object "o" is modified, the card table entry for the card containing
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// the head of "o" is dirtied, not necessarily the card containing the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// modified field itself.  For object arrays, however, the barrier *is*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// precise; only the card containing the modified element is dirtied.
29805
398335f2abed 8076241: Remove unused methods mod_card_iterate() and non_clean_card_iterate_serial()
brutisso
parents: 29325
diff changeset
    42
// Closures used to scan dirty cards should take these
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// considerations into account.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
    45
class CardTableBarrierSet: public ModRefBarrierSet {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // Some classes get to look at some private stuff.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    50
  // Used in support of ReduceInitialCardMarks; only consulted if COMPILER2
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    51
  // or INCLUDE_JVMCI is being used
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    52
  bool       _defer_initial_card_mark;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    53
  CardTable* _card_table;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    55
  CardTableBarrierSet(BarrierSetAssembler* barrier_set_assembler,
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49488
diff changeset
    56
                      BarrierSetC1* barrier_set_c1,
50180
ffa644980dff 8202377: Modularize C2 GC barriers
eosterlund
parents: 49906
diff changeset
    57
                      BarrierSetC2* barrier_set_c2,
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    58
                      CardTable* card_table,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    59
                      const BarrierSet::FakeRtti& fake_rtti);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
47658
c2b7fb8e5144 8189355: Cleanup of BarrierSet barrier functions
eosterlund
parents: 47216
diff changeset
    61
 public:
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
    62
  CardTableBarrierSet(CardTable* card_table);
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
    63
  ~CardTableBarrierSet();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    65
  CardTable* card_table() const { return _card_table; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
    66
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    67
  virtual void initialize();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    68
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    69
  void write_region(MemRegion mr) {
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    70
    invalidate(mr);
37233
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 33105
diff changeset
    71
  }
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 33105
diff changeset
    72
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    73
  void write_ref_array_work(MemRegion mr);
28830
a252e278c3d9 8064947: Clean up BarrierSet ctor/dtor
jprovino
parents: 27899
diff changeset
    74
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    75
 public:
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    76
  // Record a reference update. Note that these versions are precise!
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    77
  // The scanning code has to handle the fact that the write barrier may be
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    78
  // either precise or imprecise. We make non-virtual inline variants of
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    79
  // these functions here for performance.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    80
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    81
  void write_ref_field_post(T* field, oop newVal);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
42598
45562c0473fb 8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents: 37233
diff changeset
    83
  virtual void invalidate(MemRegion mr);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    84
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    85
  // ReduceInitialCardMarks
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    86
  void initialize_deferred_card_mark_barriers();
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    87
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    88
  // If the CollectedHeap was asked to defer a store barrier above,
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    89
  // this informs it to flush such a deferred store barrier to the
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    90
  // remembered set.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    91
  void flush_deferred_card_mark_barrier(JavaThread* thread);
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    92
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    93
  // If a compiler is eliding store barriers for TLAB-allocated objects,
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    94
  // we will be informed of a slow-path allocation by a call
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    95
  // to on_slowpath_allocation_exit() below. Such a call precedes the
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    96
  // initialization of the object itself, and no post-store-barriers will
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    97
  // be issued. Some heap types require that the barrier strictly follows
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    98
  // the initializing stores. (This is currently implemented by deferring the
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    99
  // barrier until the next slow-path allocation or gc-related safepoint.)
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   100
  // This interface answers whether a particular barrier type needs the card
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   101
  // mark to be thus strictly sequenced after the stores.
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   102
  virtual bool card_mark_must_follow_store() const;
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   103
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   104
  virtual void on_slowpath_allocation_exit(JavaThread* thread, oop new_obj);
54006
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53244
diff changeset
   105
  virtual void on_thread_detach(Thread* thread);
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   106
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   107
  virtual void make_parsable(JavaThread* thread) { flush_deferred_card_mark_barrier(thread); }
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   108
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   109
  virtual void print_on(outputStream* st) const;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   110
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
   111
  template <DecoratorSet decorators, typename BarrierSetT = CardTableBarrierSet>
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
   112
  class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   115
template<>
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
   116
struct BarrierSet::GetName<CardTableBarrierSet> {
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
   117
  static const BarrierSet::Name value = BarrierSet::CardTableBarrierSet;
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   118
};
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   119
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
   120
template<>
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
   121
struct BarrierSet::GetType<BarrierSet::CardTableBarrierSet> {
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
   122
  typedef ::CardTableBarrierSet type;
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
   123
};
9336
413920193f83 7037276: Unnecessary double traversal of dirty card windows
ysr
parents: 9183
diff changeset
   124
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50180
diff changeset
   125
#endif // SHARE_GC_SHARED_CARDTABLEBARRIERSET_HPP