c1_GraphBuilder.cpp (11866:abeecea0351c) c1_GraphBuilder.cpp (11891:8eab4734c758)
1/*
2 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *

--- 669 unchanged lines hidden (view full) ---

678 , _parsing_jsr(false)
679 , _jsr_xhandlers(NULL)
680 , _caller_stack_size(-1)
681 , _continuation(NULL)
682 , _num_returns(0)
683 , _cleanup_block(NULL)
684 , _cleanup_return_prev(NULL)
685 , _cleanup_state(NULL)
1/*
2 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *

--- 669 unchanged lines hidden (view full) ---

678 , _parsing_jsr(false)
679 , _jsr_xhandlers(NULL)
680 , _caller_stack_size(-1)
681 , _continuation(NULL)
682 , _num_returns(0)
683 , _cleanup_block(NULL)
684 , _cleanup_return_prev(NULL)
685 , _cleanup_state(NULL)
686 , _ignore_return(false)
686{
687 if (parent != NULL) {
688 _max_inline_size = (intx) ((float) NestedInliningSizeRatio * (float) parent->max_inline_size() / 100.0f);
689 } else {
690 _max_inline_size = MaxInlineSize;
691 }
692 if (_max_inline_size < MaxTrivialSize) {
693 _max_inline_size = MaxTrivialSize;

--- 746 unchanged lines hidden (view full) ---

1440 load_local(objectType, 0);
1441 append_split(new Intrinsic(voidType, vmIntrinsics::_Object_init,
1442 state()->pop_arguments(1),
1443 true, state_before, true));
1444 }
1445}
1446
1447
687{
688 if (parent != NULL) {
689 _max_inline_size = (intx) ((float) NestedInliningSizeRatio * (float) parent->max_inline_size() / 100.0f);
690 } else {
691 _max_inline_size = MaxInlineSize;
692 }
693 if (_max_inline_size < MaxTrivialSize) {
694 _max_inline_size = MaxTrivialSize;

--- 746 unchanged lines hidden (view full) ---

1441 load_local(objectType, 0);
1442 append_split(new Intrinsic(voidType, vmIntrinsics::_Object_init,
1443 state()->pop_arguments(1),
1444 true, state_before, true));
1445 }
1446}
1447
1448
1448void GraphBuilder::method_return(Value x) {
1449void GraphBuilder::method_return(Value x, bool ignore_return) {
1449 if (RegisterFinalizersAtInit &&
1450 method()->intrinsic_id() == vmIntrinsics::_Object_init) {
1451 call_register_finalizer();
1452 }
1453
1454 bool need_mem_bar = false;
1455 if (method()->name() == ciSymbol::object_initializer_name() &&
1456 (scope()->wrote_final() || (AlwaysSafeConstructors && scope()->wrote_fields())

--- 56 unchanged lines hidden (view full) ---

1513 }
1514
1515 // State at end of inlined method is the state of the caller
1516 // without the method parameters on stack, including the
1517 // return value, if any, of the inlined method on operand stack.
1518 int invoke_bci = state()->caller_state()->bci();
1519 set_state(state()->caller_state()->copy_for_parsing());
1520 if (x != NULL) {
1450 if (RegisterFinalizersAtInit &&
1451 method()->intrinsic_id() == vmIntrinsics::_Object_init) {
1452 call_register_finalizer();
1453 }
1454
1455 bool need_mem_bar = false;
1456 if (method()->name() == ciSymbol::object_initializer_name() &&
1457 (scope()->wrote_final() || (AlwaysSafeConstructors && scope()->wrote_fields())

--- 56 unchanged lines hidden (view full) ---

1514 }
1515
1516 // State at end of inlined method is the state of the caller
1517 // without the method parameters on stack, including the
1518 // return value, if any, of the inlined method on operand stack.
1519 int invoke_bci = state()->caller_state()->bci();
1520 set_state(state()->caller_state()->copy_for_parsing());
1521 if (x != NULL) {
1521 state()->push(x->type(), x);
1522 if (!ignore_return) {
1523 state()->push(x->type(), x);
1524 }
1522 if (profile_return() && x->type()->is_object_kind()) {
1523 ciMethod* caller = state()->scope()->method();
1524 ciMethodData* md = caller->method_data_or_null();
1525 ciProfileData* data = md->bci_to_data(invoke_bci);
1526 if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) {
1527 bool has_return = data->is_CallTypeData() ? ((ciCallTypeData*)data)->has_return() : ((ciVirtualCallTypeData*)data)->has_return();
1528 // May not be true in case of an inlined call through a method handle intrinsic.
1529 if (has_return) {

--- 28 unchanged lines hidden (view full) ---

1558 }
1559 append_split(new MonitorExit(receiver, state()->unlock()));
1560 }
1561
1562 if (need_mem_bar) {
1563 append(new MemBar(lir_membar_storestore));
1564 }
1565
1525 if (profile_return() && x->type()->is_object_kind()) {
1526 ciMethod* caller = state()->scope()->method();
1527 ciMethodData* md = caller->method_data_or_null();
1528 ciProfileData* data = md->bci_to_data(invoke_bci);
1529 if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) {
1530 bool has_return = data->is_CallTypeData() ? ((ciCallTypeData*)data)->has_return() : ((ciVirtualCallTypeData*)data)->has_return();
1531 // May not be true in case of an inlined call through a method handle intrinsic.
1532 if (has_return) {

--- 28 unchanged lines hidden (view full) ---

1561 }
1562 append_split(new MonitorExit(receiver, state()->unlock()));
1563 }
1564
1565 if (need_mem_bar) {
1566 append(new MemBar(lir_membar_storestore));
1567 }
1568
1569 assert(!ignore_return, "Ignoring return value works only for inlining");
1566 append(new Return(x));
1567}
1568
1569Value GraphBuilder::make_constant(ciConstant field_value, ciField* field) {
1570 if (!field_value.is_valid()) return NULL;
1571
1572 BasicType field_type = field_value.basic_type();
1573 ValueType* value = as_ValueType(field_value);

--- 402 unchanged lines hidden (view full) ---

1976 && !patch_for_appendix) {
1977 // callee is known => check if we have static binding
1978 if (code == Bytecodes::_invokestatic ||
1979 code == Bytecodes::_invokespecial ||
1980 code == Bytecodes::_invokevirtual && target->is_final_method() ||
1981 code == Bytecodes::_invokedynamic) {
1982 ciMethod* inline_target = (cha_monomorphic_target != NULL) ? cha_monomorphic_target : target;
1983 // static binding => check if callee is ok
1570 append(new Return(x));
1571}
1572
1573Value GraphBuilder::make_constant(ciConstant field_value, ciField* field) {
1574 if (!field_value.is_valid()) return NULL;
1575
1576 BasicType field_type = field_value.basic_type();
1577 ValueType* value = as_ValueType(field_value);

--- 402 unchanged lines hidden (view full) ---

1980 && !patch_for_appendix) {
1981 // callee is known => check if we have static binding
1982 if (code == Bytecodes::_invokestatic ||
1983 code == Bytecodes::_invokespecial ||
1984 code == Bytecodes::_invokevirtual && target->is_final_method() ||
1985 code == Bytecodes::_invokedynamic) {
1986 ciMethod* inline_target = (cha_monomorphic_target != NULL) ? cha_monomorphic_target : target;
1987 // static binding => check if callee is ok
1984 bool success = try_inline(inline_target, (cha_monomorphic_target != NULL) || (exact_target != NULL), code, better_receiver);
1988 bool success = try_inline(inline_target, (cha_monomorphic_target != NULL) || (exact_target != NULL), false, code, better_receiver);
1985
1986 CHECK_BAILOUT();
1987 clear_inline_bailout();
1988
1989 if (success) {
1990 // Register dependence if JVMTI has either breakpoint
1991 // setting or hotswapping of methods capabilities since they may
1992 // cause deoptimization.

--- 613 unchanged lines hidden (view full) ---

2606 Bytecodes::Code code = Bytecodes::_illegal;
2607 bool push_exception = false;
2608
2609 if (block()->is_set(BlockBegin::exception_entry_flag) && block()->next() == NULL) {
2610 // first thing in the exception entry block should be the exception object.
2611 push_exception = true;
2612 }
2613
1989
1990 CHECK_BAILOUT();
1991 clear_inline_bailout();
1992
1993 if (success) {
1994 // Register dependence if JVMTI has either breakpoint
1995 // setting or hotswapping of methods capabilities since they may
1996 // cause deoptimization.

--- 613 unchanged lines hidden (view full) ---

2610 Bytecodes::Code code = Bytecodes::_illegal;
2611 bool push_exception = false;
2612
2613 if (block()->is_set(BlockBegin::exception_entry_flag) && block()->next() == NULL) {
2614 // first thing in the exception entry block should be the exception object.
2615 push_exception = true;
2616 }
2617
2618 bool ignore_return = scope_data()->ignore_return();
2619
2614 while (!bailed_out() && last()->as_BlockEnd() == NULL &&
2615 (code = stream()->next()) != ciBytecodeStream::EOBC() &&
2616 (block_at(s.cur_bci()) == NULL || block_at(s.cur_bci()) == block())) {
2617 assert(state()->kind() == ValueStack::Parsing, "invalid state kind");
2618
2619 if (log != NULL)
2620 log->set_context("bc code='%d' bci='%d'", (int)code, s.cur_bci());
2621

--- 179 unchanged lines hidden (view full) ---

2801 case Bytecodes::_if_icmple : if_same(intType , If::leq); break;
2802 case Bytecodes::_if_acmpeq : if_same(objectType, If::eql); break;
2803 case Bytecodes::_if_acmpne : if_same(objectType, If::neq); break;
2804 case Bytecodes::_goto : _goto(s.cur_bci(), s.get_dest()); break;
2805 case Bytecodes::_jsr : jsr(s.get_dest()); break;
2806 case Bytecodes::_ret : ret(s.get_index()); break;
2807 case Bytecodes::_tableswitch : table_switch(); break;
2808 case Bytecodes::_lookupswitch : lookup_switch(); break;
2620 while (!bailed_out() && last()->as_BlockEnd() == NULL &&
2621 (code = stream()->next()) != ciBytecodeStream::EOBC() &&
2622 (block_at(s.cur_bci()) == NULL || block_at(s.cur_bci()) == block())) {
2623 assert(state()->kind() == ValueStack::Parsing, "invalid state kind");
2624
2625 if (log != NULL)
2626 log->set_context("bc code='%d' bci='%d'", (int)code, s.cur_bci());
2627

--- 179 unchanged lines hidden (view full) ---

2807 case Bytecodes::_if_icmple : if_same(intType , If::leq); break;
2808 case Bytecodes::_if_acmpeq : if_same(objectType, If::eql); break;
2809 case Bytecodes::_if_acmpne : if_same(objectType, If::neq); break;
2810 case Bytecodes::_goto : _goto(s.cur_bci(), s.get_dest()); break;
2811 case Bytecodes::_jsr : jsr(s.get_dest()); break;
2812 case Bytecodes::_ret : ret(s.get_index()); break;
2813 case Bytecodes::_tableswitch : table_switch(); break;
2814 case Bytecodes::_lookupswitch : lookup_switch(); break;
2809 case Bytecodes::_ireturn : method_return(ipop()); break;
2810 case Bytecodes::_lreturn : method_return(lpop()); break;
2811 case Bytecodes::_freturn : method_return(fpop()); break;
2812 case Bytecodes::_dreturn : method_return(dpop()); break;
2813 case Bytecodes::_areturn : method_return(apop()); break;
2814 case Bytecodes::_return : method_return(NULL ); break;
2815 case Bytecodes::_ireturn : method_return(ipop(), ignore_return); break;
2816 case Bytecodes::_lreturn : method_return(lpop(), ignore_return); break;
2817 case Bytecodes::_freturn : method_return(fpop(), ignore_return); break;
2818 case Bytecodes::_dreturn : method_return(dpop(), ignore_return); break;
2819 case Bytecodes::_areturn : method_return(apop(), ignore_return); break;
2820 case Bytecodes::_return : method_return(NULL , ignore_return); break;
2815 case Bytecodes::_getstatic : // fall through
2816 case Bytecodes::_putstatic : // fall through
2817 case Bytecodes::_getfield : // fall through
2818 case Bytecodes::_putfield : access_field(code); break;
2819 case Bytecodes::_invokevirtual : // fall through
2820 case Bytecodes::_invokespecial : // fall through
2821 case Bytecodes::_invokestatic : // fall through
2822 case Bytecodes::_invokedynamic : // fall through

--- 508 unchanged lines hidden (view full) ---

3331 if (s->method() == cur_callee) {
3332 ++recur_level;
3333 }
3334 }
3335 return recur_level;
3336}
3337
3338
2821 case Bytecodes::_getstatic : // fall through
2822 case Bytecodes::_putstatic : // fall through
2823 case Bytecodes::_getfield : // fall through
2824 case Bytecodes::_putfield : access_field(code); break;
2825 case Bytecodes::_invokevirtual : // fall through
2826 case Bytecodes::_invokespecial : // fall through
2827 case Bytecodes::_invokestatic : // fall through
2828 case Bytecodes::_invokedynamic : // fall through

--- 508 unchanged lines hidden (view full) ---

3337 if (s->method() == cur_callee) {
3338 ++recur_level;
3339 }
3340 }
3341 return recur_level;
3342}
3343
3344
3339bool GraphBuilder::try_inline(ciMethod* callee, bool holder_known, Bytecodes::Code bc, Value receiver) {
3345bool GraphBuilder::try_inline(ciMethod* callee, bool holder_known, bool ignore_return, Bytecodes::Code bc, Value receiver) {
3340 const char* msg = NULL;
3341
3342 // clear out any existing inline bailout condition
3343 clear_inline_bailout();
3344
3345 // exclude methods we don't want to inline
3346 msg = should_not_inline(callee);
3347 if (msg != NULL) {
3348 print_inlining(callee, msg, /*success*/ false);
3349 return false;
3350 }
3351
3352 // method handle invokes
3353 if (callee->is_method_handle_intrinsic()) {
3346 const char* msg = NULL;
3347
3348 // clear out any existing inline bailout condition
3349 clear_inline_bailout();
3350
3351 // exclude methods we don't want to inline
3352 msg = should_not_inline(callee);
3353 if (msg != NULL) {
3354 print_inlining(callee, msg, /*success*/ false);
3355 return false;
3356 }
3357
3358 // method handle invokes
3359 if (callee->is_method_handle_intrinsic()) {
3354 if (try_method_handle_inline(callee)) {
3360 if (try_method_handle_inline(callee, ignore_return)) {
3355 if (callee->has_reserved_stack_access()) {
3356 compilation()->set_has_reserved_stack_access(true);
3357 }
3358 return true;
3359 }
3360 return false;
3361 }
3362
3363 // handle intrinsics
3364 if (callee->intrinsic_id() != vmIntrinsics::_none &&
3365 (CheckIntrinsics ? callee->intrinsic_candidate() : true)) {
3361 if (callee->has_reserved_stack_access()) {
3362 compilation()->set_has_reserved_stack_access(true);
3363 }
3364 return true;
3365 }
3366 return false;
3367 }
3368
3369 // handle intrinsics
3370 if (callee->intrinsic_id() != vmIntrinsics::_none &&
3371 (CheckIntrinsics ? callee->intrinsic_candidate() : true)) {
3366 if (try_inline_intrinsics(callee)) {
3372 if (try_inline_intrinsics(callee, ignore_return)) {
3367 print_inlining(callee, "intrinsic");
3368 if (callee->has_reserved_stack_access()) {
3369 compilation()->set_has_reserved_stack_access(true);
3370 }
3371 return true;
3372 }
3373 // try normal inlining
3374 }

--- 4 unchanged lines hidden (view full) ---

3379 print_inlining(callee, msg, /*success*/ false);
3380 return false;
3381 }
3382
3383 // If bytecode not set use the current one.
3384 if (bc == Bytecodes::_illegal) {
3385 bc = code();
3386 }
3373 print_inlining(callee, "intrinsic");
3374 if (callee->has_reserved_stack_access()) {
3375 compilation()->set_has_reserved_stack_access(true);
3376 }
3377 return true;
3378 }
3379 // try normal inlining
3380 }

