OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 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 "test/cctest/compiler/simplified-graph-builder.h" | 5 #include "test/cctest/compiler/simplified-graph-builder.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
11 SimplifiedGraphBuilder::SimplifiedGraphBuilder( | 11 SimplifiedGraphBuilder::SimplifiedGraphBuilder( |
12 Graph* graph, CommonOperatorBuilder* common, | 12 Graph* graph, CommonOperatorBuilder* common, |
13 MachineOperatorBuilder* machine, SimplifiedOperatorBuilder* simplified) | 13 MachineOperatorBuilder* machine, SimplifiedOperatorBuilder* simplified) |
14 : StructuredGraphBuilder(graph, common), | 14 : StructuredGraphBuilder(graph, common), |
15 machine_(machine), | 15 machine_(machine), |
16 simplified_(simplified) {} | 16 simplified_(simplified) {} |
17 | 17 |
18 | 18 |
19 void SimplifiedGraphBuilder::Begin() { | 19 void SimplifiedGraphBuilder::Begin() { |
20 ASSERT(graph()->start() == NULL); | 20 DCHECK(graph()->start() == NULL); |
21 Node* start = graph()->NewNode(common()->Start()); | 21 Node* start = graph()->NewNode(common()->Start()); |
22 graph()->SetStart(start); | 22 graph()->SetStart(start); |
23 set_environment(new (zone()) Environment(this, start)); | 23 set_environment(new (zone()) Environment(this, start)); |
24 } | 24 } |
25 | 25 |
26 | 26 |
27 void SimplifiedGraphBuilder::Return(Node* value) { | 27 void SimplifiedGraphBuilder::Return(Node* value) { |
28 Node* control = NewNode(common()->Return(), value); | 28 Node* control = NewNode(common()->Return(), value); |
29 UpdateControlDependencyToLeaveFunction(control); | 29 UpdateControlDependencyToLeaveFunction(control); |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 void SimplifiedGraphBuilder::End() { | 33 void SimplifiedGraphBuilder::End() { |
34 environment()->UpdateControlDependency(exit_control()); | 34 environment()->UpdateControlDependency(exit_control()); |
35 graph()->SetEnd(NewNode(common()->End())); | 35 graph()->SetEnd(NewNode(common()->End())); |
36 } | 36 } |
37 | 37 |
38 | 38 |
39 SimplifiedGraphBuilder::Environment::Environment( | 39 SimplifiedGraphBuilder::Environment::Environment( |
40 SimplifiedGraphBuilder* builder, Node* control_dependency) | 40 SimplifiedGraphBuilder* builder, Node* control_dependency) |
41 : StructuredGraphBuilder::Environment(builder, control_dependency) {} | 41 : StructuredGraphBuilder::Environment(builder, control_dependency) {} |
42 | 42 |
43 | 43 |
44 Node* SimplifiedGraphBuilder::Environment::Top() { | 44 Node* SimplifiedGraphBuilder::Environment::Top() { |
45 ASSERT(!values()->empty()); | 45 DCHECK(!values()->empty()); |
46 return values()->back(); | 46 return values()->back(); |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 void SimplifiedGraphBuilder::Environment::Push(Node* node) { | 50 void SimplifiedGraphBuilder::Environment::Push(Node* node) { |
51 values()->push_back(node); | 51 values()->push_back(node); |
52 } | 52 } |
53 | 53 |
54 | 54 |
55 Node* SimplifiedGraphBuilder::Environment::Pop() { | 55 Node* SimplifiedGraphBuilder::Environment::Pop() { |
56 ASSERT(!values()->empty()); | 56 DCHECK(!values()->empty()); |
57 Node* back = values()->back(); | 57 Node* back = values()->back(); |
58 values()->pop_back(); | 58 values()->pop_back(); |
59 return back; | 59 return back; |
60 } | 60 } |
61 | 61 |
62 | 62 |
63 void SimplifiedGraphBuilder::Environment::Poke(size_t depth, Node* node) { | 63 void SimplifiedGraphBuilder::Environment::Poke(size_t depth, Node* node) { |
64 ASSERT(depth < values()->size()); | 64 DCHECK(depth < values()->size()); |
65 size_t index = values()->size() - depth - 1; | 65 size_t index = values()->size() - depth - 1; |
66 values()->at(index) = node; | 66 values()->at(index) = node; |
67 } | 67 } |
68 | 68 |
69 | 69 |
70 Node* SimplifiedGraphBuilder::Environment::Peek(size_t depth) { | 70 Node* SimplifiedGraphBuilder::Environment::Peek(size_t depth) { |
71 ASSERT(depth < values()->size()); | 71 DCHECK(depth < values()->size()); |
72 size_t index = values()->size() - depth - 1; | 72 size_t index = values()->size() - depth - 1; |
73 return values()->at(index); | 73 return values()->at(index); |
74 } | 74 } |
75 | 75 |
76 } // namespace compiler | 76 } // namespace compiler |
77 } // namespace internal | 77 } // namespace internal |
78 } // namespace v8 | 78 } // namespace v8 |
OLD | NEW |