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

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

Issue 2263273003: [turbofan] Improve fast case of JSInstanceOf lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 3 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 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 EXPECT_THAT(r.replacement(), 1018 EXPECT_THAT(r.replacement(),
1019 IsSpeculativeNumberSubtract(NumberOperationHint::kSignedSmall, 1019 IsSpeculativeNumberSubtract(NumberOperationHint::kSignedSmall,
1020 lhs, rhs, effect, control)); 1020 lhs, rhs, effect, control));
1021 } 1021 }
1022 1022
1023 // ----------------------------------------------------------------------------- 1023 // -----------------------------------------------------------------------------
1024 // JSInstanceOf 1024 // JSInstanceOf
1025 // Test that instanceOf is reduced if and only if the right-hand side is a 1025 // Test that instanceOf is reduced if and only if the right-hand side is a
1026 // function constant. Functional correctness is ensured elsewhere. 1026 // function constant. Functional correctness is ensured elsewhere.
1027 1027
1028 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithoutSmiCheck) { 1028 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecialization) {
1029 Node* const context = Parameter(Type::Any()); 1029 Node* const context = Parameter(Type::Any());
1030 Node* const frame_state = EmptyFrameState(); 1030 Node* const frame_state = EmptyFrameState();
1031 Node* const effect = graph()->start(); 1031 Node* const effect = graph()->start();
1032 Node* const control = graph()->start(); 1032 Node* const control = graph()->start();
1033 1033
1034 // Reduce if left-hand side is known to be an object.
1035 Node* instanceOf =
1036 graph()->NewNode(javascript()->InstanceOf(), Parameter(Type::Object(), 0),
1037 HeapConstant(isolate()->object_function()), context,
1038 frame_state, effect, control);
1039 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context,
1040 frame_state, effect, control);
1041 Reduction r = Reduce(instanceOf);
1042 ASSERT_TRUE(r.Changed());
1043 ASSERT_EQ(r.replacement(), dummy->InputAt(0));
1044 ASSERT_NE(instanceOf, dummy->InputAt(0));
1045 }
1046
1047
1048 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithSmiCheck) {
1049 Node* const context = Parameter(Type::Any());
1050 Node* const frame_state = EmptyFrameState();
1051 Node* const effect = graph()->start();
1052 Node* const control = graph()->start();
1053
1054 // Reduce if left-hand side could be a Smi.
1055 Node* instanceOf = 1034 Node* instanceOf =
1056 graph()->NewNode(javascript()->InstanceOf(), Parameter(Type::Any(), 0), 1035 graph()->NewNode(javascript()->InstanceOf(), Parameter(Type::Any(), 0),
1057 HeapConstant(isolate()->object_function()), context, 1036 HeapConstant(isolate()->object_function()), context,
1058 frame_state, effect, control); 1037 frame_state, effect, control);
1059 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context,
1060 frame_state, effect, control);
1061 Reduction r = Reduce(instanceOf); 1038 Reduction r = Reduce(instanceOf);
1062 ASSERT_TRUE(r.Changed()); 1039 ASSERT_TRUE(r.Changed());
1063 ASSERT_EQ(r.replacement(), dummy->InputAt(0));
1064 ASSERT_NE(instanceOf, dummy->InputAt(0));
1065 } 1040 }
1066 1041
1067 1042
1068 TEST_F(JSTypedLoweringTest, JSInstanceOfNoSpecialization) { 1043 TEST_F(JSTypedLoweringTest, JSInstanceOfNoSpecialization) {
1069 Node* const context = Parameter(Type::Any()); 1044 Node* const context = Parameter(Type::Any());
1070 Node* const frame_state = EmptyFrameState(); 1045 Node* const frame_state = EmptyFrameState();
1071 Node* const effect = graph()->start(); 1046 Node* const effect = graph()->start();
1072 Node* const control = graph()->start(); 1047 Node* const control = graph()->start();
1073 1048
1074 // Do not reduce if right-hand side is not a function constant. 1049 // Do not reduce if right-hand side is not a function constant.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 EmptyFrameState(), effect, control)); 1197 EmptyFrameState(), effect, control));
1223 ASSERT_TRUE(r.Changed()); 1198 ASSERT_TRUE(r.Changed());
1224 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( 1199 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor(
1225 NumberOperationHint::kNumberOrOddball, lhs, 1200 NumberOperationHint::kNumberOrOddball, lhs,
1226 rhs, effect, control)); 1201 rhs, effect, control));
1227 } 1202 }
1228 1203
1229 } // namespace compiler 1204 } // namespace compiler
1230 } // namespace internal 1205 } // namespace internal
1231 } // namespace v8 1206 } // namespace v8
OLDNEW
« src/compiler/js-typed-lowering.cc ('K') | « src/compiler/js-typed-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698