Chromium Code Reviews| 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/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 6289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6300 } | 6300 } |
| 6301 | 6301 |
| 6302 if (IsNonConstant(left) || IsNonConstant(right)) { | 6302 if (IsNonConstant(left) || IsNonConstant(right)) { |
| 6303 // TODO(vegorov): incorporate nullability information into the lattice. | 6303 // TODO(vegorov): incorporate nullability information into the lattice. |
| 6304 if ((left.IsNull() && instr->right()->Type()->HasDecidableNullability()) || | 6304 if ((left.IsNull() && instr->right()->Type()->HasDecidableNullability()) || |
| 6305 (right.IsNull() && instr->left()->Type()->HasDecidableNullability())) { | 6305 (right.IsNull() && instr->left()->Type()->HasDecidableNullability())) { |
| 6306 bool result = left.IsNull() ? instr->right()->Type()->IsNull() | 6306 bool result = left.IsNull() ? instr->right()->Type()->IsNull() |
| 6307 : instr->left()->Type()->IsNull(); | 6307 : instr->left()->Type()->IsNull(); |
| 6308 if (instr->kind() == Token::kNE_STRICT) result = !result; | 6308 if (instr->kind() == Token::kNE_STRICT) result = !result; |
| 6309 SetValue(instr, Bool::Get(result)); | 6309 SetValue(instr, Bool::Get(result)); |
| 6310 } else { | 6310 return; |
|
Kevin Millikin (Google)
2013/11/07 11:29:37
If you want the early return, this should be:
if
| |
| 6311 SetValue(instr, non_constant_); | |
| 6312 } | 6311 } |
| 6313 } else if (IsConstant(left) && IsConstant(right)) { | 6312 } |
| 6313 if (IsConstant(left) && IsConstant(right)) { | |
| 6314 bool result = (left.raw() == right.raw()); | 6314 bool result = (left.raw() == right.raw()); |
| 6315 if (instr->kind() == Token::kNE_STRICT) result = !result; | 6315 if (instr->kind() == Token::kNE_STRICT) result = !result; |
| 6316 SetValue(instr, Bool::Get(result)); | 6316 SetValue(instr, Bool::Get(result)); |
| 6317 return; | |
| 6317 } | 6318 } |
| 6319 const intptr_t left_cid = instr->left()->Type()->ToCid(); | |
| 6320 const intptr_t right_cid = instr->right()->Type()->ToCid(); | |
| 6321 if ((left_cid != kDynamicCid) && (right_cid != kDynamicCid)) { | |
| 6322 // If exact classes (cids) are known and they differ, the result | |
| 6323 // of strict compare can be computed. | |
| 6324 if (left_cid != right_cid) { | |
| 6325 const bool result = (instr->kind() == Token::kEQ_STRICT) ? false : true; | |
| 6326 SetValue(instr, Bool::Get(result)); | |
| 6327 return; | |
| 6328 } | |
| 6329 } | |
| 6330 SetValue(instr, non_constant_); | |
|
Kevin Millikin (Google)
2013/11/07 11:29:37
Abbreviate non-constant by X, constant by C, unkno
| |
| 6318 } | 6331 } |
| 6319 | 6332 |
| 6320 | 6333 |
| 6321 static bool CompareIntegers(Token::Kind kind, | 6334 static bool CompareIntegers(Token::Kind kind, |
| 6322 const Integer& left, | 6335 const Integer& left, |
| 6323 const Integer& right) { | 6336 const Integer& right) { |
| 6324 const int result = left.CompareWith(right); | 6337 const int result = left.CompareWith(right); |
| 6325 switch (kind) { | 6338 switch (kind) { |
| 6326 case Token::kEQ: return (result == 0); | 6339 case Token::kEQ: return (result == 0); |
| 6327 case Token::kNE: return (result != 0); | 6340 case Token::kNE: return (result != 0); |
| (...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7851 } | 7864 } |
| 7852 | 7865 |
| 7853 // Insert materializations at environment uses. | 7866 // Insert materializations at environment uses. |
| 7854 for (intptr_t i = 0; i < exits.length(); i++) { | 7867 for (intptr_t i = 0; i < exits.length(); i++) { |
| 7855 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 7868 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
| 7856 } | 7869 } |
| 7857 } | 7870 } |
| 7858 | 7871 |
| 7859 | 7872 |
| 7860 } // namespace dart | 7873 } // namespace dart |
| OLD | NEW |