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 SourcePositionTable table(&graph); |
| 38 os << AsJSON(graph, &table); |
37 } | 39 } |
38 | 40 |
39 | 41 |
40 TEST(NodeWithNullControlReachableFromEnd) { | 42 TEST(NodeWithNullControlReachableFromEnd) { |
41 HandleAndZoneScope scope; | 43 HandleAndZoneScope scope; |
42 Graph graph(scope.main_zone()); | 44 Graph graph(scope.main_zone()); |
43 CommonOperatorBuilder common(scope.main_zone()); | 45 CommonOperatorBuilder common(scope.main_zone()); |
44 | 46 |
45 Node* start = graph.NewNode(common.Start(0)); | 47 Node* start = graph.NewNode(common.Start(0)); |
46 graph.SetStart(start); | 48 graph.SetStart(start); |
47 Node* k = graph.NewNode(common.Int32Constant(0)); | 49 Node* k = graph.NewNode(common.Int32Constant(0)); |
48 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); | 50 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); |
49 phi->ReplaceInput(1, NULL); | 51 phi->ReplaceInput(1, NULL); |
50 graph.SetEnd(phi); | 52 graph.SetEnd(phi); |
51 | 53 |
52 OFStream os(stdout); | 54 OFStream os(stdout); |
53 os << AsDOT(graph); | 55 os << AsDOT(graph); |
54 os << AsJSON(graph); | 56 SourcePositionTable table(&graph); |
| 57 os << AsJSON(graph, &table); |
55 } | 58 } |
56 | 59 |
57 | 60 |
58 TEST(NodeWithNullInputReachableFromStart) { | 61 TEST(NodeWithNullInputReachableFromStart) { |
59 HandleAndZoneScope scope; | 62 HandleAndZoneScope scope; |
60 Graph graph(scope.main_zone()); | 63 Graph graph(scope.main_zone()); |
61 CommonOperatorBuilder common(scope.main_zone()); | 64 CommonOperatorBuilder common(scope.main_zone()); |
62 | 65 |
63 Node* start = graph.NewNode(common.Start(0)); | 66 Node* start = graph.NewNode(common.Start(0)); |
64 graph.SetStart(start); | 67 graph.SetStart(start); |
65 Node* k = graph.NewNode(common.Int32Constant(0)); | 68 Node* k = graph.NewNode(common.Int32Constant(0)); |
66 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); | 69 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); |
67 phi->ReplaceInput(0, NULL); | 70 phi->ReplaceInput(0, NULL); |
68 graph.SetEnd(start); | 71 graph.SetEnd(start); |
69 | 72 |
70 OFStream os(stdout); | 73 OFStream os(stdout); |
71 os << AsDOT(graph); | 74 os << AsDOT(graph); |
72 os << AsJSON(graph); | 75 SourcePositionTable table(&graph); |
| 76 os << AsJSON(graph, &table); |
73 } | 77 } |
74 | 78 |
75 | 79 |
76 TEST(NodeWithNullControlReachableFromStart) { | 80 TEST(NodeWithNullControlReachableFromStart) { |
77 HandleAndZoneScope scope; | 81 HandleAndZoneScope scope; |
78 Graph graph(scope.main_zone()); | 82 Graph graph(scope.main_zone()); |
79 CommonOperatorBuilder common(scope.main_zone()); | 83 CommonOperatorBuilder common(scope.main_zone()); |
80 | 84 |
81 Node* start = graph.NewNode(common.Start(0)); | 85 Node* start = graph.NewNode(common.Start(0)); |
82 graph.SetStart(start); | 86 graph.SetStart(start); |
83 Node* merge = graph.NewNode(common.Merge(2), start, start); | 87 Node* merge = graph.NewNode(common.Merge(2), start, start); |
84 merge->ReplaceInput(1, NULL); | 88 merge->ReplaceInput(1, NULL); |
85 graph.SetEnd(merge); | 89 graph.SetEnd(merge); |
86 | 90 |
87 OFStream os(stdout); | 91 OFStream os(stdout); |
88 os << AsDOT(graph); | 92 os << AsDOT(graph); |
89 os << AsJSON(graph); | 93 SourcePositionTable table(&graph); |
| 94 os << AsJSON(graph, &table); |
90 } | 95 } |
OLD | NEW |