author | tschatzl |
Tue, 29 May 2018 09:26:00 +0200 | |
changeset 50605 | 7f63c74f0974 |
parent 50180 | ffa644980dff |
child 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
1 | 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 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
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 | 22 |
* |
23 |
*/ |
|
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 | 27 |
|
30764 | 28 |
#include "gc/shared/modRefBarrierSet.hpp" |
46625 | 29 |
#include "utilities/align.hpp" |
7397 | 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 | 33 |
// This kind of "BarrierSet" allows a "CollectedHeap" to detect and |
34 |
// enumerate ref fields that have been modified (since the last |
|
35 |
// enumeration.) |
|
36 |
||
37 |
// As it currently stands, this barrier is *imprecise*: when a ref field in |
|
38 |
// an object "o" is modified, the card table entry for the card containing |
|
39 |
// the head of "o" is dirtied, not necessarily the card containing the |
|
40 |
// modified field itself. For object arrays, however, the barrier *is* |
|
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 | 43 |
// considerations into account. |
44 |
||
49455
848864ed9b17
8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents:
49164
diff
changeset
|
45 |
class CardTableBarrierSet: public ModRefBarrierSet { |
1 | 46 |
// Some classes get to look at some private stuff. |
47 |
friend class VMStructs; |
|
48 |
protected: |
|
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 | 54 |
|
49484
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
49455
diff
changeset
|
55 |
CardTableBarrierSet(BarrierSetAssembler* barrier_set_assembler, |
49906 | 56 |
BarrierSetC1* barrier_set_c1, |
50180 | 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 | 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 | 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 | 67 |
virtual void initialize(); |
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 | 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 | 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); |
49007
82d9d5744e5f
8197994: Move JavaThread::initialize_queues() logic to G1SATBCardTableLoggingModRefBS
pliden
parents:
48961
diff
changeset
|
105 |
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
|
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 | 113 |
}; |
114 |
||
29325 | 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 | 118 |
}; |
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 |
|
49455
848864ed9b17
8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents:
49164
diff
changeset
|
125 |
#endif // SHARE_VM_GC_SHARED_CARDTABLEBARRIERSET_HPP |