1.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Wed Aug 06 11:57:31 2008 -0400 1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Thu Aug 21 23:36:31 2008 -0400 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -3196,31 +3196,16 @@ 1.11 // YSR: All of this generation expansion/shrinking stuff is an exact copy of 1.12 // OneContigSpaceCardGeneration, which makes me wonder if we should move this 1.13 // to CardGeneration and share it... 1.14 +bool ConcurrentMarkSweepGeneration::expand(size_t bytes, size_t expand_bytes) { 1.15 + return CardGeneration::expand(bytes, expand_bytes); 1.16 +} 1.17 + 1.18 void ConcurrentMarkSweepGeneration::expand(size_t bytes, size_t expand_bytes, 1.19 CMSExpansionCause::Cause cause) 1.20 { 1.21 - assert_locked_or_safepoint(Heap_lock); 1.22 - 1.23 - size_t aligned_bytes = ReservedSpace::page_align_size_up(bytes); 1.24 - size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes); 1.25 - bool success = false; 1.26 - if (aligned_expand_bytes > aligned_bytes) { 1.27 - success = grow_by(aligned_expand_bytes); 1.28 - } 1.29 - if (!success) { 1.30 - success = grow_by(aligned_bytes); 1.31 - } 1.32 - if (!success) { 1.33 - size_t remaining_bytes = _virtual_space.uncommitted_size(); 1.34 - if (remaining_bytes > 0) { 1.35 - success = grow_by(remaining_bytes); 1.36 - } 1.37 - } 1.38 - if (GC_locker::is_active()) { 1.39 - if (PrintGC && Verbose) { 1.40 - gclog_or_tty->print_cr("Garbage collection disabled, expanded heap instead"); 1.41 - } 1.42 - } 1.43 + 1.44 + bool success = expand(bytes, expand_bytes); 1.45 + 1.46 // remember why we expanded; this information is used 1.47 // by shouldConcurrentCollect() when making decisions on whether to start 1.48 // a new CMS cycle. 1.49 @@ -6886,11 +6871,9 @@ 1.50 // during the preclean or remark phase. (CMSCleanOnEnter) 1.51 if (CMSCleanOnEnter) { 1.52 size_t sz = _collector->block_size_using_printezis_bits(addr); 1.53 - HeapWord* start_card_addr = (HeapWord*)round_down( 1.54 - (intptr_t)addr, CardTableModRefBS::card_size); 1.55 HeapWord* end_card_addr = (HeapWord*)round_to( 1.56 (intptr_t)(addr+sz), CardTableModRefBS::card_size); 1.57 - MemRegion redirty_range = MemRegion(start_card_addr, end_card_addr); 1.58 + MemRegion redirty_range = MemRegion(addr, end_card_addr); 1.59 assert(!redirty_range.is_empty(), "Arithmetical tautology"); 1.60 // Bump _threshold to end_card_addr; note that 1.61 // _threshold cannot possibly exceed end_card_addr, anyhow. 1.62 @@ -7486,12 +7469,25 @@ 1.63 ) 1.64 if (simulate_overflow || !_mark_stack->push(obj)) { 1.65 if (_concurrent_precleaning) { 1.66 - // During precleaning we can just dirty the appropriate card 1.67 + // During precleaning we can just dirty the appropriate card(s) 1.68 // in the mod union table, thus ensuring that the object remains 1.69 - // in the grey set and continue. Note that no one can be intefering 1.70 - // with us in this action of dirtying the mod union table, so 1.71 - // no locking is required. 1.72 - _mod_union_table->mark(addr); 1.73 + // in the grey set and continue. In the case of object arrays 1.74 + // we need to dirty all of the cards that the object spans, 1.75 + // since the rescan of object arrays will be limited to the 1.76 + // dirty cards. 1.77 + // Note that no one can be intefering with us in this action 1.78 + // of dirtying the mod union table, so no locking or atomics 1.79 + // are required. 1.80 + if (obj->is_objArray()) { 1.81 + size_t sz = obj->size(); 1.82 + HeapWord* end_card_addr = (HeapWord*)round_to( 1.83 + (intptr_t)(addr+sz), CardTableModRefBS::card_size); 1.84 + MemRegion redirty_range = MemRegion(addr, end_card_addr); 1.85 + assert(!redirty_range.is_empty(), "Arithmetical tautology"); 1.86 + _mod_union_table->mark_range(redirty_range); 1.87 + } else { 1.88 + _mod_union_table->mark(addr); 1.89 + } 1.90 _collector->_ser_pmc_preclean_ovflw++; 1.91 } else { 1.92 // During the remark phase, we need to remember this oop