Path: blob/master/src/hotspot/share/compiler/compilerOracle.hpp
40930 views
/*1* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_COMPILER_COMPILERORACLE_HPP25#define SHARE_COMPILER_COMPILERORACLE_HPP2627#include "memory/allocation.hpp"28#include "oops/oopsHierarchy.hpp"2930class methodHandle;313233// CompilerOracle is an interface for turning on and off compilation34// for some methods3536// OPTION_TYPES: type, name37#define OPTION_TYPES(type) \38type(Intx, "intx") \39type(Uintx, "uintx") \40type(Bool, "bool") \41type(Ccstr, "ccstr") \42type(Ccstrlist, "ccstrlist") \43type(Double, "double")4445// COMPILECOMMAND_OPTIONS: option, name, variant, type46#define COMPILECOMMAND_OPTIONS(option) \47option(Help, "help", Unknown) \48option(Quiet, "quiet", Unknown) \49option(Log, "log", Bool) \50option(Print, "print", Bool) \51option(Inline, "inline", Bool) \52option(DontInline, "dontinline", Bool) \53option(Blackhole, "blackhole", Bool) \54option(CompileOnly, "compileonly", Bool)\55option(Exclude, "exclude", Bool) \56option(Break, "break", Bool) \57option(BreakAtExecute, "BreakAtExecute", Bool) \58option(BreakAtCompile, "BreakAtCompile", Bool) \59option(PrintAssembly, "PrintAssembly", Bool) \60option(PrintInlining, "PrintInlining", Bool) \61option(PrintIntrinsics, "PrintIntrinsics", Bool) \62option(PrintNMethods, "PrintNMethods", Bool) \63option(PrintOptoAssembly, "PrintOptoAssembly", Bool) \64option(PrintDebugInfo, "PrintDebugInfo", Bool) \65option(PrintRelocations, "PrintRelocations", Bool) \66option(PrintDependencies, "PrintDependencies", Bool) \67option(BackgroundCompilation, "BackgroundCompilation", Bool) \68option(RepeatCompilation, "RepeatCompilation", Intx) \69option(ReplayInline, "ReplayInline", Bool) \70option(DumpReplay, "DumpReplay", Bool) \71option(DumpInline, "DumpInline", Bool) \72option(CompileThresholdScaling, "CompileThresholdScaling", Double) \73option(ControlIntrinsic, "ControlIntrinsic", Ccstrlist) \74option(DisableIntrinsic, "DisableIntrinsic", Ccstrlist) \75option(NoRTMLockEliding, "NoRTMLockEliding", Bool) \76option(UseRTMLockEliding, "UseRTMLockEliding", Bool) \77option(BlockLayoutByFrequency, "BlockLayoutByFrequency", Bool) \78option(TraceOptoPipelining, "TraceOptoPipelining", Bool) \79option(TraceOptoOutput, "TraceOptoOutput", Bool) \80option(TraceSpilling, "TraceSpilling", Bool) \81option(PrintIdeal, "PrintIdeal", Bool) \82option(IGVPrintLevel, "IGVPrintLevel", Intx) \83option(Vectorize, "Vectorize", Bool) \84option(VectorizeDebug, "VectorizeDebug", Uintx) \85option(CloneMapDebug, "CloneMapDebug", Bool) \86option(IncrementalInlineForceCleanup, "IncrementalInlineForceCleanup", Bool) \87option(MaxNodeLimit, "MaxNodeLimit", Intx) \88NOT_PRODUCT(option(TestOptionInt, "TestOptionInt", Intx)) \89NOT_PRODUCT(option(TestOptionUint, "TestOptionUint", Uintx)) \90NOT_PRODUCT(option(TestOptionBool, "TestOptionBool", Bool)) \91NOT_PRODUCT(option(TestOptionBool2, "TestOptionBool2", Bool)) \92NOT_PRODUCT(option(TestOptionStr, "TestOptionStr", Ccstr)) \93NOT_PRODUCT(option(TestOptionList, "TestOptionList", Ccstrlist)) \94NOT_PRODUCT(option(TestOptionDouble, "TestOptionDouble", Double)) \95option(Option, "option", Unknown) \96option(Unknown, "unknown", Unknown)9798enum class CompileCommand {99#define enum_of_options(option, name, ctype) option,100COMPILECOMMAND_OPTIONS(enum_of_options)101#undef enum_of_options102Count103};104105enum class OptionType {106#define enum_of_types(type, name) type,107OPTION_TYPES(enum_of_types)108#undef enum_of_types109Unknown110};111112class CompilerOracle : AllStatic {113private:114static bool _quiet;115static void print_parse_error(char* error_msg, char* original_line);116static void print_command(enum CompileCommand option, const char* name, enum OptionType type);117118public:119// True if the command file has been specified or is implicit120static bool has_command_file();121122// Reads from file and adds to lists123static void parse_from_file();124125// Tells whether we to exclude compilation of method126static bool should_exclude(const methodHandle& method);127static bool be_quiet() { return _quiet; }128129// Tells whether we want to inline this method130static bool should_inline(const methodHandle& method);131132// Tells whether we want to disallow inlining of this method133static bool should_not_inline(const methodHandle& method);134135// Tells whether we should print the assembly for this method136static bool should_print(const methodHandle& method);137138// Tells whether we should log the compilation data for this method139static bool should_log(const methodHandle& method);140141// Tells whether to break when compiling method142static bool should_break_at(const methodHandle& method);143144// Tells whether there are any methods to print for print_method_statistics()145static bool should_print_methods();146147// Tags the method as blackhole candidate, if possible.148static void tag_blackhole_if_possible(const methodHandle& method);149150// A wrapper for checking bool options151static bool has_option(const methodHandle& method, enum CompileCommand option);152153// Check if method has option and value set. If yes, overwrite value and return true,154// otherwise leave value unchanged and return false.155template<typename T>156static bool has_option_value(const methodHandle& method, enum CompileCommand option, T& value);157158// This check is currently only needed by whitebox API159template<typename T>160static bool option_matches_type(enum CompileCommand option, T& value);161162// Reads from string instead of file163static void parse_from_string(const char* option_string, void (*parser)(char*));164static void parse_from_line(char* line);165static void parse_compile_only(char* line);166167// Fast check if there is any option set that compile control needs to know about168static bool has_any_command_set();169170// convert a string to a proper compilecommand option - used from whitebox.171// returns CompileCommand::Unknown on names not matching an option.172static enum CompileCommand string_to_option(const char* name);173174// convert a string to a proper compilecommand option175// returns CompileCommand::Unknown if name is not an option.176static enum CompileCommand parse_option_name(const char* name);177178// convert a string to a proper option type179// returns OptionType::Unknown on strings not matching an option type.180static enum OptionType parse_option_type(const char* type_str);181};182183#endif // SHARE_COMPILER_COMPILERORACLE_HPP184185186