Mercurial > hg > graal-jvmci-8
diff src/share/vm/graal/graalCompiler.cpp @ 16399:4481cf549cfc
removed (Java based) CompilationQueue
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 03 Jul 2014 23:28:35 +0200 |
parents | 9b27e69f7cec |
children | 78ddecd6255f |
line wrap: on
line diff
--- a/src/share/vm/graal/graalCompiler.cpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/graal/graalCompiler.cpp Thu Jul 03 23:28:35 2014 +0200 @@ -35,7 +35,7 @@ GraalCompiler::GraalCompiler() : AbstractCompiler(graal) { #ifdef COMPILERGRAAL _bootstrapping = false; - _compiled = 0; + _methodsCompiled = 0; #endif assert(_instance == NULL, "only one instance allowed"); _instance = this; @@ -49,44 +49,19 @@ } BufferBlob* buffer_blob = GraalRuntime::initialize_buffer_blob(); - if (!UseGraalCompilationQueue) { - // This path is used for initialization both by the native queue and the graal queue - // but set_state acquires a lock which might not be safe during JVM_CreateJavaVM, so - // only update the state flag for the native queue. - if (buffer_blob == NULL) { - set_state(failed); - } else { - set_state(initialized); - } + if (buffer_blob == NULL) { + set_state(failed); + } else { + set_state(initialized); } { HandleMark hm; - bool bootstrap_now = UseGraalCompilationQueue && (FLAG_IS_DEFAULT(BootstrapGraal) ? !TieredCompilation : BootstrapGraal); - - if (UseGraalCompilationQueue) { - _bootstrapping = bootstrap_now; - start_compilation_queue(); - } - // Graal is considered as application code so we need to // stop the VM deferring compilation now. CompilationPolicy::completed_vm_startup(); - if (bootstrap_now) { - // Avoid -Xcomp and -Xbatch problems by turning on interpreter and background compilation for bootstrapping. - FlagSetting a(UseInterpreter, true); - FlagSetting b(BackgroundCompilation, true); -#ifndef PRODUCT - // Turn off CompileTheWorld during bootstrap so that a counter overflow event - // triggers further compilation (see NonTieredCompPolicy::event()) hence - // allowing a complete bootstrap - FlagSetting c(CompileTheWorld, false); -#endif - bootstrap(); - } - #ifndef PRODUCT if (CompileTheWorld) { compile_the_world(); @@ -97,83 +72,50 @@ } #ifdef COMPILERGRAAL -void GraalCompiler::start_compilation_queue() { - JavaThread* THREAD = JavaThread::current(); - HandleMark hm(THREAD); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/CompilationQueue", THREAD); - KlassHandle klass = GraalRuntime::load_required_class(name); - NoGraalCompilationScheduling ngcs(THREAD); - klass->initialize(THREAD); - GUARANTEE_NO_PENDING_EXCEPTION("Error while calling start_compilation_queue"); -} - - -void GraalCompiler::shutdown_compilation_queue() { - JavaThread* THREAD = JavaThread::current(); - HandleMark hm(THREAD); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/CompilationQueue", THREAD); - KlassHandle klass = GraalRuntime::load_required_class(name); - JavaValue result(T_VOID); - JavaCallArguments args; - JavaCalls::call_static(&result, klass, vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, THREAD); - GUARANTEE_NO_PENDING_EXCEPTION("Error while calling shutdown_compilation_queue"); -} - void GraalCompiler::bootstrap() { JavaThread* THREAD = JavaThread::current(); _bootstrapping = true; - if (!UseGraalCompilationQueue) { - ResourceMark rm; - HandleMark hm; - if (PrintBootstrap) { - tty->print("Bootstrapping Graal"); - } - jlong start = os::javaTimeMillis(); + ResourceMark rm; + HandleMark hm; + if (PrintBootstrap) { + tty->print("Bootstrapping Graal"); + } + jlong start = os::javaTimeMillis(); - Array<Method*>* objectMethods = InstanceKlass::cast(SystemDictionary::Object_klass())->methods(); - // Initialize compile queue with a selected set of methods. - int len = objectMethods->length(); - for (int i = 0; i < len; i++) { - methodHandle mh = objectMethods->at(i); - if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) { - ResourceMark rm; - int hot_count = 10; // TODO: what's the appropriate value? - CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, "bootstrap", THREAD); + Array<Method*>* objectMethods = InstanceKlass::cast(SystemDictionary::Object_klass())->methods(); + // Initialize compile queue with a selected set of methods. + int len = objectMethods->length(); + for (int i = 0; i < len; i++) { + methodHandle mh = objectMethods->at(i); + if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) { + ResourceMark rm; + int hot_count = 10; // TODO: what's the appropriate value? + CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, "bootstrap", THREAD); + } + } + + int qsize; + jlong sleep_time = 1000; + int z = 0; + do { + os::sleep(THREAD, sleep_time, true); + sleep_time = 100; + qsize = CompileBroker::queue_size(CompLevel_full_optimization); + if (PrintBootstrap) { + while (z < (_methodsCompiled / 100)) { + ++z; + tty->print_raw("."); } } + } while (qsize != 0); - int qsize; - jlong sleep_time = 1000; - int z = 0; - do { - os::sleep(THREAD, sleep_time, true); - sleep_time = 100; - qsize = CompileBroker::queue_size(CompLevel_full_optimization); - if (PrintBootstrap) { - while (z < (_compiled / 100)) { - ++z; - tty->print_raw("."); - } - } - } while (qsize != 0); - - if (PrintBootstrap) { - tty->print_cr(" in %d ms (compiled %d methods)", os::javaTimeMillis() - start, _compiled); - } - } else { - - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/CompilationQueue", THREAD); - KlassHandle klass = GraalRuntime::load_required_class(name); - JavaValue result(T_VOID); - TempNewSymbol bootstrap = SymbolTable::new_symbol("bootstrap", THREAD); - NoGraalCompilationScheduling ngcs(THREAD); - JavaCalls::call_static(&result, klass, bootstrap, vmSymbols::void_method_signature(), THREAD); - GUARANTEE_NO_PENDING_EXCEPTION("Error while calling bootstrap"); + if (PrintBootstrap) { + tty->print_cr(" in %d ms (compiled %d methods)", os::javaTimeMillis() - start, _methodsCompiled); } _bootstrapping = false; } -void GraalCompiler::compile_method(methodHandle method, int entry_bci, CompileTask* task, jboolean blocking) { +void GraalCompiler::compile_method(methodHandle method, int entry_bci, CompileTask* task) { GRAAL_EXCEPTION_CONTEXT bool is_osr = entry_bci != InvocationEntryBci; @@ -190,11 +132,11 @@ args.push_long((jlong) (address) method()); args.push_int(entry_bci); args.push_long((jlong) (address) task); - args.push_int(blocking); + args.push_int(task->compile_id()); JavaCalls::call_static(&result, SystemDictionary::CompilationTask_klass(), vmSymbols::compileMetaspaceMethod_name(), vmSymbols::compileMetaspaceMethod_signature(), &args, THREAD); GUARANTEE_NO_PENDING_EXCEPTION("Error while calling compile_method"); - _compiled++; + _methodsCompiled++; } @@ -203,12 +145,6 @@ ShouldNotReachHere(); } -void GraalCompiler::shutdown() { - if (UseGraalCompilationQueue) { - shutdown_compilation_queue(); - } -} - // Print compilation timers and statistics void GraalCompiler::print_timers() { TRACE_graal_1("GraalCompiler::print_timers");