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 GenCollectorPolicy;
  34 class GCMemoryManager;
  35 class MemoryPool;
  36 class TenuredGeneration;
  37 
  38 class SerialHeap : public GenCollectedHeap {
  39 private:
  40   MemoryPool* _eden_pool;
  41   MemoryPool* _survivor_pool;
  42   MemoryPool* _old_pool;
  43 
  44   virtual void initialize_serviceability();
  45 
  46 public:
  47   static SerialHeap* heap();
  48 
  49   SerialHeap(GenCollectorPolicy* policy);
  50 
  51   virtual Name kind() const {
  52     return CollectedHeap::Serial;
  53   }
  54 
  55   virtual const char* name() const {
  56     return "Serial";
  57   }
  58 
  59   virtual GrowableArray<GCMemoryManager*> memory_managers();
  60   virtual GrowableArray<MemoryPool*> memory_pools();
  61 
  62   // override
  63   virtual bool is_in_closed_subset(const void* p) const {
  64     return is_in(p);
  65   }
  66 
  67   DefNewGeneration* young_gen() const {
  68     assert(_young_gen->kind() == Generation::DefNew, "Wrong generation type");
  69     return static_cast<DefNewGeneration*>(_young_gen);
  70   }
  71 
  72   TenuredGeneration* old_gen() const {
  73     assert(_old_gen->kind() == Generation::MarkSweepCompact, "Wrong generation type");
  74     return static_cast<TenuredGeneration*>(_old_gen);
  75   }
  76 
  77   // Apply "cur->do_oop" or "older->do_oop" to all the oops in objects
  78   // allocated since the last call to save_marks in the young generation.
  79   // The "cur" closure is applied to references in the younger generation
  80   // at "level", and the "older" closure to older generations.
  81   template <typename OopClosureType1, typename OopClosureType2>
  82   void oop_since_save_marks_iterate(OopClosureType1* cur,
  83                                     OopClosureType2* older);
  84 };
  85 
  86 #endif // SHARE_GC_SERIAL_SERIALHEAP_HPP