Merge
This commit is contained in:
commit
47e31eaa7a
@ -6536,6 +6536,9 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure {
|
|||||||
|
|
||||||
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||||
|
|
||||||
|
oop obj = (oop)r->bottom();
|
||||||
|
CMBitMap* next_bitmap = g1h->concurrent_mark()->nextMarkBitMap();
|
||||||
|
|
||||||
// The following checks whether the humongous object is live are sufficient.
|
// The following checks whether the humongous object is live are sufficient.
|
||||||
// The main additional check (in addition to having a reference from the roots
|
// The main additional check (in addition to having a reference from the roots
|
||||||
// or the young gen) is whether the humongous object has a remembered set entry.
|
// or the young gen) is whether the humongous object has a remembered set entry.
|
||||||
@ -6572,37 +6575,41 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure {
|
|||||||
g1h->humongous_region_is_always_live(region_idx)) {
|
g1h->humongous_region_is_always_live(region_idx)) {
|
||||||
|
|
||||||
if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
|
if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
|
||||||
gclog_or_tty->print_cr("Live humongous %d region %d with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is dead-bitmap %d live-other %d obj array %d",
|
gclog_or_tty->print_cr("Live humongous %d region %d with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other %d obj array %d",
|
||||||
r->isHumongous(),
|
r->isHumongous(),
|
||||||
region_idx,
|
region_idx,
|
||||||
r->rem_set()->occupied(),
|
r->rem_set()->occupied(),
|
||||||
r->rem_set()->strong_code_roots_list_length(),
|
r->rem_set()->strong_code_roots_list_length(),
|
||||||
g1h->mark_in_progress() && !g1h->g1_policy()->during_initial_mark_pause(),
|
next_bitmap->isMarked(r->bottom()),
|
||||||
g1h->humongous_is_live(region_idx),
|
g1h->humongous_is_live(region_idx),
|
||||||
oop(r->bottom())->is_objArray()
|
obj->is_objArray()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
guarantee(!((oop)(r->bottom()))->is_objArray(),
|
guarantee(!obj->is_objArray(),
|
||||||
err_msg("Eagerly reclaiming object arrays is not supported, but the object "PTR_FORMAT" is.",
|
err_msg("Eagerly reclaiming object arrays is not supported, but the object "PTR_FORMAT" is.",
|
||||||
r->bottom()));
|
r->bottom()));
|
||||||
|
|
||||||
if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
|
if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
|
||||||
gclog_or_tty->print_cr("Reclaim humongous region %d start "PTR_FORMAT" region %d length "UINT32_FORMAT" with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is dead-bitmap %d live-other %d obj array %d",
|
gclog_or_tty->print_cr("Reclaim humongous region %d start "PTR_FORMAT" region %d length "UINT32_FORMAT" with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other %d obj array %d",
|
||||||
r->isHumongous(),
|
r->isHumongous(),
|
||||||
r->bottom(),
|
r->bottom(),
|
||||||
region_idx,
|
region_idx,
|
||||||
r->region_num(),
|
r->region_num(),
|
||||||
r->rem_set()->occupied(),
|
r->rem_set()->occupied(),
|
||||||
r->rem_set()->strong_code_roots_list_length(),
|
r->rem_set()->strong_code_roots_list_length(),
|
||||||
g1h->mark_in_progress() && !g1h->g1_policy()->during_initial_mark_pause(),
|
next_bitmap->isMarked(r->bottom()),
|
||||||
g1h->humongous_is_live(region_idx),
|
g1h->humongous_is_live(region_idx),
|
||||||
oop(r->bottom())->is_objArray()
|
obj->is_objArray()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// Need to clear mark bit of the humongous object if already set.
|
||||||
|
if (next_bitmap->isMarked(r->bottom())) {
|
||||||
|
next_bitmap->clear(r->bottom());
|
||||||
|
}
|
||||||
_freed_bytes += r->used();
|
_freed_bytes += r->used();
|
||||||
r->set_containing_set(NULL);
|
r->set_containing_set(NULL);
|
||||||
_humongous_regions_removed.increment(1u, r->capacity());
|
_humongous_regions_removed.increment(1u, r->capacity());
|
||||||
|
@ -288,7 +288,12 @@ void G1ParScanThreadState::undo_allocation(GCAllocPurpose purpose, HeapWord* obj
|
|||||||
}
|
}
|
||||||
|
|
||||||
HeapWord* G1ParScanThreadState::allocate(GCAllocPurpose purpose, size_t word_sz) {
|
HeapWord* G1ParScanThreadState::allocate(GCAllocPurpose purpose, size_t word_sz) {
|
||||||
HeapWord* obj = alloc_buffer(purpose)->allocate(word_sz);
|
HeapWord* obj = NULL;
|
||||||
|
if (purpose == GCAllocForSurvived) {
|
||||||
|
obj = alloc_buffer(GCAllocForSurvived)->allocate_aligned(word_sz, SurvivorAlignmentInBytes);
|
||||||
|
} else {
|
||||||
|
obj = alloc_buffer(GCAllocForTenured)->allocate(word_sz);
|
||||||
|
}
|
||||||
if (obj != NULL) {
|
if (obj != NULL) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,12 @@
|
|||||||
#include "gc_implementation/parNew/parOopClosures.inline.hpp"
|
#include "gc_implementation/parNew/parOopClosures.inline.hpp"
|
||||||
#include "gc_implementation/shared/adaptiveSizePolicy.hpp"
|
#include "gc_implementation/shared/adaptiveSizePolicy.hpp"
|
||||||
#include "gc_implementation/shared/ageTable.hpp"
|
#include "gc_implementation/shared/ageTable.hpp"
|
||||||
#include "gc_implementation/shared/parGCAllocBuffer.hpp"
|
#include "gc_implementation/shared/copyFailedInfo.hpp"
|
||||||
#include "gc_implementation/shared/gcHeapSummary.hpp"
|
#include "gc_implementation/shared/gcHeapSummary.hpp"
|
||||||
#include "gc_implementation/shared/gcTimer.hpp"
|
#include "gc_implementation/shared/gcTimer.hpp"
|
||||||
#include "gc_implementation/shared/gcTrace.hpp"
|
#include "gc_implementation/shared/gcTrace.hpp"
|
||||||
#include "gc_implementation/shared/gcTraceTime.hpp"
|
#include "gc_implementation/shared/gcTraceTime.hpp"
|
||||||
#include "gc_implementation/shared/copyFailedInfo.hpp"
|
#include "gc_implementation/shared/parGCAllocBuffer.inline.hpp"
|
||||||
#include "gc_implementation/shared/spaceDecorator.hpp"
|
#include "gc_implementation/shared/spaceDecorator.hpp"
|
||||||
#include "memory/defNewGeneration.inline.hpp"
|
#include "memory/defNewGeneration.inline.hpp"
|
||||||
#include "memory/genCollectedHeap.hpp"
|
#include "memory/genCollectedHeap.hpp"
|
||||||
@ -252,7 +252,7 @@ HeapWord* ParScanThreadState::alloc_in_to_space_slow(size_t word_sz) {
|
|||||||
plab->set_word_size(buf_size);
|
plab->set_word_size(buf_size);
|
||||||
plab->set_buf(buf_space);
|
plab->set_buf(buf_space);
|
||||||
record_survivor_plab(buf_space, buf_size);
|
record_survivor_plab(buf_space, buf_size);
|
||||||
obj = plab->allocate(word_sz);
|
obj = plab->allocate_aligned(word_sz, SurvivorAlignmentInBytes);
|
||||||
// Note that we cannot compare buf_size < word_sz below
|
// Note that we cannot compare buf_size < word_sz below
|
||||||
// because of AlignmentReserve (see ParGCAllocBuffer::allocate()).
|
// because of AlignmentReserve (see ParGCAllocBuffer::allocate()).
|
||||||
assert(obj != NULL || plab->words_remaining() < word_sz,
|
assert(obj != NULL || plab->words_remaining() < word_sz,
|
||||||
|
@ -168,7 +168,7 @@ class ParScanThreadState {
|
|||||||
HeapWord* alloc_in_to_space_slow(size_t word_sz);
|
HeapWord* alloc_in_to_space_slow(size_t word_sz);
|
||||||
|
|
||||||
HeapWord* alloc_in_to_space(size_t word_sz) {
|
HeapWord* alloc_in_to_space(size_t word_sz) {
|
||||||
HeapWord* obj = to_space_alloc_buffer()->allocate(word_sz);
|
HeapWord* obj = to_space_alloc_buffer()->allocate_aligned(word_sz, SurvivorAlignmentInBytes);
|
||||||
if (obj != NULL) return obj;
|
if (obj != NULL) return obj;
|
||||||
else return alloc_in_to_space_slow(word_sz);
|
else return alloc_in_to_space_slow(word_sz);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
|
#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
|
||||||
|
|
||||||
#include "gc_implementation/parallelScavenge/objectStartArray.hpp"
|
#include "gc_implementation/parallelScavenge/objectStartArray.hpp"
|
||||||
|
#include "gc_interface/collectedHeap.inline.hpp"
|
||||||
#include "memory/allocation.hpp"
|
#include "memory/allocation.hpp"
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -94,23 +95,9 @@ class PSYoungPromotionLAB : public PSPromotionLAB {
|
|||||||
PSYoungPromotionLAB() { }
|
PSYoungPromotionLAB() { }
|
||||||
|
|
||||||
// Not MT safe
|
// Not MT safe
|
||||||
HeapWord* allocate(size_t size) {
|
inline HeapWord* allocate(size_t size);
|
||||||
// Can't assert this, when young fills, we keep the LAB around, but flushed.
|
|
||||||
// assert(_state != flushed, "Sanity");
|
|
||||||
HeapWord* obj = top();
|
|
||||||
HeapWord* new_top = obj + size;
|
|
||||||
// The 'new_top>obj' check is needed to detect overflow of obj+size.
|
|
||||||
if (new_top > obj && new_top <= end()) {
|
|
||||||
set_top(new_top);
|
|
||||||
assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
|
|
||||||
"checking alignment");
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
debug_only(virtual bool lab_is_valid(MemRegion lab);)
|
||||||
}
|
|
||||||
|
|
||||||
debug_only(virtual bool lab_is_valid(MemRegion lab));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PSOldPromotionLAB : public PSPromotionLAB {
|
class PSOldPromotionLAB : public PSPromotionLAB {
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_INLINE_HPP
|
||||||
|
#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_INLINE_HPP
|
||||||
|
|
||||||
|
#include "gc_implementation/parallelScavenge/psPromotionLAB.hpp"
|
||||||
|
#include "gc_interface/collectedHeap.inline.hpp"
|
||||||
|
|
||||||
|
HeapWord* PSYoungPromotionLAB::allocate(size_t size) {
|
||||||
|
// Can't assert this, when young fills, we keep the LAB around, but flushed.
|
||||||
|
// assert(_state != flushed, "Sanity");
|
||||||
|
HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end(), SurvivorAlignmentInBytes);
|
||||||
|
if (obj == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HeapWord* new_top = obj + size;
|
||||||
|
// The 'new_top>obj' check is needed to detect overflow of obj+size.
|
||||||
|
if (new_top > obj && new_top <= end()) {
|
||||||
|
set_top(new_top);
|
||||||
|
assert(is_ptr_aligned(obj, SurvivorAlignmentInBytes) && is_object_aligned((intptr_t)new_top),
|
||||||
|
"checking alignment");
|
||||||
|
return obj;
|
||||||
|
} else {
|
||||||
|
set_top(obj);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_INLINE_HPP
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "gc_implementation/parallelScavenge/psOldGen.hpp"
|
#include "gc_implementation/parallelScavenge/psOldGen.hpp"
|
||||||
#include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
|
#include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
|
||||||
|
#include "gc_implementation/parallelScavenge/psPromotionLAB.inline.hpp"
|
||||||
#include "gc_implementation/parallelScavenge/psScavenge.hpp"
|
#include "gc_implementation/parallelScavenge/psScavenge.hpp"
|
||||||
#include "oops/oop.psgc.inline.hpp"
|
#include "oops/oop.psgc.inline.hpp"
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP
|
#ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP
|
||||||
#define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP
|
#define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP
|
||||||
|
#include "gc_interface/collectedHeap.hpp"
|
||||||
#include "memory/allocation.hpp"
|
#include "memory/allocation.hpp"
|
||||||
#include "memory/blockOffsetTable.hpp"
|
#include "memory/blockOffsetTable.hpp"
|
||||||
#include "memory/threadLocalAllocBuffer.hpp"
|
#include "memory/threadLocalAllocBuffer.hpp"
|
||||||
@ -84,6 +84,9 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allocate the object aligned to "alignment_in_bytes".
|
||||||
|
HeapWord* allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes);
|
||||||
|
|
||||||
// Undo the last allocation in the buffer, which is required to be of the
|
// Undo the last allocation in the buffer, which is required to be of the
|
||||||
// "obj" of the given "word_sz".
|
// "obj" of the given "word_sz".
|
||||||
void undo_allocation(HeapWord* obj, size_t word_sz) {
|
void undo_allocation(HeapWord* obj, size_t word_sz) {
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_PARGCALLOCBUFFER_INLINE_HPP
|
||||||
|
#define SHARE_VM_GC_IMPLEMENTATION_SHARED_PARGCALLOCBUFFER_INLINE_HPP
|
||||||
|
|
||||||
|
#include "gc_implementation/shared/parGCAllocBuffer.hpp"
|
||||||
|
#include "gc_interface/collectedHeap.inline.hpp"
|
||||||
|
|
||||||
|
HeapWord* ParGCAllocBuffer::allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes) {
|
||||||
|
|
||||||
|
HeapWord* res = CollectedHeap::align_allocation_or_fail(_top, _end, alignment_in_bytes);
|
||||||
|
if (res == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set _top so that allocate(), which expects _top to be correctly set,
|
||||||
|
// can be used below.
|
||||||
|
_top = res;
|
||||||
|
return allocate(word_sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_PARGCALLOCBUFFER_INLINE_HPP
|
@ -351,6 +351,12 @@ class CollectedHeap : public CHeapObj<mtInternal> {
|
|||||||
fill_with_object(start, pointer_delta(end, start), zap);
|
fill_with_object(start, pointer_delta(end, start), zap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the address "addr" aligned by "alignment_in_bytes" if such
|
||||||
|
// an address is below "end". Return NULL otherwise.
|
||||||
|
inline static HeapWord* align_allocation_or_fail(HeapWord* addr,
|
||||||
|
HeapWord* end,
|
||||||
|
unsigned short alignment_in_bytes);
|
||||||
|
|
||||||
// Some heaps may offer a contiguous region for shared non-blocking
|
// Some heaps may offer a contiguous region for shared non-blocking
|
||||||
// allocation, via inlined code (by exporting the address of the top and
|
// allocation, via inlined code (by exporting the address of the top and
|
||||||
// end fields defining the extent of the contiguous allocation region.)
|
// end fields defining the extent of the contiguous allocation region.)
|
||||||
|
@ -241,6 +241,44 @@ inline void CollectedHeap::oop_iterate_no_header(OopClosure* cl) {
|
|||||||
oop_iterate(&no_header_cl);
|
oop_iterate(&no_header_cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline HeapWord* CollectedHeap::align_allocation_or_fail(HeapWord* addr,
|
||||||
|
HeapWord* end,
|
||||||
|
unsigned short alignment_in_bytes) {
|
||||||
|
if (alignment_in_bytes <= ObjectAlignmentInBytes) {
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(is_ptr_aligned(addr, HeapWordSize),
|
||||||
|
err_msg("Address " PTR_FORMAT " is not properly aligned.", p2i(addr)));
|
||||||
|
assert(is_size_aligned(alignment_in_bytes, HeapWordSize),
|
||||||
|
err_msg("Alignment size %u is incorrect.", alignment_in_bytes));
|
||||||
|
|
||||||
|
HeapWord* new_addr = (HeapWord*) align_pointer_up(addr, alignment_in_bytes);
|
||||||
|
size_t padding = pointer_delta(new_addr, addr);
|
||||||
|
|
||||||
|
if (padding == 0) {
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (padding < CollectedHeap::min_fill_size()) {
|
||||||
|
padding += alignment_in_bytes / HeapWordSize;
|
||||||
|
assert(padding >= CollectedHeap::min_fill_size(),
|
||||||
|
err_msg("alignment_in_bytes %u is expect to be larger "
|
||||||
|
"than the minimum object size", alignment_in_bytes));
|
||||||
|
new_addr = addr + padding;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(new_addr > addr, err_msg("Unexpected arithmetic overflow "
|
||||||
|
PTR_FORMAT " not greater than " PTR_FORMAT, p2i(new_addr), p2i(addr)));
|
||||||
|
if(new_addr < end) {
|
||||||
|
CollectedHeap::fill_with_object(addr, padding);
|
||||||
|
return new_addr;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
|
@ -790,7 +790,7 @@ oop DefNewGeneration::copy_to_survivor_space(oop old) {
|
|||||||
|
|
||||||
// Try allocating obj in to-space (unless too old)
|
// Try allocating obj in to-space (unless too old)
|
||||||
if (old->age() < tenuring_threshold()) {
|
if (old->age() < tenuring_threshold()) {
|
||||||
obj = (oop) to()->allocate(s);
|
obj = (oop) to()->allocate_aligned(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise try allocating obj tenured
|
// Otherwise try allocating obj tenured
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "gc_implementation/shared/liveRange.hpp"
|
#include "gc_implementation/shared/liveRange.hpp"
|
||||||
#include "gc_implementation/shared/markSweep.hpp"
|
#include "gc_implementation/shared/markSweep.hpp"
|
||||||
#include "gc_implementation/shared/spaceDecorator.hpp"
|
#include "gc_implementation/shared/spaceDecorator.hpp"
|
||||||
|
#include "gc_interface/collectedHeap.inline.hpp"
|
||||||
#include "memory/blockOffsetTable.inline.hpp"
|
#include "memory/blockOffsetTable.inline.hpp"
|
||||||
#include "memory/defNewGeneration.hpp"
|
#include "memory/defNewGeneration.hpp"
|
||||||
#include "memory/genCollectedHeap.hpp"
|
#include "memory/genCollectedHeap.hpp"
|
||||||
@ -720,6 +721,27 @@ inline HeapWord* ContiguousSpace::par_allocate_impl(size_t size,
|
|||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HeapWord* ContiguousSpace::allocate_aligned(size_t size) {
|
||||||
|
assert(Heap_lock->owned_by_self() || (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()), "not locked");
|
||||||
|
HeapWord* end_value = end();
|
||||||
|
|
||||||
|
HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end_value, SurvivorAlignmentInBytes);
|
||||||
|
if (obj == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pointer_delta(end_value, obj) >= size) {
|
||||||
|
HeapWord* new_top = obj + size;
|
||||||
|
set_top(new_top);
|
||||||
|
assert(is_ptr_aligned(obj, SurvivorAlignmentInBytes) && is_aligned(new_top),
|
||||||
|
"checking alignment");
|
||||||
|
return obj;
|
||||||
|
} else {
|
||||||
|
set_top(obj);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Requires locking.
|
// Requires locking.
|
||||||
HeapWord* ContiguousSpace::allocate(size_t size) {
|
HeapWord* ContiguousSpace::allocate(size_t size) {
|
||||||
return allocate_impl(size, end());
|
return allocate_impl(size, end());
|
||||||
|
@ -526,6 +526,7 @@ class ContiguousSpace: public CompactibleSpace {
|
|||||||
// Allocation (return NULL if full)
|
// Allocation (return NULL if full)
|
||||||
virtual HeapWord* allocate(size_t word_size);
|
virtual HeapWord* allocate(size_t word_size);
|
||||||
virtual HeapWord* par_allocate(size_t word_size);
|
virtual HeapWord* par_allocate(size_t word_size);
|
||||||
|
HeapWord* allocate_aligned(size_t word_size);
|
||||||
|
|
||||||
// Iteration
|
// Iteration
|
||||||
void oop_iterate(ExtendedOopClosure* cl);
|
void oop_iterate(ExtendedOopClosure* cl);
|
||||||
|
@ -55,8 +55,6 @@ inline void oopDesc::follow_contents(ParCompactionManager* cm) {
|
|||||||
klass()->oop_follow_contents(cm, this);
|
klass()->oop_follow_contents(cm, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used by parallel old GC.
|
|
||||||
|
|
||||||
inline oop oopDesc::forward_to_atomic(oop p) {
|
inline oop oopDesc::forward_to_atomic(oop p) {
|
||||||
assert(ParNewGeneration::is_legal_forward_ptr(p),
|
assert(ParNewGeneration::is_legal_forward_ptr(p),
|
||||||
"illegal forwarding pointer value.");
|
"illegal forwarding pointer value.");
|
||||||
|
@ -1431,6 +1431,22 @@ bool verify_object_alignment() {
|
|||||||
(int)ObjectAlignmentInBytes, os::vm_page_size());
|
(int)ObjectAlignmentInBytes, os::vm_page_size());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(SurvivorAlignmentInBytes == 0) {
|
||||||
|
SurvivorAlignmentInBytes = ObjectAlignmentInBytes;
|
||||||
|
} else {
|
||||||
|
if (!is_power_of_2(SurvivorAlignmentInBytes)) {
|
||||||
|
jio_fprintf(defaultStream::error_stream(),
|
||||||
|
"error: SurvivorAlignmentInBytes=%d must be power of 2\n",
|
||||||
|
(int)SurvivorAlignmentInBytes);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (SurvivorAlignmentInBytes < ObjectAlignmentInBytes) {
|
||||||
|
jio_fprintf(defaultStream::error_stream(),
|
||||||
|
"error: SurvivorAlignmentInBytes=%d must be greater than ObjectAlignmentInBytes=%d \n",
|
||||||
|
(int)SurvivorAlignmentInBytes, (int)ObjectAlignmentInBytes);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3871,6 +3871,9 @@ class CommandLineFlags {
|
|||||||
product(bool, PrintGCCause, true, \
|
product(bool, PrintGCCause, true, \
|
||||||
"Include GC cause in GC logging") \
|
"Include GC cause in GC logging") \
|
||||||
\
|
\
|
||||||
|
experimental(intx, SurvivorAlignmentInBytes, 0, \
|
||||||
|
"Default survivor space alignment in bytes") \
|
||||||
|
\
|
||||||
product(bool , AllowNonVirtualCalls, false, \
|
product(bool , AllowNonVirtualCalls, false, \
|
||||||
"Obey the ACC_SUPER flag and allow invokenonvirtual calls") \
|
"Obey the ACC_SUPER flag and allow invokenonvirtual calls") \
|
||||||
\
|
\
|
||||||
|
122
hotspot/test/gc/g1/TestEagerReclaimHumongousRegions2.java
Normal file
122
hotspot/test/gc/g1/TestEagerReclaimHumongousRegions2.java
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test TestEagerReclaimHumongousRegions2
|
||||||
|
* @bug 8051973
|
||||||
|
* @summary Test to make sure that eager reclaim of humongous objects correctly clears
|
||||||
|
* mark bitmaps at reclaim.
|
||||||
|
* @key gc
|
||||||
|
* @library /testlibrary
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.oracle.java.testlibrary.OutputAnalyzer;
|
||||||
|
import com.oracle.java.testlibrary.ProcessTools;
|
||||||
|
|
||||||
|
// An object that has a few references to other instances to slow down marking.
|
||||||
|
class ObjectWithSomeRefs {
|
||||||
|
public ObjectWithSomeRefs other1;
|
||||||
|
public ObjectWithSomeRefs other2;
|
||||||
|
public ObjectWithSomeRefs other3;
|
||||||
|
public ObjectWithSomeRefs other4;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ReclaimRegionFast {
|
||||||
|
public static final int M = 1024*1024;
|
||||||
|
|
||||||
|
public static LinkedList<Object> garbageList = new LinkedList<Object>();
|
||||||
|
|
||||||
|
public static void genGarbage(Object large) {
|
||||||
|
for (int i = 0; i < 64*1024; i++) {
|
||||||
|
Object[] garbage = new Object[50];
|
||||||
|
garbage[0] = large;
|
||||||
|
garbageList.add(garbage);
|
||||||
|
}
|
||||||
|
garbageList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<ObjectWithSomeRefs> longList = new ArrayList<ObjectWithSomeRefs>();
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
for (int i = 0; i < 16*1024; i++) {
|
||||||
|
longList.add(new ObjectWithSomeRefs());
|
||||||
|
}
|
||||||
|
|
||||||
|
Random rnd = new Random();
|
||||||
|
for (int i = 0; i < longList.size(); i++) {
|
||||||
|
int len = longList.size();
|
||||||
|
longList.get(i).other1 = longList.get(rnd.nextInt(len));
|
||||||
|
longList.get(i).other2 = longList.get(rnd.nextInt(len));
|
||||||
|
longList.get(i).other3 = longList.get(rnd.nextInt(len));
|
||||||
|
longList.get(i).other4 = longList.get(rnd.nextInt(len));
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] large1 = new int[M];
|
||||||
|
int[] large2 = null;
|
||||||
|
int[] large3 = null;
|
||||||
|
int[] large4 = null;
|
||||||
|
|
||||||
|
Object ref_from_stack = large1;
|
||||||
|
|
||||||
|
for (int i = 0; i < 20; i++) {
|
||||||
|
// A set of large objects that will be reclaimed eagerly - and hopefully marked.
|
||||||
|
large1 = new int[M - 20];
|
||||||
|
large2 = new int[M - 20];
|
||||||
|
large3 = new int[M - 20];
|
||||||
|
large4 = new int[M - 20];
|
||||||
|
genGarbage(large1);
|
||||||
|
// Make sure that the compiler cannot completely remove
|
||||||
|
// the allocation of the large object until here.
|
||||||
|
System.out.println(large1 + " " + large2 + " " + large3 + " " + large4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep the reference to the first object alive.
|
||||||
|
System.out.println(ref_from_stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestEagerReclaimHumongousRegions2 {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||||
|
"-XX:+UseG1GC",
|
||||||
|
"-Xms128M",
|
||||||
|
"-Xmx128M",
|
||||||
|
"-Xmn2M",
|
||||||
|
"-XX:G1HeapRegionSize=1M",
|
||||||
|
"-XX:InitiatingHeapOccupancyPercent=0", // Want to have as much as possible initial marks.
|
||||||
|
"-XX:+PrintGC",
|
||||||
|
"-XX:+VerifyAfterGC",
|
||||||
|
"-XX:ConcGCThreads=1", // Want to make marking as slow as possible.
|
||||||
|
"-XX:+IgnoreUnrecognizedVMOptions", // G1VerifyBitmaps is develop only.
|
||||||
|
"-XX:+G1VerifyBitmaps",
|
||||||
|
ReclaimRegionFast.class.getName());
|
||||||
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
|
output.shouldHaveExitValue(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user