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

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

Issue 2618273002: [turbofan] A bug fix of loadElimination (Closed)
Patch Set: add test case Created 3 years, 11 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/compiler/load-elimination.cc ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/load-elimination.h" 5 #include "src/compiler/load-elimination.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/compiler/simplified-operator.h" 9 #include "src/compiler/simplified-operator.h"
10 #include "test/unittests/compiler/graph-reducer-unittest.h" 10 #include "test/unittests/compiler/graph-reducer-unittest.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 load_elimination.Reduce(store); 167 load_elimination.Reduce(store);
168 168
169 Node* load = effect = graph()->NewNode(simplified()->LoadField(access), 169 Node* load = effect = graph()->NewNode(simplified()->LoadField(access),
170 object, effect, control); 170 object, effect, control);
171 EXPECT_CALL(editor, ReplaceWithValue(load, value, store, _)); 171 EXPECT_CALL(editor, ReplaceWithValue(load, value, store, _));
172 Reduction r = load_elimination.Reduce(load); 172 Reduction r = load_elimination.Reduce(load);
173 ASSERT_TRUE(r.Changed()); 173 ASSERT_TRUE(r.Changed());
174 EXPECT_EQ(value, r.replacement()); 174 EXPECT_EQ(value, r.replacement());
175 } 175 }
176 176
177 TEST_F(LoadEliminationTest, StoreFieldAndKillFields) {
178 Node* object = Parameter(Type::Any(), 0);
179 Node* value = Parameter(Type::Any(), 1);
180 Node* effect = graph()->start();
181 Node* control = graph()->start();
182
183 FieldAccess access1 = {kTaggedBase, kPointerSize,
184 MaybeHandle<Name>(), MaybeHandle<Map>(),
185 Type::Any(), MachineType::AnyTagged(),
186 kNoWriteBarrier};
187
188 // Offset that out of field cache size.
189 FieldAccess access2 = {kTaggedBase, 2048 * kPointerSize,
190 MaybeHandle<Name>(), MaybeHandle<Map>(),
191 Type::Any(), MachineType::AnyTagged(),
192 kNoWriteBarrier};
193
194 StrictMock<MockAdvancedReducerEditor> editor;
195 LoadElimination load_elimination(&editor, jsgraph(), zone());
196
197 load_elimination.Reduce(graph()->start());
198
199 Node* store1 = effect = graph()->NewNode(simplified()->StoreField(access1),
200 object, value, effect, control);
201 load_elimination.Reduce(store1);
202
203 // Invalidate caches of object.
204 Node* store2 = effect = graph()->NewNode(simplified()->StoreField(access2),
205 object, value, effect, control);
206 load_elimination.Reduce(store2);
207
208 Node* store3 = graph()->NewNode(simplified()->StoreField(access1),
209 object, value, effect, control);
210
211 Reduction r = load_elimination.Reduce(store3);
212
213 // store3 shall not be replaced, since caches were invalidated.
214 EXPECT_EQ(store3, r.replacement());
215 }
216
177 TEST_F(LoadEliminationTest, StoreFieldAndStoreElementAndLoadField) { 217 TEST_F(LoadEliminationTest, StoreFieldAndStoreElementAndLoadField) {
178 Node* object = Parameter(Type::Any(), 0); 218 Node* object = Parameter(Type::Any(), 0);
179 Node* value = Parameter(Type::Any(), 1); 219 Node* value = Parameter(Type::Any(), 1);
180 Node* index = Parameter(Type::UnsignedSmall(), 2); 220 Node* index = Parameter(Type::UnsignedSmall(), 2);
181 Node* effect = graph()->start(); 221 Node* effect = graph()->start();
182 Node* control = graph()->start(); 222 Node* control = graph()->start();
183 FieldAccess access = {kTaggedBase, kPointerSize, 223 FieldAccess access = {kTaggedBase, kPointerSize,
184 MaybeHandle<Name>(), MaybeHandle<Map>(), 224 MaybeHandle<Name>(), MaybeHandle<Map>(),
185 Type::Any(), MachineType::AnyTagged(), 225 Type::Any(), MachineType::AnyTagged(),
186 kNoWriteBarrier}; 226 kNoWriteBarrier};
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 effect, control); 498 effect, control);
459 EXPECT_CALL(editor, ReplaceWithValue(load, value0, effect, _)); 499 EXPECT_CALL(editor, ReplaceWithValue(load, value0, effect, _));
460 Reduction r = load_elimination.Reduce(load); 500 Reduction r = load_elimination.Reduce(load);
461 ASSERT_TRUE(r.Changed()); 501 ASSERT_TRUE(r.Changed());
462 EXPECT_EQ(value0, r.replacement()); 502 EXPECT_EQ(value0, r.replacement());
463 } 503 }
464 504
465 } // namespace compiler 505 } // namespace compiler
466 } // namespace internal 506 } // namespace internal
467 } // namespace v8 507 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/load-elimination.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698