src/share/vm/opto/graphKit.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/graphKit.cpp

Print this page
rev 5771 : 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
Summary: type methods shouldn't always operate on speculative part
Reviewed-by:
rev 5772 : imported patch typefixes-8027422-chris
rev 5774 : 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
Summary: support for speculative traps that keep track of the root of the compilation in which a trap occurs.
Reviewed-by:
rev 5777 : 8031754: Type speculation should favor profile data from outermost inlined method
Summary: favor profile data coming from outer most method
Reviewed-by:


2092     if( targ->basic_type() == T_DOUBLE ) {
2093       // If any parameters are doubles, they must be rounded before
2094       // the call, dstore_rounding does gvn.transform
2095       Node *arg = argument(j);
2096       arg = dstore_rounding(arg);
2097       set_argument(j, arg);
2098     }
2099   }
2100 }
2101 
2102 /**
2103  * Record profiling data exact_kls for Node n with the type system so
2104  * that it can propagate it (speculation)
2105  *
2106  * @param n          node that the type applies to
2107  * @param exact_kls  type from profiling
2108  *
2109  * @return           node with improved type
2110  */
2111 Node* GraphKit::record_profile_for_speculation(Node* n, ciKlass* exact_kls) {
2112   const TypeOopPtr* current_type = _gvn.type(n)->isa_oopptr();
2113   assert(UseTypeSpeculation, "type speculation must be on");
2114   if (exact_kls != NULL &&
2115       // nothing to improve if type is already exact
2116       (current_type == NULL ||
2117        (!current_type->klass_is_exact() &&
2118         (current_type->speculative() == NULL ||
2119          !current_type->speculative()->klass_is_exact())))) {








2120     const TypeKlassPtr* tklass = TypeKlassPtr::make(exact_kls);
2121     const TypeOopPtr* xtype = tklass->as_instance_type();
2122     assert(xtype->klass_is_exact(), "Should be exact");




2123 

2124     // 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)
2126     const TypeOopPtr* spec_type = TypeOopPtr::make(TypePtr::BotPTR, Type::OffsetBot, TypeOopPtr::InstanceBot, xtype);
2127     // We're changing the type, we need a new cast node to carry the
2128     // new type. The new type depends on the control: what profiling
2129     // tells us is only valid from here as far as we can tell.
2130     Node* cast = new(C) CastPPNode(n, spec_type);
2131     cast->init_req(0, control());
2132     cast = _gvn.transform(cast);
2133     replace_in_map(n, cast);
2134     n = cast;
2135   }

2136   return n;
2137 }
2138 
2139 /**
2140  * Record profiling data from receiver profiling at an invoke with the
2141  * type system so that it can propagate it (speculation)
2142  *
2143  * @param n  receiver node
2144  *
2145  * @return   node with improved type
2146  */
2147 Node* GraphKit::record_profiled_receiver_for_speculation(Node* n) {
2148   if (!UseTypeSpeculation) {
2149     return n;
2150   }
2151   ciKlass* exact_kls = profile_has_unique_klass();
2152   return record_profile_for_speculation(n, exact_kls);
2153 }
2154 
2155 /**




2092     if( targ->basic_type() == T_DOUBLE ) {
2093       // If any parameters are doubles, they must be rounded before
2094       // the call, dstore_rounding does gvn.transform
2095       Node *arg = argument(j);
2096       arg = dstore_rounding(arg);
2097       set_argument(j, arg);
2098     }
2099   }
2100 }
2101 
2102 /**
2103  * Record profiling data exact_kls for Node n with the type system so
2104  * that it can propagate it (speculation)
2105  *
2106  * @param n          node that the type applies to
2107  * @param exact_kls  type from profiling
2108  *
2109  * @return           node with improved type
2110  */
2111 Node* GraphKit::record_profile_for_speculation(Node* n, ciKlass* exact_kls) {
2112   const Type* current_type = _gvn.type(n);
2113   assert(UseTypeSpeculation, "type speculation must be on");
2114 
2115   // nothing to improve if type is already exact
2116   bool do_klass = current_type->isa_oopptr() == NULL || !current_type->is_oopptr()->klass_is_exact();
2117 
2118   const TypeOopPtr* speculative = current_type->speculative();
2119 
2120   // If the node already has an exact speculative type keep it, unless
2121   // it was provided by profiling that is at a deeper inlining
2122   // level. Profiling at a higher inlining depth is expected to be
2123   // less accurate.
2124   if (do_klass &&
2125       (current_type->speculative_type() == NULL ||
2126        ((int)jvms()->depth()) < current_type->speculative()->inline_depth())) {
2127     if (exact_kls != NULL) {
2128       const TypeKlassPtr* tklass = TypeKlassPtr::make(exact_kls);
2129       const TypeOopPtr* xtype = tklass->as_instance_type();
2130       assert(xtype->klass_is_exact(), "Should be exact");
2131       // record the new speculative type's depth
2132       speculative = xtype->with_inline_depth(jvms()->depth());
2133     }
2134   }
2135 
2136   if (speculative != current_type->speculative()) {
2137     // Build a type with a speculative type (what we think we know
2138     // about the type but will need a guard when we use it)
2139     const TypeOopPtr* spec_type = TypeOopPtr::make(TypePtr::BotPTR, Type::OffsetBot, TypeOopPtr::InstanceBot, speculative);
2140     // We're changing the type, we need a new CheckCast node to carry
2141     // the new type. The new type depends on the control: what
2142     // profiling tells us is only valid from here as far as we can
2143     // tell.
2144     Node* cast = new(C) CheckCastPPNode(control(), n, current_type->remove_speculative()->join_speculative(spec_type));
2145     cast = _gvn.transform(cast);
2146     replace_in_map(n, cast);
2147     n = cast;
2148   }
2149   
2150   return n;
2151 }
2152 
2153 /**
2154  * Record profiling data from receiver profiling at an invoke with the
2155  * type system so that it can propagate it (speculation)
2156  *
2157  * @param n  receiver node
2158  *
2159  * @return   node with improved type
2160  */
2161 Node* GraphKit::record_profiled_receiver_for_speculation(Node* n) {
2162   if (!UseTypeSpeculation) {
2163     return n;
2164   }
2165   ciKlass* exact_kls = profile_has_unique_klass();
2166   return record_profile_for_speculation(n, exact_kls);
2167 }
2168 
2169 /**


src/share/vm/opto/graphKit.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File