1 /*
   2  * Copyright (c) 2017, 2018, 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 #include "precompiled.hpp"
  25 #include "gc/z/zArguments.hpp"
  26 #include "gc/z/zCollectedHeap.hpp"
  27 #include "gc/z/zCollectorPolicy.hpp"
  28 #include "gc/z/zWorkers.hpp"
  29 #include "gc/shared/gcArguments.inline.hpp"
  30 #include "runtime/globals.hpp"
  31 #include "runtime/globals_extension.hpp"
  32 
  33 size_t ZArguments::conservative_max_heap_alignment() {
  34   return 0;
  35 }
  36 
  37 void ZArguments::initialize() {
  38   GCArguments::initialize();
  39 
  40   // Enable NUMA by default
  41   if (FLAG_IS_DEFAULT(UseNUMA)) {
  42     FLAG_SET_DEFAULT(UseNUMA, true);
  43   }
  44 
  45   // Disable biased locking by default
  46   if (FLAG_IS_DEFAULT(UseBiasedLocking)) {
  47     FLAG_SET_DEFAULT(UseBiasedLocking, false);
  48   }
  49 
  50   // Select number of parallel threads
  51   if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
  52     FLAG_SET_DEFAULT(ParallelGCThreads, ZWorkers::calculate_nparallel());
  53   }
  54 
  55   if (ParallelGCThreads == 0) {
  56     vm_exit_during_initialization("The flag -XX:+UseZGC can not be combined with -XX:ParallelGCThreads=0");
  57   }
  58 
  59   // Select number of concurrent threads
  60   if (FLAG_IS_DEFAULT(ConcGCThreads)) {
  61     FLAG_SET_DEFAULT(ConcGCThreads, ZWorkers::calculate_nconcurrent());
  62   }
  63 
  64   if (ConcGCThreads == 0) {
  65     vm_exit_during_initialization("The flag -XX:+UseZGC can not be combined with -XX:ConcGCThreads=0");
  66   }
  67 
  68 #ifdef COMPILER2
  69   // Enable loop strip mining by default
  70   if (FLAG_IS_DEFAULT(UseCountedLoopSafepoints)) {
  71     FLAG_SET_DEFAULT(UseCountedLoopSafepoints, true);
  72     if (FLAG_IS_DEFAULT(LoopStripMiningIter)) {
  73       FLAG_SET_DEFAULT(LoopStripMiningIter, 1000);
  74     }
  75   }
  76 #endif
  77 
  78   // CompressedOops/UseCompressedClassPointers not supported
  79   FLAG_SET_DEFAULT(UseCompressedOops, false);
  80   FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
  81 
  82   // Verification before startup and after exit not (yet) supported
  83   FLAG_SET_DEFAULT(VerifyDuringStartup, false);
  84   FLAG_SET_DEFAULT(VerifyBeforeExit, false);
  85 
  86   // Verification before heap iteration not (yet) supported, for the
  87   // same reason we need fixup_partial_loads
  88   FLAG_SET_DEFAULT(VerifyBeforeIteration, false);
  89 
  90   // Verification of stacks not (yet) supported, for the same reason
  91   // we need fixup_partial_loads
  92   DEBUG_ONLY(FLAG_SET_DEFAULT(VerifyStack, false));
  93 
  94   // Initialize platform specific arguments
  95   initialize_platform();
  96 }
  97 
  98 CollectedHeap* ZArguments::create_heap() {
  99   return create_heap_with_policy<ZCollectedHeap, ZCollectorPolicy>();
 100 }