# HG changeset patch # User rkennke # Date 1508328160 -7200 # Wed Oct 18 14:02:40 2017 +0200 # Node ID 921104ceaed9e942628bb12e8adb6ada3afb7b22 # Parent 3e7702cd3f19732fc3d210e98d6ffc537faaee8f 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass diff --git a/src/hotspot/share/gc/cms/cmsHeap.hpp b/src/hotspot/share/gc/cms/cmsHeap.hpp --- a/src/hotspot/share/gc/cms/cmsHeap.hpp +++ b/src/hotspot/share/gc/cms/cmsHeap.hpp @@ -39,14 +39,16 @@ class WorkGang; class CMSHeap : public GenCollectedHeap { + +protected: + virtual void check_gen_kinds(); + public: CMSHeap(GenCollectorPolicy *policy); // Returns JNI_OK on success virtual jint initialize(); - virtual void check_gen_kinds(); - // Convenience function to be used in situations where the heap type can be // asserted to be this type. static CMSHeap* heap(); @@ -70,10 +72,6 @@ // supports. Caller does not hold the Heap_lock on entry. void collect(GCCause::Cause cause); - bool is_in_closed_subset(const void* p) const { - return is_in_reserved(p); - } - bool card_mark_must_follow_store() const { return true; } diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp new file mode 100644 --- /dev/null +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017, 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 "gc/serial/serialHeap.hpp" + +SerialHeap::SerialHeap(GenCollectorPolicy* policy) : GenCollectedHeap(policy) {} + +void SerialHeap::check_gen_kinds() { + assert(young_gen()->kind() == Generation::DefNew, + "Wrong youngest generation type"); + assert(old_gen()->kind() == Generation::MarkSweepCompact, + "Wrong generation kind"); +} diff --git a/src/hotspot/share/gc/serial/serialHeap.hpp b/src/hotspot/share/gc/serial/serialHeap.hpp new file mode 100644 --- /dev/null +++ b/src/hotspot/share/gc/serial/serialHeap.hpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017, 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_SERIAL_SERIALHEAP_HPP +#define SHARE_VM_GC_SERIAL_SERIALHEAP_HPP + +#include "gc/shared/genCollectedHeap.hpp" + +class GenCollectorPolicy; + +class SerialHeap : public GenCollectedHeap { +protected: + virtual void check_gen_kinds(); + +public: + SerialHeap(GenCollectorPolicy* policy); + + virtual Name kind() const { + return CollectedHeap::SerialHeap; + } + + virtual const char* name() const { + return "Serial"; + } + + // override + virtual bool is_in_closed_subset(const void* p) const { + return is_in(p); + } + + virtual bool card_mark_must_follow_store() const { + return false; + } + +}; + +#endif // SHARE_VM_GC_CMS_CMSHEAP_HPP diff --git a/src/hotspot/share/gc/shared/collectedHeap.hpp b/src/hotspot/share/gc/shared/collectedHeap.hpp --- a/src/hotspot/share/gc/shared/collectedHeap.hpp +++ b/src/hotspot/share/gc/shared/collectedHeap.hpp @@ -81,9 +81,10 @@ // // CollectedHeap // GenCollectedHeap +// SerialHeap +// CMSHeap // G1CollectedHeap // ParallelScavengeHeap -// CMSHeap // class CollectedHeap : public CHeapObj { friend class VMStructs; @@ -193,7 +194,7 @@ public: enum Name { - GenCollectedHeap, + SerialHeap, ParallelScavengeHeap, G1CollectedHeap, CMSHeap diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp --- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp +++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp @@ -152,13 +152,6 @@ _gen_policy->initialize_gc_policy_counters(); } -void GenCollectedHeap::check_gen_kinds() { - assert(young_gen()->kind() == Generation::DefNew, - "Wrong youngest generation type"); - assert(old_gen()->kind() == Generation::MarkSweepCompact, - "Wrong generation kind"); -} - void GenCollectedHeap::ref_processing_init() { _young_gen->ref_processor_init(); _old_gen->ref_processor_init(); @@ -983,7 +976,7 @@ GenCollectedHeap* GenCollectedHeap::heap() { CollectedHeap* heap = Universe::heap(); assert(heap != NULL, "Uninitialized access to GenCollectedHeap::heap()"); - assert(heap->kind() == CollectedHeap::GenCollectedHeap || + assert(heap->kind() == CollectedHeap::SerialHeap || heap->kind() == CollectedHeap::CMSHeap, "Not a GenCollectedHeap"); return (GenCollectedHeap*) heap; } diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.hpp b/src/hotspot/share/gc/shared/genCollectedHeap.hpp --- a/src/hotspot/share/gc/shared/genCollectedHeap.hpp +++ b/src/hotspot/share/gc/shared/genCollectedHeap.hpp @@ -83,6 +83,12 @@ bool run_verification, bool clear_soft_refs, bool restore_marks_for_biased_locking); + // Reserve aligned space for the heap as needed by the contained generations. + char* allocate(size_t alignment, ReservedSpace* heap_rs); + + // Initialize ("weak") refs processing support + void ref_processing_init(); + protected: // The set of potentially parallel tasks in root scanning. @@ -134,31 +140,18 @@ // we absolutely __must__ clear soft refs? bool must_clear_all_soft_refs(); + GenCollectedHeap(GenCollectorPolicy *policy); + + virtual void check_gen_kinds() = 0; + public: - GenCollectedHeap(GenCollectorPolicy *policy); // Returns JNI_OK on success virtual jint initialize(); - // Reserve aligned space for the heap as needed by the contained generations. - char* allocate(size_t alignment, ReservedSpace* heap_rs); - // Does operations required after initialization has been done. void post_initialize(); - virtual void check_gen_kinds(); - - // Initialize ("weak") refs processing support - virtual void ref_processing_init(); - - virtual Name kind() const { - return CollectedHeap::GenCollectedHeap; - } - - virtual const char* name() const { - return "Serial"; - } - Generation* young_gen() const { return _young_gen; } Generation* old_gen() const { return _old_gen; } @@ -215,11 +208,6 @@ // assertion checking or verification only. bool is_in(const void* p) const; - // override - virtual bool is_in_closed_subset(const void* p) const { - return is_in(p); - } - // Returns true if the reference is to an object in the reserved space // for the young generation. // Assumes the the young gen address range is less than that of the old gen. @@ -286,10 +274,6 @@ return true; } - virtual bool card_mark_must_follow_store() const { - return false; - } - // We don't need barriers for stores to objects in the // young gen and, a fortiori, for initializing stores to // objects therein. This applies to DefNew+Tenured and ParNew+CMS diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp --- a/src/hotspot/share/memory/universe.cpp +++ b/src/hotspot/share/memory/universe.cpp @@ -32,10 +32,10 @@ #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/dependencies.hpp" +#include "gc/serial/serialHeap.hpp" #include "gc/shared/cardTableModRefBS.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "gc/shared/gcLocker.inline.hpp" -#include "gc/shared/genCollectedHeap.hpp" #include "gc/shared/generation.hpp" #include "gc/shared/gcTraceTime.inline.hpp" #include "gc/shared/space.hpp" @@ -762,7 +762,7 @@ return Universe::create_heap_with_policy(); #endif } else if (UseSerialGC) { - return Universe::create_heap_with_policy(); + return Universe::create_heap_with_policy(); } ShouldNotReachHere(); diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -2255,7 +2255,8 @@ \ declare_constant(G1SATBCardTableModRefBS::g1_young_gen) \ \ - declare_constant(CollectedHeap::GenCollectedHeap) \ + declare_constant(CollectedHeap::SerialHeap) \ + declare_constant(CollectedHeap::CMSHeap) \ declare_constant(CollectedHeap::ParallelScavengeHeap) \ declare_constant(CollectedHeap::G1CollectedHeap) \ \ diff --git a/src/hotspot/share/services/memoryService.cpp b/src/hotspot/share/services/memoryService.cpp --- a/src/hotspot/share/services/memoryService.cpp +++ b/src/hotspot/share/services/memoryService.cpp @@ -86,7 +86,7 @@ void MemoryService::set_universe_heap(CollectedHeap* heap) { CollectedHeap::Name kind = heap->kind(); switch (kind) { - case CollectedHeap::GenCollectedHeap : + case CollectedHeap::SerialHeap : case CollectedHeap::CMSHeap : { add_gen_collected_heap_info(GenCollectedHeap::heap()); break;