--- old/src/share/vm/jvmci/jvmciRuntime.cpp 2016-05-10 14:10:37.000000000 +0200 +++ new/src/share/vm/jvmci/jvmciRuntime.cpp 2016-05-10 14:10:36.000000000 +0200 @@ -54,6 +54,7 @@ bool JVMCIRuntime::_well_known_classes_initialized = false; int JVMCIRuntime::_trivial_prefixes_count = 0; char** JVMCIRuntime::_trivial_prefixes = NULL; +JVMCIRuntime::CompLevelAdjustment JVMCIRuntime::_comp_level_adjustment = JVMCIRuntime::none; bool JVMCIRuntime::_shutdown_called = false; BasicType JVMCIRuntime::kindToBasicType(Handle kind, TRAPS) { @@ -666,6 +667,11 @@ _trivial_prefixes = prefixes; _trivial_prefixes_count = trivial_prefixes->length(); } + int adjustment = HotSpotJVMCIRuntime::compilationLevelAdjustment(result); + assert(adjustment >= JVMCIRuntime::none && + adjustment <= JVMCIRuntime::by_full_signature, + "compilation level adjustment out of bounds"); + _comp_level_adjustment = (CompLevelAdjustment) adjustment; _HotSpotJVMCIRuntime_initialized = true; _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result()); } @@ -803,6 +809,64 @@ } } +CompLevel JVMCIRuntime::adjust_comp_level_inner(methodHandle method, bool is_osr, CompLevel level, JavaThread* thread) { + JVMCICompiler* compiler = JVMCICompiler::instance(thread); + if (compiler != NULL && compiler->is_bootstrapping()) { + return level; + } + if (!is_HotSpotJVMCIRuntime_initialized() || !_comp_level_adjustment) { + // JVMCI cannot participate in compilation scheduling until + // JVMCI is initialized and indicates it wants to participate. + return level; + } + +#define CHECK_RETURN THREAD); \ +if (HAS_PENDING_EXCEPTION) { \ + Handle exception(THREAD, PENDING_EXCEPTION); \ + CLEAR_PENDING_EXCEPTION; \ +\ + java_lang_Throwable::java_printStackTrace(exception, THREAD); \ + if (HAS_PENDING_EXCEPTION) { \ + CLEAR_PENDING_EXCEPTION; \ + } \ + return level; \ +} \ +(void)(0 + + + Thread* THREAD = thread; + HandleMark hm; + Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_RETURN); + Handle name; + Handle sig; + if (_comp_level_adjustment == JVMCIRuntime::by_full_signature) { + name = java_lang_String::create_from_symbol(method->name(), CHECK_RETURN); + sig = java_lang_String::create_from_symbol(method->signature(), CHECK_RETURN); + } else { + name = Handle(); + sig = Handle(); + } + + JavaValue result(T_INT); + JavaCallArguments args; + args.push_oop(receiver); + args.push_oop(method->method_holder()->java_mirror()); + args.push_oop(name()); + args.push_oop(sig()); + args.push_int(is_osr); + args.push_int(level); + JavaCalls::call_special(&result, receiver->klass(), vmSymbols::adjustCompilationLevel_name(), + vmSymbols::adjustCompilationLevel_signature(), &args, CHECK_RETURN); + + int comp_level = result.get_jint(); + if (comp_level < CompLevel_none || comp_level > CompLevel_full_optimization) { + assert(false, "compilation level out of bounds"); + return level; + } + return (CompLevel) comp_level; +#undef CHECK_RETURN +} + bool JVMCIRuntime::treat_as_trivial(Method* method) { if (_HotSpotJVMCIRuntime_initialized) { for (int i = 0; i < _trivial_prefixes_count; i++) {