< prev index next >

src/hotspot/share/gc/z/zHeap.cpp

Print this page




   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 #include "precompiled.hpp"

  25 #include "gc/shared/oopStorage.hpp"
  26 #include "gc/z/zAddress.hpp"
  27 #include "gc/z/zGlobals.hpp"
  28 #include "gc/z/zHeap.inline.hpp"
  29 #include "gc/z/zHeapIterator.hpp"
  30 #include "gc/z/zList.inline.hpp"
  31 #include "gc/z/zLock.inline.hpp"
  32 #include "gc/z/zMark.inline.hpp"
  33 #include "gc/z/zOopClosures.inline.hpp"
  34 #include "gc/z/zPage.inline.hpp"
  35 #include "gc/z/zPageTable.inline.hpp"
  36 #include "gc/z/zRelocationSet.inline.hpp"
  37 #include "gc/z/zResurrection.hpp"
  38 #include "gc/z/zRootsIterator.hpp"
  39 #include "gc/z/zStat.hpp"
  40 #include "gc/z/zTask.hpp"
  41 #include "gc/z/zThread.hpp"
  42 #include "gc/z/zTracer.inline.hpp"
  43 #include "gc/z/zVirtualMemory.inline.hpp"
  44 #include "gc/z/zWorkers.inline.hpp"


  56 static const ZStatSampler ZSamplerHeapUsedAfterRelocation("Memory", "Heap Used After Relocation", ZStatUnitBytes);
  57 static const ZStatCounter ZCounterUndoPageAllocation("Memory", "Undo Page Allocation", ZStatUnitOpsPerSecond);
  58 static const ZStatCounter ZCounterOutOfMemory("Memory", "Out Of Memory", ZStatUnitOpsPerSecond);
  59 
  60 ZHeap* ZHeap::_heap = NULL;
  61 
  62 ZHeap::ZHeap() :
  63     _workers(),
  64     _object_allocator(_workers.nworkers()),
  65     _page_allocator(heap_min_size(), heap_max_size(), heap_max_reserve_size()),
  66     _pagetable(),
  67     _mark(&_workers, &_pagetable),
  68     _reference_processor(&_workers),
  69     _weak_roots_processor(&_workers),
  70     _relocate(&_workers),
  71     _relocation_set(),
  72     _serviceability(heap_min_size(), heap_max_size()) {
  73   // Install global heap instance
  74   assert(_heap == NULL, "Already initialized");
  75   _heap = this;



  76 
  77   // Update statistics
  78   ZStatHeap::set_at_initialize(heap_max_size(), heap_max_reserve_size());
  79 }
  80 
  81 size_t ZHeap::heap_min_size() const {
  82   const size_t aligned_min_size = align_up(InitialHeapSize, ZPageSizeMin);
  83   return MIN2(aligned_min_size, heap_max_size());
  84 }
  85 
  86 size_t ZHeap::heap_max_size() const {
  87   const size_t aligned_max_size = align_up(MaxHeapSize, ZPageSizeMin);
  88   return MIN2(aligned_max_size, ZAddressOffsetMax);
  89 }
  90 
  91 size_t ZHeap::heap_max_reserve_size() const {
  92   // Reserve one small page per worker plus one shared medium page. This is still just
  93   // an estimate and doesn't guarantee that we can't run out of memory during relocation.
  94   const size_t max_reserve_size = (_workers.nworkers() * ZPageSizeSmall) + ZPageSizeMedium;
  95   return MIN2(max_reserve_size, heap_max_size());




   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 #include "precompiled.hpp"
  25 #include "gc/shared/fill.hpp"
  26 #include "gc/shared/oopStorage.hpp"
  27 #include "gc/z/zAddress.hpp"
  28 #include "gc/z/zGlobals.hpp"
  29 #include "gc/z/zHeap.inline.hpp"
  30 #include "gc/z/zHeapIterator.hpp"
  31 #include "gc/z/zList.inline.hpp"
  32 #include "gc/z/zLock.inline.hpp"
  33 #include "gc/z/zMark.inline.hpp"
  34 #include "gc/z/zOopClosures.inline.hpp"
  35 #include "gc/z/zPage.inline.hpp"
  36 #include "gc/z/zPageTable.inline.hpp"
  37 #include "gc/z/zRelocationSet.inline.hpp"
  38 #include "gc/z/zResurrection.hpp"
  39 #include "gc/z/zRootsIterator.hpp"
  40 #include "gc/z/zStat.hpp"
  41 #include "gc/z/zTask.hpp"
  42 #include "gc/z/zThread.hpp"
  43 #include "gc/z/zTracer.inline.hpp"
  44 #include "gc/z/zVirtualMemory.inline.hpp"
  45 #include "gc/z/zWorkers.inline.hpp"


  57 static const ZStatSampler ZSamplerHeapUsedAfterRelocation("Memory", "Heap Used After Relocation", ZStatUnitBytes);
  58 static const ZStatCounter ZCounterUndoPageAllocation("Memory", "Undo Page Allocation", ZStatUnitOpsPerSecond);
  59 static const ZStatCounter ZCounterOutOfMemory("Memory", "Out Of Memory", ZStatUnitOpsPerSecond);
  60 
  61 ZHeap* ZHeap::_heap = NULL;
  62 
  63 ZHeap::ZHeap() :
  64     _workers(),
  65     _object_allocator(_workers.nworkers()),
  66     _page_allocator(heap_min_size(), heap_max_size(), heap_max_reserve_size()),
  67     _pagetable(),
  68     _mark(&_workers, &_pagetable),
  69     _reference_processor(&_workers),
  70     _weak_roots_processor(&_workers),
  71     _relocate(&_workers),
  72     _relocation_set(),
  73     _serviceability(heap_min_size(), heap_max_size()) {
  74   // Install global heap instance
  75   assert(_heap == NULL, "Already initialized");
  76   _heap = this;
  77 
  78   // Heap not parsable
  79   Fill::set_disabled();
  80 
  81   // Update statistics
  82   ZStatHeap::set_at_initialize(heap_max_size(), heap_max_reserve_size());
  83 }
  84 
  85 size_t ZHeap::heap_min_size() const {
  86   const size_t aligned_min_size = align_up(InitialHeapSize, ZPageSizeMin);
  87   return MIN2(aligned_min_size, heap_max_size());
  88 }
  89 
  90 size_t ZHeap::heap_max_size() const {
  91   const size_t aligned_max_size = align_up(MaxHeapSize, ZPageSizeMin);
  92   return MIN2(aligned_max_size, ZAddressOffsetMax);
  93 }
  94 
  95 size_t ZHeap::heap_max_reserve_size() const {
  96   // Reserve one small page per worker plus one shared medium page. This is still just
  97   // an estimate and doesn't guarantee that we can't run out of memory during relocation.
  98   const size_t max_reserve_size = (_workers.nworkers() * ZPageSizeSmall) + ZPageSizeMedium;
  99   return MIN2(max_reserve_size, heap_max_size());


< prev index next >