Tue, 19 May 2015 15:49:27 +0200
8061715: gc/g1/TestShrinkAuxiliaryData15.java fails with java.lang.RuntimeException: heap decommit failed - after > before
Summary: added WhiteBox methods to count regions and exact aux data sizes
Reviewed-by: jwilhelm, brutisso
tschatzl@6402 | 1 | /* |
tschatzl@6402 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
tschatzl@6402 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
tschatzl@6402 | 4 | * |
tschatzl@6402 | 5 | * This code is free software; you can redistribute it and/or modify it |
tschatzl@6402 | 6 | * under the terms of the GNU General Public License version 2 only, as |
tschatzl@6402 | 7 | * published by the Free Software Foundation. |
tschatzl@6402 | 8 | * |
tschatzl@6402 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
tschatzl@6402 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
tschatzl@6402 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
tschatzl@6402 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
tschatzl@6402 | 13 | * accompanied this code). |
tschatzl@6402 | 14 | * |
tschatzl@6402 | 15 | * You should have received a copy of the GNU General Public License version |
tschatzl@6402 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
tschatzl@6402 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
tschatzl@6402 | 18 | * |
tschatzl@6402 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
tschatzl@6402 | 20 | * or visit www.oracle.com if you need additional information or have any |
tschatzl@6402 | 21 | * questions. |
tschatzl@6402 | 22 | * |
tschatzl@6402 | 23 | */ |
tschatzl@6402 | 24 | |
tschatzl@6402 | 25 | #include "precompiled.hpp" |
mgerdin@7208 | 26 | #include "code/codeCache.hpp" |
tschatzl@6402 | 27 | #include "code/nmethod.hpp" |
tschatzl@6402 | 28 | #include "gc_implementation/g1/g1CodeCacheRemSet.hpp" |
mgerdin@7208 | 29 | #include "gc_implementation/g1/heapRegion.hpp" |
mgerdin@7208 | 30 | #include "memory/heap.hpp" |
tschatzl@6402 | 31 | #include "memory/iterator.hpp" |
mgerdin@7208 | 32 | #include "oops/oop.inline.hpp" |
mgerdin@7208 | 33 | #include "utilities/hashtable.inline.hpp" |
mgerdin@7208 | 34 | #include "utilities/stack.inline.hpp" |
tschatzl@6402 | 35 | |
drchase@6680 | 36 | PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
drchase@6680 | 37 | |
mgerdin@7208 | 38 | class CodeRootSetTable : public Hashtable<nmethod*, mtGC> { |
mgerdin@7208 | 39 | friend class G1CodeRootSetTest; |
mgerdin@7208 | 40 | typedef HashtableEntry<nmethod*, mtGC> Entry; |
mgerdin@7208 | 41 | |
mgerdin@7208 | 42 | static CodeRootSetTable* volatile _purge_list; |
mgerdin@7208 | 43 | |
mgerdin@7208 | 44 | CodeRootSetTable* _purge_next; |
mgerdin@7208 | 45 | |
mgerdin@7208 | 46 | unsigned int compute_hash(nmethod* nm) { |
mgerdin@7208 | 47 | uintptr_t hash = (uintptr_t)nm; |
mgerdin@7208 | 48 | return hash ^ (hash >> 7); // code heap blocks are 128byte aligned |
mgerdin@7208 | 49 | } |
mgerdin@7208 | 50 | |
mgerdin@7209 | 51 | void remove_entry(Entry* e, Entry* previous); |
mgerdin@7208 | 52 | Entry* new_entry(nmethod* nm); |
mgerdin@7208 | 53 | |
mgerdin@7208 | 54 | public: |
mgerdin@7208 | 55 | CodeRootSetTable(int size) : Hashtable<nmethod*, mtGC>(size, sizeof(Entry)), _purge_next(NULL) {} |
mgerdin@7208 | 56 | ~CodeRootSetTable(); |
mgerdin@7208 | 57 | |
mgerdin@7208 | 58 | // Needs to be protected locks |
mgerdin@7208 | 59 | bool add(nmethod* nm); |
mgerdin@7208 | 60 | bool remove(nmethod* nm); |
mgerdin@7208 | 61 | |
mgerdin@7208 | 62 | // Can be called without locking |
mgerdin@7208 | 63 | bool contains(nmethod* nm); |
mgerdin@7208 | 64 | |
mgerdin@7208 | 65 | int entry_size() const { return BasicHashtable<mtGC>::entry_size(); } |
mgerdin@7208 | 66 | |
mgerdin@7208 | 67 | void copy_to(CodeRootSetTable* new_table); |
mgerdin@7208 | 68 | void nmethods_do(CodeBlobClosure* blk); |
mgerdin@7208 | 69 | |
mgerdin@7208 | 70 | template<typename CB> |
mgerdin@7209 | 71 | int remove_if(CB& should_remove); |
mgerdin@7208 | 72 | |
mgerdin@7208 | 73 | static void purge_list_append(CodeRootSetTable* tbl); |
mgerdin@7208 | 74 | static void purge(); |
mgerdin@7208 | 75 | |
mgerdin@7208 | 76 | static size_t static_mem_size() { |
mgerdin@7208 | 77 | return sizeof(_purge_list); |
mgerdin@7208 | 78 | } |
mgerdin@7208 | 79 | }; |
mgerdin@7208 | 80 | |
mgerdin@7208 | 81 | CodeRootSetTable* volatile CodeRootSetTable::_purge_list = NULL; |
mgerdin@7208 | 82 | |
mgerdin@7208 | 83 | CodeRootSetTable::Entry* CodeRootSetTable::new_entry(nmethod* nm) { |
mgerdin@7208 | 84 | unsigned int hash = compute_hash(nm); |
mgerdin@7208 | 85 | Entry* entry = (Entry*) new_entry_free_list(); |
mgerdin@7208 | 86 | if (entry == NULL) { |
mgerdin@7208 | 87 | entry = (Entry*) NEW_C_HEAP_ARRAY2(char, entry_size(), mtGC, CURRENT_PC); |
mgerdin@7208 | 88 | } |
mgerdin@7208 | 89 | entry->set_next(NULL); |
mgerdin@7208 | 90 | entry->set_hash(hash); |
mgerdin@7208 | 91 | entry->set_literal(nm); |
mgerdin@7208 | 92 | return entry; |
tschatzl@6402 | 93 | } |
tschatzl@6402 | 94 | |
mgerdin@7209 | 95 | void CodeRootSetTable::remove_entry(Entry* e, Entry* previous) { |
mgerdin@7209 | 96 | int index = hash_to_index(e->hash()); |
mgerdin@7209 | 97 | assert((e == bucket(index)) == (previous == NULL), "if e is the first entry then previous should be null"); |
mgerdin@7209 | 98 | |
mgerdin@7209 | 99 | if (previous == NULL) { |
mgerdin@7209 | 100 | set_entry(index, e->next()); |
mgerdin@7209 | 101 | } else { |
mgerdin@7209 | 102 | previous->set_next(e->next()); |
mgerdin@7209 | 103 | } |
mgerdin@7209 | 104 | free_entry(e); |
mgerdin@7209 | 105 | } |
mgerdin@7209 | 106 | |
mgerdin@7208 | 107 | CodeRootSetTable::~CodeRootSetTable() { |
mgerdin@7208 | 108 | for (int index = 0; index < table_size(); ++index) { |
mgerdin@7208 | 109 | for (Entry* e = bucket(index); e != NULL; ) { |
mgerdin@7208 | 110 | Entry* to_remove = e; |
mgerdin@7208 | 111 | // read next before freeing. |
mgerdin@7208 | 112 | e = e->next(); |
mgerdin@7208 | 113 | unlink_entry(to_remove); |
mgerdin@7208 | 114 | FREE_C_HEAP_ARRAY(char, to_remove, mtGC); |
stefank@6992 | 115 | } |
mgerdin@7208 | 116 | } |
mgerdin@7208 | 117 | assert(number_of_entries() == 0, "should have removed all entries"); |
mgerdin@7208 | 118 | free_buckets(); |
mgerdin@7208 | 119 | for (BasicHashtableEntry<mtGC>* e = new_entry_free_list(); e != NULL; e = new_entry_free_list()) { |
mgerdin@7208 | 120 | FREE_C_HEAP_ARRAY(char, e, mtGC); |
tschatzl@6402 | 121 | } |
tschatzl@6402 | 122 | } |
tschatzl@6402 | 123 | |
mgerdin@7208 | 124 | bool CodeRootSetTable::add(nmethod* nm) { |
mgerdin@7208 | 125 | if (!contains(nm)) { |
mgerdin@7208 | 126 | Entry* e = new_entry(nm); |
mgerdin@7208 | 127 | int index = hash_to_index(e->hash()); |
mgerdin@7208 | 128 | add_entry(index, e); |
mgerdin@7208 | 129 | return true; |
mgerdin@7208 | 130 | } |
mgerdin@7208 | 131 | return false; |
mgerdin@7208 | 132 | } |
stefank@6992 | 133 | |
mgerdin@7208 | 134 | bool CodeRootSetTable::contains(nmethod* nm) { |
mgerdin@7208 | 135 | int index = hash_to_index(compute_hash(nm)); |
mgerdin@7208 | 136 | for (Entry* e = bucket(index); e != NULL; e = e->next()) { |
mgerdin@7208 | 137 | if (e->literal() == nm) { |
stefank@6992 | 138 | return true; |
stefank@6992 | 139 | } |
stefank@6992 | 140 | } |
stefank@6992 | 141 | return false; |
stefank@6992 | 142 | } |
stefank@6992 | 143 | |
mgerdin@7208 | 144 | bool CodeRootSetTable::remove(nmethod* nm) { |
mgerdin@7208 | 145 | int index = hash_to_index(compute_hash(nm)); |
mgerdin@7208 | 146 | Entry* previous = NULL; |
mgerdin@7208 | 147 | for (Entry* e = bucket(index); e != NULL; previous = e, e = e->next()) { |
mgerdin@7208 | 148 | if (e->literal() == nm) { |
mgerdin@7209 | 149 | remove_entry(e, previous); |
mgerdin@7208 | 150 | return true; |
mgerdin@7208 | 151 | } |
mgerdin@7208 | 152 | } |
mgerdin@7208 | 153 | return false; |
tschatzl@6402 | 154 | } |
tschatzl@6402 | 155 | |
mgerdin@7208 | 156 | void CodeRootSetTable::copy_to(CodeRootSetTable* new_table) { |
mgerdin@7208 | 157 | for (int index = 0; index < table_size(); ++index) { |
mgerdin@7208 | 158 | for (Entry* e = bucket(index); e != NULL; e = e->next()) { |
mgerdin@7208 | 159 | new_table->add(e->literal()); |
mgerdin@7208 | 160 | } |
mgerdin@7208 | 161 | } |
mgerdin@7208 | 162 | new_table->copy_freelist(this); |
tschatzl@6402 | 163 | } |
tschatzl@6402 | 164 | |
mgerdin@7208 | 165 | void CodeRootSetTable::nmethods_do(CodeBlobClosure* blk) { |
mgerdin@7208 | 166 | for (int index = 0; index < table_size(); ++index) { |
mgerdin@7208 | 167 | for (Entry* e = bucket(index); e != NULL; e = e->next()) { |
mgerdin@7208 | 168 | blk->do_code_blob(e->literal()); |
mgerdin@7208 | 169 | } |
tschatzl@6402 | 170 | } |
tschatzl@6402 | 171 | } |
tschatzl@6402 | 172 | |
mgerdin@7208 | 173 | template<typename CB> |
mgerdin@7209 | 174 | int CodeRootSetTable::remove_if(CB& should_remove) { |
mgerdin@7209 | 175 | int num_removed = 0; |
mgerdin@7208 | 176 | for (int index = 0; index < table_size(); ++index) { |
mgerdin@7208 | 177 | Entry* previous = NULL; |
mgerdin@7208 | 178 | Entry* e = bucket(index); |
mgerdin@7208 | 179 | while (e != NULL) { |
mgerdin@7208 | 180 | Entry* next = e->next(); |
mgerdin@7208 | 181 | if (should_remove(e->literal())) { |
mgerdin@7209 | 182 | remove_entry(e, previous); |
mgerdin@7209 | 183 | ++num_removed; |
mgerdin@7208 | 184 | } else { |
mgerdin@7208 | 185 | previous = e; |
mgerdin@7208 | 186 | } |
mgerdin@7208 | 187 | e = next; |
mgerdin@7208 | 188 | } |
mgerdin@7208 | 189 | } |
mgerdin@7209 | 190 | return num_removed; |
tschatzl@6402 | 191 | } |
tschatzl@6402 | 192 | |
mgerdin@7208 | 193 | G1CodeRootSet::~G1CodeRootSet() { |
mgerdin@7208 | 194 | delete _table; |
mgerdin@7208 | 195 | } |
tschatzl@6925 | 196 | |
mgerdin@7208 | 197 | CodeRootSetTable* G1CodeRootSet::load_acquire_table() { |
mgerdin@7208 | 198 | return (CodeRootSetTable*) OrderAccess::load_ptr_acquire(&_table); |
mgerdin@7208 | 199 | } |
mgerdin@7208 | 200 | |
mgerdin@7208 | 201 | void G1CodeRootSet::allocate_small_table() { |
mgerdin@7208 | 202 | _table = new CodeRootSetTable(SmallSize); |
mgerdin@7208 | 203 | } |
mgerdin@7208 | 204 | |
mgerdin@7208 | 205 | void CodeRootSetTable::purge_list_append(CodeRootSetTable* table) { |
mgerdin@7208 | 206 | for (;;) { |
mgerdin@7208 | 207 | table->_purge_next = _purge_list; |
mgerdin@7208 | 208 | CodeRootSetTable* old = (CodeRootSetTable*) Atomic::cmpxchg_ptr(table, &_purge_list, table->_purge_next); |
mgerdin@7208 | 209 | if (old == table->_purge_next) { |
mgerdin@7208 | 210 | break; |
mgerdin@7208 | 211 | } |
tschatzl@6925 | 212 | } |
mgerdin@7208 | 213 | } |
mgerdin@7208 | 214 | |
mgerdin@7208 | 215 | void CodeRootSetTable::purge() { |
mgerdin@7208 | 216 | CodeRootSetTable* table = _purge_list; |
mgerdin@7208 | 217 | _purge_list = NULL; |
mgerdin@7208 | 218 | while (table != NULL) { |
mgerdin@7208 | 219 | CodeRootSetTable* to_purge = table; |
mgerdin@7208 | 220 | table = table->_purge_next; |
mgerdin@7208 | 221 | delete to_purge; |
mgerdin@7208 | 222 | } |
mgerdin@7208 | 223 | } |
mgerdin@7208 | 224 | |
mgerdin@7208 | 225 | void G1CodeRootSet::move_to_large() { |
mgerdin@7208 | 226 | CodeRootSetTable* temp = new CodeRootSetTable(LargeSize); |
mgerdin@7208 | 227 | |
mgerdin@7208 | 228 | _table->copy_to(temp); |
mgerdin@7208 | 229 | |
mgerdin@7208 | 230 | CodeRootSetTable::purge_list_append(_table); |
mgerdin@7208 | 231 | |
mgerdin@7208 | 232 | OrderAccess::release_store_ptr(&_table, temp); |
mgerdin@7208 | 233 | } |
mgerdin@7208 | 234 | |
mgerdin@7208 | 235 | |
mgerdin@7208 | 236 | void G1CodeRootSet::purge() { |
mgerdin@7208 | 237 | CodeRootSetTable::purge(); |
mgerdin@7208 | 238 | } |
mgerdin@7208 | 239 | |
mgerdin@7208 | 240 | size_t G1CodeRootSet::static_mem_size() { |
mgerdin@7208 | 241 | return CodeRootSetTable::static_mem_size(); |
mgerdin@7208 | 242 | } |
mgerdin@7208 | 243 | |
mgerdin@7208 | 244 | void G1CodeRootSet::add(nmethod* method) { |
mgerdin@7208 | 245 | bool added = false; |
mgerdin@7208 | 246 | if (is_empty()) { |
mgerdin@7208 | 247 | allocate_small_table(); |
mgerdin@7208 | 248 | } |
mgerdin@7208 | 249 | added = _table->add(method); |
mgerdin@7208 | 250 | if (_length == Threshold) { |
mgerdin@7208 | 251 | move_to_large(); |
mgerdin@7208 | 252 | } |
mgerdin@7208 | 253 | if (added) { |
mgerdin@7208 | 254 | ++_length; |
mgerdin@7208 | 255 | } |
mgerdin@7208 | 256 | } |
mgerdin@7208 | 257 | |
mgerdin@7208 | 258 | bool G1CodeRootSet::remove(nmethod* method) { |
mgerdin@7208 | 259 | bool removed = false; |
mgerdin@7208 | 260 | if (_table != NULL) { |
mgerdin@7208 | 261 | removed = _table->remove(method); |
mgerdin@7208 | 262 | } |
mgerdin@7208 | 263 | if (removed) { |
mgerdin@7208 | 264 | _length--; |
mgerdin@7208 | 265 | if (_length == 0) { |
mgerdin@7208 | 266 | clear(); |
mgerdin@7208 | 267 | } |
mgerdin@7208 | 268 | } |
mgerdin@7208 | 269 | return removed; |
mgerdin@7208 | 270 | } |
mgerdin@7208 | 271 | |
mgerdin@7208 | 272 | bool G1CodeRootSet::contains(nmethod* method) { |
mgerdin@7208 | 273 | CodeRootSetTable* table = load_acquire_table(); |
mgerdin@7208 | 274 | if (table != NULL) { |
mgerdin@7208 | 275 | return table->contains(method); |
mgerdin@7208 | 276 | } |
mgerdin@7208 | 277 | return false; |
mgerdin@7208 | 278 | } |
mgerdin@7208 | 279 | |
mgerdin@7208 | 280 | void G1CodeRootSet::clear() { |
mgerdin@7208 | 281 | delete _table; |
mgerdin@7208 | 282 | _table = NULL; |
mgerdin@7208 | 283 | _length = 0; |
mgerdin@7208 | 284 | } |
mgerdin@7208 | 285 | |
mgerdin@7208 | 286 | size_t G1CodeRootSet::mem_size() { |
mgerdin@7208 | 287 | return sizeof(*this) + |
mgerdin@7208 | 288 | (_table != NULL ? sizeof(CodeRootSetTable) + _table->entry_size() * _length : 0); |
mgerdin@7208 | 289 | } |
mgerdin@7208 | 290 | |
mgerdin@7208 | 291 | void G1CodeRootSet::nmethods_do(CodeBlobClosure* blk) const { |
mgerdin@7208 | 292 | if (_table != NULL) { |
mgerdin@7208 | 293 | _table->nmethods_do(blk); |
mgerdin@7208 | 294 | } |
mgerdin@7208 | 295 | } |
mgerdin@7208 | 296 | |
mgerdin@7208 | 297 | class CleanCallback : public StackObj { |
mgerdin@7208 | 298 | class PointsIntoHRDetectionClosure : public OopClosure { |
mgerdin@7208 | 299 | HeapRegion* _hr; |
mgerdin@7208 | 300 | public: |
mgerdin@7208 | 301 | bool _points_into; |
mgerdin@7208 | 302 | PointsIntoHRDetectionClosure(HeapRegion* hr) : _hr(hr), _points_into(false) {} |
mgerdin@7208 | 303 | |
mgerdin@7208 | 304 | void do_oop(narrowOop* o) { |
mgerdin@7208 | 305 | do_oop_work(o); |
mgerdin@7208 | 306 | } |
mgerdin@7208 | 307 | |
mgerdin@7208 | 308 | void do_oop(oop* o) { |
mgerdin@7208 | 309 | do_oop_work(o); |
mgerdin@7208 | 310 | } |
mgerdin@7208 | 311 | |
mgerdin@7208 | 312 | template <typename T> |
mgerdin@7208 | 313 | void do_oop_work(T* p) { |
mgerdin@7208 | 314 | if (_hr->is_in(oopDesc::load_decode_heap_oop(p))) { |
mgerdin@7208 | 315 | _points_into = true; |
mgerdin@7208 | 316 | } |
mgerdin@7208 | 317 | } |
mgerdin@7208 | 318 | }; |
mgerdin@7208 | 319 | |
mgerdin@7208 | 320 | PointsIntoHRDetectionClosure _detector; |
mgerdin@7208 | 321 | CodeBlobToOopClosure _blobs; |
mgerdin@7208 | 322 | |
mgerdin@7208 | 323 | public: |
mgerdin@7208 | 324 | CleanCallback(HeapRegion* hr) : _detector(hr), _blobs(&_detector, !CodeBlobToOopClosure::FixRelocations) {} |
mgerdin@7208 | 325 | |
mgerdin@7208 | 326 | bool operator() (nmethod* nm) { |
mgerdin@7208 | 327 | _detector._points_into = false; |
mgerdin@7208 | 328 | _blobs.do_code_blob(nm); |
mgerdin@7209 | 329 | return !_detector._points_into; |
mgerdin@7208 | 330 | } |
mgerdin@7208 | 331 | }; |
mgerdin@7208 | 332 | |
mgerdin@7208 | 333 | void G1CodeRootSet::clean(HeapRegion* owner) { |
mgerdin@7208 | 334 | CleanCallback should_clean(owner); |
mgerdin@7208 | 335 | if (_table != NULL) { |
mgerdin@7209 | 336 | int removed = _table->remove_if(should_clean); |
mgerdin@7209 | 337 | assert((size_t)removed <= _length, "impossible"); |
mgerdin@7209 | 338 | _length -= removed; |
mgerdin@7209 | 339 | } |
mgerdin@7209 | 340 | if (_length == 0) { |
mgerdin@7209 | 341 | clear(); |
mgerdin@7208 | 342 | } |
tschatzl@6402 | 343 | } |
tschatzl@6402 | 344 | |
tschatzl@6925 | 345 | #ifndef PRODUCT |
tschatzl@6925 | 346 | |
mgerdin@7208 | 347 | class G1CodeRootSetTest { |
mgerdin@7208 | 348 | public: |
mgerdin@7208 | 349 | static void test() { |
mgerdin@7208 | 350 | { |
mgerdin@7208 | 351 | G1CodeRootSet set1; |
mgerdin@7208 | 352 | assert(set1.is_empty(), "Code root set must be initially empty but is not."); |
tschatzl@6402 | 353 | |
mgerdin@7208 | 354 | assert(G1CodeRootSet::static_mem_size() == sizeof(void*), |
mgerdin@7208 | 355 | err_msg("The code root set's static memory usage is incorrect, "SIZE_FORMAT" bytes", G1CodeRootSet::static_mem_size())); |
mgerdin@7208 | 356 | |
mgerdin@7208 | 357 | set1.add((nmethod*)1); |
mgerdin@7208 | 358 | assert(set1.length() == 1, err_msg("Added exactly one element, but set contains " |
mgerdin@7208 | 359 | SIZE_FORMAT" elements", set1.length())); |
mgerdin@7208 | 360 | |
mgerdin@7208 | 361 | const size_t num_to_add = (size_t)G1CodeRootSet::Threshold + 1; |
mgerdin@7208 | 362 | |
mgerdin@7208 | 363 | for (size_t i = 1; i <= num_to_add; i++) { |
mgerdin@7208 | 364 | set1.add((nmethod*)1); |
mgerdin@7208 | 365 | } |
mgerdin@7208 | 366 | assert(set1.length() == 1, |
mgerdin@7208 | 367 | err_msg("Duplicate detection should not have increased the set size but " |
mgerdin@7208 | 368 | "is "SIZE_FORMAT, set1.length())); |
mgerdin@7208 | 369 | |
mgerdin@7208 | 370 | for (size_t i = 2; i <= num_to_add; i++) { |
mgerdin@7208 | 371 | set1.add((nmethod*)(uintptr_t)(i)); |
mgerdin@7208 | 372 | } |
mgerdin@7208 | 373 | assert(set1.length() == num_to_add, |
mgerdin@7208 | 374 | err_msg("After adding in total "SIZE_FORMAT" distinct code roots, they " |
mgerdin@7208 | 375 | "need to be in the set, but there are only "SIZE_FORMAT, |
mgerdin@7208 | 376 | num_to_add, set1.length())); |
mgerdin@7208 | 377 | |
mgerdin@7208 | 378 | assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable"); |
mgerdin@7208 | 379 | |
mgerdin@7208 | 380 | size_t num_popped = 0; |
mgerdin@7208 | 381 | for (size_t i = 1; i <= num_to_add; i++) { |
mgerdin@7208 | 382 | bool removed = set1.remove((nmethod*)i); |
mgerdin@7208 | 383 | if (removed) { |
mgerdin@7208 | 384 | num_popped += 1; |
mgerdin@7208 | 385 | } else { |
mgerdin@7208 | 386 | break; |
mgerdin@7208 | 387 | } |
mgerdin@7208 | 388 | } |
mgerdin@7208 | 389 | assert(num_popped == num_to_add, |
mgerdin@7208 | 390 | err_msg("Managed to pop "SIZE_FORMAT" code roots, but only "SIZE_FORMAT" " |
mgerdin@7208 | 391 | "were added", num_popped, num_to_add)); |
mgerdin@7208 | 392 | assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable"); |
mgerdin@7208 | 393 | |
mgerdin@7208 | 394 | G1CodeRootSet::purge(); |
mgerdin@7208 | 395 | |
mgerdin@7208 | 396 | assert(CodeRootSetTable::_purge_list == NULL, "should have purged old small tables"); |
mgerdin@7208 | 397 | |
mgerdin@7208 | 398 | } |
mgerdin@7208 | 399 | |
mgerdin@7208 | 400 | } |
mgerdin@7208 | 401 | }; |
mgerdin@7208 | 402 | |
mgerdin@7208 | 403 | void TestCodeCacheRemSet_test() { |
mgerdin@7208 | 404 | G1CodeRootSetTest::test(); |
tschatzl@6925 | 405 | } |
tschatzl@6925 | 406 | |
tschatzl@6925 | 407 | #endif |