| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 Instruction* Instruction::Canonicalize() { | 1329 Instruction* Instruction::Canonicalize() { |
| 1330 return this; | 1330 return this; |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 | 1333 |
| 1334 Definition* Definition::Canonicalize() { | 1334 Definition* Definition::Canonicalize() { |
| 1335 return this; | 1335 return this; |
| 1336 } | 1336 } |
| 1337 | 1337 |
| 1338 | 1338 |
| 1339 Definition* AssertBooleanInstr::Canonicalize() { |
| 1340 const intptr_t value_cid = value()->ResultCid(); |
| 1341 return (value_cid == kBoolCid) ? value()->definition() : this; |
| 1342 } |
| 1343 |
| 1344 |
| 1339 Definition* StrictCompareInstr::Canonicalize() { | 1345 Definition* StrictCompareInstr::Canonicalize() { |
| 1340 if (!right()->BindsToConstant()) return this; | 1346 if (!right()->BindsToConstant()) return this; |
| 1341 const Object& right_constant = right()->BoundConstant(); | 1347 const Object& right_constant = right()->BoundConstant(); |
| 1342 Definition* left_defn = left()->definition(); | 1348 Definition* left_defn = left()->definition(); |
| 1343 // TODO(fschneider): Handle other cases: e === false and e !== true/false. | 1349 // TODO(fschneider): Handle other cases: e === false and e !== true/false. |
| 1344 // Handles e === true. | 1350 // Handles e === true. |
| 1345 if ((kind() == Token::kEQ_STRICT) && | 1351 if ((kind() == Token::kEQ_STRICT) && |
| 1346 (right_constant.raw() == Bool::True()) && | 1352 (right_constant.raw() == Bool::True()) && |
| 1347 (left()->ResultCid() == kBoolCid)) { | 1353 (left()->ResultCid() == kBoolCid)) { |
| 1348 // Return left subexpression as the replacement for this instruction. | 1354 // Return left subexpression as the replacement for this instruction. |
| 1349 return left_defn; | 1355 return left_defn; |
| 1350 } | 1356 } |
| 1351 return this; | 1357 return this; |
| 1352 } | 1358 } |
| 1353 | 1359 |
| 1354 | 1360 |
| 1355 Instruction* CheckClassInstr::Canonicalize() { | 1361 Instruction* CheckClassInstr::Canonicalize() { |
| 1356 const intptr_t v_cid = value()->ResultCid(); | 1362 const intptr_t value_cid = value()->ResultCid(); |
| 1357 const intptr_t num_checks = unary_checks().NumberOfChecks(); | 1363 const intptr_t num_checks = unary_checks().NumberOfChecks(); |
| 1358 if ((num_checks == 1) && | 1364 if ((num_checks == 1) && |
| 1359 (v_cid == unary_checks().GetReceiverClassIdAt(0))) { | 1365 (value_cid == unary_checks().GetReceiverClassIdAt(0))) { |
| 1360 // No checks needed. | 1366 // No checks needed. |
| 1361 return NULL; | 1367 return NULL; |
| 1362 } | 1368 } |
| 1363 return this; | 1369 return this; |
| 1364 } | 1370 } |
| 1365 | 1371 |
| 1366 | 1372 |
| 1367 Instruction* CheckSmiInstr::Canonicalize() { | 1373 Instruction* CheckSmiInstr::Canonicalize() { |
| 1368 return (value()->ResultCid() == kSmiCid) ? NULL : this; | 1374 return (value()->ResultCid() == kSmiCid) ? NULL : this; |
| 1369 } | 1375 } |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2086 new_max = new_max.Clamp(); | 2092 new_max = new_max.Clamp(); |
| 2087 } | 2093 } |
| 2088 | 2094 |
| 2089 return Range::Update(&range_, new_min, new_max); | 2095 return Range::Update(&range_, new_min, new_max); |
| 2090 } | 2096 } |
| 2091 | 2097 |
| 2092 | 2098 |
| 2093 #undef __ | 2099 #undef __ |
| 2094 | 2100 |
| 2095 } // namespace dart | 2101 } // namespace dart |
| OLD | NEW |