| 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" | |
| 11 #include "src/compiler/js-operator.h" | 10 #include "src/compiler/js-operator.h" |
| 12 #include "src/compiler/machine-operator.h" | 11 #include "src/compiler/machine-operator.h" |
| 13 #include "src/compiler/node.h" | 12 #include "src/compiler/node.h" |
| 14 #include "src/compiler/operator.h" | 13 #include "src/compiler/operator.h" |
| 15 #include "src/compiler/schedule.h" | 14 #include "src/compiler/schedule.h" |
| 16 #include "src/compiler/scheduler.h" | 15 #include "src/compiler/scheduler.h" |
| 17 #include "src/compiler/source-position.h" | 16 #include "src/compiler/source-position.h" |
| 18 #include "src/compiler/verifier.h" | 17 #include "src/compiler/verifier.h" |
| 18 #include "src/compiler/visualizer.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 TEST(NodeWithNullInputReachableFromEnd) { | 23 TEST(NodeWithNullInputReachableFromEnd) { |
| 24 HandleAndZoneScope scope; | 24 HandleAndZoneScope scope; |
| 25 Graph graph(scope.main_zone()); | 25 Graph graph(scope.main_zone()); |
| 26 CommonOperatorBuilder common(scope.main_zone()); | 26 CommonOperatorBuilder common(scope.main_zone()); |
| 27 | 27 |
| 28 Node* start = graph.NewNode(common.Start(0)); | 28 Node* start = graph.NewNode(common.Start(0)); |
| 29 graph.SetStart(start); | 29 graph.SetStart(start); |
| 30 Node* k = graph.NewNode(common.Int32Constant(0)); | 30 Node* k = graph.NewNode(common.Int32Constant(0)); |
| 31 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); | 31 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); |
| 32 phi->ReplaceInput(0, NULL); | 32 phi->ReplaceInput(0, NULL); |
| 33 graph.SetEnd(phi); | 33 graph.SetEnd(phi); |
| 34 | 34 |
| 35 OFStream os(stdout); | 35 OFStream os(stdout); |
| 36 os << AsDOT(graph); | 36 os << AsDOT(graph); |
| 37 SourcePositionTable table(&graph); | 37 SourcePositionTable table(&graph); |
| 38 os << AsJSON(graph, &table); | 38 os << GraphAsJSON(graph, &table); |
| 39 } | 39 } |
| 40 | 40 |
| 41 | 41 |
| 42 TEST(NodeWithNullControlReachableFromEnd) { | 42 TEST(NodeWithNullControlReachableFromEnd) { |
| 43 HandleAndZoneScope scope; | 43 HandleAndZoneScope scope; |
| 44 Graph graph(scope.main_zone()); | 44 Graph graph(scope.main_zone()); |
| 45 CommonOperatorBuilder common(scope.main_zone()); | 45 CommonOperatorBuilder common(scope.main_zone()); |
| 46 | 46 |
| 47 Node* start = graph.NewNode(common.Start(0)); | 47 Node* start = graph.NewNode(common.Start(0)); |
| 48 graph.SetStart(start); | 48 graph.SetStart(start); |
| 49 Node* k = graph.NewNode(common.Int32Constant(0)); | 49 Node* k = graph.NewNode(common.Int32Constant(0)); |
| 50 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); | 50 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); |
| 51 phi->ReplaceInput(1, NULL); | 51 phi->ReplaceInput(1, NULL); |
| 52 graph.SetEnd(phi); | 52 graph.SetEnd(phi); |
| 53 | 53 |
| 54 OFStream os(stdout); | 54 OFStream os(stdout); |
| 55 os << AsDOT(graph); | 55 os << AsDOT(graph); |
| 56 SourcePositionTable table(&graph); | 56 SourcePositionTable table(&graph); |
| 57 os << AsJSON(graph, &table); | 57 os << GraphAsJSON(graph, &table); |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 TEST(NodeWithNullInputReachableFromStart) { | 61 TEST(NodeWithNullInputReachableFromStart) { |
| 62 HandleAndZoneScope scope; | 62 HandleAndZoneScope scope; |
| 63 Graph graph(scope.main_zone()); | 63 Graph graph(scope.main_zone()); |
| 64 CommonOperatorBuilder common(scope.main_zone()); | 64 CommonOperatorBuilder common(scope.main_zone()); |
| 65 | 65 |
| 66 Node* start = graph.NewNode(common.Start(0)); | 66 Node* start = graph.NewNode(common.Start(0)); |
| 67 graph.SetStart(start); | 67 graph.SetStart(start); |
| 68 Node* k = graph.NewNode(common.Int32Constant(0)); | 68 Node* k = graph.NewNode(common.Int32Constant(0)); |
| 69 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); | 69 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); |
| 70 phi->ReplaceInput(0, NULL); | 70 phi->ReplaceInput(0, NULL); |
| 71 graph.SetEnd(start); | 71 graph.SetEnd(start); |
| 72 | 72 |
| 73 OFStream os(stdout); | 73 OFStream os(stdout); |
| 74 os << AsDOT(graph); | 74 os << AsDOT(graph); |
| 75 SourcePositionTable table(&graph); | 75 SourcePositionTable table(&graph); |
| 76 os << AsJSON(graph, &table); | 76 os << GraphAsJSON(graph, &table); |
| 77 } | 77 } |
| 78 | 78 |
| 79 | 79 |
| 80 TEST(NodeWithNullControlReachableFromStart) { | 80 TEST(NodeWithNullControlReachableFromStart) { |
| 81 HandleAndZoneScope scope; | 81 HandleAndZoneScope scope; |
| 82 Graph graph(scope.main_zone()); | 82 Graph graph(scope.main_zone()); |
| 83 CommonOperatorBuilder common(scope.main_zone()); | 83 CommonOperatorBuilder common(scope.main_zone()); |
| 84 | 84 |
| 85 Node* start = graph.NewNode(common.Start(0)); | 85 Node* start = graph.NewNode(common.Start(0)); |
| 86 graph.SetStart(start); | 86 graph.SetStart(start); |
| 87 Node* merge = graph.NewNode(common.Merge(2), start, start); | 87 Node* merge = graph.NewNode(common.Merge(2), start, start); |
| 88 merge->ReplaceInput(1, NULL); | 88 merge->ReplaceInput(1, NULL); |
| 89 graph.SetEnd(merge); | 89 graph.SetEnd(merge); |
| 90 | 90 |
| 91 OFStream os(stdout); | 91 OFStream os(stdout); |
| 92 os << AsDOT(graph); | 92 os << AsDOT(graph); |
| 93 SourcePositionTable table(&graph); | 93 SourcePositionTable table(&graph); |
| 94 os << AsJSON(graph, &table); | 94 os << GraphAsJSON(graph, &table); |
| 95 } | 95 } |
| OLD | NEW |