/* * 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/cms/cmsBarrierSet.hpp" #include "gc/cms/cmsHeap.hpp" #include "gc/cms/concurrentMarkSweepGeneration.hpp" #include "utilities/stack.inline.hpp" CMSHeap::CMSHeap(GenCollectorPolicy *policy) : GenCollectedHeap(policy) { _workers = new WorkGang("GC Thread", ParallelGCThreads, /* are_GC_task_threads */true, /* are_ConcurrentGC_threads */false); _workers->initialize_workers(); } jint CMSHeap::initialize() { jint status = GenCollectedHeap::initialize(); if (status != JNI_OK) { return status; } // If we are running CMS, create the collector responsible // for collecting the CMS generations. if (collector_policy()->is_concurrent_mark_sweep_policy()) { bool success = create_cms_collector(); if (!success) return JNI_ENOMEM; } return JNI_OK; } bool CMSHeap::create_cms_collector() { assert(old_gen()->kind() == Generation::ConcurrentMarkSweep, "Unexpected generation kinds"); // Skip two header words in the block content verification NOT_PRODUCT(_skip_header_HeapWords = CMSCollector::skip_header_HeapWords();) assert(gen_policy()->is_concurrent_mark_sweep_policy(), "Unexpected policy type"); CMSCollector* collector = new CMSCollector((ConcurrentMarkSweepGeneration*) old_gen(), rem_set(), gen_policy()->as_concurrent_mark_sweep_policy()); if (collector == NULL || !collector->completed_initialization()) { if (collector) { delete collector; // Be nice in embedded situation } vm_shutdown_during_initialization("Could not create CMS collector"); return false; } return true; // success } CardTableModRefBSForCTRS* CMSHeap::create_barrier_set(MemRegion whole_heap) { return new CMSBarrierSet(whole_heap); }