author | kbarrett |
Mon, 01 Apr 2019 17:11:38 -0400 | |
changeset 54366 | 2b48cedce327 |
parent 54255 | c81fbf340ceb |
child 58059 | baa4dd528de0 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
53404 | 2 |
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
1374 | 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:
5082
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5082
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:
5082
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
49347
edb65305d3ac
8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents:
49164
diff
changeset
|
26 |
#include "gc/g1/g1BarrierSet.inline.hpp" |
49484
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
49455
diff
changeset
|
27 |
#include "gc/g1/g1BarrierSetAssembler.hpp" |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
28 |
#include "gc/g1/g1CardTable.inline.hpp" |
30764 | 29 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
51441
2e91d927e00c
8154343: Make SATB related code available to other GCs
kbarrett
parents:
51390
diff
changeset
|
30 |
#include "gc/g1/g1SATBMarkQueueSet.hpp" |
49752
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
31 |
#include "gc/g1/g1ThreadLocalData.hpp" |
30764 | 32 |
#include "gc/g1/heapRegion.hpp" |
51441
2e91d927e00c
8154343: Make SATB related code available to other GCs
kbarrett
parents:
51390
diff
changeset
|
33 |
#include "gc/shared/satbMarkQueue.hpp" |
35061 | 34 |
#include "logging/log.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49484
diff
changeset
|
35 |
#include "oops/access.inline.hpp" |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49484
diff
changeset
|
36 |
#include "oops/compressedOops.inline.hpp" |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
28830
diff
changeset
|
37 |
#include "oops/oop.inline.hpp" |
50180 | 38 |
#include "runtime/interfaceSupport.inline.hpp" |
7397 | 39 |
#include "runtime/mutexLocker.hpp" |
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
10565
diff
changeset
|
40 |
#include "runtime/thread.inline.hpp" |
49484
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
49455
diff
changeset
|
41 |
#include "utilities/macros.hpp" |
49906 | 42 |
#ifdef COMPILER1 |
43 |
#include "gc/g1/c1/g1BarrierSetC1.hpp" |
|
44 |
#endif |
|
50180 | 45 |
#ifdef COMPILER2 |
46 |
#include "gc/g1/c2/g1BarrierSetC2.hpp" |
|
47 |
#endif |
|
49906 | 48 |
|
49 |
class G1BarrierSetC1; |
|
50180 | 50 |
class G1BarrierSetC2; |
1374 | 51 |
|
49347
edb65305d3ac
8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents:
49164
diff
changeset
|
52 |
G1BarrierSet::G1BarrierSet(G1CardTable* card_table) : |
49484
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
49455
diff
changeset
|
53 |
CardTableBarrierSet(make_barrier_set_assembler<G1BarrierSetAssembler>(), |
49906 | 54 |
make_barrier_set_c1<G1BarrierSetC1>(), |
50180 | 55 |
make_barrier_set_c2<G1BarrierSetC2>(), |
49484
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
49455
diff
changeset
|
56 |
card_table, |
51390
135285dfc551
8209396: Make PtrQueueSets not statically allocated
kbarrett
parents:
51368
diff
changeset
|
57 |
BarrierSet::FakeRtti(BarrierSet::G1BarrierSet)), |
53404 | 58 |
_satb_mark_queue_buffer_allocator("SATB Buffer Allocator", G1SATBBufferSize), |
59 |
_dirty_card_queue_buffer_allocator("DC Buffer Allocator", G1UpdateBufferSize), |
|
51390
135285dfc551
8209396: Make PtrQueueSets not statically allocated
kbarrett
parents:
51368
diff
changeset
|
60 |
_satb_mark_queue_set(), |
54255 | 61 |
_dirty_card_queue_set(), |
62 |
_shared_dirty_card_queue(&_dirty_card_queue_set) |
|
51390
135285dfc551
8209396: Make PtrQueueSets not statically allocated
kbarrett
parents:
51368
diff
changeset
|
63 |
{} |
1374 | 64 |
|
49347
edb65305d3ac
8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents:
49164
diff
changeset
|
65 |
void G1BarrierSet::enqueue(oop pre_val) { |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
7397
diff
changeset
|
66 |
// Nulls should have been already filtered. |
46968
9119841280f4
8160399: is_oop_or_null involves undefined behavior
coleenp
parents:
42598
diff
changeset
|
67 |
assert(oopDesc::is_oop(pre_val, true), "Error"); |
54006 | 68 |
G1ThreadLocalData::satb_mark_queue(Thread::current()).enqueue(pre_val); |
1374 | 69 |
} |
70 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
1374
diff
changeset
|
71 |
template <class T> void |
49484
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
49455
diff
changeset
|
72 |
G1BarrierSet::write_ref_array_pre_work(T* dst, size_t count) { |
49751
c3a10df652c0
8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents:
49679
diff
changeset
|
73 |
if (!_satb_mark_queue_set.is_active()) return; |
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
1374
diff
changeset
|
74 |
T* elem_ptr = dst; |
49484
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
49455
diff
changeset
|
75 |
for (size_t i = 0; i < count; i++, elem_ptr++) { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49484
diff
changeset
|
76 |
T heap_oop = RawAccess<>::oop_load(elem_ptr); |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49484
diff
changeset
|
77 |
if (!CompressedOops::is_null(heap_oop)) { |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49484
diff
changeset
|
78 |
enqueue(CompressedOops::decode_not_null(heap_oop)); |
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
1374
diff
changeset
|
79 |
} |
1374 | 80 |
} |
81 |
} |
|
82 |
||
49484
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
49455
diff
changeset
|
83 |
void G1BarrierSet::write_ref_array_pre(oop* dst, size_t count, bool dest_uninitialized) { |
25480
190facf4e732
8048214: Linker error when compiling G1SATBCardTableModRefBS after include order changes
mgerdin
parents:
25351
diff
changeset
|
84 |
if (!dest_uninitialized) { |
190facf4e732
8048214: Linker error when compiling G1SATBCardTableModRefBS after include order changes
mgerdin
parents:
25351
diff
changeset
|
85 |
write_ref_array_pre_work(dst, count); |
190facf4e732
8048214: Linker error when compiling G1SATBCardTableModRefBS after include order changes
mgerdin
parents:
25351
diff
changeset
|
86 |
} |
190facf4e732
8048214: Linker error when compiling G1SATBCardTableModRefBS after include order changes
mgerdin
parents:
25351
diff
changeset
|
87 |
} |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47794
diff
changeset
|
88 |
|
49484
ee8fa73b90f9
8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents:
49455
diff
changeset
|
89 |
void G1BarrierSet::write_ref_array_pre(narrowOop* dst, size_t count, bool dest_uninitialized) { |
25480
190facf4e732
8048214: Linker error when compiling G1SATBCardTableModRefBS after include order changes
mgerdin
parents:
25351
diff
changeset
|
90 |
if (!dest_uninitialized) { |
190facf4e732
8048214: Linker error when compiling G1SATBCardTableModRefBS after include order changes
mgerdin
parents:
25351
diff
changeset
|
91 |
write_ref_array_pre_work(dst, count); |
190facf4e732
8048214: Linker error when compiling G1SATBCardTableModRefBS after include order changes
mgerdin
parents:
25351
diff
changeset
|
92 |
} |
190facf4e732
8048214: Linker error when compiling G1SATBCardTableModRefBS after include order changes
mgerdin
parents:
25351
diff
changeset
|
93 |
} |
190facf4e732
8048214: Linker error when compiling G1SATBCardTableModRefBS after include order changes
mgerdin
parents:
25351
diff
changeset
|
94 |
|
54110 | 95 |
void G1BarrierSet::write_ref_field_post_slow(volatile CardValue* byte) { |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47794
diff
changeset
|
96 |
// In the slow path, we know a card is not young |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
97 |
assert(*byte != G1CardTable::g1_young_card_val(), "slow path invoked without filtering"); |
20403
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20309
diff
changeset
|
98 |
OrderAccess::storeload(); |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
99 |
if (*byte != G1CardTable::dirty_card_val()) { |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
100 |
*byte = G1CardTable::dirty_card_val(); |
1374 | 101 |
Thread* thr = Thread::current(); |
54006 | 102 |
G1ThreadLocalData::dirty_card_queue(thr).enqueue(byte); |
1374 | 103 |
} |
104 |
} |
|
105 |
||
49347
edb65305d3ac
8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents:
49164
diff
changeset
|
106 |
void G1BarrierSet::invalidate(MemRegion mr) { |
48102
08be4c1e540e
8182050: assert(_whole_heap.contains(p)) failed: Attempt to access p out of bounds of card marking array's _whole_heap
tschatzl
parents:
47998
diff
changeset
|
107 |
if (mr.is_empty()) { |
08be4c1e540e
8182050: assert(_whole_heap.contains(p)) failed: Attempt to access p out of bounds of card marking array's _whole_heap
tschatzl
parents:
47998
diff
changeset
|
108 |
return; |
08be4c1e540e
8182050: assert(_whole_heap.contains(p)) failed: Attempt to access p out of bounds of card marking array's _whole_heap
tschatzl
parents:
47998
diff
changeset
|
109 |
} |
54110 | 110 |
volatile CardValue* byte = _card_table->byte_for(mr.start()); |
111 |
CardValue* last_byte = _card_table->byte_for(mr.last()); |
|
54006 | 112 |
// skip initial young cards |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
113 |
for (; byte <= last_byte && *byte == G1CardTable::g1_young_card_val(); byte++); |
20403
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20309
diff
changeset
|
114 |
|
42598
45562c0473fb
8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents:
40655
diff
changeset
|
115 |
if (byte <= last_byte) { |
45562c0473fb
8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents:
40655
diff
changeset
|
116 |
OrderAccess::storeload(); |
45562c0473fb
8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents:
40655
diff
changeset
|
117 |
// Enqueue if necessary. |
54006 | 118 |
Thread* thr = Thread::current(); |
119 |
G1DirtyCardQueue& queue = G1ThreadLocalData::dirty_card_queue(thr); |
|
120 |
for (; byte <= last_byte; byte++) { |
|
54110 | 121 |
CardValue bv = *byte; |
54006 | 122 |
if ((bv != G1CardTable::g1_young_card_val()) && |
123 |
(bv != G1CardTable::dirty_card_val())) { |
|
124 |
*byte = G1CardTable::dirty_card_val(); |
|
125 |
queue.enqueue(byte); |
|
1374 | 126 |
} |
127 |
} |
|
128 |
} |
|
129 |
} |
|
48961
120b61d50f85
8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
48102
diff
changeset
|
130 |
|
49752
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
131 |
void G1BarrierSet::on_thread_create(Thread* thread) { |
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
132 |
// Create thread local data |
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
133 |
G1ThreadLocalData::create(thread); |
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
134 |
} |
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
135 |
|
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
136 |
void G1BarrierSet::on_thread_destroy(Thread* thread) { |
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
137 |
// Destroy thread local data |
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
138 |
G1ThreadLocalData::destroy(thread); |
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
139 |
} |
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
140 |
|
54006 | 141 |
void G1BarrierSet::on_thread_attach(Thread* thread) { |
49752
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
142 |
assert(!G1ThreadLocalData::satb_mark_queue(thread).is_active(), "SATB queue should not be active"); |
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
143 |
assert(G1ThreadLocalData::satb_mark_queue(thread).is_empty(), "SATB queue should be empty"); |
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
144 |
assert(G1ThreadLocalData::dirty_card_queue(thread).is_active(), "Dirty card queue should be active"); |
54006 | 145 |
// Can't assert that the DCQ is empty. There is early execution on |
146 |
// the main thread, before it gets added to the threads list, which |
|
147 |
// is where this is called. That execution may enqueue dirty cards. |
|
49007
82d9d5744e5f
8197994: Move JavaThread::initialize_queues() logic to G1SATBCardTableLoggingModRefBS
pliden
parents:
48961
diff
changeset
|
148 |
|
82d9d5744e5f
8197994: Move JavaThread::initialize_queues() logic to G1SATBCardTableLoggingModRefBS
pliden
parents:
48961
diff
changeset
|
149 |
// If we are creating the thread during a marking cycle, we should |
54006 | 150 |
// set the active field of the SATB queue to true. That involves |
54366
2b48cedce327
8220671: Initialization race for non-JavaThread PtrQueues
kbarrett
parents:
54255
diff
changeset
|
151 |
// copying the global is_active value to this thread's queue. |
54006 | 152 |
bool is_satb_active = _satb_mark_queue_set.is_active(); |
153 |
G1ThreadLocalData::satb_mark_queue(thread).set_active(is_satb_active); |
|
49007
82d9d5744e5f
8197994: Move JavaThread::initialize_queues() logic to G1SATBCardTableLoggingModRefBS
pliden
parents:
48961
diff
changeset
|
154 |
} |
82d9d5744e5f
8197994: Move JavaThread::initialize_queues() logic to G1SATBCardTableLoggingModRefBS
pliden
parents:
48961
diff
changeset
|
155 |
|
54006 | 156 |
void G1BarrierSet::on_thread_detach(Thread* thread) { |
157 |
// Flush any deferred card marks. |
|
49455
848864ed9b17
8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents:
49347
diff
changeset
|
158 |
CardTableBarrierSet::on_thread_detach(thread); |
49752
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
159 |
G1ThreadLocalData::satb_mark_queue(thread).flush(); |
93d84f667d12
8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents:
49751
diff
changeset
|
160 |
G1ThreadLocalData::dirty_card_queue(thread).flush(); |
48961
120b61d50f85
8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
48102
diff
changeset
|
161 |
} |
52582
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
162 |
|
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
163 |
BufferNode::Allocator& G1BarrierSet::satb_mark_queue_buffer_allocator() { |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
164 |
return _satb_mark_queue_buffer_allocator; |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
165 |
} |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
166 |
|
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
167 |
BufferNode::Allocator& G1BarrierSet::dirty_card_queue_buffer_allocator() { |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
168 |
return _dirty_card_queue_buffer_allocator; |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
169 |
} |