1.1 --- a/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Wed Jan 19 19:24:34 2011 -0800 1.2 +++ b/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Thu Jan 20 13:57:12 2011 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. 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 @@ -181,26 +181,46 @@ 1.11 } 1.12 1.13 class G1PrepareCompactClosure: public HeapRegionClosure { 1.14 + G1CollectedHeap* _g1h; 1.15 ModRefBarrierSet* _mrbs; 1.16 CompactPoint _cp; 1.17 + size_t _pre_used; 1.18 + FreeRegionList _free_list; 1.19 + HumongousRegionSet _humongous_proxy_set; 1.20 1.21 void free_humongous_region(HeapRegion* hr) { 1.22 - HeapWord* bot = hr->bottom(); 1.23 HeapWord* end = hr->end(); 1.24 assert(hr->startsHumongous(), 1.25 "Only the start of a humongous region should be freed."); 1.26 - G1CollectedHeap::heap()->free_region(hr); 1.27 + _g1h->free_humongous_region(hr, &_pre_used, &_free_list, 1.28 + &_humongous_proxy_set, false /* par */); 1.29 + // Do we also need to do this for the continues humongous regions 1.30 + // we just collapsed? 1.31 hr->prepare_for_compaction(&_cp); 1.32 // Also clear the part of the card table that will be unused after 1.33 // compaction. 1.34 - _mrbs->clear(MemRegion(hr->compaction_top(), hr->end())); 1.35 + _mrbs->clear(MemRegion(hr->compaction_top(), end)); 1.36 } 1.37 1.38 public: 1.39 - G1PrepareCompactClosure(CompactibleSpace* cs) : 1.40 + G1PrepareCompactClosure(CompactibleSpace* cs) 1.41 + : _g1h(G1CollectedHeap::heap()), 1.42 + _mrbs(G1CollectedHeap::heap()->mr_bs()), 1.43 _cp(NULL, cs, cs->initialize_threshold()), 1.44 - _mrbs(G1CollectedHeap::heap()->mr_bs()) 1.45 - {} 1.46 + _pre_used(0), 1.47 + _free_list("Local Free List for G1MarkSweep"), 1.48 + _humongous_proxy_set("G1MarkSweep Humongous Proxy Set") { } 1.49 + 1.50 + void update_sets() { 1.51 + // We'll recalculate total used bytes and recreate the free list 1.52 + // at the end of the GC, so no point in updating those values here. 1.53 + _g1h->update_sets_after_freeing_regions(0, /* pre_used */ 1.54 + NULL, /* free_list */ 1.55 + &_humongous_proxy_set, 1.56 + false /* par */); 1.57 + _free_list.remove_all(); 1.58 + } 1.59 + 1.60 bool doHeapRegion(HeapRegion* hr) { 1.61 if (hr->isHumongous()) { 1.62 if (hr->startsHumongous()) { 1.63 @@ -266,6 +286,7 @@ 1.64 1.65 G1PrepareCompactClosure blk(sp); 1.66 g1h->heap_region_iterate(&blk); 1.67 + blk.update_sets(); 1.68 1.69 CompactPoint perm_cp(pg, NULL, NULL); 1.70 pg->prepare_for_compaction(&perm_cp);