comparison src/share/vm/opto/graphKit.cpp @ 14512:484a359ff649

8031754: Type speculation should favor profile data from outermost inlined method Summary: favor profile data coming from outer most method Reviewed-by: kvn, twisti
author roland
date Fri, 28 Feb 2014 13:44:16 +0100
parents fdad2932c73f
children 16c705d792be
comparison
equal deleted inserted replaced
14511:7e8e4d1a41d6 14512:484a359ff649
2111 * @param exact_kls type from profiling 2111 * @param exact_kls type from profiling
2112 * 2112 *
2113 * @return node with improved type 2113 * @return node with improved type
2114 */ 2114 */
2115 Node* GraphKit::record_profile_for_speculation(Node* n, ciKlass* exact_kls) { 2115 Node* GraphKit::record_profile_for_speculation(Node* n, ciKlass* exact_kls) {
2116 const TypeOopPtr* current_type = _gvn.type(n)->isa_oopptr(); 2116 const Type* current_type = _gvn.type(n);
2117 assert(UseTypeSpeculation, "type speculation must be on"); 2117 assert(UseTypeSpeculation, "type speculation must be on");
2118 if (exact_kls != NULL && 2118
2119 // nothing to improve if type is already exact 2119 const TypeOopPtr* speculative = current_type->speculative();
2120 (current_type == NULL || 2120
2121 (!current_type->klass_is_exact() && 2121 if (current_type->would_improve_type(exact_kls, jvms()->depth())) {
2122 (current_type->speculative() == NULL ||
2123 !current_type->speculative()->klass_is_exact())))) {
2124 const TypeKlassPtr* tklass = TypeKlassPtr::make(exact_kls); 2122 const TypeKlassPtr* tklass = TypeKlassPtr::make(exact_kls);
2125 const TypeOopPtr* xtype = tklass->as_instance_type(); 2123 const TypeOopPtr* xtype = tklass->as_instance_type();
2126 assert(xtype->klass_is_exact(), "Should be exact"); 2124 assert(xtype->klass_is_exact(), "Should be exact");
2127 2125 // record the new speculative type's depth
2126 speculative = xtype->with_inline_depth(jvms()->depth());
2127 }
2128
2129 if (speculative != current_type->speculative()) {
2128 // Build a type with a speculative type (what we think we know 2130 // Build a type with a speculative type (what we think we know
2129 // about the type but will need a guard when we use it) 2131 // about the type but will need a guard when we use it)
2130 const TypeOopPtr* spec_type = TypeOopPtr::make(TypePtr::BotPTR, Type::OffsetBot, TypeOopPtr::InstanceBot, xtype); 2132 const TypeOopPtr* spec_type = TypeOopPtr::make(TypePtr::BotPTR, Type::OffsetBot, TypeOopPtr::InstanceBot, speculative);
2131 // We're changing the type, we need a new cast node to carry the 2133 // We're changing the type, we need a new CheckCast node to carry
2132 // new type. The new type depends on the control: what profiling 2134 // the new type. The new type depends on the control: what
2133 // tells us is only valid from here as far as we can tell. 2135 // profiling tells us is only valid from here as far as we can
2134 Node* cast = new(C) CastPPNode(n, spec_type); 2136 // tell.
2135 cast->init_req(0, control()); 2137 Node* cast = new(C) CheckCastPPNode(control(), n, current_type->remove_speculative()->join_speculative(spec_type));
2136 cast = _gvn.transform(cast); 2138 cast = _gvn.transform(cast);
2137 replace_in_map(n, cast); 2139 replace_in_map(n, cast);
2138 n = cast; 2140 n = cast;
2139 } 2141 }
2142
2140 return n; 2143 return n;
2141 } 2144 }
2142 2145
2143 /** 2146 /**
2144 * Record profiling data from receiver profiling at an invoke with the 2147 * Record profiling data from receiver profiling at an invoke with the