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 #ifndef SHARE_VM_COMPILER_COMPILERDEFINITIONS_HPP
  26 #define SHARE_VM_COMPILER_COMPILERDEFINITIONS_HPP
  27 
  28 #include "utilities/globalDefinitions.hpp"
  29 
  30 // The (closed set) of concrete compiler classes.
  31 enum CompilerType {
  32   compiler_none,
  33   compiler_c1,
  34   compiler_c2,
  35   compiler_jvmci,
  36   compiler_shark,
  37   compiler_number_of_types
  38 };
  39 
  40 extern const char* compilertype2name_tab[compiler_number_of_types];     // Map CompilerType to its name
  41 inline const char* compilertype2name(CompilerType t) { return (uint)t < compiler_number_of_types ? compilertype2name_tab[t] : NULL; }
  42 
  43 // Handy constants for deciding which compiler mode to use.
  44 enum MethodCompilation {
  45   InvocationEntryBci = -1     // i.e., not a on-stack replacement compilation
  46 };
  47 
  48 // Enumeration to distinguish tiers of compilation
  49 enum CompLevel {
  50   CompLevel_any               = -2,
  51   CompLevel_all               = -2,
  52   CompLevel_aot               = -1,
  53   CompLevel_none              = 0,         // Interpreter
  54   CompLevel_simple            = 1,         // C1
  55   CompLevel_limited_profile   = 2,         // C1, invocation & backedge counters
  56   CompLevel_full_profile      = 3,         // C1, invocation & backedge counters + mdo
  57   CompLevel_full_optimization = 4          // C2, Shark or JVMCI
  58 };
  59 
  60 extern CompLevel CompLevel_highest_tier;
  61 extern CompLevel CompLevel_initial_compile;
  62 
  63 enum CompMode {
  64   CompMode_none = 0,
  65   CompMode_client = 1,
  66   CompMode_server = 2
  67 };
  68 
  69 extern CompMode Compilation_mode;
  70 
  71 inline bool is_server_compilation_mode_vm() {
  72   return Compilation_mode == CompMode_server;
  73 }
  74 
  75 inline bool is_client_compilation_mode_vm() {
  76   return Compilation_mode == CompMode_client;
  77 }
  78 
  79 extern void set_client_compilation_mode();
  80 
  81 inline bool is_c1_compile(int comp_level) {
  82   return comp_level > CompLevel_none && comp_level < CompLevel_full_optimization;
  83 }
  84 
  85 inline bool is_c2_compile(int comp_level) {
  86   return comp_level == CompLevel_full_optimization;
  87 }
  88 
  89 inline bool is_highest_tier_compile(int comp_level) {
  90   return comp_level == CompLevel_highest_tier;
  91 }
  92 
  93 inline bool is_compile(int comp_level) {
  94   return is_c1_compile(comp_level) || is_c2_compile(comp_level);
  95 }
  96 
  97 // States of Restricted Transactional Memory usage.
  98 enum RTMState {
  99   NoRTM      = 0x2, // Don't use RTM
 100   UseRTM     = 0x1, // Use RTM
 101   ProfileRTM = 0x0  // Use RTM with abort ratio calculation
 102 };
 103 
 104 #ifndef INCLUDE_RTM_OPT
 105 #define INCLUDE_RTM_OPT 0
 106 #endif
 107 #if INCLUDE_RTM_OPT
 108 #define RTM_OPT_ONLY(code) code
 109 #else
 110 #define RTM_OPT_ONLY(code)
 111 #endif
 112 
 113 #endif // SHARE_VM_COMPILER_COMPILERDEFINITIONS_HPP