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

Side by Side Diff: test/unittests/compiler/simplified-operator-reducer-unittest.cc

Issue 2362173003: [turbofan] Improve representation selection for Smi checking. (Closed)
Patch Set: Address comments Created 4 years, 2 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
« no previous file with comments | « src/compiler/verifier.cc ('k') | no next file » | 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/simplified-operator.h" 5 #include "src/compiler/simplified-operator.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/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 #include "src/compiler/simplified-operator-reducer.h" 9 #include "src/compiler/simplified-operator-reducer.h"
10 #include "src/compiler/types.h" 10 #include "src/compiler/types.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 TEST_F(SimplifiedOperatorReducerTest, TruncateTaggedToWord32WithConstant) { 343 TEST_F(SimplifiedOperatorReducerTest, TruncateTaggedToWord32WithConstant) {
344 TRACED_FOREACH(double, n, kFloat64Values) { 344 TRACED_FOREACH(double, n, kFloat64Values) {
345 Reduction reduction = Reduce(graph()->NewNode( 345 Reduction reduction = Reduce(graph()->NewNode(
346 simplified()->TruncateTaggedToWord32(), NumberConstant(n))); 346 simplified()->TruncateTaggedToWord32(), NumberConstant(n)));
347 ASSERT_TRUE(reduction.Changed()); 347 ASSERT_TRUE(reduction.Changed());
348 EXPECT_THAT(reduction.replacement(), IsInt32Constant(DoubleToInt32(n))); 348 EXPECT_THAT(reduction.replacement(), IsInt32Constant(DoubleToInt32(n)));
349 } 349 }
350 } 350 }
351 351
352 // ----------------------------------------------------------------------------- 352 // -----------------------------------------------------------------------------
353 // CheckTaggedPointer 353 // CheckHeapObject
354 354
355 TEST_F(SimplifiedOperatorReducerTest, CheckTaggedPointerWithChangeBitToTagged) { 355 TEST_F(SimplifiedOperatorReducerTest, CheckHeapObjectWithChangeBitToTagged) {
356 Node* param0 = Parameter(0); 356 Node* param0 = Parameter(0);
357 Node* effect = graph()->start(); 357 Node* effect = graph()->start();
358 Node* control = graph()->start(); 358 Node* control = graph()->start();
359 Node* value = graph()->NewNode(simplified()->ChangeBitToTagged(), param0); 359 Node* value = graph()->NewNode(simplified()->ChangeBitToTagged(), param0);
360 Reduction reduction = Reduce(graph()->NewNode( 360 Reduction reduction = Reduce(graph()->NewNode(simplified()->CheckHeapObject(),
361 simplified()->CheckTaggedPointer(), value, effect, control)); 361 value, effect, control));
362 ASSERT_TRUE(reduction.Changed()); 362 ASSERT_TRUE(reduction.Changed());
363 EXPECT_EQ(value, reduction.replacement()); 363 EXPECT_EQ(value, reduction.replacement());
364 } 364 }
365 365
366 TEST_F(SimplifiedOperatorReducerTest, CheckTaggedPointerWithHeapConstant) { 366 TEST_F(SimplifiedOperatorReducerTest, CheckHeapObjectWithHeapConstant) {
367 Node* effect = graph()->start(); 367 Node* effect = graph()->start();
368 Node* control = graph()->start(); 368 Node* control = graph()->start();
369 Handle<HeapObject> kHeapObjects[] = { 369 Handle<HeapObject> kHeapObjects[] = {
370 factory()->empty_string(), factory()->null_value(), 370 factory()->empty_string(), factory()->null_value(),
371 factory()->species_symbol(), factory()->undefined_value()}; 371 factory()->species_symbol(), factory()->undefined_value()};
372 TRACED_FOREACH(Handle<HeapObject>, object, kHeapObjects) { 372 TRACED_FOREACH(Handle<HeapObject>, object, kHeapObjects) {
373 Node* value = HeapConstant(object); 373 Node* value = HeapConstant(object);
374 Reduction reduction = Reduce(graph()->NewNode( 374 Reduction reduction = Reduce(graph()->NewNode(
375 simplified()->CheckTaggedPointer(), value, effect, control)); 375 simplified()->CheckHeapObject(), value, effect, control));
376 ASSERT_TRUE(reduction.Changed()); 376 ASSERT_TRUE(reduction.Changed());
377 EXPECT_EQ(value, reduction.replacement()); 377 EXPECT_EQ(value, reduction.replacement());
378 } 378 }
379 } 379 }
380 380
381 TEST_F(SimplifiedOperatorReducerTest, 381 TEST_F(SimplifiedOperatorReducerTest, CheckHeapObjectWithCheckHeapObject) {
382 CheckTaggedPointerWithCheckTaggedPointer) {
383 Node* param0 = Parameter(0); 382 Node* param0 = Parameter(0);
384 Node* effect = graph()->start(); 383 Node* effect = graph()->start();
385 Node* control = graph()->start(); 384 Node* control = graph()->start();
386 Node* value = effect = graph()->NewNode(simplified()->CheckTaggedPointer(), 385 Node* value = effect = graph()->NewNode(simplified()->CheckHeapObject(),
387 param0, effect, control); 386 param0, effect, control);
388 Reduction reduction = Reduce(graph()->NewNode( 387 Reduction reduction = Reduce(graph()->NewNode(simplified()->CheckHeapObject(),
389 simplified()->CheckTaggedPointer(), value, effect, control)); 388 value, effect, control));
390 ASSERT_TRUE(reduction.Changed()); 389 ASSERT_TRUE(reduction.Changed());
391 EXPECT_EQ(value, reduction.replacement()); 390 EXPECT_EQ(value, reduction.replacement());
392 } 391 }
393 392
394 // ----------------------------------------------------------------------------- 393 // -----------------------------------------------------------------------------
395 // CheckTaggedSigned 394 // CheckSmi
396 395
397 TEST_F(SimplifiedOperatorReducerTest, 396 TEST_F(SimplifiedOperatorReducerTest, CheckSmiWithChangeInt31ToTaggedSigned) {
398 CheckTaggedSignedWithChangeInt31ToTaggedSigned) {
399 Node* param0 = Parameter(0); 397 Node* param0 = Parameter(0);
400 Node* effect = graph()->start(); 398 Node* effect = graph()->start();
401 Node* control = graph()->start(); 399 Node* control = graph()->start();
402 Node* value = 400 Node* value =
403 graph()->NewNode(simplified()->ChangeInt31ToTaggedSigned(), param0); 401 graph()->NewNode(simplified()->ChangeInt31ToTaggedSigned(), param0);
404 Reduction reduction = Reduce(graph()->NewNode( 402 Reduction reduction = Reduce(
405 simplified()->CheckTaggedSigned(), value, effect, control)); 403 graph()->NewNode(simplified()->CheckSmi(), value, effect, control));
406 ASSERT_TRUE(reduction.Changed()); 404 ASSERT_TRUE(reduction.Changed());
407 EXPECT_EQ(value, reduction.replacement()); 405 EXPECT_EQ(value, reduction.replacement());
408 } 406 }
409 407
410 TEST_F(SimplifiedOperatorReducerTest, CheckTaggedSignedWithNumberConstant) { 408 TEST_F(SimplifiedOperatorReducerTest, CheckSmiWithNumberConstant) {
411 Node* effect = graph()->start(); 409 Node* effect = graph()->start();
412 Node* control = graph()->start(); 410 Node* control = graph()->start();
413 Node* value = NumberConstant(1.0); 411 Node* value = NumberConstant(1.0);
414 Reduction reduction = Reduce(graph()->NewNode( 412 Reduction reduction = Reduce(
415 simplified()->CheckTaggedSigned(), value, effect, control)); 413 graph()->NewNode(simplified()->CheckSmi(), value, effect, control));
416 ASSERT_TRUE(reduction.Changed()); 414 ASSERT_TRUE(reduction.Changed());
417 EXPECT_EQ(value, reduction.replacement()); 415 EXPECT_EQ(value, reduction.replacement());
418 } 416 }
419 417
420 TEST_F(SimplifiedOperatorReducerTest, CheckTaggedSignedWithCheckTaggedSigned) { 418 TEST_F(SimplifiedOperatorReducerTest, CheckSmiWithCheckSmi) {
421 Node* param0 = Parameter(0); 419 Node* param0 = Parameter(0);
422 Node* effect = graph()->start(); 420 Node* effect = graph()->start();
423 Node* control = graph()->start(); 421 Node* control = graph()->start();
424 Node* value = effect = graph()->NewNode(simplified()->CheckTaggedSigned(), 422 Node* value = effect =
425 param0, effect, control); 423 graph()->NewNode(simplified()->CheckSmi(), param0, effect, control);
426 Reduction reduction = Reduce(graph()->NewNode( 424 Reduction reduction = Reduce(
427 simplified()->CheckTaggedSigned(), value, effect, control)); 425 graph()->NewNode(simplified()->CheckSmi(), value, effect, control));
428 ASSERT_TRUE(reduction.Changed()); 426 ASSERT_TRUE(reduction.Changed());
429 EXPECT_EQ(value, reduction.replacement()); 427 EXPECT_EQ(value, reduction.replacement());
430 } 428 }
431 429
432 // ----------------------------------------------------------------------------- 430 // -----------------------------------------------------------------------------
433 // NumberAbs 431 // NumberAbs
434 432
435 TEST_F(SimplifiedOperatorReducerTest, NumberAbsWithNumberConstant) { 433 TEST_F(SimplifiedOperatorReducerTest, NumberAbsWithNumberConstant) {
436 TRACED_FOREACH(double, n, kFloat64Values) { 434 TRACED_FOREACH(double, n, kFloat64Values) {
437 Reduction reduction = 435 Reduction reduction =
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 Reduction reduction = Reduce( 478 Reduction reduction = Reduce(
481 graph()->NewNode(simplified()->ObjectIsSmi(), NumberConstant(n))); 479 graph()->NewNode(simplified()->ObjectIsSmi(), NumberConstant(n)));
482 ASSERT_TRUE(reduction.Changed()); 480 ASSERT_TRUE(reduction.Changed());
483 EXPECT_THAT(reduction.replacement(), IsBooleanConstant(IsSmiDouble(n))); 481 EXPECT_THAT(reduction.replacement(), IsBooleanConstant(IsSmiDouble(n)));
484 } 482 }
485 } 483 }
486 484
487 } // namespace compiler 485 } // namespace compiler
488 } // namespace internal 486 } // namespace internal
489 } // namespace v8 487 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/verifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698