comparison src/share/vm/compiler/compileBroker.cpp @ 1454:7cf1952ec5fb

Added flag -XX:BootstrapC1X that precompiles Object::<init> and then every method in the compilation queue until it is empty.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Fri, 12 Nov 2010 20:57:08 +0100
parents 72cfb36c6bb2
children 1845386f5403
comparison
equal deleted inserted replaced
1453:d603bdbec024 1454:7cf1952ec5fb
318 318
319 // print osr_bci if any 319 // print osr_bci if any
320 if (is_osr) tty->print(" @ %d", osr_bci()); 320 if (is_osr) tty->print(" @ %d", osr_bci());
321 321
322 // print method size 322 // print method size
323 tty->print_cr(" (%d bytes)", method->code_size()); 323 tty->print(" (%d bytes)", method->code_size());
324
325 // invocation count
326 tty->print_cr(" %d invocations", _hot_count);
324 } 327 }
325 328
326 329
327 // ------------------------------------------------------------------ 330 // ------------------------------------------------------------------
328 // CompileTask::log_task 331 // CompileTask::log_task
475 _first =_first->next(); 478 _first =_first->next();
476 if (_first == NULL) { 479 if (_first == NULL) {
477 _last = NULL; 480 _last = NULL;
478 } 481 }
479 482
483 // (tw) Immediately set compiling flag.
484 JavaThread::current()->as_CompilerThread()->set_compiling(true);
485
480 return task; 486 return task;
481 487
482 } 488 }
483 489
484 490
528 534
529 name = PerfDataManager::counter_name(thread_i, "compiles"); 535 name = PerfDataManager::counter_name(thread_i, "compiles");
530 _perf_compiles = PerfDataManager::create_counter(SUN_CI, name, 536 _perf_compiles = PerfDataManager::create_counter(SUN_CI, name,
531 PerfData::U_Events, CHECK); 537 PerfData::U_Events, CHECK);
532 } 538 }
539 }
540
541 // Bootstrap the C1X compiler. Compiles all methods until compile queue is empty and no compilation is active.
542 void CompileBroker::bootstrap_c1x() {
543 Thread* THREAD = Thread::current();
544 tty->print_cr("Bootstrapping C1X...");
545
546 C1XCompiler* compiler = C1XCompiler::instance();
547 if (compiler == NULL) fatal("must use flag -XX:+UseC1X");
548
549 jlong start = os::javaTimeMillis();
550 {
551 HandleMark hm;
552 instanceKlass* klass = (instanceKlass*)SystemDictionary::Object_klass()->klass_part();
553 methodOop method = klass->find_method(vmSymbols::object_initializer_name(), vmSymbols::void_method_signature());
554 CompileBroker::compile_method(method, -1, method, 0, "initial compile of object initializer", THREAD);
555 if (HAS_PENDING_EXCEPTION) {
556 CLEAR_PENDING_EXCEPTION;
557 fatal("error inserting object initializer into compile queue");
558 }
559 }
560 int z = 0;
561 while (true) {
562 {
563 HandleMark hm;
564 ResourceMark rm;
565 MutexLocker locker(_method_queue->lock(), Thread::current());
566 if (_method_queue->is_empty()) {
567 MutexLocker mu(Threads_lock); // grab Threads_lock
568 JavaThread* current = Threads::first();
569 bool compiling = false;
570 while (current != NULL) {
571 if (current->is_Compiler_thread()) {
572 CompilerThread* comp_thread = current->as_CompilerThread();
573 if (comp_thread->is_compiling()) {
574 if (TraceC1X >= 4) {
575 tty->print_cr("Compile queue empty, but following thread is still compiling:");
576 comp_thread->print();
577 }
578 compiling = true;
579 }
580 }
581 current = current->next();
582 }
583 if (!compiling) {
584 break;
585 }
586 }
587 if (TraceC1X >= 4) {
588 _method_queue->print();
589 }
590 }
591
592 {
593 ThreadToNativeFromVM trans(JavaThread::current());
594 usleep(1000);
595 }
596 ++z;
597 }
598 jlong diff = os::javaTimeMillis() - start;
599 tty->print_cr("Finished bootstrap in %d ms", diff);
600 if (CITime) CompileBroker::print_times();
601 tty->print_cr("===========================================================================");
533 } 602 }
534 603
535 604
536 // ------------------------------------------------------------------ 605 // ------------------------------------------------------------------
537 // CompileBroker::compilation_init 606 // CompileBroker::compilation_init
861 bool blocking = false; 930 bool blocking = false;
862 931
863 // Acquire our lock. 932 // Acquire our lock.
864 { 933 {
865 MutexLocker locker(_method_queue->lock(), THREAD); 934 MutexLocker locker(_method_queue->lock(), THREAD);
866 /* 935
867 if (Thread::current()->is_Compiler_thread() && CompilerThread::current()->is_compiling()) { 936 if (Thread::current()->is_Compiler_thread() && CompilerThread::current()->is_compiling() && !BackgroundCompilation) {
868 937
869 TRACE_C1X_1("Recursive compile %s!", method->name_and_sig_as_C_string()); 938 TRACE_C1X_1("Recursive compile %s!", method->name_and_sig_as_C_string());
870 //method->set_not_compilable(); 939 method->set_not_compilable();
871 return; 940 return;
872 } 941 }
873 */ 942
874 // Make sure the method has not slipped into the queues since 943 // Make sure the method has not slipped into the queues since
875 // last we checked; note that those checks were "fast bail-outs". 944 // last we checked; note that those checks were "fast bail-outs".
876 // Here we need to be more careful, see 14012000 below. 945 // Here we need to be more careful, see 14012000 below.
877 if (compilation_is_in_queue(method, osr_bci)) { 946 if (compilation_is_in_queue(method, osr_bci)) {
878 return; 947 return;
1350 log->end_elem(); 1419 log->end_elem();
1351 } 1420 }
1352 1421
1353 while (true) { 1422 while (true) {
1354 { 1423 {
1424 // Unset compiling flag.
1425 thread->set_compiling(false);
1426
1355 // We need this HandleMark to avoid leaking VM handles. 1427 // We need this HandleMark to avoid leaking VM handles.
1356 HandleMark hm(thread); 1428 HandleMark hm(thread);
1357 1429
1358 if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) { 1430 if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) {
1359 // the code cache is really full 1431 // the code cache is really full