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

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

Issue 638853004: [turbofan] Eliminate typed array bounds checks if both key and length are constant. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
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 | Annotate | Revision Log
« 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 "test/unittests/compiler/graph-unittest.h" 10 #include "test/unittests/compiler/graph-unittest.h"
10 11
11 namespace v8 { 12 namespace v8 {
12 namespace internal { 13 namespace internal {
13 namespace compiler { 14 namespace compiler {
14 15
15 class SimplifiedOperatorReducerTest : public GraphTest { 16 class SimplifiedOperatorReducerTest : public GraphTest {
16 public: 17 public:
17 explicit SimplifiedOperatorReducerTest(int num_parameters = 1) 18 explicit SimplifiedOperatorReducerTest(int num_parameters = 1)
18 : GraphTest(num_parameters), simplified_(zone()) {} 19 : GraphTest(num_parameters), simplified_(zone()) {}
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 TEST_F(SimplifiedOperatorReducerTest, ChangeUint32ToTagged) { 470 TEST_F(SimplifiedOperatorReducerTest, ChangeUint32ToTagged) {
470 TRACED_FOREACH(uint32_t, n, kUint32Values) { 471 TRACED_FOREACH(uint32_t, n, kUint32Values) {
471 Reduction reduction = 472 Reduction reduction =
472 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), 473 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(),
473 Int32Constant(bit_cast<int32_t>(n)))); 474 Int32Constant(bit_cast<int32_t>(n))));
474 ASSERT_TRUE(reduction.Changed()); 475 ASSERT_TRUE(reduction.Changed());
475 EXPECT_THAT(reduction.replacement(), IsNumberConstant(FastUI2D(n))); 476 EXPECT_THAT(reduction.replacement(), IsNumberConstant(FastUI2D(n)));
476 } 477 }
477 } 478 }
478 479
480
481 // -----------------------------------------------------------------------------
482 // LoadElement
483
484
485 TEST_F(SimplifiedOperatorReducerTest, LoadElementWithConstantKeyAndLength) {
486 ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0,
487 Type::Any(), kMachAnyTagged};
488 ElementAccess access_nocheck = access;
489 access_nocheck.bounds_check = kNoBoundsCheck;
490 Node* const base = Parameter(0);
491 Node* const effect = graph()->start();
492 Node* const control = graph()->start();
493 TRACED_FOREACH(double, key, kFloat64Values) {
494 TRACED_FOREACH(int32_t, length, kInt32Values) {
495 if (key < length) {
496 Reduction r = Reduce(graph()->NewNode(
497 simplified()->LoadElement(access), base, NumberConstant(key),
498 Int32Constant(length), effect, control));
499 ASSERT_TRUE(r.Changed());
500 EXPECT_THAT(r.replacement(),
501 IsLoadElement(access_nocheck, base, IsNumberConstant(key),
502 IsInt32Constant(length), effect, control));
503 }
504 }
505 }
506 }
507
508
509 // -----------------------------------------------------------------------------
510 // StoreElement
511
512
513 TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) {
514 ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0,
515 Type::Any(), kMachAnyTagged};
516 ElementAccess access_nocheck = access;
517 access_nocheck.bounds_check = kNoBoundsCheck;
518 Node* const base = Parameter(0);
519 Node* const value = Parameter(1);
520 Node* const effect = graph()->start();
521 Node* const control = graph()->start();
522 TRACED_FOREACH(int32_t, key, kInt32Values) {
523 TRACED_FOREACH(double, length, kFloat64Values) {
524 if (key < length) {
525 Reduction r = Reduce(graph()->NewNode(
526 simplified()->StoreElement(access), base, Int32Constant(key),
527 NumberConstant(length), value, effect, control));
528 ASSERT_TRUE(r.Changed());
529 EXPECT_THAT(
530 r.replacement(),
531 IsStoreElement(access_nocheck, base, IsInt32Constant(key),
532 IsNumberConstant(length), value, effect, control));
533 }
534 }
535 }
536 }
537
479 } // namespace compiler 538 } // namespace compiler
480 } // namespace internal 539 } // namespace internal
481 } // namespace v8 540 } // 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