Mon, 22 Oct 2012 16:56:03 -0700
8000821: JSR 292: C1 fails to call virtual method (JRUBY-6920)
Reviewed-by: kvn
src/share/vm/c1/c1_GraphBuilder.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp Mon Oct 22 11:44:30 2012 -0700 1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Mon Oct 22 16:56:03 2012 -0700 1.3 @@ -1844,17 +1844,12 @@ 1.4 code == Bytecodes::_invokevirtual && target->is_final_method() || 1.5 code == Bytecodes::_invokedynamic) { 1.6 ciMethod* inline_target = (cha_monomorphic_target != NULL) ? cha_monomorphic_target : target; 1.7 - bool success = false; 1.8 - if (target->is_method_handle_intrinsic()) { 1.9 - // method handle invokes 1.10 - success = try_method_handle_inline(target); 1.11 - } else { 1.12 - // static binding => check if callee is ok 1.13 - success = try_inline(inline_target, (cha_monomorphic_target != NULL) || (exact_target != NULL), code, better_receiver); 1.14 - } 1.15 + // static binding => check if callee is ok 1.16 + bool success = try_inline(inline_target, (cha_monomorphic_target != NULL) || (exact_target != NULL), code, better_receiver); 1.17 + 1.18 CHECK_BAILOUT(); 1.19 - 1.20 clear_inline_bailout(); 1.21 + 1.22 if (success) { 1.23 // Register dependence if JVMTI has either breakpoint 1.24 // setting or hotswapping of methods capabilities since they may 1.25 @@ -3201,6 +3196,11 @@ 1.26 return false; 1.27 } 1.28 1.29 + // method handle invokes 1.30 + if (callee->is_method_handle_intrinsic()) { 1.31 + return try_method_handle_inline(callee); 1.32 + } 1.33 + 1.34 // handle intrinsics 1.35 if (callee->intrinsic_id() != vmIntrinsics::_none) { 1.36 if (try_inline_intrinsics(callee)) { 1.37 @@ -3885,10 +3885,14 @@ 1.38 ValueType* type = state()->stack_at(args_base)->type(); 1.39 if (type->is_constant()) { 1.40 ciMethod* target = type->as_ObjectType()->constant_value()->as_method_handle()->get_vmtarget(); 1.41 - guarantee(!target->is_method_handle_intrinsic(), "should not happen"); // XXX remove 1.42 - Bytecodes::Code bc = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual; 1.43 - if (try_inline(target, /*holder_known*/ true, bc)) { 1.44 - return true; 1.45 + // We don't do CHA here so only inline static and statically bindable methods. 1.46 + if (target->is_static() || target->can_be_statically_bound()) { 1.47 + Bytecodes::Code bc = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual; 1.48 + if (try_inline(target, /*holder_known*/ true, bc)) { 1.49 + return true; 1.50 + } 1.51 + } else { 1.52 + print_inlining(target, "not static or statically bindable", /*success*/ false); 1.53 } 1.54 } else { 1.55 print_inlining(callee, "receiver not constant", /*success*/ false); 1.56 @@ -3941,9 +3945,14 @@ 1.57 } 1.58 j += t->size(); // long and double take two slots 1.59 } 1.60 - Bytecodes::Code bc = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual; 1.61 - if (try_inline(target, /*holder_known*/ true, bc)) { 1.62 - return true; 1.63 + // We don't do CHA here so only inline static and statically bindable methods. 1.64 + if (target->is_static() || target->can_be_statically_bound()) { 1.65 + Bytecodes::Code bc = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual; 1.66 + if (try_inline(target, /*holder_known*/ true, bc)) { 1.67 + return true; 1.68 + } 1.69 + } else { 1.70 + print_inlining(target, "not static or statically bindable", /*success*/ false); 1.71 } 1.72 } 1.73 } else {