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

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

Issue 1657863004: [turbofan] Introduce proper ObjectIsReceiver operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/diamond.h" 6 #include "src/compiler/diamond.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-intrinsic-lowering.h" 8 #include "src/compiler/js-intrinsic-lowering.h"
9 #include "src/compiler/js-operator.h" 9 #include "src/compiler/js-operator.h"
10 #include "test/unittests/compiler/graph-unittest.h" 10 #include "test/unittests/compiler/graph-unittest.h"
11 #include "test/unittests/compiler/node-test-utils.h" 11 #include "test/unittests/compiler/node-test-utils.h"
12 #include "testing/gmock-support.h" 12 #include "testing/gmock-support.h"
13 13
14 14
15 using testing::_; 15 using testing::_;
16 using testing::AllOf; 16 using testing::AllOf;
17 using testing::BitEq; 17 using testing::BitEq;
18 using testing::Capture; 18 using testing::Capture;
19 using testing::CaptureEq; 19 using testing::CaptureEq;
20 20
21 21
22 namespace v8 { 22 namespace v8 {
23 namespace internal { 23 namespace internal {
24 namespace compiler { 24 namespace compiler {
25 25
26 class JSIntrinsicLoweringTest : public TypedGraphTest { 26 class JSIntrinsicLoweringTest : public GraphTest {
27 public: 27 public:
28 JSIntrinsicLoweringTest() : TypedGraphTest(3), javascript_(zone()) {} 28 JSIntrinsicLoweringTest() : GraphTest(3), javascript_(zone()) {}
29 ~JSIntrinsicLoweringTest() override {} 29 ~JSIntrinsicLoweringTest() override {}
30 30
31 protected: 31 protected:
32 Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags = 32 Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags =
33 MachineOperatorBuilder::kNoFlags) { 33 MachineOperatorBuilder::kNoFlags) {
34 MachineOperatorBuilder machine(zone(), MachineType::PointerRepresentation(), 34 MachineOperatorBuilder machine(zone(), MachineType::PointerRepresentation(),
35 flags); 35 flags);
36 SimplifiedOperatorBuilder simplified(zone()); 36 SimplifiedOperatorBuilder simplified(zone());
37 JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified, 37 JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified,
38 &machine); 38 &machine);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 IsMerge(IsIfTrue(AllOf(CaptureEq(&branch), 250 IsMerge(IsIfTrue(AllOf(CaptureEq(&branch),
251 IsBranch(IsObjectIsSmi(input), control))), 251 IsBranch(IsObjectIsSmi(input), control))),
252 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); 252 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch))))));
253 } 253 }
254 254
255 255
256 // ----------------------------------------------------------------------------- 256 // -----------------------------------------------------------------------------
257 // %_IsJSReceiver 257 // %_IsJSReceiver
258 258
259 259
260 TEST_F(JSIntrinsicLoweringTest, InlineIsJSReceiverWithAny) { 260 TEST_F(JSIntrinsicLoweringTest, InlineIsJSReceiver) {
261 Node* const input = Parameter(Type::Any()); 261 Node* const input = Parameter(0);
262 Node* const context = Parameter(Type::Any()); 262 Node* const context = Parameter(1);
263 Node* const effect = graph()->start(); 263 Node* const effect = graph()->start();
264 Node* const control = graph()->start(); 264 Node* const control = graph()->start();
265 Reduction const r = Reduce(graph()->NewNode( 265 Reduction const r = Reduce(graph()->NewNode(
266 javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), input, 266 javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), input,
267 context, effect, control)); 267 context, effect, control));
268 ASSERT_TRUE(r.Changed()); 268 ASSERT_TRUE(r.Changed());
269 269 EXPECT_THAT(r.replacement(), IsObjectIsReceiver(input));
270 Node* phi = r.replacement();
271 Capture<Node *> branch, if_false;
272 EXPECT_THAT(
273 phi,
274 IsPhi(
275 MachineRepresentation::kTagged, IsFalseConstant(),
276 IsUint32LessThanOrEqual(
277 IsInt32Constant(FIRST_JS_RECEIVER_TYPE),
278 IsLoadField(AccessBuilder::ForMapInstanceType(),
279 IsLoadField(AccessBuilder::ForMap(), input, effect,
280 CaptureEq(&if_false)),
281 effect, _)),
282 IsMerge(IsIfTrue(AllOf(CaptureEq(&branch),
283 IsBranch(IsObjectIsSmi(input), control))),
284 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch))))));
285 } 270 }
286 271
287 272
288 TEST_F(JSIntrinsicLoweringTest, InlineIsJSReceiverWithReceiver) {
289 Node* const input = Parameter(Type::Receiver());
290 Node* const context = Parameter(Type::Any());
291 Node* const effect = graph()->start();
292 Node* const control = graph()->start();
293 Reduction const r = Reduce(graph()->NewNode(
294 javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), input,
295 context, effect, control));
296 ASSERT_TRUE(r.Changed());
297 EXPECT_THAT(r.replacement(), IsTrueConstant());
298 }
299
300
301 TEST_F(JSIntrinsicLoweringTest, InlineIsJSReceiverWithUndefined) {
302 Node* const input = Parameter(Type::Undefined());
303 Node* const context = Parameter(Type::Any());
304 Node* const effect = graph()->start();
305 Node* const control = graph()->start();
306 Reduction const r = Reduce(graph()->NewNode(
307 javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), input,
308 context, effect, control));
309 ASSERT_TRUE(r.Changed());
310 EXPECT_THAT(r.replacement(), IsFalseConstant());
311 }
312
313
314 // ----------------------------------------------------------------------------- 273 // -----------------------------------------------------------------------------
315 // %_JSValueGetValue 274 // %_JSValueGetValue
316 275
317 276
318 TEST_F(JSIntrinsicLoweringTest, InlineJSValueGetValue) { 277 TEST_F(JSIntrinsicLoweringTest, InlineJSValueGetValue) {
319 Node* const input = Parameter(0); 278 Node* const input = Parameter(0);
320 Node* const context = Parameter(1); 279 Node* const context = Parameter(1);
321 Node* const effect = graph()->start(); 280 Node* const effect = graph()->start();
322 Node* const control = graph()->start(); 281 Node* const control = graph()->start();
323 Reduction const r = Reduce(graph()->NewNode( 282 Reduction const r = Reduce(graph()->NewNode(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 CaptureEq(&if_false0)))))), 379 CaptureEq(&if_false0)))))),
421 IsMerge( 380 IsMerge(
422 IsIfTrue(AllOf(CaptureEq(&branch0), 381 IsIfTrue(AllOf(CaptureEq(&branch0),
423 IsBranch(IsObjectIsSmi(input), control))), 382 IsBranch(IsObjectIsSmi(input), control))),
424 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); 383 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0))))));
425 } 384 }
426 385
427 } // namespace compiler 386 } // namespace compiler
428 } // namespace internal 387 } // namespace internal
429 } // namespace v8 388 } // namespace v8
OLDNEW
« no previous file with comments | « test/mjsunit/compiler/double-array-to-global.js ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698