src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp

changeset 435
a61af66fc99e
child 1875
bb843ebc7c55
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,139 @@
     1.4 +/*
     1.5 + * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// The VM_CMS_Operation is slightly different from
    1.29 +// a VM_GC_Operation -- and would not have subclassed easily
    1.30 +// to VM_GC_Operation without several changes to VM_GC_Operation.
    1.31 +// To minimize the changes, we have replicated some of the VM_GC_Operation
    1.32 +// functionality here. We will consolidate that back by doing subclassing
    1.33 +// as appropriate in Dolphin.
    1.34 +//
    1.35 +//  VM_Operation
    1.36 +//    VM_CMS_Operation
    1.37 +//    - implements the common portion of work done in support
    1.38 +//      of CMS' stop-world phases (initial mark and remark).
    1.39 +//
    1.40 +//      VM_CMS_Initial_Mark
    1.41 +//      VM_CMS_Final_Mark
    1.42 +//
    1.43 +
    1.44 +// Forward decl.
    1.45 +class CMSCollector;
    1.46 +
    1.47 +class VM_CMS_Operation: public VM_Operation {
    1.48 + protected:
    1.49 +  CMSCollector*  _collector;                 // associated collector
    1.50 +  bool           _prologue_succeeded;     // whether doit_prologue succeeded
    1.51 +
    1.52 +  bool lost_race() const;
    1.53 +
    1.54 +  // java.lang.ref.Reference support
    1.55 +  void acquire_pending_list_lock();
    1.56 +  void release_and_notify_pending_list_lock();
    1.57 +
    1.58 + public:
    1.59 +  VM_CMS_Operation(CMSCollector* collector):
    1.60 +    _collector(collector),
    1.61 +    _prologue_succeeded(false) {}
    1.62 +  ~VM_CMS_Operation() {}
    1.63 +
    1.64 +  // The legal collector state for executing this CMS op.
    1.65 +  virtual const CMSCollector::CollectorState legal_state() const = 0;
    1.66 +
    1.67 +  // Whether the pending list lock needs to be held
    1.68 +  virtual const bool needs_pll() const = 0;
    1.69 +
    1.70 +  // Execute operations in the context of the caller,
    1.71 +  // prior to execution of the vm operation itself.
    1.72 +  virtual bool doit_prologue();
    1.73 +  // Execute operations in the context of the caller,
    1.74 +  // following completion of the vm operation.
    1.75 +  virtual void doit_epilogue();
    1.76 +
    1.77 +  virtual bool evaluate_at_safepoint() const { return true; }
    1.78 +  virtual bool is_cheap_allocated() const { return false; }
    1.79 +  virtual bool allow_nested_vm_operations() const  { return false; }
    1.80 +  bool prologue_succeeded() const { return _prologue_succeeded; }
    1.81 +
    1.82 +  void verify_before_gc();
    1.83 +  void verify_after_gc();
    1.84 +};
    1.85 +
    1.86 +
    1.87 +// VM_CMS_Operation for the initial marking phase of CMS.
    1.88 +class VM_CMS_Initial_Mark: public VM_CMS_Operation {
    1.89 + public:
    1.90 +  VM_CMS_Initial_Mark(CMSCollector* _collector) :
    1.91 +    VM_CMS_Operation(_collector) {}
    1.92 +
    1.93 +  virtual VMOp_Type type() const { return VMOp_CMS_Initial_Mark; }
    1.94 +  virtual void doit();
    1.95 +
    1.96 +  virtual const CMSCollector::CollectorState legal_state() const {
    1.97 +    return CMSCollector::InitialMarking;
    1.98 +  }
    1.99 +
   1.100 +  virtual const bool needs_pll() const {
   1.101 +    return false;
   1.102 +  }
   1.103 +};
   1.104 +
   1.105 +// VM_CMS_Operation for the final remark phase of CMS.
   1.106 +class VM_CMS_Final_Remark: public VM_CMS_Operation {
   1.107 + public:
   1.108 +  VM_CMS_Final_Remark(CMSCollector* _collector) :
   1.109 +    VM_CMS_Operation(_collector) {}
   1.110 +  virtual VMOp_Type type() const { return VMOp_CMS_Final_Remark; }
   1.111 +  virtual void doit();
   1.112 +
   1.113 +  virtual const CMSCollector::CollectorState legal_state() const {
   1.114 +    return CMSCollector::FinalMarking;
   1.115 +  }
   1.116 +
   1.117 +  virtual const bool needs_pll() const {
   1.118 +    return true;
   1.119 +  }
   1.120 +};
   1.121 +
   1.122 +
   1.123 +// VM operation to invoke a concurrent collection of the heap as a
   1.124 +// GenCollectedHeap heap.
   1.125 +class VM_GenCollectFullConcurrent: public VM_GC_Operation {
   1.126 + public:
   1.127 +  VM_GenCollectFullConcurrent(unsigned int gc_count_before,
   1.128 +                              unsigned int full_gc_count_before,
   1.129 +                              GCCause::Cause gc_cause)
   1.130 +    : VM_GC_Operation(gc_count_before, full_gc_count_before, true /* full */) {
   1.131 +    _gc_cause = gc_cause;
   1.132 +    assert(FullGCCount_lock != NULL && UseConcMarkSweepGC &&
   1.133 +           ExplicitGCInvokesConcurrent, "Otherwise shouldn't be here");
   1.134 +    assert(UseAsyncConcMarkSweepGC, "Else will hang caller");
   1.135 +  }
   1.136 +  ~VM_GenCollectFullConcurrent() {}
   1.137 +  virtual VMOp_Type type() const { return VMOp_GenCollectFullConcurrent; }
   1.138 +  virtual void doit();
   1.139 +  virtual void doit_epilogue();
   1.140 +  virtual bool is_cheap_allocated() const { return false; }
   1.141 +  virtual bool evaluate_at_safepoint() const;
   1.142 +};

mercurial