--- 4 unchanged lines hidden (view full) ---

3385 print_inlining(callee, msg, /*success*/ false);
3386 return false;
3387 }
3388
3389 // If bytecode not set use the current one.
3390 if (bc == Bytecodes::_illegal) {
3391 bc = code();
3392 }
3387 if (try_inline_full(callee, holder_known, bc, receiver)) {
3393 if (try_inline_full(callee, holder_known, ignore_return, bc, receiver)) {
3388 if (callee->has_reserved_stack_access()) {
3389 compilation()->set_has_reserved_stack_access(true);
3390 }
3391 return true;
3392 }
3393
3394 // Entire compilation could fail during try_inline_full call.
3395 // In that case printing inlining decision info is useless.

--- 14 unchanged lines hidden (view full) ---

3410
3411// negative filter: should callee NOT be inlined? returns NULL, ok to inline, or rejection msg
3412const char* GraphBuilder::should_not_inline(ciMethod* callee) const {
3413 if ( compilation()->directive()->should_not_inline(callee)) return "disallowed by CompileCommand";
3414 if ( callee->dont_inline()) return "don't inline by annotation";
3415 return NULL;
3416}
3417
3394 if (callee->has_reserved_stack_access()) {
3395 compilation()->set_has_reserved_stack_access(true);
3396 }
3397 return true;
3398 }
3399
3400 // Entire compilation could fail during try_inline_full call.
3401 // In that case printing inlining decision info is useless.

