--- old/src/share/vm/compiler/compileBroker.cpp 2015-10-02 15:58:56.898706768 +0200 +++ new/src/share/vm/compiler/compileBroker.cpp 2015-10-02 15:58:56.786706771 +0200 @@ -29,6 +29,7 @@ #include "compiler/compileBroker.hpp" #include "compiler/compileLog.hpp" #include "compiler/compilerOracle.hpp" +#include "compiler/directivesParser.hpp" #include "interpreter/linkResolver.hpp" #include "memory/allocation.inline.hpp" #include "oops/methodData.hpp" @@ -197,10 +198,18 @@ static CompilationLog* _compilation_log = NULL; -void compileBroker_init() { +bool compileBroker_init() { if (LogEvents) { _compilation_log = new CompilationLog(); } + + // init directives stack, adding default directive + DirectivesStack::init(); + + if (DirectivesParser::has_file()) { + return DirectivesParser::parse_from_flag(); + } + return true; } CompileTaskWrapper::CompileTaskWrapper(CompileTask* task) { @@ -1143,11 +1152,15 @@ return true; } + // Breaking the abstraction - directives are only used inside a compilation otherwise. + DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, comp); + bool excluded = directive->ExcludeOption; + DirectivesStack::release(directive); + // The method may be explicitly excluded by the user. - bool quietly; double scale; - if (CompilerOracle::should_exclude(method, quietly) - || (CompilerOracle::has_option_value(method, "CompileThresholdScaling", scale) && scale == 0)) { + if (excluded || (CompilerOracle::has_option_value(method, "CompileThresholdScaling", scale) && scale == 0)) { + bool quietly = CompilerOracle::should_exclude_quietly(); if (!quietly) { // This does not happen quietly... ResourceMark rm; @@ -1311,7 +1324,6 @@ ThreadInVMfromNative tv(thread); ResetNoHandleMark rnhm; - if (!comp->is_shark()) { // Perform per-thread and global initializations comp->initialize(); @@ -1558,6 +1570,10 @@ tty->print("%s", s.as_string()); } +int DirectivesStack::_depth = 0; +CompilerDirectives* DirectivesStack::_top = NULL; +CompilerDirectives* DirectivesStack::_bottom = NULL; + // ------------------------------------------------------------------ // CompileBroker::invoke_compiler_on_method // @@ -1584,16 +1600,20 @@ bool should_log = (thread->log() != NULL); bool should_break = false; int task_level = task->comp_level(); + + // Look up matching directives + DirectiveSet* directive = DirectivesStack::getMatchingDirective(task->method(), compiler(task_level)); + + should_break = directive->BreakAtExecuteOption || task->check_break_at_flags(); + if (should_log && !directive->LogOption) { + should_log = false; + } { // create the handle inside it's own block so it can't // accidentally be referenced once the thread transitions to // native. The NoHandleMark before the transition should catch // any cases where this occurs in the future. methodHandle method(thread, task->method()); - should_break = check_break_at(method, compile_id, is_osr); - if (should_log && !CompilerOracle::should_log(method)) { - should_log = false; - } assert(!method->is_native(), "no longer compile natives"); // Save information about this method in case of failure. @@ -1647,7 +1667,7 @@ locker.wait(Mutex::_no_safepoint_check_flag); } } - comp->compile_method(&ci_env, target, osr_bci); + comp->compile_method(&ci_env, target, osr_bci, directive); } if (!ci_env.failing() && task->code() == NULL) { @@ -1696,6 +1716,7 @@ event.commit(); } } + DirectivesStack::release(directive); pop_jni_handle_block(); methodHandle method(thread, task->method()); @@ -1881,21 +1902,6 @@ JNIHandleBlock::release_block(compile_handles, thread); // may block } - -// ------------------------------------------------------------------ -// CompileBroker::check_break_at -// -// Should the compilation break at the current compilation. -bool CompileBroker::check_break_at(methodHandle method, int compile_id, bool is_osr) { - if (CICountOSR && is_osr && (compile_id == CIBreakAtOSR)) { - return true; - } else if( CompilerOracle::should_break_at(method) ) { // break when compiling - return true; - } else { - return (compile_id == CIBreakAt); - } -} - // ------------------------------------------------------------------ // CompileBroker::collect_statistics // @@ -2075,3 +2081,4 @@ st->cr(); #endif } +