Emily Bernier | 958fae7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "src/v8.h" |
| 6 | #include "test/cctest/cctest.h" |
| 7 | |
| 8 | #include "src/compiler/common-operator.h" |
| 9 | #include "src/compiler/graph.h" |
| 10 | #include "src/compiler/graph-visualizer.h" |
| 11 | #include "src/compiler/js-operator.h" |
| 12 | #include "src/compiler/machine-operator.h" |
| 13 | #include "src/compiler/node.h" |
| 14 | #include "src/compiler/operator.h" |
| 15 | #include "src/compiler/schedule.h" |
| 16 | #include "src/compiler/scheduler.h" |
| 17 | #include "src/compiler/verifier.h" |
| 18 | |
| 19 | using namespace v8::internal; |
| 20 | using namespace v8::internal::compiler; |
| 21 | |
| 22 | TEST(NodeWithNullInputReachableFromEnd) { |
| 23 | HandleAndZoneScope scope; |
| 24 | Graph graph(scope.main_zone()); |
| 25 | CommonOperatorBuilder common(scope.main_zone()); |
| 26 | |
| 27 | Node* start = graph.NewNode(common.Start(0)); |
| 28 | graph.SetStart(start); |
| 29 | Node* k = graph.NewNode(common.Int32Constant(0)); |
| 30 | Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); |
| 31 | phi->ReplaceInput(0, NULL); |
| 32 | graph.SetEnd(phi); |
| 33 | |
| 34 | OFStream os(stdout); |
| 35 | os << AsDOT(graph); |
| 36 | os << AsJSON(graph); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | TEST(NodeWithNullControlReachableFromEnd) { |
| 41 | HandleAndZoneScope scope; |
| 42 | Graph graph(scope.main_zone()); |
| 43 | CommonOperatorBuilder common(scope.main_zone()); |
| 44 | |
| 45 | Node* start = graph.NewNode(common.Start(0)); |
| 46 | graph.SetStart(start); |
| 47 | Node* k = graph.NewNode(common.Int32Constant(0)); |
| 48 | Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); |
| 49 | phi->ReplaceInput(1, NULL); |
| 50 | graph.SetEnd(phi); |
| 51 | |
| 52 | OFStream os(stdout); |
| 53 | os << AsDOT(graph); |
| 54 | os << AsJSON(graph); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | TEST(NodeWithNullInputReachableFromStart) { |
| 59 | HandleAndZoneScope scope; |
| 60 | Graph graph(scope.main_zone()); |
| 61 | CommonOperatorBuilder common(scope.main_zone()); |
| 62 | |
| 63 | Node* start = graph.NewNode(common.Start(0)); |
| 64 | graph.SetStart(start); |
| 65 | Node* k = graph.NewNode(common.Int32Constant(0)); |
| 66 | Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 1), k, start); |
| 67 | phi->ReplaceInput(0, NULL); |
| 68 | graph.SetEnd(start); |
| 69 | |
| 70 | OFStream os(stdout); |
| 71 | os << AsDOT(graph); |
| 72 | os << AsJSON(graph); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | TEST(NodeWithNullControlReachableFromStart) { |
| 77 | HandleAndZoneScope scope; |
| 78 | Graph graph(scope.main_zone()); |
| 79 | CommonOperatorBuilder common(scope.main_zone()); |
| 80 | |
| 81 | Node* start = graph.NewNode(common.Start(0)); |
| 82 | graph.SetStart(start); |
| 83 | Node* merge = graph.NewNode(common.Merge(2), start, start); |
| 84 | merge->ReplaceInput(1, NULL); |
| 85 | graph.SetEnd(merge); |
| 86 | |
| 87 | OFStream os(stdout); |
| 88 | os << AsDOT(graph); |
| 89 | os << AsJSON(graph); |
| 90 | } |