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

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

Issue 2530773002: [turbofan] Improve typed lowering rules for JSToBoolean. (Closed)
Patch Set: Created 4 years 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 | « test/unittests/compiler/graph-unittest.cc ('k') | test/unittests/compiler/node-test-utils.h » ('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/js-typed-lowering.h" 5 #include "src/compiler/js-typed-lowering.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 #include "src/compilation-dependencies.h" 7 #include "src/compilation-dependencies.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/js-operator.h" 10 #include "src/compiler/js-operator.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 TEST_F(JSTypedLoweringTest, JSToBooleanWithNumber) { 105 TEST_F(JSTypedLoweringTest, JSToBooleanWithNumber) {
106 Node* input = Parameter(Type::Number(), 0); 106 Node* input = Parameter(Type::Number(), 0);
107 Node* context = Parameter(Type::Any(), 1); 107 Node* context = Parameter(Type::Any(), 1);
108 Reduction r = Reduce(graph()->NewNode( 108 Reduction r = Reduce(graph()->NewNode(
109 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); 109 javascript()->ToBoolean(ToBooleanHint::kAny), input, context));
110 ASSERT_TRUE(r.Changed()); 110 ASSERT_TRUE(r.Changed());
111 EXPECT_THAT(r.replacement(), IsNumberToBoolean(input)); 111 EXPECT_THAT(r.replacement(), IsNumberToBoolean(input));
112 } 112 }
113 113
114 TEST_F(JSTypedLoweringTest, JSToBooleanWithDetectableReceiverOrNull) {
115 Node* input = Parameter(Type::DetectableReceiverOrNull(), 0);
116 Node* context = Parameter(Type::Any(), 1);
117 Reduction r = Reduce(graph()->NewNode(
118 javascript()->ToBoolean(ToBooleanHint::kAny), input, context));
119 ASSERT_TRUE(r.Changed());
120 EXPECT_THAT(r.replacement(),
121 IsBooleanNot(IsReferenceEqual(input, IsNullConstant())));
122 }
123
124 TEST_F(JSTypedLoweringTest, JSToBooleanWithReceiverOrNullOrUndefined) {
125 Node* input = Parameter(Type::ReceiverOrNullOrUndefined(), 0);
126 Node* context = Parameter(Type::Any(), 1);
127 Reduction r = Reduce(graph()->NewNode(
128 javascript()->ToBoolean(ToBooleanHint::kAny), input, context));
129 ASSERT_TRUE(r.Changed());
130 EXPECT_THAT(r.replacement(), IsBooleanNot(IsObjectIsUndetectable(input)));
131 }
132
114 TEST_F(JSTypedLoweringTest, JSToBooleanWithAny) { 133 TEST_F(JSTypedLoweringTest, JSToBooleanWithAny) {
115 Node* input = Parameter(Type::Any(), 0); 134 Node* input = Parameter(Type::Any(), 0);
116 Node* context = Parameter(Type::Any(), 1); 135 Node* context = Parameter(Type::Any(), 1);
117 Reduction r = Reduce(graph()->NewNode( 136 Reduction r = Reduce(graph()->NewNode(
118 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); 137 javascript()->ToBoolean(ToBooleanHint::kAny), input, context));
119 ASSERT_FALSE(r.Changed()); 138 ASSERT_FALSE(r.Changed());
120 } 139 }
121 140
122 141
123 // ----------------------------------------------------------------------------- 142 // -----------------------------------------------------------------------------
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 TEST_F(JSTypedLoweringTest, JSStrictEqualWithUnique) { 263 TEST_F(JSTypedLoweringTest, JSStrictEqualWithUnique) {
245 Node* const lhs = Parameter(Type::Unique(), 0); 264 Node* const lhs = Parameter(Type::Unique(), 0);
246 Node* const rhs = Parameter(Type::Unique(), 1); 265 Node* const rhs = Parameter(Type::Unique(), 1);
247 Node* const context = Parameter(Type::Any(), 2); 266 Node* const context = Parameter(Type::Any(), 2);
248 Node* const effect = graph()->start(); 267 Node* const effect = graph()->start();
249 Node* const control = graph()->start(); 268 Node* const control = graph()->start();
250 Reduction r = Reduce( 269 Reduction r = Reduce(
251 graph()->NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), 270 graph()->NewNode(javascript()->StrictEqual(CompareOperationHint::kAny),
252 lhs, rhs, context, effect, control)); 271 lhs, rhs, context, effect, control));
253 ASSERT_TRUE(r.Changed()); 272 ASSERT_TRUE(r.Changed());
254 EXPECT_THAT(r.replacement(), IsReferenceEqual(Type::Unique(), lhs, rhs)); 273 EXPECT_THAT(r.replacement(), IsReferenceEqual(lhs, rhs));
255 } 274 }
256 275
257 276
258 // ----------------------------------------------------------------------------- 277 // -----------------------------------------------------------------------------
259 // JSShiftLeft 278 // JSShiftLeft
260 279
261 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { 280 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) {
262 BinaryOperationHint const hint = BinaryOperationHint::kAny; 281 BinaryOperationHint const hint = BinaryOperationHint::kAny;
263 Node* const lhs = Parameter(Type::Signed32()); 282 Node* const lhs = Parameter(Type::Signed32());
264 Node* const context = UndefinedConstant(); 283 Node* const context = UndefinedConstant();
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 EmptyFrameState(), effect, control)); 1012 EmptyFrameState(), effect, control));
994 ASSERT_TRUE(r.Changed()); 1013 ASSERT_TRUE(r.Changed());
995 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( 1014 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor(
996 NumberOperationHint::kNumberOrOddball, lhs, 1015 NumberOperationHint::kNumberOrOddball, lhs,
997 rhs, effect, control)); 1016 rhs, effect, control));
998 } 1017 }
999 1018
1000 } // namespace compiler 1019 } // namespace compiler
1001 } // namespace internal 1020 } // namespace internal
1002 } // namespace v8 1021 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/graph-unittest.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698