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

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

Issue 763963002: [turbofan] Add checked load/store operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reapply fix. Created 6 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
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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 TEST_F(SimplifiedOperatorReducerTest, ChangeUint32ToTagged) { 471 TEST_F(SimplifiedOperatorReducerTest, ChangeUint32ToTagged) {
472 TRACED_FOREACH(uint32_t, n, kUint32Values) { 472 TRACED_FOREACH(uint32_t, n, kUint32Values) {
473 Reduction reduction = 473 Reduction reduction =
474 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), 474 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(),
475 Int32Constant(bit_cast<int32_t>(n)))); 475 Int32Constant(bit_cast<int32_t>(n))));
476 ASSERT_TRUE(reduction.Changed()); 476 ASSERT_TRUE(reduction.Changed());
477 EXPECT_THAT(reduction.replacement(), IsNumberConstant(FastUI2D(n))); 477 EXPECT_THAT(reduction.replacement(), IsNumberConstant(FastUI2D(n)));
478 } 478 }
479 } 479 }
480 480
481
482 // -----------------------------------------------------------------------------
483 // LoadElement
484
485
486 TEST_F(SimplifiedOperatorReducerTest, LoadElementWithConstantKeyAndLength) {
487 ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0,
488 Type::Any(), kMachAnyTagged};
489 ElementAccess access_nocheck = access;
490 access_nocheck.bounds_check = kNoBoundsCheck;
491 Node* const base = Parameter(0);
492 Node* const effect = graph()->start();
493 {
494 Node* const key = NumberConstant(-42.0);
495 Node* const length = NumberConstant(100.0);
496 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
497 base, key, length, effect));
498 ASSERT_FALSE(r.Changed());
499 }
500 {
501 Node* const key = NumberConstant(-0.0);
502 Node* const length = NumberConstant(1.0);
503 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
504 base, key, length, effect));
505 ASSERT_TRUE(r.Changed());
506 EXPECT_THAT(r.replacement(),
507 IsLoadElement(access_nocheck, base, key, length, effect));
508 }
509 {
510 Node* const key = NumberConstant(0);
511 Node* const length = NumberConstant(1);
512 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
513 base, key, length, effect));
514 ASSERT_TRUE(r.Changed());
515 EXPECT_THAT(r.replacement(),
516 IsLoadElement(access_nocheck, base, key, length, effect));
517 }
518 {
519 Node* const key = NumberConstant(42.2);
520 Node* const length = NumberConstant(128);
521 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
522 base, key, length, effect));
523 ASSERT_TRUE(r.Changed());
524 EXPECT_THAT(r.replacement(),
525 IsLoadElement(access_nocheck, base, key, length, effect));
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));
532 ASSERT_FALSE(r.Changed());
533 }
534 }
535
536
537 // -----------------------------------------------------------------------------
538 // StoreElement
539
540
541 TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) {
542 ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0,
543 Type::Any(), kMachAnyTagged};
544 ElementAccess access_nocheck = access;
545 access_nocheck.bounds_check = kNoBoundsCheck;
546 Node* const base = Parameter(0);
547 Node* const value = Parameter(1);
548 Node* const effect = graph()->start();
549 Node* const control = graph()->start();
550 {
551 Node* const key = NumberConstant(-72.1);
552 Node* const length = NumberConstant(0.0);
553 Reduction r =
554 Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
555 length, value, effect, control));
556 ASSERT_FALSE(r.Changed());
557 }
558 {
559 Node* const key = NumberConstant(-0.0);
560 Node* const length = NumberConstant(999);
561 Reduction r =
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 = NumberConstant(0);
571 Node* const length = NumberConstant(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 = NumberConstant(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());
598 }
599 }
600
601 } // namespace compiler 481 } // namespace compiler
602 } // namespace internal 482 } // namespace internal
603 } // namespace v8 483 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/node-test-utils.cc ('k') | test/unittests/compiler/simplified-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698