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 "src/v8.h" | 5 #include "src/v8.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
10 #include "src/compiler/graph-visualizer.h" | 10 #include "src/compiler/graph-visualizer.h" |
11 #include "src/compiler/js-operator.h" | 11 #include "src/compiler/js-operator.h" |
12 #include "src/compiler/machine-operator.h" | 12 #include "src/compiler/machine-operator.h" |
13 #include "src/compiler/node.h" | 13 #include "src/compiler/node.h" |
14 #include "src/compiler/operator.h" | 14 #include "src/compiler/operator.h" |
15 #include "src/compiler/schedule.h" | 15 #include "src/compiler/schedule.h" |
16 #include "src/compiler/scheduler.h" | 16 #include "src/compiler/scheduler.h" |
17 #include "src/compiler/source-position.h" | 17 #include "src/compiler/source-position.h" |
18 #include "src/compiler/verifier.h" | 18 #include "src/compiler/verifier.h" |
19 | 19 |
20 using namespace v8::internal; | 20 using namespace v8::internal; |
21 using namespace v8::internal::compiler; | 21 using namespace v8::internal::compiler; |
22 | 22 |
| 23 static Operator dummy_operator(IrOpcode::kParameter, Operator::kNoWrite, |
| 24 "dummy", 0, 0, 0, 1, 0, 0); |
| 25 |
| 26 |
23 TEST(NodeWithNullInputReachableFromEnd) { | 27 TEST(NodeWithNullInputReachableFromEnd) { |
24 HandleAndZoneScope scope; | 28 HandleAndZoneScope scope; |
25 Graph graph(scope.main_zone()); | 29 Graph graph(scope.main_zone()); |
26 CommonOperatorBuilder common(scope.main_zone()); | 30 CommonOperatorBuilder common(scope.main_zone()); |
27 | 31 |
28 Node* start = graph.NewNode(common.Start(0)); | 32 Node* start = graph.NewNode(common.Start(0)); |
29 graph.SetStart(start); | 33 graph.SetStart(start); |
30 Node* k = graph.NewNode(common.Int32Constant(0)); | 34 Node* k = graph.NewNode(common.Int32Constant(0)); |
31 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); | 35 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); |
32 phi->ReplaceInput(0, NULL); | 36 phi->ReplaceInput(0, NULL); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 graph.SetStart(start); | 90 graph.SetStart(start); |
87 Node* merge = graph.NewNode(common.Merge(2), start, start); | 91 Node* merge = graph.NewNode(common.Merge(2), start, start); |
88 merge->ReplaceInput(1, NULL); | 92 merge->ReplaceInput(1, NULL); |
89 graph.SetEnd(merge); | 93 graph.SetEnd(merge); |
90 | 94 |
91 OFStream os(stdout); | 95 OFStream os(stdout); |
92 os << AsDOT(graph); | 96 os << AsDOT(graph); |
93 SourcePositionTable table(&graph); | 97 SourcePositionTable table(&graph); |
94 os << AsJSON(graph, &table); | 98 os << AsJSON(graph, &table); |
95 } | 99 } |
| 100 |
| 101 |
| 102 TEST(NodeNetworkOfDummiesReachableFromEnd) { |
| 103 HandleAndZoneScope scope; |
| 104 Graph graph(scope.main_zone()); |
| 105 CommonOperatorBuilder common(scope.main_zone()); |
| 106 |
| 107 Node* start = graph.NewNode(common.Start(0)); |
| 108 graph.SetStart(start); |
| 109 Node* n2 = graph.NewNode(&dummy_operator, graph.start()); |
| 110 Node* n3 = graph.NewNode(&dummy_operator, graph.start()); |
| 111 Node* n4 = graph.NewNode(&dummy_operator, n2); |
| 112 Node* n5 = graph.NewNode(&dummy_operator, n2); |
| 113 Node* n6 = graph.NewNode(&dummy_operator, n3); |
| 114 Node* n7 = graph.NewNode(&dummy_operator, n3); |
| 115 Node* n8 = graph.NewNode(&dummy_operator, n5); |
| 116 Node* n9 = graph.NewNode(&dummy_operator, n5); |
| 117 Node* n10 = graph.NewNode(&dummy_operator, n9); |
| 118 Node* n11 = graph.NewNode(&dummy_operator, n9); |
| 119 Node* end_dependencies[6] = {n4, n8, n10, n11, n6, n7}; |
| 120 Node* end = graph.NewNode(&dummy_operator, 6, end_dependencies); |
| 121 graph.SetEnd(end); |
| 122 |
| 123 OFStream os(stdout); |
| 124 os << AsDOT(graph); |
| 125 SourcePositionTable table(&graph); |
| 126 os << AsJSON(graph, &table); |
| 127 } |
OLD | NEW |