| 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/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
| 6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
| 7 #include "src/compiler/graph-visualizer.h" | 7 #include "src/compiler/graph-visualizer.h" |
| 8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
| 9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
| 10 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 Node* start = graph.NewNode(common.Start(0)); | 33 Node* start = graph.NewNode(common.Start(0)); |
| 34 graph.SetStart(start); | 34 graph.SetStart(start); |
| 35 Node* k = graph.NewNode(common.Int32Constant(0)); | 35 Node* k = graph.NewNode(common.Int32Constant(0)); |
| 36 Node* phi = | 36 Node* phi = |
| 37 graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start); | 37 graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start); |
| 38 phi->ReplaceInput(0, NULL); | 38 phi->ReplaceInput(0, NULL); |
| 39 graph.SetEnd(phi); | 39 graph.SetEnd(phi); |
| 40 | 40 |
| 41 OFStream os(stdout); | 41 OFStream os(stdout); |
| 42 os << AsDOT(graph); | |
| 43 SourcePositionTable table(&graph); | 42 SourcePositionTable table(&graph); |
| 44 os << AsJSON(graph, &table); | 43 os << AsJSON(graph, &table); |
| 45 } | 44 } |
| 46 | 45 |
| 47 | 46 |
| 48 TEST(NodeWithNullControlReachableFromEnd) { | 47 TEST(NodeWithNullControlReachableFromEnd) { |
| 49 HandleAndZoneScope scope; | 48 HandleAndZoneScope scope; |
| 50 Graph graph(scope.main_zone()); | 49 Graph graph(scope.main_zone()); |
| 51 CommonOperatorBuilder common(scope.main_zone()); | 50 CommonOperatorBuilder common(scope.main_zone()); |
| 52 | 51 |
| 53 Node* start = graph.NewNode(common.Start(0)); | 52 Node* start = graph.NewNode(common.Start(0)); |
| 54 graph.SetStart(start); | 53 graph.SetStart(start); |
| 55 Node* k = graph.NewNode(common.Int32Constant(0)); | 54 Node* k = graph.NewNode(common.Int32Constant(0)); |
| 56 Node* phi = | 55 Node* phi = |
| 57 graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start); | 56 graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start); |
| 58 phi->ReplaceInput(1, NULL); | 57 phi->ReplaceInput(1, NULL); |
| 59 graph.SetEnd(phi); | 58 graph.SetEnd(phi); |
| 60 | 59 |
| 61 OFStream os(stdout); | 60 OFStream os(stdout); |
| 62 os << AsDOT(graph); | |
| 63 SourcePositionTable table(&graph); | 61 SourcePositionTable table(&graph); |
| 64 os << AsJSON(graph, &table); | 62 os << AsJSON(graph, &table); |
| 65 } | 63 } |
| 66 | 64 |
| 67 | 65 |
| 68 TEST(NodeWithNullInputReachableFromStart) { | 66 TEST(NodeWithNullInputReachableFromStart) { |
| 69 HandleAndZoneScope scope; | 67 HandleAndZoneScope scope; |
| 70 Graph graph(scope.main_zone()); | 68 Graph graph(scope.main_zone()); |
| 71 CommonOperatorBuilder common(scope.main_zone()); | 69 CommonOperatorBuilder common(scope.main_zone()); |
| 72 | 70 |
| 73 Node* start = graph.NewNode(common.Start(0)); | 71 Node* start = graph.NewNode(common.Start(0)); |
| 74 graph.SetStart(start); | 72 graph.SetStart(start); |
| 75 Node* k = graph.NewNode(common.Int32Constant(0)); | 73 Node* k = graph.NewNode(common.Int32Constant(0)); |
| 76 Node* phi = | 74 Node* phi = |
| 77 graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start); | 75 graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start); |
| 78 phi->ReplaceInput(0, NULL); | 76 phi->ReplaceInput(0, NULL); |
| 79 graph.SetEnd(start); | 77 graph.SetEnd(start); |
| 80 | 78 |
| 81 OFStream os(stdout); | 79 OFStream os(stdout); |
| 82 os << AsDOT(graph); | |
| 83 SourcePositionTable table(&graph); | 80 SourcePositionTable table(&graph); |
| 84 os << AsJSON(graph, &table); | 81 os << AsJSON(graph, &table); |
| 85 } | 82 } |
| 86 | 83 |
| 87 | 84 |
| 88 TEST(NodeWithNullControlReachableFromStart) { | 85 TEST(NodeWithNullControlReachableFromStart) { |
| 89 HandleAndZoneScope scope; | 86 HandleAndZoneScope scope; |
| 90 Graph graph(scope.main_zone()); | 87 Graph graph(scope.main_zone()); |
| 91 CommonOperatorBuilder common(scope.main_zone()); | 88 CommonOperatorBuilder common(scope.main_zone()); |
| 92 | 89 |
| 93 Node* start = graph.NewNode(common.Start(0)); | 90 Node* start = graph.NewNode(common.Start(0)); |
| 94 graph.SetStart(start); | 91 graph.SetStart(start); |
| 95 Node* merge = graph.NewNode(common.Merge(2), start, start); | 92 Node* merge = graph.NewNode(common.Merge(2), start, start); |
| 96 merge->ReplaceInput(1, NULL); | 93 merge->ReplaceInput(1, NULL); |
| 97 graph.SetEnd(merge); | 94 graph.SetEnd(merge); |
| 98 | 95 |
| 99 OFStream os(stdout); | 96 OFStream os(stdout); |
| 100 os << AsDOT(graph); | |
| 101 SourcePositionTable table(&graph); | 97 SourcePositionTable table(&graph); |
| 102 os << AsJSON(graph, &table); | 98 os << AsJSON(graph, &table); |
| 103 } | 99 } |
| 104 | 100 |
| 105 | 101 |
| 106 TEST(NodeNetworkOfDummiesReachableFromEnd) { | 102 TEST(NodeNetworkOfDummiesReachableFromEnd) { |
| 107 HandleAndZoneScope scope; | 103 HandleAndZoneScope scope; |
| 108 Graph graph(scope.main_zone()); | 104 Graph graph(scope.main_zone()); |
| 109 CommonOperatorBuilder common(scope.main_zone()); | 105 CommonOperatorBuilder common(scope.main_zone()); |
| 110 | 106 |
| 111 Node* start = graph.NewNode(common.Start(0)); | 107 Node* start = graph.NewNode(common.Start(0)); |
| 112 graph.SetStart(start); | 108 graph.SetStart(start); |
| 113 Node* n2 = graph.NewNode(&dummy_operator1, graph.start()); | 109 Node* n2 = graph.NewNode(&dummy_operator1, graph.start()); |
| 114 Node* n3 = graph.NewNode(&dummy_operator1, graph.start()); | 110 Node* n3 = graph.NewNode(&dummy_operator1, graph.start()); |
| 115 Node* n4 = graph.NewNode(&dummy_operator1, n2); | 111 Node* n4 = graph.NewNode(&dummy_operator1, n2); |
| 116 Node* n5 = graph.NewNode(&dummy_operator1, n2); | 112 Node* n5 = graph.NewNode(&dummy_operator1, n2); |
| 117 Node* n6 = graph.NewNode(&dummy_operator1, n3); | 113 Node* n6 = graph.NewNode(&dummy_operator1, n3); |
| 118 Node* n7 = graph.NewNode(&dummy_operator1, n3); | 114 Node* n7 = graph.NewNode(&dummy_operator1, n3); |
| 119 Node* n8 = graph.NewNode(&dummy_operator1, n5); | 115 Node* n8 = graph.NewNode(&dummy_operator1, n5); |
| 120 Node* n9 = graph.NewNode(&dummy_operator1, n5); | 116 Node* n9 = graph.NewNode(&dummy_operator1, n5); |
| 121 Node* n10 = graph.NewNode(&dummy_operator1, n9); | 117 Node* n10 = graph.NewNode(&dummy_operator1, n9); |
| 122 Node* n11 = graph.NewNode(&dummy_operator1, n9); | 118 Node* n11 = graph.NewNode(&dummy_operator1, n9); |
| 123 Node* end_dependencies[6] = {n4, n8, n10, n11, n6, n7}; | 119 Node* end_dependencies[6] = {n4, n8, n10, n11, n6, n7}; |
| 124 Node* end = graph.NewNode(&dummy_operator6, 6, end_dependencies); | 120 Node* end = graph.NewNode(&dummy_operator6, 6, end_dependencies); |
| 125 graph.SetEnd(end); | 121 graph.SetEnd(end); |
| 126 | 122 |
| 127 OFStream os(stdout); | 123 OFStream os(stdout); |
| 128 os << AsDOT(graph); | |
| 129 SourcePositionTable table(&graph); | 124 SourcePositionTable table(&graph); |
| 130 os << AsJSON(graph, &table); | 125 os << AsJSON(graph, &table); |
| 131 } | 126 } |
| 132 | 127 |
| 133 } // namespace compiler | 128 } // namespace compiler |
| 134 } // namespace internal | 129 } // namespace internal |
| 135 } // namespace v8 | 130 } // namespace v8 |
| OLD | NEW |