1 /*
   2  * Copyright (c) 2017, 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_SERIAL_SERIALHEAP_HPP
  26 #define SHARE_GC_SERIAL_SERIALHEAP_HPP
  27 
  28 #include "gc/serial/defNewGeneration.hpp"
  29 #include "gc/serial/tenuredGeneration.hpp"
  30 #include "gc/shared/genCollectedHeap.hpp"
  31 #include "utilities/growableArray.hpp"
  32 
  33 class GCMemoryManager;
  34 class MemoryPool;
  35 class TenuredGeneration;
  36 
  37 class SerialHeap : public GenCollectedHeap {
  38 private:
  39   MemoryPool* _eden_pool;
  40   MemoryPool* _survivor_pool;
  41   MemoryPool* _old_pool;
  42 
  43   virtual void initialize_serviceability();
  44 
  45 public:
  46   static SerialHeap* heap();
  47 
  48   SerialHeap();
  49 
  50   virtual Name kind() const {
  51     return CollectedHeap::Serial;
  52   }
  53 
  54   virtual const char* name() const {
  55     return "Serial";
  56   }
  57 
  58   virtual GrowableArray<GCMemoryManager*> memory_managers();
  59   virtual GrowableArray<MemoryPool*> memory_pools();
  60 
  61   DefNewGeneration* young_gen() const {
  62     assert(_young_gen->kind() == Generation::DefNew, "Wrong generation type");
  63     return static_cast<DefNewGeneration*>(_young_gen);
  64   }
  65 
  66   TenuredGeneration* old_gen() const {
  67     assert(_old_gen->kind() == Generation::MarkSweepCompact, "Wrong generation type");
  68     return static_cast<TenuredGeneration*>(_old_gen);
  69   }
  70 
  71   // Apply "cur->do_oop" or "older->do_oop" to all the oops in objects
  72   // allocated since the last call to save_marks in the young generation.
  73   // The "cur" closure is applied to references in the younger generation
  74   // at "level", and the "older" closure to older generations.
  75   template <typename OopClosureType1, typename OopClosureType2>
  76   void oop_since_save_marks_iterate(OopClosureType1* cur,
  77                                     OopClosureType2* older);
  78 
  79   // Runs the given AbstractGangTask with the current active workers.
  80   virtual void run_task(AbstractGangTask* task);
  81 };
  82 
  83 #endif // SHARE_GC_SERIAL_SERIALHEAP_HPP