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 6295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6306 SetValue(instr, Bool::Get(instr->kind() == Token::kEQ_STRICT)); | 6306 SetValue(instr, Bool::Get(instr->kind() == Token::kEQ_STRICT)); |
6307 return; | 6307 return; |
6308 } | 6308 } |
6309 | 6309 |
6310 if (IsNonConstant(left) || IsNonConstant(right)) { | 6310 if (IsNonConstant(left) || IsNonConstant(right)) { |
6311 // TODO(vegorov): incorporate nullability information into the lattice. | 6311 // TODO(vegorov): incorporate nullability information into the lattice. |
6312 if ((left.IsNull() && instr->right()->Type()->HasDecidableNullability()) || | 6312 if ((left.IsNull() && instr->right()->Type()->HasDecidableNullability()) || |
6313 (right.IsNull() && instr->left()->Type()->HasDecidableNullability())) { | 6313 (right.IsNull() && instr->left()->Type()->HasDecidableNullability())) { |
6314 bool result = left.IsNull() ? instr->right()->Type()->IsNull() | 6314 bool result = left.IsNull() ? instr->right()->Type()->IsNull() |
6315 : instr->left()->Type()->IsNull(); | 6315 : instr->left()->Type()->IsNull(); |
6316 if (instr->kind() == Token::kNE_STRICT) result = !result; | 6316 if (instr->kind() == Token::kNE_STRICT) { |
| 6317 result = !result; |
| 6318 } |
6317 SetValue(instr, Bool::Get(result)); | 6319 SetValue(instr, Bool::Get(result)); |
6318 } else { | 6320 } else { |
6319 SetValue(instr, non_constant_); | 6321 const intptr_t left_cid = instr->left()->Type()->ToCid(); |
| 6322 const intptr_t right_cid = instr->right()->Type()->ToCid(); |
| 6323 // If exact classes (cids) are known and they differ, the result |
| 6324 // of strict compare can be computed. |
| 6325 if ((left_cid != kDynamicCid) && (right_cid != kDynamicCid) && |
| 6326 (left_cid != right_cid)) { |
| 6327 const bool result = (instr->kind() != Token::kEQ_STRICT); |
| 6328 SetValue(instr, Bool::Get(result)); |
| 6329 } else { |
| 6330 SetValue(instr, non_constant_); |
| 6331 } |
6320 } | 6332 } |
6321 } else if (IsConstant(left) && IsConstant(right)) { | 6333 } else if (IsConstant(left) && IsConstant(right)) { |
6322 bool result = (left.raw() == right.raw()); | 6334 bool result = (left.raw() == right.raw()); |
6323 if (instr->kind() == Token::kNE_STRICT) result = !result; | 6335 if (instr->kind() == Token::kNE_STRICT) { |
| 6336 result = !result; |
| 6337 } |
6324 SetValue(instr, Bool::Get(result)); | 6338 SetValue(instr, Bool::Get(result)); |
6325 } | 6339 } |
6326 } | 6340 } |
6327 | 6341 |
6328 | 6342 |
6329 static bool CompareIntegers(Token::Kind kind, | 6343 static bool CompareIntegers(Token::Kind kind, |
6330 const Integer& left, | 6344 const Integer& left, |
6331 const Integer& right) { | 6345 const Integer& right) { |
6332 const int result = left.CompareWith(right); | 6346 const int result = left.CompareWith(right); |
6333 switch (kind) { | 6347 switch (kind) { |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7892 } | 7906 } |
7893 | 7907 |
7894 // Insert materializations at environment uses. | 7908 // Insert materializations at environment uses. |
7895 for (intptr_t i = 0; i < exits.length(); i++) { | 7909 for (intptr_t i = 0; i < exits.length(); i++) { |
7896 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 7910 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
7897 } | 7911 } |
7898 } | 7912 } |
7899 | 7913 |
7900 | 7914 |
7901 } // namespace dart | 7915 } // namespace dart |
OLD | NEW |