comparison src/share/vm/memory/cardTableRS.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents c7a555a9449a
children db9981fd3124
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
296 } 296 }
297 #endif 297 #endif
298 _ct_bs->non_clean_card_iterate_possibly_parallel(sp, urasm, cl, this); 298 _ct_bs->non_clean_card_iterate_possibly_parallel(sp, urasm, cl, this);
299 } 299 }
300 300
301 void CardTableRS::clear_into_younger(Generation* gen, bool clear_perm) { 301 void CardTableRS::clear_into_younger(Generation* gen) {
302 GenCollectedHeap* gch = GenCollectedHeap::heap(); 302 GenCollectedHeap* gch = GenCollectedHeap::heap();
303 // Generations younger than gen have been evacuated. We can clear 303 // Generations younger than gen have been evacuated. We can clear
304 // card table entries for gen (we know that it has no pointers 304 // card table entries for gen (we know that it has no pointers
305 // to younger gens) and for those below. The card tables for 305 // to younger gens) and for those below. The card tables for
306 // the youngest gen need never be cleared, and those for perm gen 306 // the youngest gen need never be cleared.
307 // will be cleared based on the parameter clear_perm.
308 // There's a bit of subtlety in the clear() and invalidate() 307 // There's a bit of subtlety in the clear() and invalidate()
309 // methods that we exploit here and in invalidate_or_clear() 308 // methods that we exploit here and in invalidate_or_clear()
310 // below to avoid missing cards at the fringes. If clear() or 309 // below to avoid missing cards at the fringes. If clear() or
311 // invalidate() are changed in the future, this code should 310 // invalidate() are changed in the future, this code should
312 // be revisited. 20040107.ysr 311 // be revisited. 20040107.ysr
315 prev_gen != NULL; 314 prev_gen != NULL;
316 g = prev_gen, prev_gen = gch->prev_gen(g)) { 315 g = prev_gen, prev_gen = gch->prev_gen(g)) {
317 MemRegion to_be_cleared_mr = g->prev_used_region(); 316 MemRegion to_be_cleared_mr = g->prev_used_region();
318 clear(to_be_cleared_mr); 317 clear(to_be_cleared_mr);
319 } 318 }
320 // Clear perm gen cards if asked to do so. 319 }
321 if (clear_perm) { 320
322 MemRegion to_be_cleared_mr = gch->perm_gen()->prev_used_region(); 321 void CardTableRS::invalidate_or_clear(Generation* gen, bool younger) {
323 clear(to_be_cleared_mr);
324 }
325 }
326
327 void CardTableRS::invalidate_or_clear(Generation* gen, bool younger,
328 bool perm) {
329 GenCollectedHeap* gch = GenCollectedHeap::heap(); 322 GenCollectedHeap* gch = GenCollectedHeap::heap();
330 // For each generation gen (and younger and/or perm) 323 // For each generation gen (and younger)
331 // invalidate the cards for the currently occupied part 324 // invalidate the cards for the currently occupied part
332 // of that generation and clear the cards for the 325 // of that generation and clear the cards for the
333 // unoccupied part of the generation (if any, making use 326 // unoccupied part of the generation (if any, making use
334 // of that generation's prev_used_region to determine that 327 // of that generation's prev_used_region to determine that
335 // region). No need to do anything for the youngest 328 // region). No need to do anything for the youngest
342 if (!to_be_cleared_mr.is_empty()) { 335 if (!to_be_cleared_mr.is_empty()) {
343 clear(to_be_cleared_mr); 336 clear(to_be_cleared_mr);
344 } 337 }
345 invalidate(used_mr); 338 invalidate(used_mr);
346 if (!younger) break; 339 if (!younger) break;
347 }
348 // Clear perm gen cards if asked to do so.
349 if (perm) {
350 g = gch->perm_gen();
351 MemRegion used_mr = g->used_region();
352 MemRegion to_be_cleared_mr = g->prev_used_region().minus(used_mr);
353 if (!to_be_cleared_mr.is_empty()) {
354 clear(to_be_cleared_mr);
355 }
356 invalidate(used_mr);
357 } 340 }
358 } 341 }
359 342
360 343
361 class VerifyCleanCardClosure: public OopClosure { 344 class VerifyCleanCardClosure: public OopClosure {
454 if (begin < end) { 437 if (begin < end) {
455 MemRegion mr(begin, end); 438 MemRegion mr(begin, end);
456 VerifyCleanCardClosure verify_blk(gen_boundary, begin, end); 439 VerifyCleanCardClosure verify_blk(gen_boundary, begin, end);
457 for (HeapWord* cur = start_block; cur < end; cur += s->block_size(cur)) { 440 for (HeapWord* cur = start_block; cur < end; cur += s->block_size(cur)) {
458 if (s->block_is_obj(cur) && s->obj_is_alive(cur)) { 441 if (s->block_is_obj(cur) && s->obj_is_alive(cur)) {
459 oop(cur)->oop_iterate(&verify_blk, mr); 442 oop(cur)->oop_iterate_no_header(&verify_blk, mr);
460 } 443 }
461 } 444 }
462 } 445 }
463 cur_entry = first_dirty; 446 cur_entry = first_dirty;
464 } else { 447 } else {
622 void CardTableRS::verify() { 605 void CardTableRS::verify() {
623 // At present, we only know how to verify the card table RS for 606 // At present, we only know how to verify the card table RS for
624 // generational heaps. 607 // generational heaps.
625 VerifyCTGenClosure blk(this); 608 VerifyCTGenClosure blk(this);
626 CollectedHeap* ch = Universe::heap(); 609 CollectedHeap* ch = Universe::heap();
627 // We will do the perm-gen portion of the card table, too.
628 Generation* pg = SharedHeap::heap()->perm_gen();
629 HeapWord* pg_boundary = pg->reserved().start();
630 610
631 if (ch->kind() == CollectedHeap::GenCollectedHeap) { 611 if (ch->kind() == CollectedHeap::GenCollectedHeap) {
632 GenCollectedHeap::heap()->generation_iterate(&blk, false); 612 GenCollectedHeap::heap()->generation_iterate(&blk, false);
633 _ct_bs->verify(); 613 _ct_bs->verify();
634 614 }
635 // If the old gen collections also collect perm, then we are only 615 }
636 // interested in perm-to-young pointers, not perm-to-old pointers.
637 GenCollectedHeap* gch = GenCollectedHeap::heap();
638 CollectorPolicy* cp = gch->collector_policy();
639 if (cp->is_mark_sweep_policy() || cp->is_concurrent_mark_sweep_policy()) {
640 pg_boundary = gch->get_gen(1)->reserved().start();
641 }
642 }
643 VerifyCTSpaceClosure perm_space_blk(this, pg_boundary);
644 SharedHeap::heap()->perm_gen()->space_iterate(&perm_space_blk, true);
645 }
646 616
647 617
648 void CardTableRS::verify_aligned_region_empty(MemRegion mr) { 618 void CardTableRS::verify_aligned_region_empty(MemRegion mr) {
649 if (!mr.is_empty()) { 619 if (!mr.is_empty()) {
650 jbyte* cur_entry = byte_for(mr.start()); 620 jbyte* cur_entry = byte_for(mr.start());