1 /*
   2  * Copyright (c) 2017, 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_G1FULLCOLLECTOR_HPP
  26 #define SHARE_GC_G1_G1FULLCOLLECTOR_HPP
  27 
  28 #include "gc/g1/g1FullGCCompactionPoint.hpp"
  29 #include "gc/g1/g1FullGCMarker.hpp"
  30 #include "gc/g1/g1FullGCOopClosures.hpp"
  31 #include "gc/g1/g1FullGCScope.hpp"
  32 #include "gc/shared/preservedMarks.hpp"
  33 #include "gc/shared/referenceProcessor.hpp"
  34 #include "gc/shared/taskqueue.hpp"
  35 #include "memory/allocation.hpp"
  36 
  37 class AbstractGangTask;
  38 class G1CMBitMap;
  39 class G1FullGCMarker;
  40 class G1FullGCScope;
  41 class G1FullGCCompactionPoint;
  42 class ReferenceProcessor;
  43 
  44 // The G1FullCollector holds data associated with the current Full GC.
  45 class G1FullCollector : StackObj {
  46   G1CollectedHeap*          _heap;
  47   G1FullGCScope             _scope;
  48   uint                      _num_workers;
  49   G1FullGCMarker**          _markers;
  50   G1FullGCCompactionPoint** _compaction_points;
  51   OopQueueSet               _oop_queue_set;
  52   ObjArrayTaskQueueSet      _array_queue_set;
  53   PreservedMarksSet         _preserved_marks_set;
  54   G1FullGCCompactionPoint   _serial_compaction_point;
  55   G1IsAliveClosure          _is_alive;
  56   ReferenceProcessorIsAliveMutator _is_alive_mutator;
  57 
  58 public:
  59   G1FullCollector(G1CollectedHeap* heap, bool explicit_gc, bool clear_soft_refs);
  60   ~G1FullCollector();
  61 
  62   void prepare_collection();
  63   void collect();
  64   void complete_collection();
  65 
  66   G1FullGCScope*           scope() { return &_scope; }
  67   uint                     workers() { return _num_workers; }
  68   G1FullGCMarker*          marker(uint id) { return _markers[id]; }
  69   G1FullGCCompactionPoint* compaction_point(uint id) { return _compaction_points[id]; }
  70   OopQueueSet*             oop_queue_set() { return &_oop_queue_set; }
  71   ObjArrayTaskQueueSet*    array_queue_set() { return &_array_queue_set; }
  72   PreservedMarksSet*       preserved_mark_set() { return &_preserved_marks_set; }
  73   G1FullGCCompactionPoint* serial_compaction_point() { return &_serial_compaction_point; }
  74   G1CMBitMap*              mark_bitmap();
  75   ReferenceProcessor*      reference_processor();
  76 
  77 private:
  78   void phase1_mark_live_objects();
  79   void phase2_prepare_compaction();
  80   void phase3_adjust_pointers();
  81   void phase4_do_compaction();
  82 
  83   void restore_marks();
  84   void verify_after_marking();
  85 
  86   void run_task(AbstractGangTask* task);
  87 
  88   // Prepare compaction extension support.
  89   void prepare_compaction_ext();
  90   void prepare_compaction_common();
  91 };
  92 
  93 
  94 #endif // SHARE_GC_G1_G1FULLCOLLECTOR_HPP