comparison src/share/vm/gc_implementation/g1/heapRegion.cpp @ 1930:2d26b0046e0d

Merge.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Tue, 30 Nov 2010 14:53:30 +0100
parents 0ba67bb5392c 72a161e62cc4
children 06f017f7daa7
comparison
equal deleted inserted replaced
1484:6b7001391c97 1930:2d26b0046e0d
1 /* 1 /*
2 * Copyright 2001-2010 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright (c) 2001, 2010, 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.
14 * 14 *
15 * You should have received a copy of the GNU General Public License version 15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation, 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 * 18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * CA 95054 USA or visit www.sun.com if you need additional information or 20 * or visit www.oracle.com if you need additional information or have any
21 * have any questions. 21 * questions.
22 * 22 *
23 */ 23 */
24 24
25 #include "incls/_precompiled.incl" 25 #include "incls/_precompiled.incl"
26 #include "incls/_heapRegion.cpp.incl" 26 #include "incls/_heapRegion.cpp.incl"
288 288
289 int region_size_log = log2_long((jlong) region_size); 289 int region_size_log = log2_long((jlong) region_size);
290 // Recalculate the region size to make sure it's a power of 290 // Recalculate the region size to make sure it's a power of
291 // 2. This means that region_size is the largest power of 2 that's 291 // 2. This means that region_size is the largest power of 2 that's
292 // <= what we've calculated so far. 292 // <= what we've calculated so far.
293 region_size = ((uintx)1) << region_size_log; 293 region_size = ((uintx)1 << region_size_log);
294 294
295 // Now make sure that we don't go over or under our limits. 295 // Now make sure that we don't go over or under our limits.
296 if (region_size < MIN_REGION_SIZE) { 296 if (region_size < MIN_REGION_SIZE) {
297 region_size = MIN_REGION_SIZE; 297 region_size = MIN_REGION_SIZE;
298 } else if (region_size > MAX_REGION_SIZE) { 298 } else if (region_size > MAX_REGION_SIZE) {
375 _gc_efficiency = (double) garbage_bytes() / 375 _gc_efficiency = (double) garbage_bytes() /
376 g1h->predict_region_elapsed_time_ms(this, false); 376 g1h->predict_region_elapsed_time_ms(this, false);
377 } 377 }
378 // </PREDICTION> 378 // </PREDICTION>
379 379
380 void HeapRegion::set_startsHumongous() { 380 void HeapRegion::set_startsHumongous(HeapWord* new_end) {
381 assert(end() == _orig_end,
382 "Should be normal before the humongous object allocation");
383 assert(top() == bottom(), "should be empty");
384
381 _humongous_type = StartsHumongous; 385 _humongous_type = StartsHumongous;
382 _humongous_start_region = this; 386 _humongous_start_region = this;
383 assert(end() == _orig_end, "Should be normal before alloc."); 387
388 set_end(new_end);
389 _offsets.set_for_starts_humongous(new_end);
390 }
391
392 void HeapRegion::set_continuesHumongous(HeapRegion* start) {
393 assert(end() == _orig_end,
394 "Should be normal before the humongous object allocation");
395 assert(top() == bottom(), "should be empty");
396 assert(start->startsHumongous(), "pre-condition");
397
398 _humongous_type = ContinuesHumongous;
399 _humongous_start_region = start;
384 } 400 }
385 401
386 bool HeapRegion::claimHeapRegion(jint claimValue) { 402 bool HeapRegion::claimHeapRegion(jint claimValue) {
387 jint current = _claimed; 403 jint current = _claimed;
388 if (current != claimValue) { 404 if (current != claimValue) {
498 NextCompactionHeapRegionClosure blk(r); 514 NextCompactionHeapRegionClosure blk(r);
499 g1h->heap_region_iterate_from(r, &blk); 515 g1h->heap_region_iterate_from(r, &blk);
500 return blk.result(); 516 return blk.result();
501 } 517 }
502 518
503 void HeapRegion::set_continuesHumongous(HeapRegion* start) {
504 // The order is important here.
505 start->add_continuingHumongousRegion(this);
506 _humongous_type = ContinuesHumongous;
507 _humongous_start_region = start;
508 }
509
510 void HeapRegion::add_continuingHumongousRegion(HeapRegion* cont) {
511 // Must join the blocks of the current H region seq with the block of the
512 // added region.
513 offsets()->join_blocks(bottom(), cont->bottom());
514 arrayOop obj = (arrayOop)(bottom());
515 obj->set_length((int) (obj->length() + cont->capacity()/jintSize));
516 set_end(cont->end());
517 set_top(cont->end());
518 }
519
520 void HeapRegion::save_marks() { 519 void HeapRegion::save_marks() {
521 set_saved_mark(); 520 set_saved_mark();
522 } 521 }
523 522
524 void HeapRegion::oops_in_mr_iterate(MemRegion mr, OopClosure* cl) { 523 void HeapRegion::oops_in_mr_iterate(MemRegion mr, OopClosure* cl) {
552 return G1OffsetTableContigSpace::allocate(size); 551 return G1OffsetTableContigSpace::allocate(size);
553 } 552 }
554 #endif 553 #endif
555 554
556 void HeapRegion::set_zero_fill_state_work(ZeroFillState zfs) { 555 void HeapRegion::set_zero_fill_state_work(ZeroFillState zfs) {
557 assert(top() == bottom() || zfs == Allocated,
558 "Region must be empty, or we must be setting it to allocated.");
559 assert(ZF_mon->owned_by_self() || 556 assert(ZF_mon->owned_by_self() ||
560 Universe::heap()->is_gc_active(), 557 Universe::heap()->is_gc_active(),
561 "Must hold the lock or be a full GC to modify."); 558 "Must hold the lock or be a full GC to modify.");
559 #ifdef ASSERT
560 if (top() != bottom() && zfs != Allocated) {
561 ResourceMark rm;
562 stringStream region_str;
563 print_on(&region_str);
564 assert(top() == bottom() || zfs == Allocated,
565 err_msg("Region must be empty, or we must be setting it to allocated. "
566 "_zfs=%d, zfs=%d, region: %s", _zfs, zfs, region_str.as_string()));
567 }
568 #endif
562 _zfs = zfs; 569 _zfs = zfs;
563 } 570 }
564 571
565 void HeapRegion::set_zero_fill_complete() { 572 void HeapRegion::set_zero_fill_complete() {
566 set_zero_fill_state_work(ZeroFilled); 573 set_zero_fill_state_work(ZeroFilled);
648 } 655 }
649 656
650 HeapWord* 657 HeapWord*
651 HeapRegion:: 658 HeapRegion::
652 oops_on_card_seq_iterate_careful(MemRegion mr, 659 oops_on_card_seq_iterate_careful(MemRegion mr,
653 FilterOutOfRegionClosure* cl) { 660 FilterOutOfRegionClosure* cl,
661 bool filter_young) {
654 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 662 G1CollectedHeap* g1h = G1CollectedHeap::heap();
655 663
656 // If we're within a stop-world GC, then we might look at a card in a 664 // If we're within a stop-world GC, then we might look at a card in a
657 // GC alloc region that extends onto a GC LAB, which may not be 665 // GC alloc region that extends onto a GC LAB, which may not be
658 // parseable. Stop such at the "saved_mark" of the region. 666 // parseable. Stop such at the "saved_mark" of the region.
661 } else { 669 } else {
662 mr = mr.intersection(used_region()); 670 mr = mr.intersection(used_region());
663 } 671 }
664 if (mr.is_empty()) return NULL; 672 if (mr.is_empty()) return NULL;
665 // Otherwise, find the obj that extends onto mr.start(). 673 // Otherwise, find the obj that extends onto mr.start().
674
675 // The intersection of the incoming mr (for the card) and the
676 // allocated part of the region is non-empty. This implies that
677 // we have actually allocated into this region. The code in
678 // G1CollectedHeap.cpp that allocates a new region sets the
679 // is_young tag on the region before allocating. Thus we
680 // safely know if this region is young.
681 if (is_young() && filter_young) {
682 return NULL;
683 }
684
685 assert(!is_young(), "check value of filter_young");
666 686
667 // We used to use "block_start_careful" here. But we're actually happy 687 // We used to use "block_start_careful" here. But we're actually happy
668 // to update the BOT while we do this... 688 // to update the BOT while we do this...
669 HeapWord* cur = block_start(mr.start()); 689 HeapWord* cur = block_start(mr.start());
670 assert(cur <= mr.start(), "Postcondition"); 690 assert(cur <= mr.start(), "Postcondition");
767 HeapWord* p = bottom(); 787 HeapWord* p = bottom();
768 HeapWord* prev_p = NULL; 788 HeapWord* prev_p = NULL;
769 int objs = 0; 789 int objs = 0;
770 int blocks = 0; 790 int blocks = 0;
771 VerifyLiveClosure vl_cl(g1, use_prev_marking); 791 VerifyLiveClosure vl_cl(g1, use_prev_marking);
792 bool is_humongous = isHumongous();
793 size_t object_num = 0;
772 while (p < top()) { 794 while (p < top()) {
773 size_t size = oop(p)->size(); 795 size_t size = oop(p)->size();
796 if (is_humongous != g1->isHumongous(size)) {
797 gclog_or_tty->print_cr("obj "PTR_FORMAT" is of %shumongous size ("
798 SIZE_FORMAT" words) in a %shumongous region",
799 p, g1->isHumongous(size) ? "" : "non-",
800 size, is_humongous ? "" : "non-");
801 *failures = true;
802 }
803 object_num += 1;
774 if (blocks == BLOCK_SAMPLE_INTERVAL) { 804 if (blocks == BLOCK_SAMPLE_INTERVAL) {
775 HeapWord* res = block_start_const(p + (size/2)); 805 HeapWord* res = block_start_const(p + (size/2));
776 if (p != res) { 806 if (p != res) {
777 gclog_or_tty->print_cr("offset computation 1 for "PTR_FORMAT" and " 807 gclog_or_tty->print_cr("offset computation 1 for "PTR_FORMAT" and "
778 SIZE_FORMAT" returned "PTR_FORMAT, 808 SIZE_FORMAT" returned "PTR_FORMAT,
834 *failures = true; 864 *failures = true;
835 return; 865 return;
836 } 866 }
837 } 867 }
838 868
869 if (is_humongous && object_num > 1) {
870 gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is humongous "
871 "but has "SIZE_FORMAT", objects",
872 bottom(), end(), object_num);
873 *failures = true;
874 }
875
839 if (p != top()) { 876 if (p != top()) {
840 gclog_or_tty->print_cr("end of last object "PTR_FORMAT" " 877 gclog_or_tty->print_cr("end of last object "PTR_FORMAT" "
841 "does not match top "PTR_FORMAT, p, top()); 878 "does not match top "PTR_FORMAT, p, top());
842 *failures = true; 879 *failures = true;
843 return; 880 return;