8133821: Refactor initialization of the heap and the collector policy
Reviewed-by: pliden, tschatzl
This commit is contained in:
parent
513aa02851
commit
6ad40faac5
@ -694,13 +694,29 @@ jint universe_init() {
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
template <class Heap, class Policy>
|
||||
jint Universe::create_heap() {
|
||||
CollectedHeap* Universe::create_heap() {
|
||||
assert(_collectedHeap == NULL, "Heap already created");
|
||||
Policy* policy = new Policy();
|
||||
policy->initialize_all();
|
||||
_collectedHeap = new Heap(policy);
|
||||
return _collectedHeap->initialize();
|
||||
#if !INCLUDE_ALL_GCS
|
||||
if (UseParallelGC) {
|
||||
fatal("UseParallelGC not supported in this VM.");
|
||||
} else if (UseG1GC) {
|
||||
fatal("UseG1GC not supported in this VM.");
|
||||
} else if (UseConcMarkSweepGC) {
|
||||
fatal("UseConcMarkSweepGC not supported in this VM.");
|
||||
#else
|
||||
if (UseParallelGC) {
|
||||
return Universe::create_heap_with_policy<ParallelScavengeHeap, GenerationSizer>();
|
||||
} else if (UseG1GC) {
|
||||
return Universe::create_heap_with_policy<G1CollectedHeap, G1CollectorPolicyExt>();
|
||||
} else if (UseConcMarkSweepGC) {
|
||||
return Universe::create_heap_with_policy<GenCollectedHeap, ConcurrentMarkSweepPolicy>();
|
||||
#endif
|
||||
} else if (UseSerialGC) {
|
||||
return Universe::create_heap_with_policy<GenCollectedHeap, MarkSweepPolicy>();
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Choose the heap base address and oop encoding mode
|
||||
@ -714,27 +730,12 @@ jint Universe::create_heap() {
|
||||
jint Universe::initialize_heap() {
|
||||
jint status = JNI_ERR;
|
||||
|
||||
#if !INCLUDE_ALL_GCS
|
||||
if (UseParallelGC) {
|
||||
fatal("UseParallelGC not supported in this VM.");
|
||||
} else if (UseG1GC) {
|
||||
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 if (UseSerialGC) {
|
||||
status = Universe::create_heap<GenCollectedHeap, MarkSweepPolicy>();
|
||||
} else {
|
||||
ShouldNotReachHere();
|
||||
_collectedHeap = create_heap_ext();
|
||||
if (_collectedHeap == NULL) {
|
||||
_collectedHeap = create_heap();
|
||||
}
|
||||
|
||||
status = _collectedHeap->initialize();
|
||||
if (status != JNI_OK) {
|
||||
return status;
|
||||
}
|
||||
|
@ -214,7 +214,9 @@ 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();
|
||||
template <class Heap, class Policy> static CollectedHeap* create_heap_with_policy();
|
||||
static CollectedHeap* create_heap();
|
||||
static CollectedHeap* create_heap_ext();
|
||||
static jint initialize_heap();
|
||||
static void initialize_basic_type_mirrors(TRAPS);
|
||||
static void fixup_mirrors(TRAPS);
|
||||
|
@ -49,4 +49,11 @@ inline void Universe::set_allocation_context_notification_obj(oop obj) {
|
||||
_allocation_context_notification_obj = obj;
|
||||
}
|
||||
|
||||
template <class Heap, class Policy>
|
||||
CollectedHeap* Universe::create_heap_with_policy() {
|
||||
Policy* policy = new Policy();
|
||||
policy->initialize_all();
|
||||
return new Heap(policy);
|
||||
}
|
||||
|
||||
#endif // SHARE_VM_MEMORY_UNIVERSE_INLINE_HPP
|
||||
|
30
hotspot/src/share/vm/memory/universe_ext.cpp
Normal file
30
hotspot/src/share/vm/memory/universe_ext.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
|
||||
CollectedHeap* Universe::create_heap_ext() {
|
||||
return NULL;
|
||||
}
|
Loading…
Reference in New Issue
Block a user