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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/asm/int32array-constant-key.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/simplified-operator-reducer-unittest.cc
diff --git a/test/unittests/compiler/simplified-operator-reducer-unittest.cc b/test/unittests/compiler/simplified-operator-reducer-unittest.cc
index ac502416264bad2ffba984b2f68989d4d9af76d7..694bdd87aa5b2c349a1f2fbc9429b3cb15d06300 100644
--- a/test/unittests/compiler/simplified-operator-reducer-unittest.cc
+++ b/test/unittests/compiler/simplified-operator-reducer-unittest.cc
@@ -6,6 +6,7 @@
#include "src/compiler/simplified-operator.h"
#include "src/compiler/simplified-operator-reducer.h"
#include "src/conversions.h"
+#include "src/types.h"
#include "test/unittests/compiler/graph-unittest.h"
namespace v8 {
@@ -476,6 +477,64 @@ TEST_F(SimplifiedOperatorReducerTest, ChangeUint32ToTagged) {
}
}
+
+// -----------------------------------------------------------------------------
+// LoadElement
+
+
+TEST_F(SimplifiedOperatorReducerTest, LoadElementWithConstantKeyAndLength) {
+ ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0,
+ Type::Any(), kMachAnyTagged};
+ ElementAccess access_nocheck = access;
+ access_nocheck.bounds_check = kNoBoundsCheck;
+ Node* const base = Parameter(0);
+ Node* const effect = graph()->start();
+ Node* const control = graph()->start();
+ TRACED_FOREACH(double, key, kFloat64Values) {
+ TRACED_FOREACH(int32_t, length, kInt32Values) {
+ if (key < length) {
+ Reduction r = Reduce(graph()->NewNode(
+ simplified()->LoadElement(access), base, NumberConstant(key),
+ Int32Constant(length), effect, control));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(),
+ IsLoadElement(access_nocheck, base, IsNumberConstant(key),
+ IsInt32Constant(length), effect, control));
+ }
+ }
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// StoreElement
+
+
+TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) {
+ ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0,
+ Type::Any(), kMachAnyTagged};
+ ElementAccess access_nocheck = access;
+ access_nocheck.bounds_check = kNoBoundsCheck;
+ Node* const base = Parameter(0);
+ Node* const value = Parameter(1);
+ Node* const effect = graph()->start();
+ Node* const control = graph()->start();
+ TRACED_FOREACH(int32_t, key, kInt32Values) {
+ TRACED_FOREACH(double, length, kFloat64Values) {
+ if (key < length) {
+ Reduction r = Reduce(graph()->NewNode(
+ simplified()->StoreElement(access), base, Int32Constant(key),
+ NumberConstant(length), value, effect, control));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(
+ r.replacement(),
+ IsStoreElement(access_nocheck, base, IsInt32Constant(key),
+ IsNumberConstant(length), value, effect, control));
+ }
+ }
+ }
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
« 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