1 /*
   2  * Copyright (c) 2017, 2018, Red Hat, Inc. 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 #include "precompiled.hpp"
  26 #include "gc/epsilon/epsilonArguments.hpp"
  27 #include "gc/epsilon/epsilonHeap.hpp"
  28 #include "gc/shared/gcArguments.hpp"
  29 #include "runtime/globals.hpp"
  30 #include "runtime/vm_version.hpp"
  31 #include "utilities/macros.hpp"
  32 
  33 size_t EpsilonArguments::conservative_max_heap_alignment() {
  34   return UseLargePages ? os::large_page_size() : os::vm_page_size();
  35 }
  36 
  37 void EpsilonArguments::initialize() {
  38   GCArguments::initialize();
  39 
  40   assert(UseEpsilonGC, "Sanity");
  41 
  42   // Forcefully exit when OOME is detected. Nothing we can do at that point.
  43   if (FLAG_IS_DEFAULT(ExitOnOutOfMemoryError)) {
  44     FLAG_SET_DEFAULT(ExitOnOutOfMemoryError, true);
  45   }
  46 
  47   // Warn users that non-resizable heap might be better for some configurations.
  48   // We are not adjusting the heap size by ourselves, because it affects startup time.
  49   if (InitialHeapSize != MaxHeapSize) {
  50     log_warning(gc)("Consider setting -Xms equal to -Xmx to avoid resizing hiccups");
  51   }
  52 
  53   // Warn users that AlwaysPreTouch might be better for some configurations.
  54   // We are not turning this on by ourselves, because it affects startup time.
  55   if (FLAG_IS_DEFAULT(AlwaysPreTouch) && !AlwaysPreTouch) {
  56     log_warning(gc)("Consider enabling -XX:+AlwaysPreTouch to avoid memory commit hiccups");
  57   }
  58 
  59   if (EpsilonMaxTLABSize < MinTLABSize) {
  60     log_warning(gc)("EpsilonMaxTLABSize < MinTLABSize, adjusting it to " SIZE_FORMAT, MinTLABSize);
  61     EpsilonMaxTLABSize = MinTLABSize;
  62   }
  63 
  64   if (!EpsilonElasticTLAB && EpsilonElasticTLABDecay) {
  65     log_warning(gc)("Disabling EpsilonElasticTLABDecay because EpsilonElasticTLAB is disabled");
  66     FLAG_SET_DEFAULT(EpsilonElasticTLABDecay, false);
  67   }
  68 
  69 #ifdef COMPILER2
  70   // Enable loop strip mining: there are still non-GC safepoints, no need to make it worse
  71   if (FLAG_IS_DEFAULT(UseCountedLoopSafepoints)) {
  72     FLAG_SET_DEFAULT(UseCountedLoopSafepoints, true);
  73     if (FLAG_IS_DEFAULT(LoopStripMiningIter)) {
  74       FLAG_SET_DEFAULT(LoopStripMiningIter, 1000);
  75     }
  76   }
  77 #endif
  78 }
  79 
  80 void EpsilonArguments::initialize_alignments() {
  81   size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size();
  82   size_t align = MAX2((size_t)os::vm_allocation_granularity(), page_size);
  83   SpaceAlignment = align;
  84   HeapAlignment  = align;
  85 }
  86 
  87 CollectedHeap* EpsilonArguments::create_heap() {
  88   return new EpsilonHeap();
  89 }