1.1 --- a/src/share/vm/opto/callGenerator.cpp Fri Sep 02 04:28:59 2011 -0700 1.2 +++ b/src/share/vm/opto/callGenerator.cpp Fri Sep 02 20:58:21 2011 -0700 1.3 @@ -149,7 +149,6 @@ 1.4 call->set_optimized_virtual(true); 1.5 if (method()->is_method_handle_invoke()) { 1.6 call->set_method_handle_invoke(true); 1.7 - kit.C->set_has_method_handle_invokes(true); 1.8 } 1.9 } 1.10 kit.set_arguments_for_java_call(call); 1.11 @@ -207,7 +206,6 @@ 1.12 call->set_optimized_virtual(true); 1.13 // Take extra care (in the presence of argument motion) not to trash the SP: 1.14 call->set_method_handle_invoke(true); 1.15 - kit.C->set_has_method_handle_invokes(true); 1.16 1.17 // Pass the target MethodHandle as first argument and shift the 1.18 // other arguments. 1.19 @@ -706,18 +704,30 @@ 1.20 } 1.21 } else if (method_handle->Opcode() == Op_Phi && method_handle->req() == 3 && 1.22 method_handle->in(1)->Opcode() == Op_ConP && method_handle->in(2)->Opcode() == Op_ConP) { 1.23 + float prob = PROB_FAIR; 1.24 + Node* meth_region = method_handle->in(0); 1.25 + if (meth_region->is_Region() && 1.26 + meth_region->in(1)->is_Proj() && meth_region->in(2)->is_Proj() && 1.27 + meth_region->in(1)->in(0) == meth_region->in(2)->in(0) && 1.28 + meth_region->in(1)->in(0)->is_If()) { 1.29 + // If diamond, so grab the probability of the test to drive the inlining below 1.30 + prob = meth_region->in(1)->in(0)->as_If()->_prob; 1.31 + if (meth_region->in(1)->is_IfTrue()) { 1.32 + prob = 1 - prob; 1.33 + } 1.34 + } 1.35 + 1.36 // selectAlternative idiom merging two constant MethodHandles. 1.37 // Generate a guard so that each can be inlined. We might want to 1.38 // do more inputs at later point but this gets the most common 1.39 // case. 1.40 - const TypeOopPtr* oop_ptr = method_handle->in(1)->bottom_type()->is_oopptr(); 1.41 - ciObject* const_oop = oop_ptr->const_oop(); 1.42 - ciMethodHandle* mh = const_oop->as_method_handle(); 1.43 - 1.44 - CallGenerator* cg1 = for_method_handle_inline(method_handle->in(1), jvms, caller, callee, profile); 1.45 - CallGenerator* cg2 = for_method_handle_inline(method_handle->in(2), jvms, caller, callee, profile); 1.46 + CallGenerator* cg1 = for_method_handle_inline(method_handle->in(1), jvms, caller, callee, profile.rescale(1.0 - prob)); 1.47 + CallGenerator* cg2 = for_method_handle_inline(method_handle->in(2), jvms, caller, callee, profile.rescale(prob)); 1.48 if (cg1 != NULL && cg2 != NULL) { 1.49 - return new PredictedDynamicCallGenerator(mh, cg2, cg1, PROB_FAIR); 1.50 + const TypeOopPtr* oop_ptr = method_handle->in(1)->bottom_type()->is_oopptr(); 1.51 + ciObject* const_oop = oop_ptr->const_oop(); 1.52 + ciMethodHandle* mh = const_oop->as_method_handle(); 1.53 + return new PredictedDynamicCallGenerator(mh, cg2, cg1, prob); 1.54 } 1.55 } 1.56 return NULL;