OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
7 #include "src/compiler/js-builtin-reducer.h" | 7 #include "src/compiler/js-builtin-reducer.h" |
8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/node-aux-data-inl.h" | 9 #include "src/compiler/node-aux-data-inl.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 // TODO(turbofan): js-typed-lowering of Equal(boolean) | 452 // TODO(turbofan): js-typed-lowering of Equal(boolean) |
453 return NoChange(); | 453 return NoChange(); |
454 } | 454 } |
455 | 455 |
456 | 456 |
457 Reduction JSTypedLowering::ReduceJSStrictEqual(Node* node, bool invert) { | 457 Reduction JSTypedLowering::ReduceJSStrictEqual(Node* node, bool invert) { |
458 JSBinopReduction r(this, node); | 458 JSBinopReduction r(this, node); |
459 if (r.left() == r.right()) { | 459 if (r.left() == r.right()) { |
460 // x === x is always true if x != NaN | 460 // x === x is always true if x != NaN |
461 if (!r.left_type()->Maybe(Type::NaN())) { | 461 if (!r.left_type()->Maybe(Type::NaN())) { |
462 return ReplaceEagerly(node, invert ? jsgraph()->FalseConstant() | 462 return ReplaceEagerly(node, jsgraph()->BooleanConstant(!invert)); |
463 : jsgraph()->TrueConstant()); | 463 } |
| 464 } |
| 465 Type* string_or_number = Type::Union(Type::String(), Type::Number(), zone()); |
| 466 if (r.OneInputCannotBe(string_or_number)) { |
| 467 // For values with canonical representation (i.e. not string nor number) an |
| 468 // empty type intersection means the values cannot be strictly equal. |
| 469 if (!r.left_type()->Maybe(r.right_type())) { |
| 470 return ReplaceEagerly(node, jsgraph()->BooleanConstant(invert)); |
464 } | 471 } |
465 } | 472 } |
466 if (r.OneInputIs(Type::Undefined())) { | 473 if (r.OneInputIs(Type::Undefined())) { |
467 return r.ChangeToPureOperator( | 474 return r.ChangeToPureOperator( |
468 simplified()->ReferenceEqual(Type::Undefined()), invert); | 475 simplified()->ReferenceEqual(Type::Undefined()), invert); |
469 } | 476 } |
470 if (r.OneInputIs(Type::Null())) { | 477 if (r.OneInputIs(Type::Null())) { |
471 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Null()), | 478 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Null()), |
472 invert); | 479 invert); |
473 } | 480 } |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 return JSBuiltinReducer(jsgraph()).Reduce(node); | 807 return JSBuiltinReducer(jsgraph()).Reduce(node); |
801 default: | 808 default: |
802 break; | 809 break; |
803 } | 810 } |
804 return NoChange(); | 811 return NoChange(); |
805 } | 812 } |
806 | 813 |
807 } // namespace compiler | 814 } // namespace compiler |
808 } // namespace internal | 815 } // namespace internal |
809 } // namespace v8 | 816 } // namespace v8 |
OLD | NEW |