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

Side by Side Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 2035383003: [turbofan] Type feedback for numeric comparisons. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixes Created 4 years, 6 months 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
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/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 378
379 // ----------------------------------------------------------------------------- 379 // -----------------------------------------------------------------------------
380 // JSStrictEqual 380 // JSStrictEqual
381 381
382 382
383 TEST_F(JSTypedLoweringTest, JSStrictEqualWithTheHole) { 383 TEST_F(JSTypedLoweringTest, JSStrictEqualWithTheHole) {
384 Node* const the_hole = HeapConstant(factory()->the_hole_value()); 384 Node* const the_hole = HeapConstant(factory()->the_hole_value());
385 Node* const context = UndefinedConstant(); 385 Node* const context = UndefinedConstant();
386 TRACED_FOREACH(Type*, type, kJSTypes) { 386 TRACED_FOREACH(Type*, type, kJSTypes) {
387 Node* const lhs = Parameter(type); 387 Node* const lhs = Parameter(type);
388 Reduction r = Reduce( 388 Reduction r = Reduce(graph()->NewNode(
389 graph()->NewNode(javascript()->StrictEqual(), lhs, the_hole, context)); 389 javascript()->StrictEqual(CompareOperationHints::Any()), lhs, the_hole,
390 context));
390 ASSERT_TRUE(r.Changed()); 391 ASSERT_TRUE(r.Changed());
391 EXPECT_THAT(r.replacement(), IsFalseConstant()); 392 EXPECT_THAT(r.replacement(), IsFalseConstant());
392 } 393 }
393 } 394 }
394 395
395 396
396 TEST_F(JSTypedLoweringTest, JSStrictEqualWithUnique) { 397 TEST_F(JSTypedLoweringTest, JSStrictEqualWithUnique) {
397 Node* const lhs = Parameter(Type::Unique(), 0); 398 Node* const lhs = Parameter(Type::Unique(), 0);
398 Node* const rhs = Parameter(Type::Unique(), 1); 399 Node* const rhs = Parameter(Type::Unique(), 1);
399 Node* const context = Parameter(Type::Any(), 2); 400 Node* const context = Parameter(Type::Any(), 2);
400 Reduction r = 401 Reduction r = Reduce(
401 Reduce(graph()->NewNode(javascript()->StrictEqual(), lhs, rhs, context)); 402 graph()->NewNode(javascript()->StrictEqual(CompareOperationHints::Any()),
403 lhs, rhs, context));
402 ASSERT_TRUE(r.Changed()); 404 ASSERT_TRUE(r.Changed());
403 EXPECT_THAT(r.replacement(), IsReferenceEqual(Type::Unique(), lhs, rhs)); 405 EXPECT_THAT(r.replacement(), IsReferenceEqual(Type::Unique(), lhs, rhs));
404 } 406 }
405 407
406 408
407 // ----------------------------------------------------------------------------- 409 // -----------------------------------------------------------------------------
408 // JSShiftLeft 410 // JSShiftLeft
409 411
410 412
411 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { 413 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) {
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 // function constant. Functional correctness is ensured elsewhere. 895 // function constant. Functional correctness is ensured elsewhere.
894 896
895 897
896 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithoutSmiCheck) { 898 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithoutSmiCheck) {
897 Node* const context = Parameter(Type::Any()); 899 Node* const context = Parameter(Type::Any());
898 Node* const frame_state = EmptyFrameState(); 900 Node* const frame_state = EmptyFrameState();
899 Node* const effect = graph()->start(); 901 Node* const effect = graph()->start();
900 Node* const control = graph()->start(); 902 Node* const control = graph()->start();
901 903
902 // Reduce if left-hand side is known to be an object. 904 // Reduce if left-hand side is known to be an object.
903 Node* instanceOf = 905 Node* instanceOf = graph()->NewNode(
904 graph()->NewNode(javascript()->InstanceOf(), Parameter(Type::Object(), 0), 906 javascript()->InstanceOf(CompareOperationHints::Any()),
905 HeapConstant(isolate()->object_function()), context, 907 Parameter(Type::Object(), 0), HeapConstant(isolate()->object_function()),
906 frame_state, effect, control); 908 context, frame_state, effect, control);
907 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, 909 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context,
908 frame_state, effect, control); 910 frame_state, effect, control);
909 Reduction r = Reduce(instanceOf); 911 Reduction r = Reduce(instanceOf);
910 ASSERT_TRUE(r.Changed()); 912 ASSERT_TRUE(r.Changed());
911 ASSERT_EQ(r.replacement(), dummy->InputAt(0)); 913 ASSERT_EQ(r.replacement(), dummy->InputAt(0));
912 ASSERT_NE(instanceOf, dummy->InputAt(0)); 914 ASSERT_NE(instanceOf, dummy->InputAt(0));
913 } 915 }
914 916
915 917
916 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithSmiCheck) { 918 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithSmiCheck) {
917 Node* const context = Parameter(Type::Any()); 919 Node* const context = Parameter(Type::Any());
918 Node* const frame_state = EmptyFrameState(); 920 Node* const frame_state = EmptyFrameState();
919 Node* const effect = graph()->start(); 921 Node* const effect = graph()->start();
920 Node* const control = graph()->start(); 922 Node* const control = graph()->start();
921 923
922 // Reduce if left-hand side could be a Smi. 924 // Reduce if left-hand side could be a Smi.
923 Node* instanceOf = 925 Node* instanceOf = graph()->NewNode(
924 graph()->NewNode(javascript()->InstanceOf(), Parameter(Type::Any(), 0), 926 javascript()->InstanceOf(CompareOperationHints::Any()),
925 HeapConstant(isolate()->object_function()), context, 927 Parameter(Type::Any(), 0), HeapConstant(isolate()->object_function()),
926 frame_state, effect, control); 928 context, frame_state, effect, control);
927 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, 929 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context,
928 frame_state, effect, control); 930 frame_state, effect, control);
929 Reduction r = Reduce(instanceOf); 931 Reduction r = Reduce(instanceOf);
930 ASSERT_TRUE(r.Changed()); 932 ASSERT_TRUE(r.Changed());
931 ASSERT_EQ(r.replacement(), dummy->InputAt(0)); 933 ASSERT_EQ(r.replacement(), dummy->InputAt(0));
932 ASSERT_NE(instanceOf, dummy->InputAt(0)); 934 ASSERT_NE(instanceOf, dummy->InputAt(0));
933 } 935 }
934 936
935 937
936 TEST_F(JSTypedLoweringTest, JSInstanceOfNoSpecialization) { 938 TEST_F(JSTypedLoweringTest, JSInstanceOfNoSpecialization) {
937 Node* const context = Parameter(Type::Any()); 939 Node* const context = Parameter(Type::Any());
938 Node* const frame_state = EmptyFrameState(); 940 Node* const frame_state = EmptyFrameState();
939 Node* const effect = graph()->start(); 941 Node* const effect = graph()->start();
940 Node* const control = graph()->start(); 942 Node* const control = graph()->start();
941 943
942 // Do not reduce if right-hand side is not a function constant. 944 // Do not reduce if right-hand side is not a function constant.
943 Node* instanceOf = graph()->NewNode( 945 Node* instanceOf =
944 javascript()->InstanceOf(), Parameter(Type::Any(), 0), 946 graph()->NewNode(javascript()->InstanceOf(CompareOperationHints::Any()),
945 Parameter(Type::Any()), context, frame_state, effect, control); 947 Parameter(Type::Any(), 0), Parameter(Type::Any()),
948 context, frame_state, effect, control);
946 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, 949 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context,
947 frame_state, effect, control); 950 frame_state, effect, control);
948 Reduction r = Reduce(instanceOf); 951 Reduction r = Reduce(instanceOf);
949 ASSERT_FALSE(r.Changed()); 952 ASSERT_FALSE(r.Changed());
950 ASSERT_EQ(instanceOf, dummy->InputAt(0)); 953 ASSERT_EQ(instanceOf, dummy->InputAt(0));
951 } 954 }
952 955
953 } // namespace compiler 956 } // namespace compiler
954 } // namespace internal 957 } // namespace internal
955 } // namespace v8 958 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698