mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
6672698: mangle_unused_area() should not remangle the entire heap at each collection
Maintain a high water mark for the allocations in a space and mangle only up to that high water mark. Reviewed-by: ysr, apetrusenko
This commit is contained in:
parent
0d9452401c
commit
18dbebd143
43 changed files with 1299 additions and 206 deletions
|
@ -87,6 +87,15 @@ void PSOldGen::initialize_work(const char* perf_data_name, int level) {
|
|||
|
||||
MemRegion cmr((HeapWord*)virtual_space()->low(),
|
||||
(HeapWord*)virtual_space()->high());
|
||||
if (ZapUnusedHeapArea) {
|
||||
// Mangle newly committed space immediately rather than
|
||||
// waiting for the initialization of the space even though
|
||||
// mangling is related to spaces. Doing it here eliminates
|
||||
// the need to carry along information that a complete mangling
|
||||
// (bottom to end) needs to be done.
|
||||
SpaceMangler::mangle_region(cmr);
|
||||
}
|
||||
|
||||
Universe::heap()->barrier_set()->resize_covered_region(cmr);
|
||||
|
||||
CardTableModRefBS* _ct = (CardTableModRefBS*)Universe::heap()->barrier_set();
|
||||
|
@ -112,7 +121,9 @@ void PSOldGen::initialize_work(const char* perf_data_name, int level) {
|
|||
if (_object_space == NULL)
|
||||
vm_exit_during_initialization("Could not allocate an old gen space");
|
||||
|
||||
object_space()->initialize(cmr, true);
|
||||
object_space()->initialize(cmr,
|
||||
SpaceDecorator::Clear,
|
||||
SpaceDecorator::Mangle);
|
||||
|
||||
_object_mark_sweep = new PSMarkSweepDecorator(_object_space, start_array(), MarkSweepDeadRatio);
|
||||
|
||||
|
@ -232,6 +243,19 @@ bool PSOldGen::expand_by(size_t bytes) {
|
|||
assert_locked_or_safepoint(Heap_lock);
|
||||
bool result = virtual_space()->expand_by(bytes);
|
||||
if (result) {
|
||||
if (ZapUnusedHeapArea) {
|
||||
// We need to mangle the newly expanded area. The memregion spans
|
||||
// end -> new_end, we assume that top -> end is already mangled.
|
||||
// Do the mangling before post_resize() is called because
|
||||
// the space is available for allocation after post_resize();
|
||||
HeapWord* const virtual_space_high = (HeapWord*) virtual_space()->high();
|
||||
assert(object_space()->end() < virtual_space_high,
|
||||
"Should be true before post_resize()");
|
||||
MemRegion mangle_region(object_space()->end(), virtual_space_high);
|
||||
// Note that the object space has not yet been updated to
|
||||
// coincede with the new underlying virtual space.
|
||||
SpaceMangler::mangle_region(mangle_region);
|
||||
}
|
||||
post_resize();
|
||||
if (UsePerfData) {
|
||||
_space_counters->update_capacity();
|
||||
|
@ -348,16 +372,7 @@ void PSOldGen::post_resize() {
|
|||
start_array()->set_covered_region(new_memregion);
|
||||
Universe::heap()->barrier_set()->resize_covered_region(new_memregion);
|
||||
|
||||
// Did we expand?
|
||||
HeapWord* const virtual_space_high = (HeapWord*) virtual_space()->high();
|
||||
if (object_space()->end() < virtual_space_high) {
|
||||
// We need to mangle the newly expanded area. The memregion spans
|
||||
// end -> new_end, we assume that top -> end is already mangled.
|
||||
// This cannot be safely tested for, as allocation may be taking
|
||||
// place.
|
||||
MemRegion mangle_region(object_space()->end(), virtual_space_high);
|
||||
object_space()->mangle_region(mangle_region);
|
||||
}
|
||||
|
||||
// ALWAYS do this last!!
|
||||
object_space()->set_end(virtual_space_high);
|
||||
|
@ -462,3 +477,10 @@ void PSOldGen::verify_object_start_array() {
|
|||
VerifyObjectStartArrayClosure check( this, &_start_array );
|
||||
object_iterate(&check);
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
void PSOldGen::record_spaces_top() {
|
||||
assert(ZapUnusedHeapArea, "Not mangling unused space");
|
||||
object_space()->set_top_for_allocations();
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue