< prev index next >
src/share/vm/compiler/compileBroker.cpp
Print this page
rev 10354 : 8150646: Add support for blocking compiles though whitebox API
Reviewed-by: kvn, ppunegov, simonis, neliasso
Contributed-by: nils.eliasson@oracle.com, volker.simonis@gmail.com
*** 1,7 ****
/*
! * Copyright (c) 1999, 2015, 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.
--- 1,7 ----
/*
! * Copyright (c) 1999, 2016, 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.
*** 836,845 ****
--- 836,846 ----
int osr_bci,
int comp_level,
const methodHandle& hot_method,
int hot_count,
const char* comment,
+ bool blocking,
Thread* thread) {
// do nothing if compiler thread(s) is not available
if (!_initialized) {
return;
}
*** 914,924 ****
method->get_method_counters(thread);
}
// Outputs from the following MutexLocker block:
CompileTask* task = NULL;
- bool blocking = false;
CompileQueue* queue = compile_queue(comp_level);
// Acquire our lock.
{
MutexLocker locker(MethodCompileQueue_lock, thread);
--- 915,924 ----
*** 944,956 ****
if (compile_id == 0) {
// The compilation falls outside the allowed range.
return;
}
- // Should this thread wait for completion of the compile?
- blocking = is_compile_blocking();
-
#if INCLUDE_JVMCI
if (UseJVMCICompiler) {
if (blocking) {
// Don't allow blocking compiles for requests triggered by JVMCI.
if (thread->is_Compiler_thread()) {
--- 944,953 ----
*** 1032,1046 ****
if (blocking) {
wait_for_completion(task);
}
}
-
nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
int comp_level,
const methodHandle& hot_method, int hot_count,
const char* comment, Thread* THREAD) {
// make sure arguments make sense
assert(method->method_holder()->is_instance_klass(), "not an instance method");
assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range");
assert(!method->is_abstract() && (osr_bci == InvocationEntryBci || !method->is_native()), "cannot compile abstract/native methods");
assert(!method->method_holder()->is_not_initialized(), "method holder must be initialized");
--- 1029,1055 ----
if (blocking) {
wait_for_completion(task);
}
}
nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
int comp_level,
const methodHandle& hot_method, int hot_count,
const char* comment, Thread* THREAD) {
+ AbstractCompiler *comp = CompileBroker::compiler(comp_level);
+ DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, comp);
+ nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_method, hot_count, comment, directive, THREAD);
+ DirectivesStack::release(directive);
+ return nm;
+ }
+
+ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
+ int comp_level,
+ const methodHandle& hot_method, int hot_count,
+ const char* comment, DirectiveSet* directive,
+ Thread* THREAD) {
+
// make sure arguments make sense
assert(method->method_holder()->is_instance_klass(), "not an instance method");
assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range");
assert(!method->is_abstract() && (osr_bci == InvocationEntryBci || !method->is_native()), "cannot compile abstract/native methods");
assert(!method->method_holder()->is_not_initialized(), "method holder must be initialized");
*** 1050,1060 ****
// lock, make sure that the compilation
// isn't prohibited in a straightforward way.
AbstractCompiler *comp = CompileBroker::compiler(comp_level);
if (comp == NULL || !comp->can_compile_method(method) ||
! compilation_is_prohibited(method, osr_bci, comp_level)) {
return NULL;
}
if (osr_bci == InvocationEntryBci) {
// standard compilation
--- 1059,1069 ----
// lock, make sure that the compilation
// isn't prohibited in a straightforward way.
AbstractCompiler *comp = CompileBroker::compiler(comp_level);
if (comp == NULL || !comp->can_compile_method(method) ||
! compilation_is_prohibited(method, osr_bci, comp_level, directive->ExcludeOption)) {
return NULL;
}
if (osr_bci == InvocationEntryBci) {
// standard compilation
*** 1158,1168 ****
// fail out now so blocking compiles dont hang the java thread
if (!should_compile_new_jobs()) {
CompilationPolicy::policy()->delay_compilation(method());
return NULL;
}
! compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, THREAD);
}
// return requested nmethod
// We accept a higher level osr method
if (osr_bci == InvocationEntryBci) {
--- 1167,1177 ----
// fail out now so blocking compiles dont hang the java thread
if (!should_compile_new_jobs()) {
CompilationPolicy::policy()->delay_compilation(method());
return NULL;
}
! compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, !directive->BackgroundCompilationOption, THREAD);
}
// return requested nmethod
// We accept a higher level osr method
if (osr_bci == InvocationEntryBci) {
*** 1215,1225 ****
// ------------------------------------------------------------------
// CompileBroker::compilation_is_prohibited
//
// See if this compilation is not allowed.
! bool CompileBroker::compilation_is_prohibited(const methodHandle& method, int osr_bci, int comp_level) {
bool is_native = method->is_native();
// Some compilers may not support the compilation of natives.
AbstractCompiler *comp = compiler(comp_level);
if (is_native &&
(!CICompileNatives || comp == NULL || !comp->supports_native())) {
--- 1224,1234 ----
// ------------------------------------------------------------------
// CompileBroker::compilation_is_prohibited
//
// See if this compilation is not allowed.
! bool CompileBroker::compilation_is_prohibited(const methodHandle& method, int osr_bci, int comp_level, bool excluded) {
bool is_native = method->is_native();
// Some compilers may not support the compilation of natives.
AbstractCompiler *comp = compiler(comp_level);
if (is_native &&
(!CICompileNatives || comp == NULL || !comp->supports_native())) {
*** 1233,1247 ****
(!CICompileOSR || comp == NULL || !comp->supports_osr())) {
method->set_not_osr_compilable(comp_level);
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.
double scale;
if (excluded || (CompilerOracle::has_option_value(method, "CompileThresholdScaling", scale) && scale == 0)) {
bool quietly = CompilerOracle::should_exclude_quietly();
if (PrintCompilation && !quietly) {
--- 1242,1251 ----
*** 1302,1321 ****
uint CompileBroker::assign_compile_id_unlocked(Thread* thread, const methodHandle& method, int osr_bci) {
MutexLocker locker(MethodCompileQueue_lock, thread);
return assign_compile_id(method, osr_bci);
}
- /**
- * Should the current thread block until this compilation request
- * has been fulfilled?
- */
- bool CompileBroker::is_compile_blocking() {
- assert(!InstanceRefKlass::owns_pending_list_lock(JavaThread::current()), "possible deadlock");
- return !BackgroundCompilation;
- }
-
-
// ------------------------------------------------------------------
// CompileBroker::preload_classes
void CompileBroker::preload_classes(const methodHandle& method, TRAPS) {
// Move this code over from c1_Compiler.cpp
ShouldNotReachHere();
--- 1306,1315 ----
< prev index next >