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

Unified Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 776243002: [turbofan] Reduce context accesses during typed lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/js-typed-lowering.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/js-typed-lowering-unittest.cc
diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc b/test/unittests/compiler/js-typed-lowering-unittest.cc
index 287bba218a952dcc2eda4e8a8c14a0654a9fe5e4..61943b1762ce5a5b05282f19cfedbeffbf0db6ae 100644
--- a/test/unittests/compiler/js-typed-lowering-unittest.cc
+++ b/test/unittests/compiler/js-typed-lowering-unittest.cc
@@ -25,6 +25,9 @@ const ExternalArrayType kExternalArrayTypes[] = {
kExternalFloat32Array, kExternalFloat64Array};
+const size_t kIndices[] = {0, 1, 42, 100, 1024};
+
+
Type* const kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(),
Type::Number(), Type::String(), Type::Object()};
@@ -230,6 +233,74 @@ TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndUnsigned32) {
// -----------------------------------------------------------------------------
+// JSLoadContext
+
+
+TEST_F(JSTypedLoweringTest, JSLoadContext) {
+ Node* const context = Parameter(Type::Any());
+ Node* const effect = graph()->start();
+ static bool kBooleans[] = {false, true};
+ TRACED_FOREACH(size_t, index, kIndices) {
+ TRACED_FOREACH(bool, immutable, kBooleans) {
+ Reduction const r1 = Reduce(
+ graph()->NewNode(javascript()->LoadContext(0, index, immutable),
+ context, context, effect));
+ ASSERT_TRUE(r1.Changed());
+ EXPECT_THAT(r1.replacement(),
+ IsLoadField(AccessBuilder::ForContextSlot(index), context,
+ effect, graph()->start()));
+
+ Reduction const r2 = Reduce(
+ graph()->NewNode(javascript()->LoadContext(1, index, immutable),
+ context, context, effect));
+ ASSERT_TRUE(r2.Changed());
+ EXPECT_THAT(r2.replacement(),
+ IsLoadField(AccessBuilder::ForContextSlot(index),
+ IsLoadField(AccessBuilder::ForContextSlot(
+ Context::PREVIOUS_INDEX),
+ context, effect, graph()->start()),
+ effect, graph()->start()));
+ }
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// JSStoreContext
+
+
+TEST_F(JSTypedLoweringTest, JSStoreContext) {
+ Node* const context = Parameter(Type::Any());
+ Node* const effect = graph()->start();
+ Node* const control = graph()->start();
+ TRACED_FOREACH(size_t, index, kIndices) {
+ TRACED_FOREACH(Type*, type, kJSTypes) {
+ Node* const value = Parameter(type);
+
+ Reduction const r1 =
+ Reduce(graph()->NewNode(javascript()->StoreContext(0, index), context,
+ value, context, effect, control));
+ ASSERT_TRUE(r1.Changed());
+ EXPECT_THAT(r1.replacement(),
+ IsStoreField(AccessBuilder::ForContextSlot(index), context,
+ value, effect, control));
+
+ Reduction const r2 =
+ Reduce(graph()->NewNode(javascript()->StoreContext(1, index), context,
+ value, context, effect, control));
+ ASSERT_TRUE(r2.Changed());
+ EXPECT_THAT(r2.replacement(),
+ IsStoreField(AccessBuilder::ForContextSlot(index),
+ IsLoadField(AccessBuilder::ForContextSlot(
+ Context::PREVIOUS_INDEX),
+ context, effect, graph()->start()),
+ value, effect, control));
+ }
+ }
+}
+
+
+// -----------------------------------------------------------------------------
// JSLoadProperty
« no previous file with comments | « src/compiler/js-typed-lowering.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698