--- 14 unchanged lines hidden (view full) ---

3416
3417// negative filter: should callee NOT be inlined? returns NULL, ok to inline, or rejection msg
3418const char* GraphBuilder::should_not_inline(ciMethod* callee) const {
3419 if ( compilation()->directive()->should_not_inline(callee)) return "disallowed by CompileCommand";
3420 if ( callee->dont_inline()) return "don't inline by annotation";
3421 return NULL;
3422}
3423
3418void GraphBuilder::build_graph_for_intrinsic(ciMethod* callee) {
3424void GraphBuilder::build_graph_for_intrinsic(ciMethod* callee, bool ignore_return) {
3419 vmIntrinsics::ID id = callee->intrinsic_id();
3420 assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
3421
3422 // Some intrinsics need special IR nodes.
3423 switch(id) {
3424 case vmIntrinsics::_getObject : append_unsafe_get_obj(callee, T_OBJECT, false); return;
3425 case vmIntrinsics::_getBoolean : append_unsafe_get_obj(callee, T_BOOLEAN, false); return;
3426 case vmIntrinsics::_getByte : append_unsafe_get_obj(callee, T_BYTE, false); return;

--- 77 unchanged lines hidden (view full) ---

3504 }
3505
3506 Intrinsic* result = new Intrinsic(result_type, callee->intrinsic_id(),
3507 args, has_receiver, state_before,
3508 vmIntrinsics::preserves_state(id),
3509 vmIntrinsics::can_trap(id));
3510 // append instruction & push result
3511 Value value = append_split(result);
3425 vmIntrinsics::ID id = callee->intrinsic_id();
3426 assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
3427
3428 // Some intrinsics need special IR nodes.
3429 switch(id) {
3430 case vmIntrinsics::_getObject : append_unsafe_get_obj(callee, T_OBJECT, false); return;
3431 case vmIntrinsics::_getBoolean : append_unsafe_get_obj(callee, T_BOOLEAN, false); return;
3432 case vmIntrinsics::_getByte : append_unsafe_get_obj(callee, T_BYTE, false); return;

--- 77 unchanged lines hidden (view full) ---

3510 }
3511
3512 Intrinsic* result = new Intrinsic(result_type, callee->intrinsic_id(),
3513 args, has_receiver, state_before,
3514 vmIntrinsics::preserves_state(id),
3515 vmIntrinsics::can_trap(id));
3516 // append instruction & push result
3517 Value value = append_split(result);
3512 if (result_type != voidType) push(result_type, value);
3518 if (result_type != voidType && !ignore_return) {
3519 push(result_type, value);
3520 }
3513
3514 if (callee != method() && profile_return() && result_type->is_object_kind()) {
3515 profile_return_type(result, callee);
3516 }
3517}
3518
3521
3522 if (callee != method() && profile_return() && result_type->is_object_kind()) {
3523 profile_return_type(result, callee);
3524 }
3525}
3526
3519bool GraphBuilder::try_inline_intrinsics(ciMethod* callee) {
3527bool GraphBuilder::try_inline_intrinsics(ciMethod* callee, bool ignore_return) {
3520 // For calling is_intrinsic_available we need to transition to
3521 // the '_thread_in_vm' state because is_intrinsic_available()
3522 // accesses critical VM-internal data.
3523 bool is_available = false;
3524 {
3525 VM_ENTRY_MARK;
3526 methodHandle mh(THREAD, callee->get_Method());
3527 is_available = _compilation->compiler()->is_intrinsic_available(mh, _compilation->directive());
3528 }
3529
3530 if (!is_available) {
3531 if (!InlineNatives) {
3532 // Return false and also set message that the inlining of
3533 // intrinsics has been disabled in general.
3534 INLINE_BAILOUT("intrinsic method inlining disabled");
3535 } else {
3536 return false;
3537 }
3538 }
3528 // For calling is_intrinsic_available we need to transition to
3529 // the '_thread_in_vm' state because is_intrinsic_available()
3530 // accesses critical VM-internal data.
3531 bool is_available = false;
3532 {
3533 VM_ENTRY_MARK;
3534 methodHandle mh(THREAD, callee->get_Method());
3535 is_available = _compilation->compiler()->is_intrinsic_available(mh, _compilation->directive());
3536 }
3537
3538 if (!is_available) {
3539 if (!InlineNatives) {
3540 // Return false and also set message that the inlining of
3541 // intrinsics has been disabled in general.
3542 INLINE_BAILOUT("intrinsic method inlining disabled");
3543 } else {
3544 return false;
3545 }
3546 }
3539 build_graph_for_intrinsic(callee);
3547 build_graph_for_intrinsic(callee, ignore_return);
3540 return true;
3541}
3542
3543
3544bool GraphBuilder::try_inline_jsr(int jsr_dest_bci) {
3545 // Introduce a new callee continuation point - all Ret instructions
3546 // will be replaced with Gotos to this point.
3547 BlockBegin* cont = block_at(next_bci());

--- 138 unchanged lines hidden (view full) ---

3686 block()->set_end(end);
3687
3688 _block = orig_block;
3689 _state = orig_state;
3690 _last = orig_last;
3691}
3692
3693
3548 return true;
3549}
3550
3551
3552bool GraphBuilder::try_inline_jsr(int jsr_dest_bci) {
3553 // Introduce a new callee continuation point - all Ret instructions
3554 // will be replaced with Gotos to this point.
3555 BlockBegin* cont = block_at(next_bci());

--- 138 unchanged lines hidden (view full) ---

3694 block()->set_end(end);
3695
3696 _block = orig_block;
3697 _state = orig_state;
3698 _last = orig_last;
3699}
3700
3701
3694bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, Bytecodes::Code bc, Value receiver) {
3702bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, bool ignore_return, Bytecodes::Code bc, Value receiver) {
3695 assert(!callee->is_native(), "callee must not be native");
3696 if (CompilationPolicy::policy()->should_not_inline(compilation()->env(), callee)) {
3697 INLINE_BAILOUT("inlining prohibited by policy");
3698 }
3699 // first perform tests of things it's not possible to inline
3700 if (callee->has_exception_handlers() &&
3701 !InlineMethodsWithExceptionHandlers) INLINE_BAILOUT("callee has exception handlers");
3702 if (callee->is_synchronized() &&

--- 181 unchanged lines hidden (view full) ---

3884
3885 _last = _block = callee_start_block;
3886
3887 scope_data()->add_to_work_list(callee_start_block);
3888 }
3889
3890 // Clear out bytecode stream
3891 scope_data()->set_stream(NULL);
3703 assert(!callee->is_native(), "callee must not be native");
3704 if (CompilationPolicy::policy()->should_not_inline(compilation()->env(), callee)) {
3705 INLINE_BAILOUT("inlining prohibited by policy");
3706 }
3707 // first perform tests of things it's not possible to inline
3708 if (callee->has_exception_handlers() &&
3709 !InlineMethodsWithExceptionHandlers) INLINE_BAILOUT("callee has exception handlers");
3710 if (callee->is_synchronized() &&

--- 181 unchanged lines hidden (view full) ---

3892
3893 _last = _block = callee_start_block;
3894
3895 scope_data()->add_to_work_list(callee_start_block);
3896 }
3897
3898 // Clear out bytecode stream
3899 scope_data()->set_stream(NULL);
3900 scope_data()->set_ignore_return(ignore_return);
3892
3893 CompileLog* log = compilation()->log();
3894 if (log != NULL) log->head("parse method='%d'", log->identify(callee));
3895
3896 // Ready to resume parsing in callee (either in the same block we
3897 // were in before or in the callee's start block)
3898 iterate_all_blocks(callee_start_block == NULL);
3899

--- 53 unchanged lines hidden (view full) ---

3953 }
3954
3955 compilation()->notice_inlined_method(callee);
3956
3957 return true;
3958}
3959
3960
3901
3902 CompileLog* log = compilation()->log();
3903 if (log != NULL) log->head("parse method='%d'", log->identify(callee));
3904
3905 // Ready to resume parsing in callee (either in the same block we
3906 // were in before or in the callee's start block)
3907 iterate_all_blocks(callee_start_block == NULL);
3908

