Line data Source code
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
3 : // found in the LICENSE file.
4 :
5 : #include "src/compiler/checkpoint-elimination.h"
6 : #include "src/compiler/common-operator.h"
7 : #include "src/compiler/operator.h"
8 : #include "test/unittests/compiler/graph-reducer-unittest.h"
9 : #include "test/unittests/compiler/graph-unittest.h"
10 : #include "test/unittests/compiler/node-test-utils.h"
11 :
12 : using testing::StrictMock;
13 :
14 : namespace v8 {
15 : namespace internal {
16 : namespace compiler {
17 :
18 : class CheckpointEliminationTest : public GraphTest {
19 : public:
20 1 : CheckpointEliminationTest() : GraphTest() {}
21 1 : ~CheckpointEliminationTest() override = default;
22 :
23 : protected:
24 : Reduction Reduce(AdvancedReducer::Editor* editor, Node* node) {
25 1 : CheckpointElimination reducer(editor);
26 1 : return reducer.Reduce(node);
27 : }
28 :
29 1 : Reduction Reduce(Node* node) {
30 1 : StrictMock<MockAdvancedReducerEditor> editor;
31 1 : return Reduce(&editor, node);
32 : }
33 : };
34 :
35 : namespace {
36 :
37 3037 : const Operator kOpNoWrite(0, Operator::kNoWrite, "OpNoWrite", 0, 1, 0, 0, 1, 0);
38 :
39 : } // namespace
40 :
41 : // -----------------------------------------------------------------------------
42 : // Checkpoint
43 :
44 15189 : TEST_F(CheckpointEliminationTest, CheckpointChain) {
45 1 : Node* const control = graph()->start();
46 1 : Node* frame_state = EmptyFrameState();
47 : Node* checkpoint1 = graph()->NewNode(common()->Checkpoint(), frame_state,
48 1 : graph()->start(), control);
49 1 : Node* effect_link = graph()->NewNode(&kOpNoWrite, checkpoint1);
50 : Node* checkpoint2 = graph()->NewNode(common()->Checkpoint(), frame_state,
51 1 : effect_link, control);
52 1 : Reduction r = Reduce(checkpoint2);
53 2 : ASSERT_TRUE(r.Changed());
54 2 : EXPECT_EQ(effect_link, r.replacement());
55 : }
56 :
57 : } // namespace compiler
58 : } // namespace internal
59 9111 : } // namespace v8
|