Mercurial > hg > graal-jvmci-8
comparison src/share/vm/c1/c1_GraphBuilder.cpp @ 6843:c3e799c37717
7177003: C1: LogCompilation support
Summary: add LogCompilation support in C1 - both client and tiered mode.
Reviewed-by: twisti, kvn
author | vlivanov |
---|---|
date | Fri, 05 Oct 2012 18:57:10 -0700 |
parents | 7eca5de9e0b6 |
children | fd1d564dd460 |
comparison
equal
deleted
inserted
replaced
6830:81e878c53615 | 6843:c3e799c37717 |
---|---|
1680 // check if CHA possible: if so, change the code to invoke_special | 1680 // check if CHA possible: if so, change the code to invoke_special |
1681 ciInstanceKlass* calling_klass = method()->holder(); | 1681 ciInstanceKlass* calling_klass = method()->holder(); |
1682 ciInstanceKlass* callee_holder = ciEnv::get_instance_klass_for_declared_method_holder(holder); | 1682 ciInstanceKlass* callee_holder = ciEnv::get_instance_klass_for_declared_method_holder(holder); |
1683 ciInstanceKlass* actual_recv = callee_holder; | 1683 ciInstanceKlass* actual_recv = callee_holder; |
1684 | 1684 |
1685 CompileLog* log = compilation()->log(); | |
1686 if (log != NULL) | |
1687 log->elem("call method='%d' instr='%s'", | |
1688 log->identify(target), | |
1689 Bytecodes::name(code)); | |
1690 | |
1685 // Some methods are obviously bindable without any type checks so | 1691 // Some methods are obviously bindable without any type checks so |
1686 // convert them directly to an invokespecial or invokestatic. | 1692 // convert them directly to an invokespecial or invokestatic. |
1687 if (target->is_loaded() && !target->is_abstract() && target->can_be_statically_bound()) { | 1693 if (target->is_loaded() && !target->is_abstract() && target->can_be_statically_bound()) { |
1688 switch (bc_raw) { | 1694 switch (bc_raw) { |
1689 case Bytecodes::_invokevirtual: | 1695 case Bytecodes::_invokevirtual: |
1824 // falsely lead us to believe that the receiver is final or private. | 1830 // falsely lead us to believe that the receiver is final or private. |
1825 dependency_recorder()->assert_unique_concrete_method(actual_recv, cha_monomorphic_target); | 1831 dependency_recorder()->assert_unique_concrete_method(actual_recv, cha_monomorphic_target); |
1826 } | 1832 } |
1827 code = Bytecodes::_invokespecial; | 1833 code = Bytecodes::_invokespecial; |
1828 } | 1834 } |
1835 | |
1829 // check if we could do inlining | 1836 // check if we could do inlining |
1830 if (!PatchALot && Inline && klass->is_loaded() && | 1837 if (!PatchALot && Inline && klass->is_loaded() && |
1831 (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized()) | 1838 (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized()) |
1832 && target->will_link(klass, callee_holder, code)) { | 1839 && target->will_link(klass, callee_holder, code)) { |
1833 // callee is known => check if we have static binding | 1840 // callee is known => check if we have static binding |
2446 tty->print_cr("locals size: %d stack size: %d", state()->locals_size(), state()->stack_size()); | 2453 tty->print_cr("locals size: %d stack size: %d", state()->locals_size(), state()->stack_size()); |
2447 } | 2454 } |
2448 #endif | 2455 #endif |
2449 _skip_block = false; | 2456 _skip_block = false; |
2450 assert(state() != NULL, "ValueStack missing!"); | 2457 assert(state() != NULL, "ValueStack missing!"); |
2458 CompileLog* log = compilation()->log(); | |
2451 ciBytecodeStream s(method()); | 2459 ciBytecodeStream s(method()); |
2452 s.reset_to_bci(bci); | 2460 s.reset_to_bci(bci); |
2453 int prev_bci = bci; | 2461 int prev_bci = bci; |
2454 scope_data()->set_stream(&s); | 2462 scope_data()->set_stream(&s); |
2455 // iterate | 2463 // iterate |
2463 | 2471 |
2464 while (!bailed_out() && last()->as_BlockEnd() == NULL && | 2472 while (!bailed_out() && last()->as_BlockEnd() == NULL && |
2465 (code = stream()->next()) != ciBytecodeStream::EOBC() && | 2473 (code = stream()->next()) != ciBytecodeStream::EOBC() && |
2466 (block_at(s.cur_bci()) == NULL || block_at(s.cur_bci()) == block())) { | 2474 (block_at(s.cur_bci()) == NULL || block_at(s.cur_bci()) == block())) { |
2467 assert(state()->kind() == ValueStack::Parsing, "invalid state kind"); | 2475 assert(state()->kind() == ValueStack::Parsing, "invalid state kind"); |
2476 | |
2477 if (log != NULL) | |
2478 log->set_context("bc code='%d' bci='%d'", (int)code, s.cur_bci()); | |
2468 | 2479 |
2469 // Check for active jsr during OSR compilation | 2480 // Check for active jsr during OSR compilation |
2470 if (compilation()->is_osr_compile() | 2481 if (compilation()->is_osr_compile() |
2471 && scope()->is_top_scope() | 2482 && scope()->is_top_scope() |
2472 && parsing_jsr() | 2483 && parsing_jsr() |
2684 case Bytecodes::_goto_w : _goto(s.cur_bci(), s.get_far_dest()); break; | 2695 case Bytecodes::_goto_w : _goto(s.cur_bci(), s.get_far_dest()); break; |
2685 case Bytecodes::_jsr_w : jsr(s.get_far_dest()); break; | 2696 case Bytecodes::_jsr_w : jsr(s.get_far_dest()); break; |
2686 case Bytecodes::_breakpoint : BAILOUT_("concurrent setting of breakpoint", NULL); | 2697 case Bytecodes::_breakpoint : BAILOUT_("concurrent setting of breakpoint", NULL); |
2687 default : ShouldNotReachHere(); break; | 2698 default : ShouldNotReachHere(); break; |
2688 } | 2699 } |
2700 | |
2701 if (log != NULL) | |
2702 log->clear_context(); // skip marker if nothing was printed | |
2703 | |
2689 // save current bci to setup Goto at the end | 2704 // save current bci to setup Goto at the end |
2690 prev_bci = s.cur_bci(); | 2705 prev_bci = s.cur_bci(); |
2706 | |
2691 } | 2707 } |
2692 CHECK_BAILOUT_(NULL); | 2708 CHECK_BAILOUT_(NULL); |
2693 // stop processing of this block (see try_inline_full) | 2709 // stop processing of this block (see try_inline_full) |
2694 if (_skip_block) { | 2710 if (_skip_block) { |
2695 _skip_block = false; | 2711 _skip_block = false; |
3665 | 3681 |
3666 if (compilation()->env()->num_inlined_bytecodes() > DesiredMethodLimit) { | 3682 if (compilation()->env()->num_inlined_bytecodes() > DesiredMethodLimit) { |
3667 INLINE_BAILOUT("total inlining greater than DesiredMethodLimit"); | 3683 INLINE_BAILOUT("total inlining greater than DesiredMethodLimit"); |
3668 } | 3684 } |
3669 // printing | 3685 // printing |
3670 print_inlining(callee, ""); | 3686 print_inlining(callee); |
3671 } | 3687 } |
3672 | 3688 |
3673 // NOTE: Bailouts from this point on, which occur at the | 3689 // NOTE: Bailouts from this point on, which occur at the |
3674 // GraphBuilder level, do not cause bailout just of the inlining but | 3690 // GraphBuilder level, do not cause bailout just of the inlining but |
3675 // in fact of the entire compilation. | 3691 // in fact of the entire compilation. |
4131 compilation()->set_has_unsafe_access(true); | 4147 compilation()->set_has_unsafe_access(true); |
4132 } | 4148 } |
4133 | 4149 |
4134 | 4150 |
4135 void GraphBuilder::print_inlining(ciMethod* callee, const char* msg, bool success) { | 4151 void GraphBuilder::print_inlining(ciMethod* callee, const char* msg, bool success) { |
4152 CompileLog* log = compilation()->log(); | |
4153 if (log != NULL) { | |
4154 if (success) { | |
4155 if (msg != NULL) | |
4156 log->inline_success(msg); | |
4157 else | |
4158 log->inline_success("receiver is statically known"); | |
4159 } else { | |
4160 log->inline_fail(msg); | |
4161 } | |
4162 } | |
4163 | |
4136 if (!PrintInlining) return; | 4164 if (!PrintInlining) return; |
4137 assert(msg != NULL, "must be"); | |
4138 CompileTask::print_inlining(callee, scope()->level(), bci(), msg); | 4165 CompileTask::print_inlining(callee, scope()->level(), bci(), msg); |
4139 if (success && CIPrintMethodCodes) { | 4166 if (success && CIPrintMethodCodes) { |
4140 callee->print_codes(); | 4167 callee->print_codes(); |
4141 } | 4168 } |
4142 } | 4169 } |