--- old/src/share/vm/gc_implementation/g1/concurrentMark.cpp 2014-10-06 14:22:18.763153150 +0200 +++ new/src/share/vm/gc_implementation/g1/concurrentMark.cpp 2014-10-06 14:22:18.696151224 +0200 @@ -131,7 +131,10 @@ storage->set_mapping_changed_listener(&_listener); } -void CMBitMapMappingChangedListener::on_commit(uint start_region, size_t num_regions) { +void CMBitMapMappingChangedListener::on_commit(uint start_region, size_t num_regions, bool zero_filled) { + if (zero_filled) { + return; + } // We need to clear the bitmap on commit, removing any existing information. MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_region), num_regions * HeapRegion::GrainWords); _bm->clearRange(mr); --- old/src/share/vm/gc_implementation/g1/concurrentMark.hpp 2014-10-06 14:22:19.158164506 +0200 +++ new/src/share/vm/gc_implementation/g1/concurrentMark.hpp 2014-10-06 14:22:19.094162666 +0200 @@ -127,7 +127,7 @@ void set_bitmap(CMBitMap* bm) { _bm = bm; } - virtual void on_commit(uint start_idx, size_t num_regions); + virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled); }; class CMBitMap : public CMBitMapRO { --- old/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp 2014-10-06 14:22:19.524175028 +0200 +++ new/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp 2014-10-06 14:22:19.459173159 +0200 @@ -109,7 +109,7 @@ class G1BlockOffsetSharedArrayMappingChangedListener : public G1MappingChangedListener { public: - virtual void on_commit(uint start_idx, size_t num_regions) { + virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled) { // Nothing to do. The BOT is hard-wired to be part of the HeapRegion, and we cannot // retrieve it here since this would cause firing of several asserts. The code // executed after commit of a region already needs to do some re-initialization of --- old/src/share/vm/gc_implementation/g1/g1CardCounts.cpp 2014-10-06 14:22:19.880185263 +0200 +++ new/src/share/vm/gc_implementation/g1/g1CardCounts.cpp 2014-10-06 14:22:19.816183423 +0200 @@ -33,7 +33,10 @@ PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC -void G1CardCountsMappingChangedListener::on_commit(uint start_idx, size_t num_regions) { +void G1CardCountsMappingChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) { + if (zero_filled) { + return; + } MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_idx), num_regions * HeapRegion::GrainWords); _counts->clear_range(mr); } --- old/src/share/vm/gc_implementation/g1/g1CardCounts.hpp 2014-10-06 14:22:20.236195497 +0200 +++ new/src/share/vm/gc_implementation/g1/g1CardCounts.hpp 2014-10-06 14:22:20.172193657 +0200 @@ -42,7 +42,7 @@ public: void set_cardcounts(G1CardCounts* counts) { _counts = counts; } - virtual void on_commit(uint start_idx, size_t num_regions); + virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled); }; // Table to track the number of times a card has been refined. Once --- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2014-10-06 14:22:20.534204065 +0200 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2014-10-06 14:22:20.463202024 +0200 @@ -389,7 +389,9 @@ OtherRegionsTable::invalidate(start_idx, num_regions); } -void G1RegionMappingChangedListener::on_commit(uint start_idx, size_t num_regions) { +void G1RegionMappingChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) { + // The from card cache is not the memory that is actually committed. So we cannot + // take advantage of the zero_filled parameter. reset_from_card_cache(start_idx, num_regions); } --- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp 2014-10-06 14:22:20.883214098 +0200 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp 2014-10-06 14:22:20.817212201 +0200 @@ -172,7 +172,7 @@ private: void reset_from_card_cache(uint start_idx, size_t num_regions); public: - virtual void on_commit(uint start_idx, size_t num_regions); + virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled); }; class G1CollectedHeap : public SharedHeap { --- old/src/share/vm/gc_implementation/g1/g1RegionToSpaceMapper.cpp 2014-10-06 14:22:21.251224678 +0200 +++ new/src/share/vm/gc_implementation/g1/g1RegionToSpaceMapper.cpp 2014-10-06 14:22:21.187222838 +0200 @@ -69,7 +69,7 @@ virtual void commit_regions(uintptr_t start_idx, size_t num_regions) { _storage.commit(start_idx * _pages_per_region, num_regions * _pages_per_region); _commit_map.set_range(start_idx, start_idx + num_regions); - fire_on_commit(start_idx, num_regions); + fire_on_commit(start_idx, num_regions, true); } virtual void uncommit_regions(uintptr_t start_idx, size_t num_regions) { @@ -115,12 +115,14 @@ assert(!_commit_map.at(i), err_msg("Trying to commit storage at region "INTPTR_FORMAT" that is already committed", i)); uintptr_t idx = region_idx_to_page_idx(i); uint old_refcount = _refcounts.get_by_index(idx); + bool zero_filled = false; if (old_refcount == 0) { _storage.commit(idx, 1); + zero_filled = true; } _refcounts.set_by_index(idx, old_refcount + 1); _commit_map.set_bit(i); - fire_on_commit(i, 1); + fire_on_commit(i, 1, zero_filled); } } @@ -139,9 +141,9 @@ } }; -void G1RegionToSpaceMapper::fire_on_commit(uint start_idx, size_t num_regions) { +void G1RegionToSpaceMapper::fire_on_commit(uint start_idx, size_t num_regions, bool zero_filled) { if (_listener != NULL) { - _listener->on_commit(start_idx, num_regions); + _listener->on_commit(start_idx, num_regions, zero_filled); } } --- old/src/share/vm/gc_implementation/g1/g1RegionToSpaceMapper.hpp 2014-10-06 14:22:21.605234855 +0200 +++ new/src/share/vm/gc_implementation/g1/g1RegionToSpaceMapper.hpp 2014-10-06 14:22:21.541233015 +0200 @@ -33,7 +33,9 @@ public: // Fired after commit of the memory, i.e. the memory this listener is registered // for can be accessed. - virtual void on_commit(uint start_idx, size_t num_regions) = 0; + // Zero_filled indicates that the memory can be considered as filled with zero bytes + // when called. + virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled) = 0; }; // Maps region based commit/uncommit requests to the underlying page sized virtual @@ -51,7 +53,7 @@ G1RegionToSpaceMapper(ReservedSpace rs, size_t commit_granularity, size_t region_granularity, MemoryType type); - void fire_on_commit(uint start_idx, size_t num_regions); + void fire_on_commit(uint start_idx, size_t num_regions, bool zero_filled); public: MemRegion reserved() { return _storage.reserved(); } --- old/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp 2014-10-06 14:22:21.896243221 +0200 +++ new/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp 2014-10-06 14:22:21.832241381 +0200 @@ -125,7 +125,8 @@ } #endif -void G1SATBCardTableLoggingModRefBSChangedListener::on_commit(uint start_idx, size_t num_regions) { +void G1SATBCardTableLoggingModRefBSChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) { + // Default value for a clean card on the card table is -1. So we cannot take advantage of the zero_filled parameter. MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_idx), num_regions * HeapRegion::GrainWords); _card_table->clear(mr); } --- old/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp 2014-10-06 14:22:22.188251616 +0200 +++ new/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp 2014-10-06 14:22:22.125249805 +0200 @@ -136,7 +136,7 @@ void set_card_table(G1SATBCardTableLoggingModRefBS* card_table) { _card_table = card_table; } - virtual void on_commit(uint start_idx, size_t num_regions); + virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled); }; // Adds card-table logging to the post-barrier.