Mercurial > hg > truffle
comparison src/share/vm/opto/graphKit.cpp @ 17731:62825ea7e51f
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, 14 Mar 2014 17:15:32 +0100 |
parents | b8413a9cbb84 |
children | 9ab9f254cfe2 |
comparison
equal
deleted
inserted
replaced
17728:b8413a9cbb84 | 17731:62825ea7e51f |
---|---|
2107 * @param exact_kls type from profiling | 2107 * @param exact_kls type from profiling |
2108 * | 2108 * |
2109 * @return node with improved type | 2109 * @return node with improved type |
2110 */ | 2110 */ |
2111 Node* GraphKit::record_profile_for_speculation(Node* n, ciKlass* exact_kls) { | 2111 Node* GraphKit::record_profile_for_speculation(Node* n, ciKlass* exact_kls) { |
2112 const TypeOopPtr* current_type = _gvn.type(n)->isa_oopptr(); | 2112 const Type* current_type = _gvn.type(n); |
2113 assert(UseTypeSpeculation, "type speculation must be on"); | 2113 assert(UseTypeSpeculation, "type speculation must be on"); |
2114 if (exact_kls != NULL && | 2114 |
2115 // nothing to improve if type is already exact | 2115 const TypeOopPtr* speculative = current_type->speculative(); |
2116 (current_type == NULL || | 2116 |
2117 (!current_type->klass_is_exact() && | 2117 if (current_type->would_improve_type(exact_kls, jvms()->depth())) { |
2118 (current_type->speculative() == NULL || | |
2119 !current_type->speculative()->klass_is_exact())))) { | |
2120 const TypeKlassPtr* tklass = TypeKlassPtr::make(exact_kls); | 2118 const TypeKlassPtr* tklass = TypeKlassPtr::make(exact_kls); |
2121 const TypeOopPtr* xtype = tklass->as_instance_type(); | 2119 const TypeOopPtr* xtype = tklass->as_instance_type(); |
2122 assert(xtype->klass_is_exact(), "Should be exact"); | 2120 assert(xtype->klass_is_exact(), "Should be exact"); |
2123 | 2121 // record the new speculative type's depth |
2122 speculative = xtype->with_inline_depth(jvms()->depth()); | |
2123 } | |
2124 | |
2125 if (speculative != current_type->speculative()) { | |
2124 // Build a type with a speculative type (what we think we know | 2126 // Build a type with a speculative type (what we think we know |
2125 // about the type but will need a guard when we use it) | 2127 // about the type but will need a guard when we use it) |
2126 const TypeOopPtr* spec_type = TypeOopPtr::make(TypePtr::BotPTR, Type::OffsetBot, TypeOopPtr::InstanceBot, xtype); | 2128 const TypeOopPtr* spec_type = TypeOopPtr::make(TypePtr::BotPTR, Type::OffsetBot, TypeOopPtr::InstanceBot, speculative); |
2127 // We're changing the type, we need a new cast node to carry the | 2129 // We're changing the type, we need a new CheckCast node to carry |
2128 // new type. The new type depends on the control: what profiling | 2130 // the new type. The new type depends on the control: what |
2129 // tells us is only valid from here as far as we can tell. | 2131 // profiling tells us is only valid from here as far as we can |
2130 Node* cast = new(C) CastPPNode(n, spec_type); | 2132 // tell. |
2131 cast->init_req(0, control()); | 2133 Node* cast = new(C) CheckCastPPNode(control(), n, current_type->remove_speculative()->join_speculative(spec_type)); |
2132 cast = _gvn.transform(cast); | 2134 cast = _gvn.transform(cast); |
2133 replace_in_map(n, cast); | 2135 replace_in_map(n, cast); |
2134 n = cast; | 2136 n = cast; |
2135 } | 2137 } |
2138 | |
2136 return n; | 2139 return n; |
2137 } | 2140 } |
2138 | 2141 |
2139 /** | 2142 /** |
2140 * Record profiling data from receiver profiling at an invoke with the | 2143 * Record profiling data from receiver profiling at an invoke with the |