author | stefank |
Thu, 15 Mar 2018 21:24:10 +0100 | |
changeset 49592 | 77fb0be7d19f |
parent 47634 | 6a0c42c40cd1 |
child 52631 | 3009ca99de32 |
permissions | -rw-r--r-- |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
1 |
/* |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
4 |
* |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
8 |
* |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
13 |
* accompanied this code). |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
14 |
* |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
18 |
* |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
21 |
* questions. |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
22 |
* |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
23 |
*/ |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
24 |
|
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
26422 | 26 |
#include "code/codeCache.hpp" |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
27 |
#include "code/nmethod.hpp" |
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
28 |
#include "gc/g1/g1CodeRootSetTable.hpp" |
30764 | 29 |
#include "gc/g1/g1CodeCacheRemSet.hpp" |
30 |
#include "gc/g1/heapRegion.hpp" |
|
26422 | 31 |
#include "memory/heap.hpp" |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
32 |
#include "memory/iterator.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47634
diff
changeset
|
33 |
#include "oops/access.inline.hpp" |
26422 | 34 |
#include "oops/oop.inline.hpp" |
35 |
#include "utilities/hashtable.inline.hpp" |
|
36 |
#include "utilities/stack.inline.hpp" |
|
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
37 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
38 |
G1CodeRootSetTable* volatile G1CodeRootSetTable::_purge_list = NULL; |
26422 | 39 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
40 |
size_t G1CodeRootSetTable::mem_size() { |
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
41 |
return sizeof(G1CodeRootSetTable) + (entry_size() * number_of_entries()) + (sizeof(HashtableBucket<mtGC>) * table_size()); |
35879 | 42 |
} |
43 |
||
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
44 |
G1CodeRootSetTable::Entry* G1CodeRootSetTable::new_entry(nmethod* nm) { |
26422 | 45 |
unsigned int hash = compute_hash(nm); |
46 |
Entry* entry = (Entry*) new_entry_free_list(); |
|
47 |
if (entry == NULL) { |
|
48 |
entry = (Entry*) NEW_C_HEAP_ARRAY2(char, entry_size(), mtGC, CURRENT_PC); |
|
49 |
} |
|
50 |
entry->set_next(NULL); |
|
51 |
entry->set_hash(hash); |
|
52 |
entry->set_literal(nm); |
|
53 |
return entry; |
|
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
54 |
} |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
55 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
56 |
void G1CodeRootSetTable::remove_entry(Entry* e, Entry* previous) { |
26574
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
57 |
int index = hash_to_index(e->hash()); |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
58 |
assert((e == bucket(index)) == (previous == NULL), "if e is the first entry then previous should be null"); |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
59 |
|
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
60 |
if (previous == NULL) { |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
61 |
set_entry(index, e->next()); |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
62 |
} else { |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
63 |
previous->set_next(e->next()); |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
64 |
} |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
65 |
free_entry(e); |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
66 |
} |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
67 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
68 |
G1CodeRootSetTable::~G1CodeRootSetTable() { |
26422 | 69 |
for (int index = 0; index < table_size(); ++index) { |
70 |
for (Entry* e = bucket(index); e != NULL; ) { |
|
71 |
Entry* to_remove = e; |
|
72 |
// read next before freeing. |
|
73 |
e = e->next(); |
|
74 |
unlink_entry(to_remove); |
|
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
26574
diff
changeset
|
75 |
FREE_C_HEAP_ARRAY(char, to_remove); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
76 |
} |
26422 | 77 |
} |
78 |
assert(number_of_entries() == 0, "should have removed all entries"); |
|
79 |
free_buckets(); |
|
80 |
for (BasicHashtableEntry<mtGC>* e = new_entry_free_list(); e != NULL; e = new_entry_free_list()) { |
|
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
26574
diff
changeset
|
81 |
FREE_C_HEAP_ARRAY(char, e); |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
82 |
} |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
83 |
} |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
84 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
85 |
bool G1CodeRootSetTable::add(nmethod* nm) { |
26422 | 86 |
if (!contains(nm)) { |
87 |
Entry* e = new_entry(nm); |
|
88 |
int index = hash_to_index(e->hash()); |
|
89 |
add_entry(index, e); |
|
90 |
return true; |
|
91 |
} |
|
92 |
return false; |
|
93 |
} |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
94 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
95 |
bool G1CodeRootSetTable::contains(nmethod* nm) { |
26422 | 96 |
int index = hash_to_index(compute_hash(nm)); |
97 |
for (Entry* e = bucket(index); e != NULL; e = e->next()) { |
|
98 |
if (e->literal() == nm) { |
|
99 |
return true; |
|
100 |
} |
|
101 |
} |
|
102 |
return false; |
|
103 |
} |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
104 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
105 |
bool G1CodeRootSetTable::remove(nmethod* nm) { |
26422 | 106 |
int index = hash_to_index(compute_hash(nm)); |
107 |
Entry* previous = NULL; |
|
108 |
for (Entry* e = bucket(index); e != NULL; previous = e, e = e->next()) { |
|
109 |
if (e->literal() == nm) { |
|
26574
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
110 |
remove_entry(e, previous); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
111 |
return true; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
112 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
113 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
114 |
return false; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
115 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
116 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
117 |
void G1CodeRootSetTable::copy_to(G1CodeRootSetTable* new_table) { |
26422 | 118 |
for (int index = 0; index < table_size(); ++index) { |
119 |
for (Entry* e = bucket(index); e != NULL; e = e->next()) { |
|
120 |
new_table->add(e->literal()); |
|
121 |
} |
|
122 |
} |
|
123 |
new_table->copy_freelist(this); |
|
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
124 |
} |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
125 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
126 |
void G1CodeRootSetTable::nmethods_do(CodeBlobClosure* blk) { |
26422 | 127 |
for (int index = 0; index < table_size(); ++index) { |
128 |
for (Entry* e = bucket(index); e != NULL; e = e->next()) { |
|
129 |
blk->do_code_blob(e->literal()); |
|
130 |
} |
|
131 |
} |
|
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
132 |
} |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
133 |
|
26422 | 134 |
template<typename CB> |
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
135 |
int G1CodeRootSetTable::remove_if(CB& should_remove) { |
26574
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
136 |
int num_removed = 0; |
26422 | 137 |
for (int index = 0; index < table_size(); ++index) { |
138 |
Entry* previous = NULL; |
|
139 |
Entry* e = bucket(index); |
|
140 |
while (e != NULL) { |
|
141 |
Entry* next = e->next(); |
|
142 |
if (should_remove(e->literal())) { |
|
26574
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
143 |
remove_entry(e, previous); |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
144 |
++num_removed; |
26422 | 145 |
} else { |
146 |
previous = e; |
|
147 |
} |
|
148 |
e = next; |
|
149 |
} |
|
150 |
} |
|
26574
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
151 |
return num_removed; |
26422 | 152 |
} |
153 |
||
154 |
G1CodeRootSet::~G1CodeRootSet() { |
|
155 |
delete _table; |
|
24099
9c132a88935d
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
23451
diff
changeset
|
156 |
} |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
157 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
158 |
G1CodeRootSetTable* G1CodeRootSet::load_acquire_table() { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
159 |
return OrderAccess::load_acquire(&_table); |
26422 | 160 |
} |
161 |
||
162 |
void G1CodeRootSet::allocate_small_table() { |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
163 |
G1CodeRootSetTable* temp = new G1CodeRootSetTable(SmallSize); |
33093 | 164 |
|
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
165 |
OrderAccess::release_store(&_table, temp); |
26422 | 166 |
} |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
167 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
168 |
void G1CodeRootSetTable::purge_list_append(G1CodeRootSetTable* table) { |
26422 | 169 |
for (;;) { |
170 |
table->_purge_next = _purge_list; |
|
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
171 |
G1CodeRootSetTable* old = Atomic::cmpxchg(table, &_purge_list, table->_purge_next); |
26422 | 172 |
if (old == table->_purge_next) { |
173 |
break; |
|
174 |
} |
|
175 |
} |
|
176 |
} |
|
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
177 |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
178 |
void G1CodeRootSetTable::purge() { |
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
179 |
G1CodeRootSetTable* table = _purge_list; |
26422 | 180 |
_purge_list = NULL; |
181 |
while (table != NULL) { |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
182 |
G1CodeRootSetTable* to_purge = table; |
26422 | 183 |
table = table->_purge_next; |
184 |
delete to_purge; |
|
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
185 |
} |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
186 |
} |
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
187 |
|
26422 | 188 |
void G1CodeRootSet::move_to_large() { |
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
189 |
G1CodeRootSetTable* temp = new G1CodeRootSetTable(LargeSize); |
26422 | 190 |
|
191 |
_table->copy_to(temp); |
|
192 |
||
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
193 |
G1CodeRootSetTable::purge_list_append(_table); |
26422 | 194 |
|
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
195 |
OrderAccess::release_store(&_table, temp); |
24099
9c132a88935d
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
23451
diff
changeset
|
196 |
} |
9c132a88935d
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
23451
diff
changeset
|
197 |
|
26422 | 198 |
void G1CodeRootSet::purge() { |
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
199 |
G1CodeRootSetTable::purge(); |
26422 | 200 |
} |
201 |
||
202 |
size_t G1CodeRootSet::static_mem_size() { |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
203 |
return G1CodeRootSetTable::static_mem_size(); |
26422 | 204 |
} |
205 |
||
206 |
void G1CodeRootSet::add(nmethod* method) { |
|
207 |
bool added = false; |
|
208 |
if (is_empty()) { |
|
209 |
allocate_small_table(); |
|
210 |
} |
|
211 |
added = _table->add(method); |
|
212 |
if (added) { |
|
35879 | 213 |
if (_length == Threshold) { |
214 |
move_to_large(); |
|
215 |
} |
|
26422 | 216 |
++_length; |
217 |
} |
|
35879 | 218 |
assert(_length == (size_t)_table->number_of_entries(), "sizes should match"); |
26422 | 219 |
} |
220 |
||
221 |
bool G1CodeRootSet::remove(nmethod* method) { |
|
222 |
bool removed = false; |
|
223 |
if (_table != NULL) { |
|
224 |
removed = _table->remove(method); |
|
225 |
} |
|
226 |
if (removed) { |
|
227 |
_length--; |
|
228 |
if (_length == 0) { |
|
229 |
clear(); |
|
230 |
} |
|
231 |
} |
|
35879 | 232 |
assert((_length == 0 && _table == NULL) || |
233 |
(_length == (size_t)_table->number_of_entries()), "sizes should match"); |
|
26422 | 234 |
return removed; |
235 |
} |
|
236 |
||
237 |
bool G1CodeRootSet::contains(nmethod* method) { |
|
40905
94ffc131534f
8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents:
35879
diff
changeset
|
238 |
G1CodeRootSetTable* table = load_acquire_table(); // contains() may be called outside of lock, so ensure mem sync. |
26422 | 239 |
if (table != NULL) { |
240 |
return table->contains(method); |
|
24099
9c132a88935d
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
23451
diff
changeset
|
241 |
} |
26422 | 242 |
return false; |
243 |
} |
|
244 |
||
245 |
void G1CodeRootSet::clear() { |
|
246 |
delete _table; |
|
247 |
_table = NULL; |
|
248 |
_length = 0; |
|
249 |
} |
|
250 |
||
251 |
size_t G1CodeRootSet::mem_size() { |
|
35879 | 252 |
return sizeof(*this) + (_table != NULL ? _table->mem_size() : 0); |
26422 | 253 |
} |
254 |
||
255 |
void G1CodeRootSet::nmethods_do(CodeBlobClosure* blk) const { |
|
256 |
if (_table != NULL) { |
|
257 |
_table->nmethods_do(blk); |
|
258 |
} |
|
259 |
} |
|
260 |
||
261 |
class CleanCallback : public StackObj { |
|
262 |
class PointsIntoHRDetectionClosure : public OopClosure { |
|
263 |
HeapRegion* _hr; |
|
264 |
public: |
|
265 |
bool _points_into; |
|
266 |
PointsIntoHRDetectionClosure(HeapRegion* hr) : _hr(hr), _points_into(false) {} |
|
267 |
||
268 |
void do_oop(narrowOop* o) { |
|
269 |
do_oop_work(o); |
|
270 |
} |
|
271 |
||
272 |
void do_oop(oop* o) { |
|
273 |
do_oop_work(o); |
|
274 |
} |
|
275 |
||
276 |
template <typename T> |
|
277 |
void do_oop_work(T* p) { |
|
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47634
diff
changeset
|
278 |
if (_hr->is_in(RawAccess<>::oop_load(p))) { |
26422 | 279 |
_points_into = true; |
280 |
} |
|
281 |
} |
|
282 |
}; |
|
283 |
||
284 |
PointsIntoHRDetectionClosure _detector; |
|
285 |
CodeBlobToOopClosure _blobs; |
|
286 |
||
287 |
public: |
|
288 |
CleanCallback(HeapRegion* hr) : _detector(hr), _blobs(&_detector, !CodeBlobToOopClosure::FixRelocations) {} |
|
289 |
||
290 |
bool operator() (nmethod* nm) { |
|
291 |
_detector._points_into = false; |
|
292 |
_blobs.do_code_blob(nm); |
|
26574
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
293 |
return !_detector._points_into; |
26422 | 294 |
} |
295 |
}; |
|
296 |
||
297 |
void G1CodeRootSet::clean(HeapRegion* owner) { |
|
298 |
CleanCallback should_clean(owner); |
|
299 |
if (_table != NULL) { |
|
26574
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
300 |
int removed = _table->remove_if(should_clean); |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
301 |
assert((size_t)removed <= _length, "impossible"); |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
302 |
_length -= removed; |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
303 |
} |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
304 |
if (_length == 0) { |
59219d1be209
8057722: G1: Code root hashtable updated incorrectly when evacuation failed
mgerdin
parents:
26422
diff
changeset
|
305 |
clear(); |
26422 | 306 |
} |
24099
9c132a88935d
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
23451
diff
changeset
|
307 |
} |