1 /*
   2  * Copyright (c) 2016, 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 #include "precompiled.hpp"
  26 #include "runtime/globals.hpp"
  27 #include "runtime/globals_extension.hpp"
  28 #include "compiler/compilerDefinitions.hpp"
  29 
  30 const char* compilertype2name_tab[compiler_number_of_types] = {
  31   "",
  32   "c1",
  33   "c2",
  34   "jvmci"
  35 };
  36 
  37 #if defined(COMPILER2)
  38 CompLevel  CompLevel_highest_tier      = CompLevel_full_optimization;  // pure C2 and tiered or JVMCI and tiered
  39 #elif defined(COMPILER1)
  40 CompLevel  CompLevel_highest_tier      = CompLevel_simple;             // pure C1 or JVMCI
  41 #else
  42 CompLevel  CompLevel_highest_tier      = CompLevel_none;
  43 #endif
  44 
  45 #if defined(TIERED)
  46 CompLevel  CompLevel_initial_compile   = CompLevel_full_profile;        // tiered
  47 #elif defined(COMPILER1) || INCLUDE_JVMCI
  48 CompLevel  CompLevel_initial_compile   = CompLevel_simple;              // pure C1 or JVMCI
  49 #elif defined(COMPILER2)
  50 CompLevel  CompLevel_initial_compile   = CompLevel_full_optimization;   // pure C2
  51 #else
  52 CompLevel  CompLevel_initial_compile   = CompLevel_none;
  53 #endif
  54 
  55 #if defined(COMPILER2)
  56 CompMode  Compilation_mode             = CompMode_server;
  57 #elif defined(COMPILER1)
  58 CompMode  Compilation_mode             = CompMode_client;
  59 #else
  60 CompMode  Compilation_mode             = CompMode_none;
  61 #endif
  62 
  63 #ifdef TIERED
  64 void set_client_compilation_mode() {
  65   Compilation_mode = CompMode_client;
  66   CompLevel_highest_tier = CompLevel_simple;
  67   CompLevel_initial_compile = CompLevel_simple;
  68   FLAG_SET_ERGO(bool, TieredCompilation, false);
  69   FLAG_SET_ERGO(bool, ProfileInterpreter, false);
  70 #if INCLUDE_JVMCI
  71   FLAG_SET_ERGO(bool, EnableJVMCI, false);
  72   FLAG_SET_ERGO(bool, UseJVMCICompiler, false);
  73 #endif
  74 #if INCLUDE_AOT
  75   FLAG_SET_ERGO(bool, UseAOT, false);
  76 #endif
  77   if (FLAG_IS_DEFAULT(NeverActAsServerClassMachine)) {
  78     FLAG_SET_ERGO(bool, NeverActAsServerClassMachine, true);
  79   }
  80   if (FLAG_IS_DEFAULT(InitialCodeCacheSize)) {
  81     FLAG_SET_ERGO(uintx, InitialCodeCacheSize, 160*K);
  82   }
  83   if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
  84     FLAG_SET_ERGO(uintx, ReservedCodeCacheSize, 32*M);
  85   }
  86   if (FLAG_IS_DEFAULT(NonProfiledCodeHeapSize)) {
  87     FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, 27*M);
  88   }
  89   if (FLAG_IS_DEFAULT(ProfiledCodeHeapSize)) {
  90     FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, 0);
  91   }
  92   if (FLAG_IS_DEFAULT(NonNMethodCodeHeapSize)) {
  93     FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, 5*M);
  94   }
  95   if (FLAG_IS_DEFAULT(CodeCacheExpansionSize)) {
  96     FLAG_SET_ERGO(uintx, CodeCacheExpansionSize, 32*K);
  97   }
  98   if (FLAG_IS_DEFAULT(MetaspaceSize)) {
  99     FLAG_SET_ERGO(size_t, MetaspaceSize, 12*M);
 100   }
 101   if (FLAG_IS_DEFAULT(MaxRAM)) {
 102     // Do not use FLAG_SET_ERGO to update MaxRAM, as this will impact
 103     // heap setting done based on available phys_mem (see Arguments::set_heap_size).
 104     FLAG_SET_DEFAULT(MaxRAM, 1ULL*G);
 105   }
 106   if (FLAG_IS_DEFAULT(CompileThreshold)) {
 107     FLAG_SET_ERGO(intx, CompileThreshold, 1500);
 108   }
 109   if (FLAG_IS_DEFAULT(OnStackReplacePercentage)) {
 110     FLAG_SET_ERGO(intx, OnStackReplacePercentage, 933);
 111   }
 112   if (FLAG_IS_DEFAULT(CICompilerCount)) {
 113     FLAG_SET_ERGO(intx, CICompilerCount, 1);
 114   }
 115 }
 116 #endif // TIERED