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

Side by Side 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: Fix DCHECK. Check types on substitution. 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 unified diff | Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
Jarin 2016/07/04 13:18:07 Actually, this is unit-testable, so we should test
Benedikt Meurer 2016/07/05 11:29:09 Done.
4
5 #include "src/compiler/access-builder.h"
6 #include "src/compiler/load-elimination.h"
7 #include "src/compiler/simplified-operator.h"
8 #include "test/unittests/compiler/graph-unittest.h"
9 #include "test/unittests/compiler/node-test-utils.h"
10
11 namespace v8 {
12 namespace internal {
13 namespace compiler {
14
15 class LoadEliminationTest : public TypedGraphTest {
16 public:
17 LoadEliminationTest() : TypedGraphTest(3), simplified_(zone()) {}
18 ~LoadEliminationTest() override {}
19
20 protected:
21 Reduction Reduce(Node* node) {
22 // TODO(titzer): mock the GraphReducer here for better unit testing.
23 GraphReducer graph_reducer(zone(), graph());
24 LoadElimination reducer(&graph_reducer, graph(), simplified());
25 return reducer.Reduce(node);
26 }
27
28 SimplifiedOperatorBuilder* simplified() { return &simplified_; }
29
30 private:
31 SimplifiedOperatorBuilder simplified_;
32 };
33
34
35 TEST_F(LoadEliminationTest, LoadFieldWithStoreField) {
36 Node* object1 = Parameter(Type::Any(), 0);
37 Node* object2 = Parameter(Type::Any(), 1);
38 Node* value = Parameter(Type::Any(), 2);
39 Node* effect = graph()->start();
40 Node* control = graph()->start();
41
42 FieldAccess access1 = AccessBuilder::ForContextSlot(42);
43 Node* store1 = graph()->NewNode(simplified()->StoreField(access1), object1,
44 value, effect, control);
45 Reduction r1 = Reduce(graph()->NewNode(simplified()->LoadField(access1),
46 object1, store1, control));
47 ASSERT_TRUE(r1.Changed());
48 EXPECT_EQ(value, r1.replacement());
49
50 FieldAccess access2 = AccessBuilder::ForMap();
51 Node* store2 = graph()->NewNode(simplified()->StoreField(access2), object1,
52 object2, store1, control);
53 Reduction r2 = Reduce(graph()->NewNode(simplified()->LoadField(access2),
54 object1, store2, control));
55 ASSERT_TRUE(r2.Changed());
56 EXPECT_EQ(object2, r2.replacement());
57
58 Node* store3 = graph()->NewNode(
59 simplified()->StoreBuffer(BufferAccess(kExternalInt8Array)), object2,
60 value, Int32Constant(10), object1, store2, control);
61
62 Reduction r3 = Reduce(graph()->NewNode(simplified()->LoadField(access1),
63 object2, store3, control));
64 ASSERT_FALSE(r3.Changed());
65
66 Reduction r4 = Reduce(graph()->NewNode(simplified()->LoadField(access1),
67 object1, store3, control));
68 ASSERT_TRUE(r4.Changed());
69 EXPECT_EQ(value, r4.replacement());
70 }
71
72 } // namespace compiler
73 } // namespace internal
74 } // namespace v8
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698