OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/aot_optimizer.h" | 5 #include "vm/aot_optimizer.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/branch_optimizer.h" | 8 #include "vm/branch_optimizer.h" |
9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2141 return false; | 2141 return false; |
2142 } | 2142 } |
2143 | 2143 |
2144 return true; // May deoptimize since we have not identified all 'true' tests. | 2144 return true; // May deoptimize since we have not identified all 'true' tests. |
2145 } | 2145 } |
2146 | 2146 |
2147 | 2147 |
2148 // TODO(srdjan): Use ICData to check if always true or false. | 2148 // TODO(srdjan): Use ICData to check if always true or false. |
2149 void AotOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) { | 2149 void AotOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) { |
2150 ASSERT(Token::IsTypeTestOperator(call->token_kind())); | 2150 ASSERT(Token::IsTypeTestOperator(call->token_kind())); |
| 2151 // Guard against repeated speculative inlining. |
| 2152 if (!use_speculative_inlining_ || |
| 2153 IsBlackListedForInlining(call->deopt_id())) { |
| 2154 return; |
| 2155 } |
2151 Definition* left = call->ArgumentAt(0); | 2156 Definition* left = call->ArgumentAt(0); |
2152 Definition* type_args = NULL; | 2157 Definition* type_args = NULL; |
2153 AbstractType& type = AbstractType::ZoneHandle(Z); | 2158 AbstractType& type = AbstractType::ZoneHandle(Z); |
2154 bool negate = false; | 2159 bool negate = false; |
2155 if (call->ArgumentCount() == 2) { | 2160 if (call->ArgumentCount() == 2) { |
2156 type_args = flow_graph()->constant_null(); | 2161 type_args = flow_graph()->constant_null(); |
2157 if (call->function_name().raw() == | 2162 if (call->function_name().raw() == |
2158 Library::PrivateCoreLibName(Symbols::_instanceOfNum()).raw()) { | 2163 Library::PrivateCoreLibName(Symbols::_instanceOfNum()).raw()) { |
2159 type = Type::Number(); | 2164 type = Type::Number(); |
2160 } else if (call->function_name().raw() == | 2165 } else if (call->function_name().raw() == |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2249 type, | 2254 type, |
2250 negate, | 2255 negate, |
2251 call->deopt_id()); | 2256 call->deopt_id()); |
2252 ReplaceCall(call, instance_of); | 2257 ReplaceCall(call, instance_of); |
2253 } | 2258 } |
2254 | 2259 |
2255 | 2260 |
2256 // TODO(srdjan): Apply optimizations as in ReplaceWithInstanceOf (TestCids). | 2261 // TODO(srdjan): Apply optimizations as in ReplaceWithInstanceOf (TestCids). |
2257 void AotOptimizer::ReplaceWithTypeCast(InstanceCallInstr* call) { | 2262 void AotOptimizer::ReplaceWithTypeCast(InstanceCallInstr* call) { |
2258 ASSERT(Token::IsTypeCastOperator(call->token_kind())); | 2263 ASSERT(Token::IsTypeCastOperator(call->token_kind())); |
| 2264 // Guard against repeated speculative inlining. |
| 2265 if (!use_speculative_inlining_ || |
| 2266 IsBlackListedForInlining(call->deopt_id())) { |
| 2267 return; |
| 2268 } |
2259 Definition* left = call->ArgumentAt(0); | 2269 Definition* left = call->ArgumentAt(0); |
2260 Definition* type_args = call->ArgumentAt(1); | 2270 Definition* type_args = call->ArgumentAt(1); |
2261 const AbstractType& type = | 2271 const AbstractType& type = |
2262 AbstractType::Cast(call->ArgumentAt(2)->AsConstant()->value()); | 2272 AbstractType::Cast(call->ArgumentAt(2)->AsConstant()->value()); |
2263 ASSERT(!type.IsMalformedOrMalbounded()); | 2273 ASSERT(!type.IsMalformedOrMalbounded()); |
2264 const ICData& unary_checks = | 2274 const ICData& unary_checks = |
2265 ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecks()); | 2275 ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecks()); |
2266 if ((unary_checks.NumberOfChecks() > 0) && | 2276 if ((unary_checks.NumberOfChecks() > 0) && |
2267 (unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks)) { | 2277 (unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks)) { |
2268 ZoneGrowableArray<intptr_t>* results = | 2278 ZoneGrowableArray<intptr_t>* results = |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2776 | 2786 |
2777 // Discard the environment from the original instruction because the store | 2787 // Discard the environment from the original instruction because the store |
2778 // can't deoptimize. | 2788 // can't deoptimize. |
2779 instr->RemoveEnvironment(); | 2789 instr->RemoveEnvironment(); |
2780 ReplaceCall(instr, store); | 2790 ReplaceCall(instr, store); |
2781 return true; | 2791 return true; |
2782 } | 2792 } |
2783 | 2793 |
2784 | 2794 |
2785 } // namespace dart | 2795 } // namespace dart |
OLD | NEW |