1/*
2 * Copyright (c) 2016, 2019, 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_COMPILER_COMPILERDEFINITIONS_HPP
26#define SHARE_COMPILER_COMPILERDEFINITIONS_HPP
27
28#include "memory/allocation.hpp"
29
30// The (closed set) of concrete compiler classes.
31enum CompilerType {
32 compiler_none,
33 compiler_c1,
34 compiler_c2,
35 compiler_jvmci,
36 compiler_number_of_types
37};
38
39extern const char* compilertype2name_tab[compiler_number_of_types]; // Map CompilerType to its name
40inline const char* compilertype2name(CompilerType t) { return (uint)t < compiler_number_of_types ? compilertype2name_tab[t] : NULL; }
41
42// Handy constants for deciding which compiler mode to use.
43enum MethodCompilation {
44 InvocationEntryBci = -1, // i.e., not a on-stack replacement compilation
45 BeforeBci = InvocationEntryBci,
46 AfterBci = -2,
47 UnwindBci = -3,
48 AfterExceptionBci = -4,
49 UnknownBci = -5,
50 InvalidFrameStateBci = -6
51};
52
53// Enumeration to distinguish tiers of compilation
54enum CompLevel {
55 CompLevel_any = -2,
56 CompLevel_all = -2,
57 CompLevel_aot = -1,
58 CompLevel_none = 0, // Interpreter
59 CompLevel_simple = 1, // C1
60 CompLevel_limited_profile = 2, // C1, invocation & backedge counters
61 CompLevel_full_profile = 3, // C1, invocation & backedge counters + mdo
62 CompLevel_full_optimization = 4 // C2 or JVMCI
63};
64
65extern CompLevel CompLevel_highest_tier;
66extern CompLevel CompLevel_initial_compile;
67
68enum CompMode {
69 CompMode_none = 0,
70 CompMode_client = 1,
71 CompMode_server = 2
72};
73
74extern CompMode Compilation_mode;
75
76inline bool is_server_compilation_mode_vm() {
77 return Compilation_mode == CompMode_server;
78}
79
80inline bool is_client_compilation_mode_vm() {
81 return Compilation_mode == CompMode_client;
82}
83
84inline bool is_c1_compile(int comp_level) {
85 return comp_level > CompLevel_none && comp_level < CompLevel_full_optimization;
86}
87
88inline bool is_c2_compile(int comp_level) {
89 return comp_level == CompLevel_full_optimization;
90}
91
92inline bool is_highest_tier_compile(int comp_level) {
93 return comp_level == CompLevel_highest_tier;
94}
95
96inline bool is_compile(int comp_level) {
97 return is_c1_compile(comp_level) || is_c2_compile(comp_level);
98}
99
100// States of Restricted Transactional Memory usage.
101enum RTMState {
102 NoRTM = 0x2, // Don't use RTM
103 UseRTM = 0x1, // Use RTM
104 ProfileRTM = 0x0 // Use RTM with abort ratio calculation
105};
106
107#ifndef INCLUDE_RTM_OPT
108#define INCLUDE_RTM_OPT 0
109#endif
110#if INCLUDE_RTM_OPT
111#define RTM_OPT_ONLY(code) code
112#else
113#define RTM_OPT_ONLY(code)
114#endif
115
116class CompilerConfig : public AllStatic {
117public:
118 // Scale compile thresholds
119 // Returns threshold scaled with CompileThresholdScaling
120 static intx scaled_compile_threshold(intx threshold, double scale);
121 static intx scaled_compile_threshold(intx threshold);
122
123 // Returns freq_log scaled with CompileThresholdScaling
124 static intx scaled_freq_log(intx freq_log, double scale);
125 static intx scaled_freq_log(intx freq_log);
126
127 static bool check_args_consistency(bool status);
128
129 static void ergo_initialize();
130
131private:
132 static void set_tiered_flags();
133};
134
135#endif // SHARE_COMPILER_COMPILERDEFINITIONS_HPP
136