--- 53 unchanged lines hidden (view full) ---

3962 }
3963
3964 compilation()->notice_inlined_method(callee);
3965
3966 return true;
3967}
3968
3969
3961bool GraphBuilder::try_method_handle_inline(ciMethod* callee) {
3970bool GraphBuilder::try_method_handle_inline(ciMethod* callee, bool ignore_return) {
3962 ValueStack* state_before = copy_state_before();
3963 vmIntrinsics::ID iid = callee->intrinsic_id();
3964 switch (iid) {
3965 case vmIntrinsics::_invokeBasic:
3966 {
3967 // get MethodHandle receiver
3968 const int args_base = state()->stack_size() - callee->arg_size();
3969 ValueType* type = state()->stack_at(args_base)->type();
3970 if (type->is_constant()) {
3971 ciMethod* target = type->as_ObjectType()->constant_value()->as_method_handle()->get_vmtarget();
3972 // We don't do CHA here so only inline static and statically bindable methods.
3973 if (target->is_static() || target->can_be_statically_bound()) {
3974 Bytecodes::Code bc = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual;
3971 ValueStack* state_before = copy_state_before();
3972 vmIntrinsics::ID iid = callee->intrinsic_id();
3973 switch (iid) {
3974 case vmIntrinsics::_invokeBasic:
3975 {
3976 // get MethodHandle receiver
3977 const int args_base = state()->stack_size() - callee->arg_size();
3978 ValueType* type = state()->stack_at(args_base)->type();
3979 if (type->is_constant()) {
3980 ciMethod* target = type->as_ObjectType()->constant_value()->as_method_handle()->get_vmtarget();
3981 // We don't do CHA here so only inline static and statically bindable methods.
3982 if (target->is_static() || target->can_be_statically_bound()) {
3983 Bytecodes::Code bc = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual;
3975 if (try_inline(target, /*holder_known*/ true, bc)) {
3984 ignore_return = ignore_return || (callee->return_type()->is_void() && !target->return_type()->is_void());
3985 if (try_inline(target, /*holder_known*/ true, ignore_return, bc)) {
3976 return true;
3977 }
3978 } else {
3979 print_inlining(target, "not static or statically bindable", /*success*/ false);
3980 }
3981 } else {
3982 print_inlining(callee, "receiver not constant", /*success*/ false);
3983 }

--- 5 unchanged lines hidden (view full) ---

3989 case vmIntrinsics::_linkToSpecial:
3990 case vmIntrinsics::_linkToInterface:
3991 {
3992 // pop MemberName argument
3993 const int args_base = state()->stack_size() - callee->arg_size();
3994 ValueType* type = apop()->type();
3995 if (type->is_constant()) {
3996 ciMethod* target = type->as_ObjectType()->constant_value()->as_member_name()->get_vmtarget();
3986 return true;
3987 }
3988 } else {
3989 print_inlining(target, "not static or statically bindable", /*success*/ false);
3990 }
3991 } else {
3992 print_inlining(callee, "receiver not constant", /*success*/ false);
3993 }

--- 5 unchanged lines hidden (view full) ---

3999 case vmIntrinsics::_linkToSpecial:
4000 case vmIntrinsics::_linkToInterface:
4001 {
4002 // pop MemberName argument
4003 const int args_base = state()->stack_size() - callee->arg_size();
4004 ValueType* type = apop()->type();
4005 if (type->is_constant()) {
4006 ciMethod* target = type->as_ObjectType()->constant_value()->as_member_name()->get_vmtarget();
4007 ignore_return = ignore_return || (callee->return_type()->is_void() && !target->return_type()->is_void());
3997 // If the target is another method handle invoke, try to recursively get
3998 // a better target.
3999 if (target->is_method_handle_intrinsic()) {
4008 // If the target is another method handle invoke, try to recursively get
4009 // a better target.
4010 if (target->is_method_handle_intrinsic()) {
4000 if (try_method_handle_inline(target)) {
4011 if (try_method_handle_inline(target, ignore_return)) {
4001 return true;
4002 }
4003 } else {
4004 ciSignature* signature = target->signature();
4005 const int receiver_skip = target->is_static() ? 0 : 1;
4006 // Cast receiver to its type.
4007 if (!target->is_static()) {
4008 ciKlass* tk = signature->accessing_klass();

--- 18 unchanged lines hidden (view full) ---

4027 state()->stack_at_put(args_base + receiver_skip + j, c);
4028 }
4029 }
4030 j += t->size(); // long and double take two slots
4031 }
4032 // We don't do CHA here so only inline static and statically bindable methods.
4033 if (target->is_static() || target->can_be_statically_bound()) {
4034 Bytecodes::Code bc = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual;
4012 return true;
4013 }
4014 } else {
4015 ciSignature* signature = target->signature();
4016 const int receiver_skip = target->is_static() ? 0 : 1;
4017 // Cast receiver to its type.
4018 if (!target->is_static()) {
4019 ciKlass* tk = signature->accessing_klass();

--- 18 unchanged lines hidden (view full) ---

4038 state()->stack_at_put(args_base + receiver_skip + j, c);
4039 }
4040 }
4041 j += t->size(); // long and double take two slots
4042 }
4043 // We don't do CHA here so only inline static and statically bindable methods.
4044 if (target->is_static() || target->can_be_statically_bound()) {
4045 Bytecodes::Code bc = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual;
4035 if (try_inline(target, /*holder_known*/ true, bc)) {
4046 if (try_inline(target, /*holder_known*/ true, ignore_return, bc)) {
4036 return true;
4037 }
4038 } else {
4039 print_inlining(target, "not static or statically bindable", /*success*/ false);
4040 }
4041 }
4042 } else {
4043 print_inlining(callee, "MemberName not constant", /*success*/ false);

--- 206 unchanged lines hidden (view full) ---

4250 log->inline_fail(msg);
4251 else
4252 log->inline_fail("reason unknown");
4253 }
4254 }
4255#if INCLUDE_TRACE
4256 EventCompilerInlining event;
4257 if (event.should_commit()) {
4047 return true;
4048 }
4049 } else {
4050 print_inlining(target, "not static or statically bindable", /*success*/ false);
4051 }
4052 }
4053 } else {
4054 print_inlining(callee, "MemberName not constant", /*success*/ false);

--- 206 unchanged lines hidden (view full) ---

4261 log->inline_fail(msg);
4262 else
4263 log->inline_fail("reason unknown");
4264 }
4265 }
4266#if INCLUDE_TRACE
4267 EventCompilerInlining event;
4268 if (event.should_commit()) {
4258 event.set_compileId(compilation()->env()->task()->compile_id());
4269 event.set_compileID(compilation()->env()->task()->compile_id());
4259 event.set_message(msg);
4260 event.set_succeeded(success);
4261 event.set_bci(bci());
4262 event.set_caller(method()->get_Method());
4263 event.set_callee(callee->to_trace_struct());
4264 event.commit();
4265 }
4266#endif // INCLUDE_TRACE

--- 61 unchanged lines hidden ---
4270 event.set_message(msg);
4271 event.set_succeeded(success);
4272 event.set_bci(bci());
4273 event.set_caller(method()->get_Method());
4274 event.set_callee(callee->to_trace_struct());
4275 event.commit();
4276 }
4277#endif // INCLUDE_TRACE

--- 61 unchanged lines hidden ---