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

Unified Diff: test/unittests/compiler/load-elimination-unittest.cc

Issue 2120253002: [turbofan] Initial version of the new LoadElimination. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@TurboFan_StackCheck_NoWrite
Patch Set: REBASE. Created 4 years, 5 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 | « src/flag-definitions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/load-elimination-unittest.cc
diff --git a/test/unittests/compiler/load-elimination-unittest.cc b/test/unittests/compiler/load-elimination-unittest.cc
index 721d6dfb1e551c5c6cf8af9b18ec9da46a4cbe4f..965390e42256ea281bd85a35d799e8aedfae2dff 100644
--- a/test/unittests/compiler/load-elimination-unittest.cc
+++ b/test/unittests/compiler/load-elimination-unittest.cc
@@ -1,9 +1,10 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
+// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "src/compiler/access-builder.h"
#include "src/compiler/load-elimination.h"
+#include "src/compiler/access-builder.h"
+#include "src/compiler/node.h"
#include "src/compiler/simplified-operator.h"
#include "test/unittests/compiler/graph-unittest.h"
#include "test/unittests/compiler/node-test-utils.h"
@@ -18,11 +19,9 @@ class LoadEliminationTest : public TypedGraphTest {
~LoadEliminationTest() override {}
protected:
- Reduction Reduce(Node* node) {
- // TODO(titzer): mock the GraphReducer here for better unit testing.
- GraphReducer graph_reducer(zone(), graph());
- LoadElimination reducer(&graph_reducer, graph(), simplified());
- return reducer.Reduce(node);
+ void Run() {
+ LoadElimination load_elimination(graph(), zone());
+ load_elimination.Run();
}
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
@@ -31,42 +30,49 @@ class LoadEliminationTest : public TypedGraphTest {
SimplifiedOperatorBuilder simplified_;
};
-
-TEST_F(LoadEliminationTest, LoadFieldWithStoreField) {
- Node* object1 = Parameter(Type::Any(), 0);
- Node* object2 = Parameter(Type::Any(), 1);
- Node* value = Parameter(Type::Any(), 2);
+TEST_F(LoadEliminationTest, LoadFieldAndLoadField) {
+ Node* object = Parameter(Type::Any(), 0);
Node* effect = graph()->start();
Node* control = graph()->start();
+ FieldAccess access = {kTaggedBase,
+ kPointerSize,
+ MaybeHandle<Name>(),
+ Type::Any(),
+ MachineType::AnyTagged(),
+ kNoWriteBarrier};
+ Node* load1 = effect = graph()->NewNode(simplified()->LoadField(access),
+ object, effect, control);
+ Node* load2 = effect = graph()->NewNode(simplified()->LoadField(access),
+ object, effect, control);
+ control = graph()->NewNode(common()->Return(), load2, effect, control);
+ graph()->end()->ReplaceInput(0, control);
- FieldAccess access1 = AccessBuilder::ForContextSlot(42);
- Node* store1 = graph()->NewNode(simplified()->StoreField(access1), object1,
- value, effect, control);
- Reduction r1 = Reduce(graph()->NewNode(simplified()->LoadField(access1),
- object1, store1, control));
- ASSERT_TRUE(r1.Changed());
- EXPECT_EQ(value, r1.replacement());
+ Run();
- FieldAccess access2 = AccessBuilder::ForMap();
- Node* store2 = graph()->NewNode(simplified()->StoreField(access2), object1,
- object2, store1, control);
- Reduction r2 = Reduce(graph()->NewNode(simplified()->LoadField(access2),
- object1, store2, control));
- ASSERT_TRUE(r2.Changed());
- EXPECT_EQ(object2, r2.replacement());
+ EXPECT_THAT(graph()->end(), IsEnd(IsReturn(load1, load1, graph()->start())));
+}
- Node* store3 = graph()->NewNode(
- simplified()->StoreBuffer(BufferAccess(kExternalInt8Array)), object2,
- value, Int32Constant(10), object1, store2, control);
+TEST_F(LoadEliminationTest, StoreFieldAndLoadField) {
+ Node* object = Parameter(Type::Any(), 0);
+ Node* value = Parameter(Type::Any(), 1);
+ Node* effect = graph()->start();
+ Node* control = graph()->start();
+ FieldAccess access = {kTaggedBase,
+ kPointerSize,
+ MaybeHandle<Name>(),
+ Type::Any(),
+ MachineType::AnyTagged(),
+ kNoWriteBarrier};
+ Node* store = effect = graph()->NewNode(simplified()->StoreField(access),
+ object, value, effect, control);
+ Node* load = effect = graph()->NewNode(simplified()->LoadField(access),
+ object, effect, control);
+ control = graph()->NewNode(common()->Return(), load, effect, control);
+ graph()->end()->ReplaceInput(0, control);
- Reduction r3 = Reduce(graph()->NewNode(simplified()->LoadField(access1),
- object2, store3, control));
- ASSERT_FALSE(r3.Changed());
+ Run();
- Reduction r4 = Reduce(graph()->NewNode(simplified()->LoadField(access1),
- object1, store3, control));
- ASSERT_TRUE(r4.Changed());
- EXPECT_EQ(value, r4.replacement());
+ EXPECT_THAT(graph()->end(), IsEnd(IsReturn(value, store, graph()->start())));
}
} // namespace compiler
« no previous file with comments | « src/flag-definitions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698