comparison src/share/vm/gc_implementation/g1/heapRegion.cpp @ 6275:957c266d8bc5

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Tue, 21 Aug 2012 10:39:19 +0200
parents 33df1aeaebbf a2f7274eb6ef
children c38f13903fdf
comparison
equal deleted inserted replaced
5891:fd8832ae511d 6275:957c266d8bc5
42 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1, 42 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
43 HeapRegion* hr, OopClosure* cl, 43 HeapRegion* hr, OopClosure* cl,
44 CardTableModRefBS::PrecisionStyle precision, 44 CardTableModRefBS::PrecisionStyle precision,
45 FilterKind fk) : 45 FilterKind fk) :
46 ContiguousSpaceDCTOC(hr, cl, precision, NULL), 46 ContiguousSpaceDCTOC(hr, cl, precision, NULL),
47 _hr(hr), _fk(fk), _g1(g1) 47 _hr(hr), _fk(fk), _g1(g1) { }
48 { }
49 48
50 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r, 49 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
51 OopClosure* oc) : 50 OopClosure* oc) :
52 _r_bottom(r->bottom()), _r_end(r->end()), 51 _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
53 _oc(oc), _out_of_region(0)
54 {}
55 52
56 class VerifyLiveClosure: public OopClosure { 53 class VerifyLiveClosure: public OopClosure {
57 private: 54 private:
58 G1CollectedHeap* _g1h; 55 G1CollectedHeap* _g1h;
59 CardTableModRefBS* _bs; 56 CardTableModRefBS* _bs;
332 // MIN_REGION_SIZE and MAX_REGION_SIZE. 329 // MIN_REGION_SIZE and MAX_REGION_SIZE.
333 GrainBytes = (size_t)region_size; 330 GrainBytes = (size_t)region_size;
334 331
335 guarantee(GrainWords == 0, "we should only set it once"); 332 guarantee(GrainWords == 0, "we should only set it once");
336 GrainWords = GrainBytes >> LogHeapWordSize; 333 GrainWords = GrainBytes >> LogHeapWordSize;
337 guarantee((size_t)(1 << LogOfHRGrainWords) == GrainWords, "sanity"); 334 guarantee((size_t) 1 << LogOfHRGrainWords == GrainWords, "sanity");
338 335
339 guarantee(CardsPerRegion == 0, "we should only set it once"); 336 guarantee(CardsPerRegion == 0, "we should only set it once");
340 CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift; 337 CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift;
341 } 338 }
342 339
368 HeapRegionRemSet* hrrs = rem_set(); 365 HeapRegionRemSet* hrrs = rem_set();
369 if (hrrs != NULL) hrrs->clear(); 366 if (hrrs != NULL) hrrs->clear();
370 _claimed = InitialClaimValue; 367 _claimed = InitialClaimValue;
371 } 368 }
372 zero_marked_bytes(); 369 zero_marked_bytes();
373 set_sort_index(-1);
374 370
375 _offsets.resize(HeapRegion::GrainWords); 371 _offsets.resize(HeapRegion::GrainWords);
376 init_top_at_mark_start(); 372 init_top_at_mark_start();
377 if (clear_space) clear(SpaceDecorator::Mangle); 373 if (clear_space) clear(SpaceDecorator::Mangle);
378 } 374 }
480 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away 476 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
481 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list 477 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
482 #endif // _MSC_VER 478 #endif // _MSC_VER
483 479
484 480
485 HeapRegion:: 481 HeapRegion::HeapRegion(uint hrs_index,
486 HeapRegion(size_t hrs_index, G1BlockOffsetSharedArray* sharedOffsetArray, 482 G1BlockOffsetSharedArray* sharedOffsetArray,
487 MemRegion mr, bool is_zeroed) 483 MemRegion mr, bool is_zeroed) :
488 : G1OffsetTableContigSpace(sharedOffsetArray, mr, is_zeroed), 484 G1OffsetTableContigSpace(sharedOffsetArray, mr, is_zeroed),
489 _hrs_index(hrs_index), 485 _hrs_index(hrs_index),
490 _humongous_type(NotHumongous), _humongous_start_region(NULL), 486 _humongous_type(NotHumongous), _humongous_start_region(NULL),
491 _in_collection_set(false), 487 _in_collection_set(false),
492 _next_in_special_set(NULL), _orig_end(NULL), 488 _next_in_special_set(NULL), _orig_end(NULL),
493 _claimed(InitialClaimValue), _evacuation_failed(false), 489 _claimed(InitialClaimValue), _evacuation_failed(false),
494 _prev_marked_bytes(0), _next_marked_bytes(0), _sort_index(-1), 490 _prev_marked_bytes(0), _next_marked_bytes(0), _gc_efficiency(0.0),
495 _gc_efficiency(0.0),
496 _young_type(NotYoung), _next_young_region(NULL), 491 _young_type(NotYoung), _next_young_region(NULL),
497 _next_dirty_cards_region(NULL), _next(NULL), _pending_removal(false), 492 _next_dirty_cards_region(NULL), _next(NULL), _pending_removal(false),
498 #ifdef ASSERT 493 #ifdef ASSERT
499 _containing_set(NULL), 494 _containing_set(NULL),
500 #endif // ASSERT 495 #endif // ASSERT
510 set_saved_mark(); 505 set_saved_mark();
511 506
512 _rem_set = new HeapRegionRemSet(sharedOffsetArray, this); 507 _rem_set = new HeapRegionRemSet(sharedOffsetArray, this);
513 508
514 assert(HeapRegionRemSet::num_par_rem_sets() > 0, "Invariant."); 509 assert(HeapRegionRemSet::num_par_rem_sets() > 0, "Invariant.");
515 // In case the region is allocated during a pause, note the top. 510 }
516 // We haven't done any counting on a brand new region.
517 _top_at_conc_mark_count = bottom();
518 }
519
520 class NextCompactionHeapRegionClosure: public HeapRegionClosure {
521 const HeapRegion* _target;
522 bool _target_seen;
523 HeapRegion* _last;
524 CompactibleSpace* _res;
525 public:
526 NextCompactionHeapRegionClosure(const HeapRegion* target) :
527 _target(target), _target_seen(false), _res(NULL) {}
528 bool doHeapRegion(HeapRegion* cur) {
529 if (_target_seen) {
530 if (!cur->isHumongous()) {
531 _res = cur;
532 return true;
533 }
534 } else if (cur == _target) {
535 _target_seen = true;
536 }
537 return false;
538 }
539 CompactibleSpace* result() { return _res; }
540 };
541 511
542 CompactibleSpace* HeapRegion::next_compaction_space() const { 512 CompactibleSpace* HeapRegion::next_compaction_space() const {
513 // We're not using an iterator given that it will wrap around when
514 // it reaches the last region and this is not what we want here.
543 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 515 G1CollectedHeap* g1h = G1CollectedHeap::heap();
544 // cast away const-ness 516 uint index = hrs_index() + 1;
545 HeapRegion* r = (HeapRegion*) this; 517 while (index < g1h->n_regions()) {
546 NextCompactionHeapRegionClosure blk(r); 518 HeapRegion* hr = g1h->region_at(index);
547 g1h->heap_region_iterate_from(r, &blk); 519 if (!hr->isHumongous()) {
548 return blk.result(); 520 return hr;
521 }
522 index += 1;
523 }
524 return NULL;
549 } 525 }
550 526
551 void HeapRegion::save_marks() { 527 void HeapRegion::save_marks() {
552 set_saved_mark(); 528 set_saved_mark();
553 } 529 }
585 if (during_initial_mark) { 561 if (during_initial_mark) {
586 // During initial-mark, we'll also explicitly mark all objects 562 // During initial-mark, we'll also explicitly mark all objects
587 // we find to be self-forwarded on the next bitmap. So all 563 // we find to be self-forwarded on the next bitmap. So all
588 // objects need to be below NTAMS. 564 // objects need to be below NTAMS.
589 _next_top_at_mark_start = top(); 565 _next_top_at_mark_start = top();
590 set_top_at_conc_mark_count(bottom());
591 _next_marked_bytes = 0; 566 _next_marked_bytes = 0;
592 } else if (during_conc_mark) { 567 } else if (during_conc_mark) {
593 // During concurrent mark, all objects in the CSet (including 568 // During concurrent mark, all objects in the CSet (including
594 // the ones we find to be self-forwarded) are implicitly live. 569 // the ones we find to be self-forwarded) are implicitly live.
595 // So all objects need to be above NTAMS. 570 // So all objects need to be above NTAMS.
596 _next_top_at_mark_start = bottom(); 571 _next_top_at_mark_start = bottom();
597 set_top_at_conc_mark_count(bottom());
598 _next_marked_bytes = 0; 572 _next_marked_bytes = 0;
599 } 573 }
600 } 574 }
601 575
602 void HeapRegion::note_self_forwarding_removal_end(bool during_initial_mark, 576 void HeapRegion::note_self_forwarding_removal_end(bool during_initial_mark,
777 st->print(" PTAMS "PTR_FORMAT" NTAMS "PTR_FORMAT, 751 st->print(" PTAMS "PTR_FORMAT" NTAMS "PTR_FORMAT,
778 prev_top_at_mark_start(), next_top_at_mark_start()); 752 prev_top_at_mark_start(), next_top_at_mark_start());
779 G1OffsetTableContigSpace::print_on(st); 753 G1OffsetTableContigSpace::print_on(st);
780 } 754 }
781 755
782 void HeapRegion::verify(bool allow_dirty) const { 756 void HeapRegion::verify() const {
783 bool dummy = false; 757 bool dummy = false;
784 verify(allow_dirty, VerifyOption_G1UsePrevMarking, /* failures */ &dummy); 758 verify(VerifyOption_G1UsePrevMarking, /* failures */ &dummy);
785 } 759 }
786 760
787 // This really ought to be commoned up into OffsetTableContigSpace somehow. 761 // This really ought to be commoned up into OffsetTableContigSpace somehow.
788 // We would need a mechanism to make that code skip dead objects. 762 // We would need a mechanism to make that code skip dead objects.
789 763
790 void HeapRegion::verify(bool allow_dirty, 764 void HeapRegion::verify(VerifyOption vo,
791 VerifyOption vo,
792 bool* failures) const { 765 bool* failures) const {
793 G1CollectedHeap* g1 = G1CollectedHeap::heap(); 766 G1CollectedHeap* g1 = G1CollectedHeap::heap();
794 *failures = false; 767 *failures = false;
795 HeapWord* p = bottom(); 768 HeapWord* p = bottom();
796 HeapWord* prev_p = NULL; 769 HeapWord* prev_p = NULL;