Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp
38921 views
/*1* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_VMCMSOPERATIONS_HPP25#define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_VMCMSOPERATIONS_HPP2627#include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"28#include "gc_implementation/shared/vmGCOperations.hpp"29#include "gc_interface/gcCause.hpp"30#include "runtime/vm_operations.hpp"3132// The VM_CMS_Operation is slightly different from33// a VM_GC_Operation -- and would not have subclassed easily34// to VM_GC_Operation without several changes to VM_GC_Operation.35// To minimize the changes, we have replicated some of the VM_GC_Operation36// functionality here. We will consolidate that back by doing subclassing37// as appropriate in Dolphin.38//39// VM_Operation40// VM_CMS_Operation41// - implements the common portion of work done in support42// of CMS' stop-world phases (initial mark and remark).43//44// VM_CMS_Initial_Mark45// VM_CMS_Final_Mark46//4748// Forward decl.49class CMSCollector;5051class VM_CMS_Operation: public VM_Operation {52protected:53CMSCollector* _collector; // associated collector54bool _prologue_succeeded; // whether doit_prologue succeeded5556bool lost_race() const;5758// java.lang.ref.Reference support59void acquire_pending_list_lock();60void release_and_notify_pending_list_lock();6162public:63VM_CMS_Operation(CMSCollector* collector):64_collector(collector),65_prologue_succeeded(false) {}66~VM_CMS_Operation() {}6768// The legal collector state for executing this CMS op.69virtual const CMSCollector::CollectorState legal_state() const = 0;7071// Whether the pending list lock needs to be held72virtual const bool needs_pll() const = 0;7374// Execute operations in the context of the caller,75// prior to execution of the vm operation itself.76virtual bool doit_prologue();77// Execute operations in the context of the caller,78// following completion of the vm operation.79virtual void doit_epilogue();8081virtual bool evaluate_at_safepoint() const { return true; }82virtual bool is_cheap_allocated() const { return false; }83virtual bool allow_nested_vm_operations() const { return false; }84bool prologue_succeeded() const { return _prologue_succeeded; }8586void verify_before_gc();87void verify_after_gc();88};899091// VM_CMS_Operation for the initial marking phase of CMS.92class VM_CMS_Initial_Mark: public VM_CMS_Operation {93public:94VM_CMS_Initial_Mark(CMSCollector* _collector) :95VM_CMS_Operation(_collector) {}9697virtual VMOp_Type type() const { return VMOp_CMS_Initial_Mark; }98virtual void doit();99100virtual const CMSCollector::CollectorState legal_state() const {101return CMSCollector::InitialMarking;102}103104virtual const bool needs_pll() const {105return false;106}107};108109// VM_CMS_Operation for the final remark phase of CMS.110class VM_CMS_Final_Remark: public VM_CMS_Operation {111public:112VM_CMS_Final_Remark(CMSCollector* _collector) :113VM_CMS_Operation(_collector) {}114virtual VMOp_Type type() const { return VMOp_CMS_Final_Remark; }115virtual void doit();116117virtual const CMSCollector::CollectorState legal_state() const {118return CMSCollector::FinalMarking;119}120121virtual const bool needs_pll() const {122return true;123}124};125126127// VM operation to invoke a concurrent collection of the heap as a128// GenCollectedHeap heap.129class VM_GenCollectFullConcurrent: public VM_GC_Operation {130bool _disabled_icms;131public:132VM_GenCollectFullConcurrent(uint gc_count_before,133uint full_gc_count_before,134GCCause::Cause gc_cause)135: VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */),136_disabled_icms(false)137{138assert(FullGCCount_lock != NULL, "Error");139assert(UseAsyncConcMarkSweepGC, "Else will hang caller");140}141~VM_GenCollectFullConcurrent() {}142virtual VMOp_Type type() const { return VMOp_GenCollectFullConcurrent; }143virtual void doit();144virtual void doit_epilogue();145virtual bool is_cheap_allocated() const { return false; }146virtual bool evaluate_at_safepoint() const;147};148149#endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_VMCMSOPERATIONS_HPP150151152