Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 722223003: Extend typed lowering to cover JSStrictEqual on differing types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments and added unit test. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/unittests/compiler/js-typed-lowering-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | test/unittests/compiler/js-typed-lowering-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698