8077417: Cleanup of Universe::initialize_heap()
Reviewed-by: stefank, kbarrett
This commit is contained in:
parent
817138c4f9
commit
4fbfdfe87b
@ -54,10 +54,6 @@ GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;
|
||||
jint ParallelScavengeHeap::initialize() {
|
||||
CollectedHeap::pre_initialize();
|
||||
|
||||
// Initialize collector policy
|
||||
_collector_policy = new GenerationSizer();
|
||||
_collector_policy->initialize_all();
|
||||
|
||||
const size_t heap_size = _collector_policy->max_heap_byte_size();
|
||||
|
||||
ReservedSpace heap_rs = Universe::reserve_heap(heap_size, _collector_policy->heap_alignment());
|
||||
|
@ -74,7 +74,8 @@ class ParallelScavengeHeap : public CollectedHeap {
|
||||
HeapWord* mem_allocate_old_gen(size_t size);
|
||||
|
||||
public:
|
||||
ParallelScavengeHeap() : CollectedHeap(), _death_march_count(0) { }
|
||||
ParallelScavengeHeap(GenerationSizer* policy) :
|
||||
CollectedHeap(), _collector_policy(policy), _death_march_count(0) { }
|
||||
|
||||
// For use by VM operations
|
||||
enum CollectionType {
|
||||
|
@ -687,6 +687,15 @@ jint universe_init() {
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
template <class Heap, class Policy>
|
||||
jint Universe::create_heap() {
|
||||
assert(_collectedHeap == NULL, "Heap already created");
|
||||
Policy* policy = new Policy();
|
||||
policy->initialize_all();
|
||||
_collectedHeap = new Heap(policy);
|
||||
return _collectedHeap->initialize();
|
||||
}
|
||||
|
||||
// Choose the heap base address and oop encoding mode
|
||||
// when compressed oops are used:
|
||||
// Unscaled - Use 32-bits oops without encoding when
|
||||
@ -696,50 +705,37 @@ jint universe_init() {
|
||||
// HeapBased - Use compressed oops with heap base + encoding.
|
||||
|
||||
jint Universe::initialize_heap() {
|
||||
jint status = JNI_ERR;
|
||||
|
||||
#if !INCLUDE_ALL_GCS
|
||||
if (UseParallelGC) {
|
||||
#if INCLUDE_ALL_GCS
|
||||
Universe::_collectedHeap = new ParallelScavengeHeap();
|
||||
#else // INCLUDE_ALL_GCS
|
||||
fatal("UseParallelGC not supported in this VM.");
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
|
||||
} else if (UseG1GC) {
|
||||
#if INCLUDE_ALL_GCS
|
||||
G1CollectorPolicyExt* g1p = new G1CollectorPolicyExt();
|
||||
g1p->initialize_all();
|
||||
G1CollectedHeap* g1h = new G1CollectedHeap(g1p);
|
||||
Universe::_collectedHeap = g1h;
|
||||
#else // INCLUDE_ALL_GCS
|
||||
fatal("UseG1GC not supported in java kernel vm.");
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
|
||||
} else {
|
||||
GenCollectorPolicy *gc_policy;
|
||||
|
||||
if (UseSerialGC) {
|
||||
gc_policy = new MarkSweepPolicy();
|
||||
} else if (UseConcMarkSweepGC) {
|
||||
#if INCLUDE_ALL_GCS
|
||||
gc_policy = new ConcurrentMarkSweepPolicy();
|
||||
#else // INCLUDE_ALL_GCS
|
||||
fatal("UseConcMarkSweepGC not supported in this VM.");
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
} else { // default old generation
|
||||
gc_policy = new MarkSweepPolicy();
|
||||
}
|
||||
gc_policy->initialize_all();
|
||||
|
||||
Universe::_collectedHeap = new GenCollectedHeap(gc_policy);
|
||||
fatal("UseG1GC not supported in this VM.");
|
||||
} else if (UseConcMarkSweepGC) {
|
||||
fatal("UseConcMarkSweepGC not supported in this VM.");
|
||||
}
|
||||
#else
|
||||
if (UseParallelGC) {
|
||||
status = Universe::create_heap<ParallelScavengeHeap, GenerationSizer>();
|
||||
} else if (UseG1GC) {
|
||||
status = Universe::create_heap<G1CollectedHeap, G1CollectorPolicyExt>();
|
||||
} else if (UseConcMarkSweepGC) {
|
||||
status = Universe::create_heap<GenCollectedHeap, ConcurrentMarkSweepPolicy>();
|
||||
}
|
||||
#endif
|
||||
else { // UseSerialGC
|
||||
// Don't assert that UseSerialGC is set here because there are cases
|
||||
// where no GC it set and we then fall back to using SerialGC.
|
||||
status = Universe::create_heap<GenCollectedHeap, MarkSweepPolicy>();
|
||||
}
|
||||
|
||||
ThreadLocalAllocBuffer::set_max_size(Universe::heap()->max_tlab_size());
|
||||
|
||||
jint status = Universe::heap()->initialize();
|
||||
if (status != JNI_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
ThreadLocalAllocBuffer::set_max_size(Universe::heap()->max_tlab_size());
|
||||
|
||||
#ifdef _LP64
|
||||
if (UseCompressedOops) {
|
||||
// Subtract a page because something can get allocated at heap base.
|
||||
@ -1063,7 +1059,7 @@ bool universe_post_init() {
|
||||
|
||||
MemoryService::add_metaspace_memory_pools();
|
||||
|
||||
MemoryService::set_universe_heap(Universe::_collectedHeap);
|
||||
MemoryService::set_universe_heap(Universe::heap());
|
||||
#if INCLUDE_CDS
|
||||
SharedClassUtil::initialize(CHECK_false);
|
||||
#endif
|
||||
|
@ -214,6 +214,7 @@ class Universe: AllStatic {
|
||||
static size_t _heap_capacity_at_last_gc;
|
||||
static size_t _heap_used_at_last_gc;
|
||||
|
||||
template <class Heap, class Policy> static jint create_heap();
|
||||
static jint initialize_heap();
|
||||
static void initialize_basic_type_mirrors(TRAPS);
|
||||
static void fixup_mirrors(TRAPS);
|
||||
|
Loading…
x
Reference in New Issue
Block a user