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()); | |
464 } | 463 } |
465 } | 464 } |
466 if (r.OneInputIs(Type::Undefined())) { | 465 if (r.OneInputIs(Type::Undefined())) { |
467 return r.ChangeToPureOperator( | 466 return r.ChangeToPureOperator( |
468 simplified()->ReferenceEqual(Type::Undefined()), invert); | 467 simplified()->ReferenceEqual(Type::Undefined()), invert); |
469 } | 468 } |
470 if (r.OneInputIs(Type::Null())) { | 469 if (r.OneInputIs(Type::Null())) { |
471 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Null()), | 470 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Null()), |
472 invert); | 471 invert); |
473 } | 472 } |
474 if (r.OneInputIs(Type::Boolean())) { | 473 if (r.OneInputIs(Type::Boolean())) { |
475 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Boolean()), | 474 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Boolean()), |
476 invert); | 475 invert); |
477 } | 476 } |
478 if (r.OneInputIs(Type::Object())) { | 477 if (r.OneInputIs(Type::Object())) { |
479 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Object()), | 478 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Object()), |
480 invert); | 479 invert); |
481 } | 480 } |
482 if (r.OneInputIs(Type::Receiver())) { | 481 if (r.OneInputIs(Type::Receiver())) { |
483 return r.ChangeToPureOperator( | 482 return r.ChangeToPureOperator( |
484 simplified()->ReferenceEqual(Type::Receiver()), invert); | 483 simplified()->ReferenceEqual(Type::Receiver()), invert); |
485 } | 484 } |
486 if (r.BothInputsAre(Type::String())) { | 485 if (r.BothInputsAre(Type::String())) { |
487 return r.ChangeToPureOperator(simplified()->StringEqual(), invert); | 486 return r.ChangeToPureOperator(simplified()->StringEqual(), invert); |
488 } | 487 } |
489 if (r.BothInputsAre(Type::Number())) { | 488 if (r.BothInputsAre(Type::Number())) { |
490 return r.ChangeToPureOperator(simplified()->NumberEqual(), invert); | 489 return r.ChangeToPureOperator(simplified()->NumberEqual(), invert); |
491 } | 490 } |
491 Type* string_or_number = Type::Union(Type::String(), Type::Number(), zone()); | |
492 if (r.OneInputCannotBe(string_or_number)) { | |
493 // For values with canonical representation (i.e. not string nor number) an | |
494 // empty type intersection means the values cannot be strictly equal. | |
495 Type* intersect = Type::Intersect(r.left_type(), r.right_type(), zone()); | |
rossberg
2014/11/14 13:41:42
That's what left_type->Maybe(right_type) is for. ;
titzer
2014/11/14 13:43:24
I like Maybe, I just want it to be reliable....
/u
Michael Starzinger
2014/11/14 14:03:06
Done.
| |
496 if (!intersect->IsInhabited()) { | |
497 return ReplaceEagerly(node, jsgraph()->BooleanConstant(invert)); | |
498 } | |
499 } | |
492 // TODO(turbofan): js-typed-lowering of StrictEqual(mixed types) | 500 // TODO(turbofan): js-typed-lowering of StrictEqual(mixed types) |
493 return NoChange(); | 501 return NoChange(); |
494 } | 502 } |
495 | 503 |
496 | 504 |
497 Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) { | 505 Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) { |
498 if (input->opcode() == IrOpcode::kJSToNumber) { | 506 if (input->opcode() == IrOpcode::kJSToNumber) { |
499 // Recursively try to reduce the input first. | 507 // Recursively try to reduce the input first. |
500 Reduction result = ReduceJSToNumberInput(input->InputAt(0)); | 508 Reduction result = ReduceJSToNumberInput(input->InputAt(0)); |
501 if (result.Changed()) { | 509 if (result.Changed()) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
800 return JSBuiltinReducer(jsgraph()).Reduce(node); | 808 return JSBuiltinReducer(jsgraph()).Reduce(node); |
801 default: | 809 default: |
802 break; | 810 break; |
803 } | 811 } |
804 return NoChange(); | 812 return NoChange(); |
805 } | 813 } |
806 | 814 |
807 } // namespace compiler | 815 } // namespace compiler |
808 } // namespace internal | 816 } // namespace internal |
809 } // namespace v8 | 817 } // namespace v8 |
OLD | NEW |