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

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

Issue 647773004: [turbofan] Skip bounds checks for positive indices only. (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Created 6 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 | « test/mjsunit/asm/int32array-constant-key.js ('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/js-graph.h" 5 #include "src/compiler/js-graph.h"
6 #include "src/compiler/simplified-operator.h" 6 #include "src/compiler/simplified-operator.h"
7 #include "src/compiler/simplified-operator-reducer.h" 7 #include "src/compiler/simplified-operator-reducer.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/types.h" 9 #include "src/types.h"
10 #include "test/unittests/compiler/graph-unittest.h" 10 #include "test/unittests/compiler/graph-unittest.h"
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 483
484 484
485 TEST_F(SimplifiedOperatorReducerTest, LoadElementWithConstantKeyAndLength) { 485 TEST_F(SimplifiedOperatorReducerTest, LoadElementWithConstantKeyAndLength) {
486 ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0, 486 ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0,
487 Type::Any(), kMachAnyTagged}; 487 Type::Any(), kMachAnyTagged};
488 ElementAccess access_nocheck = access; 488 ElementAccess access_nocheck = access;
489 access_nocheck.bounds_check = kNoBoundsCheck; 489 access_nocheck.bounds_check = kNoBoundsCheck;
490 Node* const base = Parameter(0); 490 Node* const base = Parameter(0);
491 Node* const effect = graph()->start(); 491 Node* const effect = graph()->start();
492 Node* const control = graph()->start(); 492 Node* const control = graph()->start();
493 TRACED_FOREACH(double, key, kFloat64Values) { 493 {
494 TRACED_FOREACH(int32_t, length, kInt32Values) { 494 Node* const key = NumberConstant(-42.0);
495 if (key < length) { 495 Node* const length = NumberConstant(100.0);
496 Reduction r = Reduce(graph()->NewNode( 496 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
497 simplified()->LoadElement(access), base, NumberConstant(key), 497 base, key, length, effect, control));
498 Int32Constant(length), effect, control)); 498 ASSERT_FALSE(r.Changed());
499 ASSERT_TRUE(r.Changed()); 499 }
500 EXPECT_THAT(r.replacement(), 500 {
501 IsLoadElement(access_nocheck, base, IsNumberConstant(key), 501 Node* const key = NumberConstant(-0.0);
502 IsInt32Constant(length), effect, control)); 502 Node* const length = NumberConstant(1.0);
503 } 503 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
504 } 504 base, key, length, effect, control));
505 ASSERT_TRUE(r.Changed());
506 EXPECT_THAT(r.replacement(), IsLoadElement(access_nocheck, base, key,
507 length, effect, control));
508 }
509 {
510 Node* const key = Int32Constant(0);
511 Node* const length = Int32Constant(1);
512 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
513 base, key, length, effect, control));
514 ASSERT_TRUE(r.Changed());
515 EXPECT_THAT(r.replacement(), IsLoadElement(access_nocheck, base, key,
516 length, effect, control));
517 }
518 {
519 Node* const key = NumberConstant(42.2);
520 Node* const length = Int32Constant(128);
521 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
522 base, key, length, effect, control));
523 ASSERT_TRUE(r.Changed());
524 EXPECT_THAT(r.replacement(), IsLoadElement(access_nocheck, base, key,
525 length, effect, control));
526 }
527 {
528 Node* const key = NumberConstant(39.2);
529 Node* const length = NumberConstant(32.0);
530 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
531 base, key, length, effect, control));
532 ASSERT_FALSE(r.Changed());
505 } 533 }
506 } 534 }
507 535
508 536
509 // ----------------------------------------------------------------------------- 537 // -----------------------------------------------------------------------------
510 // StoreElement 538 // StoreElement
511 539
512 540
513 TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) { 541 TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) {
514 ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0, 542 ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0,
515 Type::Any(), kMachAnyTagged}; 543 Type::Any(), kMachAnyTagged};
516 ElementAccess access_nocheck = access; 544 ElementAccess access_nocheck = access;
517 access_nocheck.bounds_check = kNoBoundsCheck; 545 access_nocheck.bounds_check = kNoBoundsCheck;
518 Node* const base = Parameter(0); 546 Node* const base = Parameter(0);
519 Node* const value = Parameter(1); 547 Node* const value = Parameter(1);
520 Node* const effect = graph()->start(); 548 Node* const effect = graph()->start();
521 Node* const control = graph()->start(); 549 Node* const control = graph()->start();
522 TRACED_FOREACH(int32_t, key, kInt32Values) { 550 {
523 TRACED_FOREACH(double, length, kFloat64Values) { 551 Node* const key = NumberConstant(-72.1);
524 if (key < length) { 552 Node* const length = NumberConstant(0.0);
525 Reduction r = Reduce(graph()->NewNode( 553 Reduction r =
526 simplified()->StoreElement(access), base, Int32Constant(key), 554 Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
527 NumberConstant(length), value, effect, control)); 555 length, value, effect, control));
528 ASSERT_TRUE(r.Changed()); 556 ASSERT_FALSE(r.Changed());
529 EXPECT_THAT( 557 }
530 r.replacement(), 558 {
531 IsStoreElement(access_nocheck, base, IsInt32Constant(key), 559 Node* const key = NumberConstant(-0.0);
532 IsNumberConstant(length), value, effect, control)); 560 Node* const length = Int32Constant(999);
533 } 561 Reduction r =
534 } 562 Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
563 length, value, effect, control));
564 ASSERT_TRUE(r.Changed());
565 EXPECT_THAT(r.replacement(),
566 IsStoreElement(access_nocheck, base, key, length, value, effect,
567 control));
568 }
569 {
570 Node* const key = Int32Constant(0);
571 Node* const length = Int32Constant(1);
572 Reduction r =
573 Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
574 length, value, effect, control));
575 ASSERT_TRUE(r.Changed());
576 EXPECT_THAT(r.replacement(),
577 IsStoreElement(access_nocheck, base, key, length, value, effect,
578 control));
579 }
580 {
581 Node* const key = NumberConstant(42.2);
582 Node* const length = Int32Constant(128);
583 Reduction r =
584 Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
585 length, value, effect, control));
586 ASSERT_TRUE(r.Changed());
587 EXPECT_THAT(r.replacement(),
588 IsStoreElement(access_nocheck, base, key, length, value, effect,
589 control));
590 }
591 {
592 Node* const key = NumberConstant(39.2);
593 Node* const length = NumberConstant(32.0);
594 Reduction r =
595 Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
596 length, value, effect, control));
597 ASSERT_FALSE(r.Changed());
535 } 598 }
536 } 599 }
537 600
538 } // namespace compiler 601 } // namespace compiler
539 } // namespace internal 602 } // namespace internal
540 } // namespace v8 603 } // namespace v8
OLDNEW
« no previous file with comments | « test/mjsunit/asm/int32array-constant-key.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698