| OLD | NEW |
| 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 StrictMock<MockAdvancedReducerEditor> editor; | 458 StrictMock<MockAdvancedReducerEditor> editor; |
| 459 LoadElimination load_elimination(&editor, jsgraph(), zone()); | 459 LoadElimination load_elimination(&editor, jsgraph(), zone()); |
| 460 | 460 |
| 461 load_elimination.Reduce(effect); | 461 load_elimination.Reduce(effect); |
| 462 | 462 |
| 463 effect = graph()->NewNode( | 463 effect = graph()->NewNode( |
| 464 common()->BeginRegion(RegionObservability::kNotObservable), effect); | 464 common()->BeginRegion(RegionObservability::kNotObservable), effect); |
| 465 load_elimination.Reduce(effect); | 465 load_elimination.Reduce(effect); |
| 466 | 466 |
| 467 Node* object0 = effect = | 467 Node* object0 = effect = |
| 468 graph()->NewNode(simplified()->Allocate(NOT_TENURED), | 468 graph()->NewNode(simplified()->Allocate(Type::Any(), NOT_TENURED), |
| 469 jsgraph()->Constant(16), effect, control); | 469 jsgraph()->Constant(16), effect, control); |
| 470 load_elimination.Reduce(effect); | 470 load_elimination.Reduce(effect); |
| 471 | 471 |
| 472 Node* region0 = effect = | 472 Node* region0 = effect = |
| 473 graph()->NewNode(common()->FinishRegion(), object0, effect); | 473 graph()->NewNode(common()->FinishRegion(), object0, effect); |
| 474 load_elimination.Reduce(effect); | 474 load_elimination.Reduce(effect); |
| 475 | 475 |
| 476 effect = graph()->NewNode( | 476 effect = graph()->NewNode( |
| 477 common()->BeginRegion(RegionObservability::kNotObservable), effect); | 477 common()->BeginRegion(RegionObservability::kNotObservable), effect); |
| 478 load_elimination.Reduce(effect); | 478 load_elimination.Reduce(effect); |
| 479 | 479 |
| 480 Node* object1 = effect = | 480 Node* object1 = effect = |
| 481 graph()->NewNode(simplified()->Allocate(NOT_TENURED), | 481 graph()->NewNode(simplified()->Allocate(Type::Any(), NOT_TENURED), |
| 482 jsgraph()->Constant(16), effect, control); | 482 jsgraph()->Constant(16), effect, control); |
| 483 load_elimination.Reduce(effect); | 483 load_elimination.Reduce(effect); |
| 484 | 484 |
| 485 Node* region1 = effect = | 485 Node* region1 = effect = |
| 486 graph()->NewNode(common()->FinishRegion(), object1, effect); | 486 graph()->NewNode(common()->FinishRegion(), object1, effect); |
| 487 load_elimination.Reduce(effect); | 487 load_elimination.Reduce(effect); |
| 488 | 488 |
| 489 effect = graph()->NewNode(simplified()->StoreField(access), region0, value0, | 489 effect = graph()->NewNode(simplified()->StoreField(access), region0, value0, |
| 490 effect, control); | 490 effect, control); |
| 491 load_elimination.Reduce(effect); | 491 load_elimination.Reduce(effect); |
| 492 | 492 |
| 493 effect = graph()->NewNode(simplified()->StoreField(access), region1, value1, | 493 effect = graph()->NewNode(simplified()->StoreField(access), region1, value1, |
| 494 effect, control); | 494 effect, control); |
| 495 load_elimination.Reduce(effect); | 495 load_elimination.Reduce(effect); |
| 496 | 496 |
| 497 Node* load = graph()->NewNode(simplified()->LoadField(access), region0, | 497 Node* load = graph()->NewNode(simplified()->LoadField(access), region0, |
| 498 effect, control); | 498 effect, control); |
| 499 EXPECT_CALL(editor, ReplaceWithValue(load, value0, effect, _)); | 499 EXPECT_CALL(editor, ReplaceWithValue(load, value0, effect, _)); |
| 500 Reduction r = load_elimination.Reduce(load); | 500 Reduction r = load_elimination.Reduce(load); |
| 501 ASSERT_TRUE(r.Changed()); | 501 ASSERT_TRUE(r.Changed()); |
| 502 EXPECT_EQ(value0, r.replacement()); | 502 EXPECT_EQ(value0, r.replacement()); |
| 503 } | 503 } |
| 504 | 504 |
| 505 } // namespace compiler | 505 } // namespace compiler |
| 506 } // namespace internal | 506 } // namespace internal |
| 507 } // namespace v8 | 507 } // namespace v8 |
| OLD | NEW |