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