| 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 return HasUses() ? this : NULL; | 1189 return HasUses() ? this : NULL; |
| 1190 } | 1190 } |
| 1191 | 1191 |
| 1192 | 1192 |
| 1193 Definition* LoadFieldInstr::Canonicalize(FlowGraphOptimizer* optimizer) { | 1193 Definition* LoadFieldInstr::Canonicalize(FlowGraphOptimizer* optimizer) { |
| 1194 if (!IsImmutableLengthLoad()) return this; | 1194 if (!IsImmutableLengthLoad()) return this; |
| 1195 | 1195 |
| 1196 // For fixed length arrays if the array is the result of a known constructor | 1196 // For fixed length arrays if the array is the result of a known constructor |
| 1197 // call we can replace the length load with the length argument passed to | 1197 // call we can replace the length load with the length argument passed to |
| 1198 // the constructor. | 1198 // the constructor. |
| 1199 StaticCallInstr* call = value()->definition()->AsStaticCall(); | 1199 StaticCallInstr* call = instance()->definition()->AsStaticCall(); |
| 1200 if ((call != NULL) && | 1200 if ((call != NULL) && |
| 1201 call->is_known_list_constructor() && | 1201 call->is_known_list_constructor() && |
| 1202 IsFixedLengthArrayCid(call->Type()->ToCid())) { | 1202 IsFixedLengthArrayCid(call->Type()->ToCid())) { |
| 1203 return call->ArgumentAt(1); | 1203 return call->ArgumentAt(1); |
| 1204 } | 1204 } |
| 1205 return this; | 1205 return this; |
| 1206 } | 1206 } |
| 1207 | 1207 |
| 1208 | 1208 |
| 1209 Definition* AssertBooleanInstr::Canonicalize(FlowGraphOptimizer* optimizer) { | 1209 Definition* AssertBooleanInstr::Canonicalize(FlowGraphOptimizer* optimizer) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1238 ConstantInstr* null_constant = new ConstantInstr(Object::ZoneHandle()); | 1238 ConstantInstr* null_constant = new ConstantInstr(Object::ZoneHandle()); |
| 1239 // It is ok to insert instructions before the current during | 1239 // It is ok to insert instructions before the current during |
| 1240 // forward iteration. | 1240 // forward iteration. |
| 1241 optimizer->InsertBefore(this, null_constant, NULL, Definition::kValue); | 1241 optimizer->InsertBefore(this, null_constant, NULL, Definition::kValue); |
| 1242 instantiator_type_arguments()->BindTo(null_constant); | 1242 instantiator_type_arguments()->BindTo(null_constant); |
| 1243 } | 1243 } |
| 1244 return this; | 1244 return this; |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 | 1247 |
| 1248 Definition* BoxDoubleInstr::Canonicalize(FlowGraphOptimizer* optimizer) { |
| 1249 if (input_use_list() == NULL) { |
| 1250 // Environments can accomodate any representation. No need to box. |
| 1251 return value()->definition(); |
| 1252 } |
| 1253 |
| 1254 // Fold away BoxDouble(UnboxDouble(v)) if value is known to be double. |
| 1255 UnboxDoubleInstr* defn = value()->definition()->AsUnboxDouble(); |
| 1256 if ((defn != NULL) && (defn->value()->Type()->ToCid() == kDoubleCid)) { |
| 1257 return defn->value()->definition(); |
| 1258 } |
| 1259 |
| 1260 return this; |
| 1261 } |
| 1262 |
| 1263 |
| 1264 Definition* UnboxDoubleInstr::Canonicalize(FlowGraphOptimizer* optimizer) { |
| 1265 // Fold away UnboxDouble(BoxDouble(v)). |
| 1266 BoxDoubleInstr* defn = value()->definition()->AsBoxDouble(); |
| 1267 return (defn != NULL) ? defn->value()->definition() : this; |
| 1268 } |
| 1269 |
| 1270 |
| 1248 Instruction* BranchInstr::Canonicalize(FlowGraphOptimizer* optimizer) { | 1271 Instruction* BranchInstr::Canonicalize(FlowGraphOptimizer* optimizer) { |
| 1249 // Only handle strict-compares. | 1272 // Only handle strict-compares. |
| 1250 if (comparison()->IsStrictCompare()) { | 1273 if (comparison()->IsStrictCompare()) { |
| 1251 Definition* replacement = comparison()->Canonicalize(optimizer); | 1274 Definition* replacement = comparison()->Canonicalize(optimizer); |
| 1252 if ((replacement == comparison()) || (replacement == NULL)) { | 1275 if ((replacement == comparison()) || (replacement == NULL)) { |
| 1253 return this; | 1276 return this; |
| 1254 } | 1277 } |
| 1255 ComparisonInstr* comp = replacement->AsComparison(); | 1278 ComparisonInstr* comp = replacement->AsComparison(); |
| 1256 if ((comp == NULL) || comp->CanDeoptimize()) { | 1279 if ((comp == NULL) || comp->CanDeoptimize()) { |
| 1257 return this; | 1280 return this; |
| (...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2393 default: | 2416 default: |
| 2394 UNREACHABLE(); | 2417 UNREACHABLE(); |
| 2395 } | 2418 } |
| 2396 return kPowRuntimeEntry; | 2419 return kPowRuntimeEntry; |
| 2397 } | 2420 } |
| 2398 | 2421 |
| 2399 | 2422 |
| 2400 #undef __ | 2423 #undef __ |
| 2401 | 2424 |
| 2402 } // namespace dart | 2425 } // namespace dart |
| OLD | NEW |