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

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,150 @@
     1.4 +/*
     1.5 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_VMCMSOPERATIONS_HPP
    1.29 +#define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_VMCMSOPERATIONS_HPP
    1.30 +
    1.31 +#include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
    1.32 +#include "gc_implementation/shared/vmGCOperations.hpp"
    1.33 +#include "gc_interface/gcCause.hpp"
    1.34 +#include "runtime/vm_operations.hpp"
    1.35 +
    1.36 +// The VM_CMS_Operation is slightly different from
    1.37 +// a VM_GC_Operation -- and would not have subclassed easily
    1.38 +// to VM_GC_Operation without several changes to VM_GC_Operation.
    1.39 +// To minimize the changes, we have replicated some of the VM_GC_Operation
    1.40 +// functionality here. We will consolidate that back by doing subclassing
    1.41 +// as appropriate in Dolphin.
    1.42 +//
    1.43 +//  VM_Operation
    1.44 +//    VM_CMS_Operation
    1.45 +//    - implements the common portion of work done in support
    1.46 +//      of CMS' stop-world phases (initial mark and remark).
    1.47 +//
    1.48 +//      VM_CMS_Initial_Mark
    1.49 +//      VM_CMS_Final_Mark
    1.50 +//
    1.51 +
    1.52 +// Forward decl.
    1.53 +class CMSCollector;
    1.54 +
    1.55 +class VM_CMS_Operation: public VM_Operation {
    1.56 + protected:
    1.57 +  CMSCollector*  _collector;                 // associated collector
    1.58 +  bool           _prologue_succeeded;     // whether doit_prologue succeeded
    1.59 +
    1.60 +  bool lost_race() const;
    1.61 +
    1.62 +  // java.lang.ref.Reference support
    1.63 +  void acquire_pending_list_lock();
    1.64 +  void release_and_notify_pending_list_lock();
    1.65 +
    1.66 + public:
    1.67 +  VM_CMS_Operation(CMSCollector* collector):
    1.68 +    _collector(collector),
    1.69 +    _prologue_succeeded(false) {}
    1.70 +  ~VM_CMS_Operation() {}
    1.71 +
    1.72 +  // The legal collector state for executing this CMS op.
    1.73 +  virtual const CMSCollector::CollectorState legal_state() const = 0;
    1.74 +
    1.75 +  // Whether the pending list lock needs to be held
    1.76 +  virtual const bool needs_pll() const = 0;
    1.77 +
    1.78 +  // Execute operations in the context of the caller,
    1.79 +  // prior to execution of the vm operation itself.
    1.80 +  virtual bool doit_prologue();
    1.81 +  // Execute operations in the context of the caller,
    1.82 +  // following completion of the vm operation.
    1.83 +  virtual void doit_epilogue();
    1.84 +
    1.85 +  virtual bool evaluate_at_safepoint() const { return true; }
    1.86 +  virtual bool is_cheap_allocated() const { return false; }
    1.87 +  virtual bool allow_nested_vm_operations() const  { return false; }
    1.88 +  bool prologue_succeeded() const { return _prologue_succeeded; }
    1.89 +
    1.90 +  void verify_before_gc();
    1.91 +  void verify_after_gc();
    1.92 +};
    1.93 +
    1.94 +
    1.95 +// VM_CMS_Operation for the initial marking phase of CMS.
    1.96 +class VM_CMS_Initial_Mark: public VM_CMS_Operation {
    1.97 + public:
    1.98 +  VM_CMS_Initial_Mark(CMSCollector* _collector) :
    1.99 +    VM_CMS_Operation(_collector) {}
   1.100 +
   1.101 +  virtual VMOp_Type type() const { return VMOp_CMS_Initial_Mark; }
   1.102 +  virtual void doit();
   1.103 +
   1.104 +  virtual const CMSCollector::CollectorState legal_state() const {
   1.105 +    return CMSCollector::InitialMarking;
   1.106 +  }
   1.107 +
   1.108 +  virtual const bool needs_pll() const {
   1.109 +    return false;
   1.110 +  }
   1.111 +};
   1.112 +
   1.113 +// VM_CMS_Operation for the final remark phase of CMS.
   1.114 +class VM_CMS_Final_Remark: public VM_CMS_Operation {
   1.115 + public:
   1.116 +  VM_CMS_Final_Remark(CMSCollector* _collector) :
   1.117 +    VM_CMS_Operation(_collector) {}
   1.118 +  virtual VMOp_Type type() const { return VMOp_CMS_Final_Remark; }
   1.119 +  virtual void doit();
   1.120 +
   1.121 +  virtual const CMSCollector::CollectorState legal_state() const {
   1.122 +    return CMSCollector::FinalMarking;
   1.123 +  }
   1.124 +
   1.125 +  virtual const bool needs_pll() const {
   1.126 +    return true;
   1.127 +  }
   1.128 +};
   1.129 +
   1.130 +
   1.131 +// VM operation to invoke a concurrent collection of the heap as a
   1.132 +// GenCollectedHeap heap.
   1.133 +class VM_GenCollectFullConcurrent: public VM_GC_Operation {
   1.134 +  bool _disabled_icms;
   1.135 + public:
   1.136 +  VM_GenCollectFullConcurrent(unsigned int gc_count_before,
   1.137 +                              unsigned int full_gc_count_before,
   1.138 +                              GCCause::Cause gc_cause)
   1.139 +    : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */),
   1.140 +      _disabled_icms(false)
   1.141 +  {
   1.142 +    assert(FullGCCount_lock != NULL, "Error");
   1.143 +    assert(UseAsyncConcMarkSweepGC, "Else will hang caller");
   1.144 +  }
   1.145 +  ~VM_GenCollectFullConcurrent() {}
   1.146 +  virtual VMOp_Type type() const { return VMOp_GenCollectFullConcurrent; }
   1.147 +  virtual void doit();
   1.148 +  virtual void doit_epilogue();
   1.149 +  virtual bool is_cheap_allocated() const { return false; }
   1.150 +  virtual bool evaluate_at_safepoint() const;
   1.151 +};
   1.152 +
   1.153 +#endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_VMCMSOPERATIONS_HPP

mercurial