author | tschatzl |
Wed, 18 Apr 2018 11:36:48 +0200 | |
changeset 49806 | 2d62570a615c |
parent 49194 | ece10494786c |
child 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
48961
120b61d50f85
8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
48784
diff
changeset
|
2 |
* Copyright (c) 2001, 2018, 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:
3262
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3262
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:
3262
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
25 |
#ifndef SHARE_VM_GC_G1_G1CARDTABLE_HPP |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
26 |
#define SHARE_VM_GC_G1_G1CARDTABLE_HPP |
7397 | 27 |
|
30764 | 28 |
#include "gc/g1/g1RegionToSpaceMapper.hpp" |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
29 |
#include "gc/shared/cardTable.hpp" |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
30 |
#include "oops/oopsHierarchy.hpp" |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
9179
diff
changeset
|
31 |
#include "utilities/macros.hpp" |
7397 | 32 |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
33 |
class G1CardTable; |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
34 |
class G1RegionToSpaceMapper; |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
35 |
|
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
36 |
class G1CardTableChangedListener : public G1MappingChangedListener { |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
37 |
private: |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
38 |
G1CardTable* _card_table; |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
39 |
public: |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
40 |
G1CardTableChangedListener() : _card_table(NULL) { } |
1374 | 41 |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
42 |
void set_card_table(G1CardTable* card_table) { _card_table = card_table; } |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
43 |
|
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
44 |
virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
45 |
}; |
1374 | 46 |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
47 |
class G1CardTable: public CardTable { |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32612
diff
changeset
|
48 |
friend class VMStructs; |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
49 |
friend class G1CardTableChangedListener; |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
50 |
|
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
51 |
G1CardTableChangedListener _listener; |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
52 |
|
20403
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20309
diff
changeset
|
53 |
enum G1CardValues { |
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20309
diff
changeset
|
54 |
g1_young_gen = CT_MR_BS_last_reserved << 1 |
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20309
diff
changeset
|
55 |
}; |
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20309
diff
changeset
|
56 |
|
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8498
diff
changeset
|
57 |
public: |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
58 |
G1CardTable(MemRegion whole_heap): CardTable(whole_heap, /* scanned concurrently */ true), _listener() { |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
59 |
_listener.set_card_table(this); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
60 |
} |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
61 |
bool is_card_dirty(size_t card_index) { |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
62 |
return _byte_map[card_index] == dirty_card_val(); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
63 |
} |
20403
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20309
diff
changeset
|
64 |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
65 |
static jbyte g1_young_card_val() { return g1_young_gen; } |
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47794
diff
changeset
|
66 |
|
20309 | 67 |
/* |
68 |
Claimed and deferred bits are used together in G1 during the evacuation |
|
69 |
pause. These bits can have the following state transitions: |
|
70 |
1. The claimed bit can be put over any other card state. Except that |
|
71 |
the "dirty -> dirty and claimed" transition is checked for in |
|
72 |
G1 code and is not used. |
|
73 |
2. Deferred bit can be set only if the previous state of the card |
|
74 |
was either clean or claimed. mark_card_deferred() is wait-free. |
|
75 |
We do not care if the operation is be successful because if |
|
76 |
it does not it will only result in duplicate entry in the update |
|
77 |
buffer because of the "cache-miss". So it's not worth spinning. |
|
78 |
*/ |
|
79 |
||
80 |
bool is_card_claimed(size_t card_index) { |
|
81 |
jbyte val = _byte_map[card_index]; |
|
82 |
return (val & (clean_card_mask_val() | claimed_card_val())) == claimed_card_val(); |
|
83 |
} |
|
84 |
||
35862
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
33784
diff
changeset
|
85 |
inline void set_card_claimed(size_t card_index); |
20309 | 86 |
|
20403
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20309
diff
changeset
|
87 |
void verify_g1_young_region(MemRegion mr) PRODUCT_RETURN; |
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20309
diff
changeset
|
88 |
void g1_mark_as_young(const MemRegion& mr); |
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20309
diff
changeset
|
89 |
|
20309 | 90 |
bool mark_card_deferred(size_t card_index); |
91 |
||
92 |
bool is_card_deferred(size_t card_index) { |
|
93 |
jbyte val = _byte_map[card_index]; |
|
94 |
return (val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val(); |
|
95 |
} |
|
48961
120b61d50f85
8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
48784
diff
changeset
|
96 |
|
26160 | 97 |
static size_t compute_size(size_t mem_region_size_in_words) { |
98 |
size_t number_of_slots = (mem_region_size_in_words / card_size_in_words); |
|
99 |
return ReservedSpace::allocation_align_size_up(number_of_slots); |
|
100 |
} |
|
101 |
||
30565
ebd5af27fe02
8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents:
29325
diff
changeset
|
102 |
// Returns how many bytes of the heap a single byte of the Card Table corresponds to. |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
103 |
static size_t heap_map_factor() { return card_size; } |
30565
ebd5af27fe02
8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents:
29325
diff
changeset
|
104 |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
105 |
void initialize() {} |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
106 |
void initialize(G1RegionToSpaceMapper* mapper); |
26160 | 107 |
|
108 |
virtual void resize_covered_region(MemRegion new_region) { ShouldNotReachHere(); } |
|
109 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
110 |
virtual bool is_in_young(oop obj) const; |
1374 | 111 |
}; |
112 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
113 |
#endif // SHARE_VM_GC_G1_G1CARDTABLE_HPP |