350 { |
350 { |
351 G1CodeRootSet set1; |
351 G1CodeRootSet set1; |
352 assert(set1.is_empty(), "Code root set must be initially empty but is not."); |
352 assert(set1.is_empty(), "Code root set must be initially empty but is not."); |
353 |
353 |
354 assert(G1CodeRootSet::static_mem_size() == sizeof(void*), |
354 assert(G1CodeRootSet::static_mem_size() == sizeof(void*), |
355 err_msg("The code root set's static memory usage is incorrect, " SIZE_FORMAT " bytes", G1CodeRootSet::static_mem_size())); |
355 "The code root set's static memory usage is incorrect, " SIZE_FORMAT " bytes", G1CodeRootSet::static_mem_size()); |
356 |
356 |
357 set1.add((nmethod*)1); |
357 set1.add((nmethod*)1); |
358 assert(set1.length() == 1, err_msg("Added exactly one element, but set contains " |
358 assert(set1.length() == 1, "Added exactly one element, but set contains " |
359 SIZE_FORMAT " elements", set1.length())); |
359 SIZE_FORMAT " elements", set1.length()); |
360 |
360 |
361 const size_t num_to_add = (size_t)G1CodeRootSet::Threshold + 1; |
361 const size_t num_to_add = (size_t)G1CodeRootSet::Threshold + 1; |
362 |
362 |
363 for (size_t i = 1; i <= num_to_add; i++) { |
363 for (size_t i = 1; i <= num_to_add; i++) { |
364 set1.add((nmethod*)1); |
364 set1.add((nmethod*)1); |
365 } |
365 } |
366 assert(set1.length() == 1, |
366 assert(set1.length() == 1, |
367 err_msg("Duplicate detection should not have increased the set size but " |
367 "Duplicate detection should not have increased the set size but " |
368 "is " SIZE_FORMAT, set1.length())); |
368 "is " SIZE_FORMAT, set1.length()); |
369 |
369 |
370 for (size_t i = 2; i <= num_to_add; i++) { |
370 for (size_t i = 2; i <= num_to_add; i++) { |
371 set1.add((nmethod*)(uintptr_t)(i)); |
371 set1.add((nmethod*)(uintptr_t)(i)); |
372 } |
372 } |
373 assert(set1.length() == num_to_add, |
373 assert(set1.length() == num_to_add, |
374 err_msg("After adding in total " SIZE_FORMAT " distinct code roots, they " |
374 "After adding in total " SIZE_FORMAT " distinct code roots, they " |
375 "need to be in the set, but there are only " SIZE_FORMAT, |
375 "need to be in the set, but there are only " SIZE_FORMAT, |
376 num_to_add, set1.length())); |
376 num_to_add, set1.length()); |
377 |
377 |
378 assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable"); |
378 assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable"); |
379 |
379 |
380 size_t num_popped = 0; |
380 size_t num_popped = 0; |
381 for (size_t i = 1; i <= num_to_add; i++) { |
381 for (size_t i = 1; i <= num_to_add; i++) { |
385 } else { |
385 } else { |
386 break; |
386 break; |
387 } |
387 } |
388 } |
388 } |
389 assert(num_popped == num_to_add, |
389 assert(num_popped == num_to_add, |
390 err_msg("Managed to pop " SIZE_FORMAT " code roots, but only " SIZE_FORMAT " " |
390 "Managed to pop " SIZE_FORMAT " code roots, but only " SIZE_FORMAT " " |
391 "were added", num_popped, num_to_add)); |
391 "were added", num_popped, num_to_add); |
392 assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable"); |
392 assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable"); |
393 |
393 |
394 G1CodeRootSet::purge(); |
394 G1CodeRootSet::purge(); |
395 |
395 |
396 assert(CodeRootSetTable::_purge_list == NULL, "should have purged old small tables"); |
396 assert(CodeRootSetTable::_purge_list == NULL, "should have purged old small tables"); |