8073463: G1 does not mangle freed heap regions

Reviewed-by: mgerdin, jwilhelm
This commit is contained in:
David Lindholm 2015-03-12 14:09:36 +01:00
parent 395543dadc
commit bcf9ea6cbf
5 changed files with 21 additions and 16 deletions

View File

@ -396,6 +396,10 @@ class CompactibleFreeListSpace: public CompactibleSpace {
// Resizing support
void set_end(HeapWord* value); // override
// Never mangle CompactibleFreeListSpace
void mangle_unused_area() {}
void mangle_unused_area_complete() {}
// Mutual exclusion support
Mutex* freelistLock() const { return &_freelistLock; }

View File

@ -934,6 +934,16 @@ void G1OffsetTableContigSpace::set_end(HeapWord* new_end) {
_offsets.resize(new_end - bottom());
}
#ifndef PRODUCT
void G1OffsetTableContigSpace::mangle_unused_area() {
mangle_unused_area_complete();
}
void G1OffsetTableContigSpace::mangle_unused_area_complete() {
SpaceMangler::mangle_region(MemRegion(top(), end()));
}
#endif
void G1OffsetTableContigSpace::print() const {
print_short();
gclog_or_tty->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", "

View File

@ -155,6 +155,9 @@ class G1OffsetTableContigSpace: public CompactibleSpace {
void set_bottom(HeapWord* value);
void set_end(HeapWord* value);
void mangle_unused_area() PRODUCT_RETURN;
void mangle_unused_area_complete() PRODUCT_RETURN;
HeapWord* scan_top() const;
void record_timestamp();
void reset_gc_time_stamp() { _gc_time_stamp = 0; }

View File

@ -353,15 +353,6 @@ void ContiguousSpace::mangle_unused_area() {
void ContiguousSpace::mangle_unused_area_complete() {
mangler()->mangle_unused_area_complete();
}
void ContiguousSpace::mangle_region(MemRegion mr) {
// Although this method uses SpaceMangler::mangle_region() which
// is not specific to a space, the when the ContiguousSpace version
// is called, it is always with regard to a space and this
// bounds checking is appropriate.
MemRegion space_mr(bottom(), end());
assert(space_mr.contains(mr), "Mangling outside space");
SpaceMangler::mangle_region(mr);
}
#endif // NOT_PRODUCT
void CompactibleSpace::initialize(MemRegion mr,

View File

@ -128,11 +128,10 @@ class Space: public CHeapObj<mtGC> {
// For detecting GC bugs. Should only be called at GC boundaries, since
// some unused space may be used as scratch space during GC's.
// Default implementation does nothing. We also call this when expanding
// a space to satisfy an allocation request. See bug #4668531
virtual void mangle_unused_area() {}
virtual void mangle_unused_area_complete() {}
virtual void mangle_region(MemRegion mr) {}
// We also call this when expanding a space to satisfy an allocation
// request. See bug #4668531
virtual void mangle_unused_area() = 0;
virtual void mangle_unused_area_complete() = 0;
// Testers
bool is_empty() const { return used() == 0; }
@ -559,8 +558,6 @@ class ContiguousSpace: public CompactibleSpace {
void mangle_unused_area() PRODUCT_RETURN;
// Mangle [top, end)
void mangle_unused_area_complete() PRODUCT_RETURN;
// Mangle the given MemRegion.
void mangle_region(MemRegion mr) PRODUCT_RETURN;
// Do some sparse checking on the area that should have been mangled.
void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;