duke@435: /* brutisso@2532: * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_VMCMSOPERATIONS_HPP stefank@2314: #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_VMCMSOPERATIONS_HPP stefank@2314: stefank@2314: #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp" stefank@2314: #include "gc_implementation/shared/vmGCOperations.hpp" stefank@2314: #include "gc_interface/gcCause.hpp" stefank@2314: #include "runtime/vm_operations.hpp" stefank@2314: duke@435: // The VM_CMS_Operation is slightly different from duke@435: // a VM_GC_Operation -- and would not have subclassed easily duke@435: // to VM_GC_Operation without several changes to VM_GC_Operation. duke@435: // To minimize the changes, we have replicated some of the VM_GC_Operation duke@435: // functionality here. We will consolidate that back by doing subclassing duke@435: // as appropriate in Dolphin. duke@435: // duke@435: // VM_Operation duke@435: // VM_CMS_Operation duke@435: // - implements the common portion of work done in support duke@435: // of CMS' stop-world phases (initial mark and remark). duke@435: // duke@435: // VM_CMS_Initial_Mark duke@435: // VM_CMS_Final_Mark duke@435: // duke@435: duke@435: // Forward decl. duke@435: class CMSCollector; duke@435: duke@435: class VM_CMS_Operation: public VM_Operation { duke@435: protected: duke@435: CMSCollector* _collector; // associated collector duke@435: bool _prologue_succeeded; // whether doit_prologue succeeded duke@435: duke@435: bool lost_race() const; duke@435: duke@435: // java.lang.ref.Reference support duke@435: void acquire_pending_list_lock(); duke@435: void release_and_notify_pending_list_lock(); duke@435: duke@435: public: duke@435: VM_CMS_Operation(CMSCollector* collector): duke@435: _collector(collector), duke@435: _prologue_succeeded(false) {} duke@435: ~VM_CMS_Operation() {} duke@435: duke@435: // The legal collector state for executing this CMS op. duke@435: virtual const CMSCollector::CollectorState legal_state() const = 0; duke@435: duke@435: // Whether the pending list lock needs to be held duke@435: virtual const bool needs_pll() const = 0; duke@435: duke@435: // Execute operations in the context of the caller, duke@435: // prior to execution of the vm operation itself. duke@435: virtual bool doit_prologue(); duke@435: // Execute operations in the context of the caller, duke@435: // following completion of the vm operation. duke@435: virtual void doit_epilogue(); duke@435: duke@435: virtual bool evaluate_at_safepoint() const { return true; } duke@435: virtual bool is_cheap_allocated() const { return false; } duke@435: virtual bool allow_nested_vm_operations() const { return false; } duke@435: bool prologue_succeeded() const { return _prologue_succeeded; } duke@435: duke@435: void verify_before_gc(); duke@435: void verify_after_gc(); duke@435: }; duke@435: duke@435: duke@435: // VM_CMS_Operation for the initial marking phase of CMS. duke@435: class VM_CMS_Initial_Mark: public VM_CMS_Operation { duke@435: public: duke@435: VM_CMS_Initial_Mark(CMSCollector* _collector) : duke@435: VM_CMS_Operation(_collector) {} duke@435: duke@435: virtual VMOp_Type type() const { return VMOp_CMS_Initial_Mark; } duke@435: virtual void doit(); duke@435: duke@435: virtual const CMSCollector::CollectorState legal_state() const { duke@435: return CMSCollector::InitialMarking; duke@435: } duke@435: duke@435: virtual const bool needs_pll() const { duke@435: return false; duke@435: } duke@435: }; duke@435: duke@435: // VM_CMS_Operation for the final remark phase of CMS. duke@435: class VM_CMS_Final_Remark: public VM_CMS_Operation { duke@435: public: duke@435: VM_CMS_Final_Remark(CMSCollector* _collector) : duke@435: VM_CMS_Operation(_collector) {} duke@435: virtual VMOp_Type type() const { return VMOp_CMS_Final_Remark; } duke@435: virtual void doit(); duke@435: duke@435: virtual const CMSCollector::CollectorState legal_state() const { duke@435: return CMSCollector::FinalMarking; duke@435: } duke@435: duke@435: virtual const bool needs_pll() const { duke@435: return true; duke@435: } duke@435: }; duke@435: duke@435: duke@435: // VM operation to invoke a concurrent collection of the heap as a duke@435: // GenCollectedHeap heap. duke@435: class VM_GenCollectFullConcurrent: public VM_GC_Operation { ysr@2647: bool _disabled_icms; duke@435: public: duke@435: VM_GenCollectFullConcurrent(unsigned int gc_count_before, duke@435: unsigned int full_gc_count_before, duke@435: GCCause::Cause gc_cause) ysr@2647: : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */), ysr@2647: _disabled_icms(false) ysr@2647: { ysr@1875: assert(FullGCCount_lock != NULL, "Error"); duke@435: assert(UseAsyncConcMarkSweepGC, "Else will hang caller"); duke@435: } duke@435: ~VM_GenCollectFullConcurrent() {} duke@435: virtual VMOp_Type type() const { return VMOp_GenCollectFullConcurrent; } duke@435: virtual void doit(); duke@435: virtual void doit_epilogue(); duke@435: virtual bool is_cheap_allocated() const { return false; } duke@435: virtual bool evaluate_at_safepoint() const; duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_VMCMSOPERATIONS_HPP