src/hotspot/share/gc/shared/cardTableBarrierSet.hpp
author eosterlund
Mon, 19 Mar 2018 07:38:18 +0100
changeset 49455 848864ed9b17
parent 49164 src/hotspot/share/gc/shared/cardTableModRefBS.hpp@7e958a8ebcd3
child 49484 ee8fa73b90f9
permissions -rw-r--r--
8199604: Rename CardTableModRefBS to CardTableBarrierSet Reviewed-by: stefank, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
     2
 * Copyright (c) 2000, 2018, 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
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
    25
#ifndef SHARE_VM_GC_SHARED_CARDTABLEBARRIERSET_HPP
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
    26
#define SHARE_VM_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
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
    55
  CardTableBarrierSet(CardTable* card_table, const BarrierSet::FakeRtti& fake_rtti);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
47658
c2b7fb8e5144 8189355: Cleanup of BarrierSet barrier functions
eosterlund
parents: 47216
diff changeset
    57
 public:
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
    58
  CardTableBarrierSet(CardTable* card_table);
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
    59
  ~CardTableBarrierSet();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    61
  CardTable* card_table() const { return _card_table; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
    62
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    63
  virtual void initialize();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 24424
diff changeset
    64
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    65
  void write_region(MemRegion mr) {
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    66
    invalidate(mr);
37233
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 33105
diff changeset
    67
  }
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 33105
diff changeset
    68
47658
c2b7fb8e5144 8189355: Cleanup of BarrierSet barrier functions
eosterlund
parents: 47216
diff changeset
    69
 protected:
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    70
  void write_ref_array_work(MemRegion mr);
28830
a252e278c3d9 8064947: Clean up BarrierSet ctor/dtor
jprovino
parents: 27899
diff changeset
    71
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    72
 public:
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    73
  // Record a reference update. Note that these versions are precise!
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    74
  // 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
    75
  // 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
    76
  // these functions here for performance.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    77
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    78
  void write_ref_field_post(T* field, oop newVal);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
42598
45562c0473fb 8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents: 37233
diff changeset
    80
  virtual void invalidate(MemRegion mr);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    81
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    82
  // ReduceInitialCardMarks
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    83
  void initialize_deferred_card_mark_barriers();
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    84
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    85
  // 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
    86
  // 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
    87
  // remembered set.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    88
  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
    89
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    90
  // Can a compiler initialize a new object without store barriers?
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    91
  // This permission only extends from the creation of a new object
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    92
  // via a TLAB up to the first subsequent safepoint. If such permission
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    93
  // is granted for this heap type, the compiler promises to call
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    94
  // defer_store_barrier() below on any slow path allocation of
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    95
  // a new object for which such initializing store barriers will
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    96
  // have been elided. G1, like CMS, allows this, but should be
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    97
  // ready to provide a compensating write barrier as necessary
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    98
  // if that storage came out of a non-young region. The efficiency
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    99
  // of this implementation depends crucially on being able to
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   100
  // answer very efficiently in constant time whether a piece of
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   101
  // storage in the heap comes from a young region or not.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   102
  // See ReduceInitialCardMarks.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   103
  virtual bool can_elide_tlab_store_barriers() const {
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   104
    return true;
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   105
  }
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
  // 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
   108
  // 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
   109
  // 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
   110
  // 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
   111
  // 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
   112
  // 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
   113
  // 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
   114
  // 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
   115
  // 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
   116
  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
   117
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   118
  virtual void on_slowpath_allocation_exit(JavaThread* thread, oop new_obj);
49007
82d9d5744e5f 8197994: Move JavaThread::initialize_queues() logic to G1SATBCardTableLoggingModRefBS
pliden
parents: 48961
diff changeset
   119
  virtual void on_thread_detach(JavaThread* thread);
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   120
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   121
  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
   122
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   123
  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
   124
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
   125
  template <DecoratorSet decorators, typename BarrierSetT = CardTableBarrierSet>
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
   126
  class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   129
template<>
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
   130
struct BarrierSet::GetName<CardTableBarrierSet> {
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
   131
  static const BarrierSet::Name value = BarrierSet::CardTableBarrierSet;
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   132
};
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   133
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
   134
template<>
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
   135
struct BarrierSet::GetType<BarrierSet::CardTableBarrierSet> {
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
   136
  typedef ::CardTableBarrierSet type;
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
   137
};
9336
413920193f83 7037276: Unnecessary double traversal of dirty card windows
ysr
parents: 9183
diff changeset
   138
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49164
diff changeset
   139
#endif // SHARE_VM_GC_SHARED_CARDTABLEBARRIERSET_HPP