Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/heapRegion.cpp @ 4970:33df1aeaebbf
Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 27 Feb 2012 13:10:13 +0100 |
parents | 04b9a2566eec a9647476d1a4 |
children | 957c266d8bc5 |
comparison
equal
deleted
inserted
replaced
4703:2cfb7fb2dce7 | 4970:33df1aeaebbf |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
92 #else // PRODUCT | 92 #else // PRODUCT |
93 obj->print_on(out); | 93 obj->print_on(out); |
94 #endif // PRODUCT | 94 #endif // PRODUCT |
95 } | 95 } |
96 | 96 |
97 template <class T> void do_oop_work(T* p) { | 97 template <class T> |
98 void do_oop_work(T* p) { | |
98 assert(_containing_obj != NULL, "Precondition"); | 99 assert(_containing_obj != NULL, "Precondition"); |
99 assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo), | 100 assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo), |
100 "Precondition"); | 101 "Precondition"); |
101 T heap_oop = oopDesc::load_heap_oop(p); | 102 T heap_oop = oopDesc::load_heap_oop(p); |
102 if (!oopDesc::is_null(heap_oop)) { | 103 if (!oopDesc::is_null(heap_oop)) { |
103 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); | 104 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
104 bool failed = false; | 105 bool failed = false; |
105 if (!_g1h->is_in_closed_subset(obj) || | 106 if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) { |
106 _g1h->is_obj_dead_cond(obj, _vo)) { | 107 MutexLockerEx x(ParGCRareEvent_lock, |
108 Mutex::_no_safepoint_check_flag); | |
109 | |
107 if (!_failures) { | 110 if (!_failures) { |
108 gclog_or_tty->print_cr(""); | 111 gclog_or_tty->print_cr(""); |
109 gclog_or_tty->print_cr("----------"); | 112 gclog_or_tty->print_cr("----------"); |
110 } | 113 } |
111 if (!_g1h->is_in_closed_subset(obj)) { | 114 if (!_g1h->is_in_closed_subset(obj)) { |
131 "["PTR_FORMAT", "PTR_FORMAT")", | 134 "["PTR_FORMAT", "PTR_FORMAT")", |
132 (void*) obj, to->bottom(), to->end()); | 135 (void*) obj, to->bottom(), to->end()); |
133 print_object(gclog_or_tty, obj); | 136 print_object(gclog_or_tty, obj); |
134 } | 137 } |
135 gclog_or_tty->print_cr("----------"); | 138 gclog_or_tty->print_cr("----------"); |
139 gclog_or_tty->flush(); | |
136 _failures = true; | 140 _failures = true; |
137 failed = true; | 141 failed = true; |
138 _n_failures++; | 142 _n_failures++; |
139 } | 143 } |
140 | 144 |
153 || !G1HRRSFlushLogBuffersOnVerify && // buffers were not flushed | 157 || !G1HRRSFlushLogBuffersOnVerify && // buffers were not flushed |
154 (_containing_obj->is_objArray() ? | 158 (_containing_obj->is_objArray() ? |
155 cv_field == dirty | 159 cv_field == dirty |
156 : cv_obj == dirty || cv_field == dirty)); | 160 : cv_obj == dirty || cv_field == dirty)); |
157 if (is_bad) { | 161 if (is_bad) { |
162 MutexLockerEx x(ParGCRareEvent_lock, | |
163 Mutex::_no_safepoint_check_flag); | |
164 | |
158 if (!_failures) { | 165 if (!_failures) { |
159 gclog_or_tty->print_cr(""); | 166 gclog_or_tty->print_cr(""); |
160 gclog_or_tty->print_cr("----------"); | 167 gclog_or_tty->print_cr("----------"); |
161 } | 168 } |
162 gclog_or_tty->print_cr("Missing rem set entry:"); | 169 gclog_or_tty->print_cr("Missing rem set entry:"); |
172 HR_FORMAT_PARAMS(to)); | 179 HR_FORMAT_PARAMS(to)); |
173 obj->print_on(gclog_or_tty); | 180 obj->print_on(gclog_or_tty); |
174 gclog_or_tty->print_cr("Obj head CTE = %d, field CTE = %d.", | 181 gclog_or_tty->print_cr("Obj head CTE = %d, field CTE = %d.", |
175 cv_obj, cv_field); | 182 cv_obj, cv_field); |
176 gclog_or_tty->print_cr("----------"); | 183 gclog_or_tty->print_cr("----------"); |
184 gclog_or_tty->flush(); | |
177 _failures = true; | 185 _failures = true; |
178 if (!failed) _n_failures++; | 186 if (!failed) _n_failures++; |
179 } | 187 } |
180 } | 188 } |
181 } | 189 } |
377 CardTableModRefBS* ct_bs = | 385 CardTableModRefBS* ct_bs = |
378 (CardTableModRefBS*)G1CollectedHeap::heap()->barrier_set(); | 386 (CardTableModRefBS*)G1CollectedHeap::heap()->barrier_set(); |
379 ct_bs->clear(MemRegion(bottom(), end())); | 387 ct_bs->clear(MemRegion(bottom(), end())); |
380 } | 388 } |
381 | 389 |
382 // <PREDICTION> | |
383 void HeapRegion::calc_gc_efficiency() { | 390 void HeapRegion::calc_gc_efficiency() { |
384 G1CollectedHeap* g1h = G1CollectedHeap::heap(); | 391 G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
385 _gc_efficiency = (double) garbage_bytes() / | 392 G1CollectorPolicy* g1p = g1h->g1_policy(); |
386 g1h->predict_region_elapsed_time_ms(this, false); | 393 _gc_efficiency = (double) reclaimable_bytes() / |
387 } | 394 g1p->predict_region_elapsed_time_ms(this, false); |
388 // </PREDICTION> | 395 } |
389 | 396 |
390 void HeapRegion::set_startsHumongous(HeapWord* new_top, HeapWord* new_end) { | 397 void HeapRegion::set_startsHumongous(HeapWord* new_top, HeapWord* new_end) { |
391 assert(!isHumongous(), "sanity / pre-condition"); | 398 assert(!isHumongous(), "sanity / pre-condition"); |
392 assert(end() == _orig_end, | 399 assert(end() == _orig_end, |
393 "Should be normal before the humongous object allocation"); | 400 "Should be normal before the humongous object allocation"); |
565 | 572 |
566 void HeapRegion::oop_before_save_marks_iterate(OopClosure* cl) { | 573 void HeapRegion::oop_before_save_marks_iterate(OopClosure* cl) { |
567 oops_in_mr_iterate(MemRegion(bottom(), saved_mark_word()), cl); | 574 oops_in_mr_iterate(MemRegion(bottom(), saved_mark_word()), cl); |
568 } | 575 } |
569 | 576 |
577 void HeapRegion::note_self_forwarding_removal_start(bool during_initial_mark, | |
578 bool during_conc_mark) { | |
579 // We always recreate the prev marking info and we'll explicitly | |
580 // mark all objects we find to be self-forwarded on the prev | |
581 // bitmap. So all objects need to be below PTAMS. | |
582 _prev_top_at_mark_start = top(); | |
583 _prev_marked_bytes = 0; | |
584 | |
585 if (during_initial_mark) { | |
586 // During initial-mark, we'll also explicitly mark all objects | |
587 // we find to be self-forwarded on the next bitmap. So all | |
588 // objects need to be below NTAMS. | |
589 _next_top_at_mark_start = top(); | |
590 set_top_at_conc_mark_count(bottom()); | |
591 _next_marked_bytes = 0; | |
592 } else if (during_conc_mark) { | |
593 // During concurrent mark, all objects in the CSet (including | |
594 // the ones we find to be self-forwarded) are implicitly live. | |
595 // So all objects need to be above NTAMS. | |
596 _next_top_at_mark_start = bottom(); | |
597 set_top_at_conc_mark_count(bottom()); | |
598 _next_marked_bytes = 0; | |
599 } | |
600 } | |
601 | |
602 void HeapRegion::note_self_forwarding_removal_end(bool during_initial_mark, | |
603 bool during_conc_mark, | |
604 size_t marked_bytes) { | |
605 assert(0 <= marked_bytes && marked_bytes <= used(), | |
606 err_msg("marked: "SIZE_FORMAT" used: "SIZE_FORMAT, | |
607 marked_bytes, used())); | |
608 _prev_marked_bytes = marked_bytes; | |
609 } | |
610 | |
570 HeapWord* | 611 HeapWord* |
571 HeapRegion::object_iterate_mem_careful(MemRegion mr, | 612 HeapRegion::object_iterate_mem_careful(MemRegion mr, |
572 ObjectClosure* cl) { | 613 ObjectClosure* cl) { |
573 G1CollectedHeap* g1h = G1CollectedHeap::heap(); | 614 G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
574 // We used to use "block_start_careful" here. But we're actually happy | 615 // We used to use "block_start_careful" here. But we're actually happy |
615 G1CollectedHeap* g1h = G1CollectedHeap::heap(); | 656 G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
616 | 657 |
617 // If we're within a stop-world GC, then we might look at a card in a | 658 // If we're within a stop-world GC, then we might look at a card in a |
618 // GC alloc region that extends onto a GC LAB, which may not be | 659 // GC alloc region that extends onto a GC LAB, which may not be |
619 // parseable. Stop such at the "saved_mark" of the region. | 660 // parseable. Stop such at the "saved_mark" of the region. |
620 if (G1CollectedHeap::heap()->is_gc_active()) { | 661 if (g1h->is_gc_active()) { |
621 mr = mr.intersection(used_region_at_save_marks()); | 662 mr = mr.intersection(used_region_at_save_marks()); |
622 } else { | 663 } else { |
623 mr = mr.intersection(used_region()); | 664 mr = mr.intersection(used_region()); |
624 } | 665 } |
625 if (mr.is_empty()) return NULL; | 666 if (mr.is_empty()) return NULL; |
644 *card_ptr = CardTableModRefBS::clean_card_val(); | 685 *card_ptr = CardTableModRefBS::clean_card_val(); |
645 // We must complete this write before we do any of the reads below. | 686 // We must complete this write before we do any of the reads below. |
646 OrderAccess::storeload(); | 687 OrderAccess::storeload(); |
647 } | 688 } |
648 | 689 |
690 // Cache the boundaries of the memory region in some const locals | |
691 HeapWord* const start = mr.start(); | |
692 HeapWord* const end = mr.end(); | |
693 | |
649 // We used to use "block_start_careful" here. But we're actually happy | 694 // We used to use "block_start_careful" here. But we're actually happy |
650 // to update the BOT while we do this... | 695 // to update the BOT while we do this... |
651 HeapWord* cur = block_start(mr.start()); | 696 HeapWord* cur = block_start(start); |
652 assert(cur <= mr.start(), "Postcondition"); | 697 assert(cur <= start, "Postcondition"); |
653 | 698 |
654 while (cur <= mr.start()) { | 699 oop obj; |
655 if (oop(cur)->klass_or_null() == NULL) { | 700 |
701 HeapWord* next = cur; | |
702 while (next <= start) { | |
703 cur = next; | |
704 obj = oop(cur); | |
705 if (obj->klass_or_null() == NULL) { | |
656 // Ran into an unparseable point. | 706 // Ran into an unparseable point. |
657 return cur; | 707 return cur; |
658 } | 708 } |
659 // Otherwise... | 709 // Otherwise... |
660 int sz = oop(cur)->size(); | 710 next = (cur + obj->size()); |
661 if (cur + sz > mr.start()) break; | 711 } |
662 // Otherwise, go on. | 712 |
663 cur = cur + sz; | 713 // If we finish the above loop...We have a parseable object that |
664 } | 714 // begins on or before the start of the memory region, and ends |
665 oop obj; | 715 // inside or spans the entire region. |
666 obj = oop(cur); | 716 |
667 // If we finish this loop... | 717 assert(obj == oop(cur), "sanity"); |
668 assert(cur <= mr.start() | 718 assert(cur <= start && |
669 && obj->klass_or_null() != NULL | 719 obj->klass_or_null() != NULL && |
670 && cur + obj->size() > mr.start(), | 720 (cur + obj->size()) > start, |
671 "Loop postcondition"); | 721 "Loop postcondition"); |
722 | |
672 if (!g1h->is_obj_dead(obj)) { | 723 if (!g1h->is_obj_dead(obj)) { |
673 obj->oop_iterate(cl, mr); | 724 obj->oop_iterate(cl, mr); |
674 } | 725 } |
675 | 726 |
676 HeapWord* next; | 727 while (cur < end) { |
677 while (cur < mr.end()) { | |
678 obj = oop(cur); | 728 obj = oop(cur); |
679 if (obj->klass_or_null() == NULL) { | 729 if (obj->klass_or_null() == NULL) { |
680 // Ran into an unparseable point. | 730 // Ran into an unparseable point. |
681 return cur; | 731 return cur; |
682 }; | 732 }; |
733 | |
683 // Otherwise: | 734 // Otherwise: |
684 next = (cur + obj->size()); | 735 next = (cur + obj->size()); |
736 | |
685 if (!g1h->is_obj_dead(obj)) { | 737 if (!g1h->is_obj_dead(obj)) { |
686 if (next < mr.end()) { | 738 if (next < end || !obj->is_objArray()) { |
739 // This object either does not span the MemRegion | |
740 // boundary, or if it does it's not an array. | |
741 // Apply closure to whole object. | |
687 obj->oop_iterate(cl); | 742 obj->oop_iterate(cl); |
688 } else { | 743 } else { |
689 // this obj spans the boundary. If it's an array, stop at the | 744 // This obj is an array that spans the boundary. |
690 // boundary. | 745 // Stop at the boundary. |
691 if (obj->is_objArray()) { | 746 obj->oop_iterate(cl, mr); |
692 obj->oop_iterate(cl, mr); | |
693 } else { | |
694 obj->oop_iterate(cl); | |
695 } | |
696 } | 747 } |
697 } | 748 } |
698 cur = next; | 749 cur = next; |
699 } | 750 } |
700 return NULL; | 751 return NULL; |