1 /*
   2  * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_G1_G1VMOPERATIONS_HPP
  26 #define SHARE_GC_G1_G1VMOPERATIONS_HPP
  27 
  28 #include "gc/shared/gcId.hpp"
  29 #include "gc/shared/gcVMOperations.hpp"
  30 
  31 // VM_operations for the G1 collector.
  32 // VM_GC_Operation:
  33 //   - VM_G1Concurrent
  34 //   - VM_G1CollectForAllocation
  35 //   - VM_G1CollectFull
  36 
  37 class VM_G1CollectFull : public VM_GC_Operation {
  38   bool _gc_succeeded;
  39 
  40 public:
  41   VM_G1CollectFull(uint gc_count_before,
  42                    uint full_gc_count_before,
  43                    GCCause::Cause cause) :
  44     VM_GC_Operation(gc_count_before, cause, full_gc_count_before, true),
  45     _gc_succeeded(false) { }
  46   virtual VMOp_Type type() const { return VMOp_G1CollectFull; }
  47   virtual void doit();
  48   bool gc_succeeded() { return _gc_succeeded; }
  49 };
  50 
  51 class VM_G1CollectForAllocation : public VM_CollectForAllocation {
  52   bool _gc_succeeded;
  53 
  54   bool _should_initiate_conc_mark;
  55   bool _should_retry_gc;
  56   double _target_pause_time_ms;
  57   uint  _old_marking_cycles_completed_before;
  58 
  59 public:
  60   VM_G1CollectForAllocation(size_t         word_size,
  61                             uint           gc_count_before,
  62                             GCCause::Cause gc_cause,
  63                             bool           should_initiate_conc_mark,
  64                             double         target_pause_time_ms);
  65   virtual VMOp_Type type() const { return VMOp_G1CollectForAllocation; }
  66   virtual bool doit_prologue();
  67   virtual void doit();
  68   virtual void doit_epilogue();
  69   bool should_retry_gc() const { return _should_retry_gc; }
  70   bool gc_succeeded() { return _gc_succeeded; }
  71 };
  72 
  73 // Concurrent G1 stop-the-world operations such as remark and cleanup.
  74 class VM_G1Concurrent : public VM_Operation {
  75   VoidClosure* _cl;
  76   const char*  _message;
  77   uint         _gc_id;
  78 
  79 public:
  80   VM_G1Concurrent(VoidClosure* cl, const char* message) :
  81     _cl(cl), _message(message), _gc_id(GCId::current()) { }
  82   virtual VMOp_Type type() const { return VMOp_G1Concurrent; }
  83   virtual void doit();
  84   virtual bool doit_prologue();
  85   virtual void doit_epilogue();
  86 };
  87 
  88 #endif // SHARE_GC_G1_G1VMOPERATIONS_HPP