--- /dev/null 2015-09-21 09:36:40.397057507 +0200 +++ new/src/share/vm/compiler/compilerDirectives.hpp 2015-09-22 16:26:56.625641772 +0200 @@ -0,0 +1,164 @@ +/* + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_COMPILER_COMPILERDIRECTIVES_HPP +#define SHARE_VM_COMPILER_COMPILERDIRECTIVES_HPP + +//#include "ci/ciExceptionHandler.hpp" +#include "ci/ciMetadata.hpp" +#include "ci/ciMethod.hpp" +#include "ci/ciUtilities.hpp" +#include "compiler/methodMatcher.hpp" +#include "compiler/compilerOracle.hpp" +#include "utilities/exceptions.hpp" + + // Directives flag name, type, default value, compile command name + #define compilerdirectives_common_flags(cflags) \ + cflags(Enabled, bool, true, X) \ + cflags(BreakAtExecute, bool, false, X) \ + cflags(BreakAtCompile, bool, false, X) \ + cflags(Log, bool, false, X) \ + cflags(PrintAssembly, bool, PrintAssembly, X) \ + cflags(PrintInlining, bool, PrintInlining, PrintInlining) \ + cflags(PrintNMethods, bool, PrintNMethods, PrintNMethods) \ + cflags(ReplayInline, bool, false, ReplayInline) \ + cflags(DumpReplay, bool, false, DumpReplay) \ + cflags(DumpInline, bool, false, DumpInline) \ + cflags(CompileCommandCompatibility, bool, false, CompileCommandCompatibility) \ + cflags(CompileThresholdScaling, double, CompileThresholdScaling, CompileThresholdScaling) + +#ifdef COMPILER1 + #define compilerdirectives_c1_flags(cflags) +#else + #define compilerdirectives_c1_flags(cflags) +#endif + +#ifdef COMPILER2 + #define compilerdirectives_c2_flags(cflags) \ + cflags(BlockLayoutByFrequency, bool, BlockLayoutByFrequency, BlockLayoutByFrequency) \ + cflags(PrintOptoAssembly, bool, PrintOptoAssembly, PrintOptoAssembly) \ + cflags(PrintIntrinsics, bool, PrintIntrinsics, PrintIntrinsics) \ + cflags(TraceOptoPipelining, bool, false, TraceOptoPipelining) \ + cflags(TraceOptoOutput, bool, false, TraceOptoOutput) \ + cflags(TraceSpilling, bool, TraceSpilling, TraceSpilling) \ + cflags(Vectorize, bool, false, Vectorize) \ + cflags(VectorizeDebug, bool, false, VectorizeDebug) \ + cflags(CloneMapDebug, bool, false, CloneMapDebug) \ + cflags(IGVPrintLevel, intx, PrintIdealGraphLevel, IGVPrintLevel) \ + cflags(MaxNodeLimit, intx, MaxNodeLimit, MaxNodeLimit) \ + cflags(DisableIntrinsics, ccstr, DisableIntrinsic, DisableIntrinsics) +#else + #define compilerdirectives_c2_flags(cflags) +#endif + +class CompilerDirectives; + +class DirectiveSet : public CHeapObj { +private: + InlineMatcher* _inlinematchers; + CompilerDirectives* _directive; + +public: + DirectiveSet(CompilerDirectives* directive); + ~DirectiveSet(); + void release(); + CompilerDirectives* directive(); + bool parse_and_add_inline(char* str, const char*& error_msg); + void append_inline(InlineMatcher* m); + bool inline_commanded(ciMethod* inlinee); + bool dont_inline_commanded(ciMethod* inlinee); + void print_inline(outputStream* st); + DirectiveSet* late_cc_init(methodHandle method); + bool is_exclusive_copy() { return _directive == NULL; } + bool matches_inline(methodHandle method, int inline_action); + bool is_intrinsic_disabled(methodHandle method); + DirectiveSet* clone(); + + typedef enum { +#define enum_of_flags(name, type, dvalue, cc_flag) name##Index, + compilerdirectives_common_flags(enum_of_flags) + compilerdirectives_c2_flags(enum_of_flags) + compilerdirectives_c1_flags(enum_of_flags) + number_of_flags + } flags; + + bool _modified[number_of_flags]; + +#define flag_store_definition(name, type, dvalue, cc_flag) type name##Option; + compilerdirectives_common_flags(flag_store_definition) + compilerdirectives_c2_flags(flag_store_definition) + compilerdirectives_c1_flags(flag_store_definition) + +// Casting to get the same function signature for all setters. Used from parser. +#define set_function_definition(name, type, dvalue, cc_flag) void set_##name(void* value) { type val = *(type*)value; name##Option = val; _modified[name##Index] = 1; } + compilerdirectives_common_flags(set_function_definition) + compilerdirectives_c2_flags(set_function_definition) + compilerdirectives_c1_flags(set_function_definition) + + void print_intx(outputStream* st, ccstr n, intx v, bool mod) { st->print_cr(" %s %s: " INTX_FORMAT, mod ? "*" : " ", n, v); } + void print_bool(outputStream* st, ccstr n, bool v, bool mod) { st->print_cr(" %s %s: %s", mod ? "*" : " ", n, v ? "true" : "false"); } + void print_double(outputStream* st, ccstr n, double v, bool mod) { st->print_cr(" %s %s: %f", mod ? "*" : " ", n, v); } + void print_ccstr(outputStream* st, ccstr n, ccstr v, bool mod) { st->print_cr(" %s %s: %s", mod ? "*" : " ", n, v); } + +void print(outputStream* st) { + print_inline(st); +#define print_function_definition(name, type, dvalue, cc_flag) print_##type(st, #name, this->name##Option, (bool)_modified[name##Index]); + compilerdirectives_common_flags(print_function_definition) + compilerdirectives_c2_flags(print_function_definition) + compilerdirectives_c1_flags(print_function_definition) + } +}; + +class CompilerDirectives : public CHeapObj { +private: + CompilerDirectives* _next; + BasicMatcher* _match; + int _ref_count; + +public: + + CompilerDirectives(); + ~CompilerDirectives(); + + static const short TargetC1 = 1; + static const short TargetC2 = 2; + + CompilerDirectives* next(); + void set_next(CompilerDirectives* next) {_next = next; } + + bool match(methodHandle method, int comp_level); + bool add_match(char* str, const char*& error_msg); + DirectiveSet* get_for(int comp_leveltarget); + void print(outputStream* st); + bool is_default_directive() { return _next == NULL; } + + void inc_refcount(); + void dec_refcount(); + + DirectiveSet* _c1_store; + DirectiveSet* _c2_store; +}; + + +#endif // SHARE_VM_COMPILER_COMPILERDIRECTIVES_HPP