author | tschatzl |
Wed, 17 Jul 2019 16:33:19 +0200 | |
changeset 55722 | 5ee183a90e65 |
parent 55510 | 3e31a8beaae4 |
child 59319 | 9ee940f1de90 |
permissions | -rw-r--r-- |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49164
diff
changeset
|
2 |
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
4 |
* |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
8 |
* |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
13 |
* accompanied this code). |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
14 |
* |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
18 |
* |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
21 |
* questions. |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
22 |
* |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
23 |
*/ |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
24 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49164
diff
changeset
|
25 |
#ifndef SHARE_GC_G1_G1CARDTABLE_INLINE_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49164
diff
changeset
|
26 |
#define SHARE_GC_G1_G1CARDTABLE_INLINE_HPP |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
27 |
|
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
28 |
#include "gc/g1/g1CardTable.hpp" |
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
29 |
#include "gc/g1/heapRegion.hpp" |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
30 |
|
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
31 |
inline uint G1CardTable::region_idx_for(CardValue* p) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
32 |
size_t const card_idx = pointer_delta(p, _byte_map, sizeof(CardValue)); |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
33 |
return (uint)(card_idx >> (HeapRegion::LogOfHRGrainBytes - card_shift)); |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
34 |
} |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
35 |
|
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
36 |
inline void G1CardTable::mark_clean_as_dirty(size_t card_index) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
37 |
CardValue value = _byte_map[card_index]; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
38 |
if (value == clean_card_val()) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
39 |
_byte_map[card_index] = dirty_card_val(); |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
40 |
} |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
41 |
} |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
diff
changeset
|
42 |
|
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
43 |
inline void G1CardTable::mark_region_dirty(size_t start_card_index, size_t num_cards) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
44 |
assert(is_aligned(start_card_index, sizeof(size_t)), "Start card index must be aligned."); |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
45 |
assert(is_aligned(num_cards, sizeof(size_t)), "Number of cards to change must be evenly divisible."); |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
46 |
|
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
47 |
size_t const num_chunks = num_cards / sizeof(size_t); |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
48 |
|
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
49 |
size_t* cur_word = (size_t*)&_byte_map[start_card_index]; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
50 |
size_t* const end_word_map = cur_word + num_chunks; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
51 |
while (cur_word < end_word_map) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
52 |
size_t value = *cur_word; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
53 |
if (value == WordAllClean) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
54 |
*cur_word = WordAllDirty; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
55 |
} else if (value == WordAllDirty) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
56 |
// do nothing. |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
57 |
} else { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
58 |
// There is a mix of cards in there. Tread slowly. |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
59 |
CardValue* cur = (CardValue*)cur_word; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
60 |
for (size_t i = 0; i < sizeof(size_t); i++) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
61 |
CardValue value = *cur; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
62 |
if (value == clean_card_val()) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
63 |
*cur = dirty_card_val(); |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
64 |
} |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
65 |
cur++; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
66 |
} |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
67 |
} |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
68 |
cur_word++; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
69 |
} |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
70 |
} |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
71 |
|
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
72 |
inline void G1CardTable::mark_as_scanned(size_t start_card_index, size_t num_cards) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
73 |
CardValue* start = &_byte_map[start_card_index]; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
74 |
CardValue* const end = start + num_cards; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
75 |
while (start < end) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
76 |
CardValue value = *start; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
77 |
assert(value == dirty_card_val(), |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
78 |
"Must have been dirty %d start " PTR_FORMAT " " PTR_FORMAT, value, p2i(start), p2i(end)); |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
79 |
*start++ = g1_card_already_scanned; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
80 |
} |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
81 |
} |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
82 |
|
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53244
diff
changeset
|
83 |
#endif /* SHARE_GC_G1_G1CARDTABLE_INLINE_HPP */ |