LCOV - code coverage report
Current view: top level - test/cctest/compiler - test-graph-visualizer.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 71 71 100.0 %
Date: 2019-04-17 Functions: 8 8 100.0 %

          Line data    Source code
       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/compiler/common-operator.h"
       6             : #include "src/compiler/compiler-source-position-table.h"
       7             : #include "src/compiler/graph-visualizer.h"
       8             : #include "src/compiler/graph.h"
       9             : #include "src/compiler/js-operator.h"
      10             : #include "src/compiler/machine-operator.h"
      11             : #include "src/compiler/node-origin-table.h"
      12             : #include "src/compiler/node.h"
      13             : #include "src/compiler/operator.h"
      14             : #include "src/compiler/schedule.h"
      15             : #include "src/compiler/scheduler.h"
      16             : #include "src/compiler/verifier.h"
      17             : #include "test/cctest/cctest.h"
      18             : 
      19             : namespace v8 {
      20             : namespace internal {
      21             : namespace compiler {
      22             : 
      23       53278 : static Operator dummy_operator1(IrOpcode::kParameter, Operator::kNoWrite,
      24       26639 :                                 "dummy", 1, 0, 0, 1, 0, 0);
      25       53278 : static Operator dummy_operator6(IrOpcode::kParameter, Operator::kNoWrite,
      26       26639 :                                 "dummy", 6, 0, 0, 1, 0, 0);
      27             : 
      28             : 
      29       26644 : TEST(NodeWithNullInputReachableFromEnd) {
      30          10 :   HandleAndZoneScope scope;
      31           5 :   Graph graph(scope.main_zone());
      32           5 :   CommonOperatorBuilder common(scope.main_zone());
      33             : 
      34           5 :   Node* start = graph.NewNode(common.Start(0));
      35             :   graph.SetStart(start);
      36           5 :   Node* k = graph.NewNode(common.Int32Constant(0));
      37             :   Node* phi =
      38           5 :       graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start);
      39           5 :   phi->ReplaceInput(0, nullptr);
      40             :   graph.SetEnd(phi);
      41             : 
      42           5 :   SourcePositionTable table(&graph);
      43           5 :   NodeOriginTable table2(&graph);
      44          10 :   StdoutStream{} << AsJSON(graph, &table, &table2);
      45           5 : }
      46             : 
      47             : 
      48       26644 : TEST(NodeWithNullControlReachableFromEnd) {
      49          10 :   HandleAndZoneScope scope;
      50           5 :   Graph graph(scope.main_zone());
      51           5 :   CommonOperatorBuilder common(scope.main_zone());
      52             : 
      53           5 :   Node* start = graph.NewNode(common.Start(0));
      54             :   graph.SetStart(start);
      55           5 :   Node* k = graph.NewNode(common.Int32Constant(0));
      56             :   Node* phi =
      57           5 :       graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start);
      58           5 :   phi->ReplaceInput(1, nullptr);
      59             :   graph.SetEnd(phi);
      60             : 
      61           5 :   SourcePositionTable table(&graph);
      62           5 :   NodeOriginTable table2(&graph);
      63          10 :   StdoutStream{} << AsJSON(graph, &table, &table2);
      64           5 : }
      65             : 
      66             : 
      67       26644 : TEST(NodeWithNullInputReachableFromStart) {
      68          10 :   HandleAndZoneScope scope;
      69           5 :   Graph graph(scope.main_zone());
      70           5 :   CommonOperatorBuilder common(scope.main_zone());
      71             : 
      72           5 :   Node* start = graph.NewNode(common.Start(0));
      73             :   graph.SetStart(start);
      74           5 :   Node* k = graph.NewNode(common.Int32Constant(0));
      75             :   Node* phi =
      76           5 :       graph.NewNode(common.Phi(MachineRepresentation::kTagged, 1), k, start);
      77           5 :   phi->ReplaceInput(0, nullptr);
      78             :   graph.SetEnd(start);
      79             : 
      80           5 :   SourcePositionTable table(&graph);
      81           5 :   NodeOriginTable table2(&graph);
      82          10 :   StdoutStream{} << AsJSON(graph, &table, &table2);
      83           5 : }
      84             : 
      85             : 
      86       26644 : TEST(NodeWithNullControlReachableFromStart) {
      87          10 :   HandleAndZoneScope scope;
      88           5 :   Graph graph(scope.main_zone());
      89           5 :   CommonOperatorBuilder common(scope.main_zone());
      90             : 
      91           5 :   Node* start = graph.NewNode(common.Start(0));
      92             :   graph.SetStart(start);
      93           5 :   Node* merge = graph.NewNode(common.Merge(2), start, start);
      94           5 :   merge->ReplaceInput(1, nullptr);
      95             :   graph.SetEnd(merge);
      96             : 
      97           5 :   SourcePositionTable table(&graph);
      98           5 :   NodeOriginTable table2(&graph);
      99          10 :   StdoutStream{} << AsJSON(graph, &table, &table2);
     100           5 : }
     101             : 
     102             : 
     103       26644 : TEST(NodeNetworkOfDummiesReachableFromEnd) {
     104          10 :   HandleAndZoneScope scope;
     105           5 :   Graph graph(scope.main_zone());
     106           5 :   CommonOperatorBuilder common(scope.main_zone());
     107             : 
     108           5 :   Node* start = graph.NewNode(common.Start(0));
     109             :   graph.SetStart(start);
     110             :   Node* n2 = graph.NewNode(&dummy_operator1, graph.start());
     111             :   Node* n3 = graph.NewNode(&dummy_operator1, graph.start());
     112             :   Node* n4 = graph.NewNode(&dummy_operator1, n2);
     113             :   Node* n5 = graph.NewNode(&dummy_operator1, n2);
     114             :   Node* n6 = graph.NewNode(&dummy_operator1, n3);
     115             :   Node* n7 = graph.NewNode(&dummy_operator1, n3);
     116             :   Node* n8 = graph.NewNode(&dummy_operator1, n5);
     117             :   Node* n9 = graph.NewNode(&dummy_operator1, n5);
     118             :   Node* n10 = graph.NewNode(&dummy_operator1, n9);
     119             :   Node* n11 = graph.NewNode(&dummy_operator1, n9);
     120           5 :   Node* end_dependencies[6] = {n4, n8, n10, n11, n6, n7};
     121           5 :   Node* end = graph.NewNode(&dummy_operator6, 6, end_dependencies);
     122             :   graph.SetEnd(end);
     123             : 
     124           5 :   SourcePositionTable table(&graph);
     125           5 :   NodeOriginTable table2(&graph);
     126          10 :   StdoutStream{} << AsJSON(graph, &table, &table2);
     127           5 : }
     128             : 
     129       26644 : TEST(TestSourceIdAssigner) {
     130             :   Handle<SharedFunctionInfo> shared1;
     131             :   Handle<SharedFunctionInfo> shared2;
     132             : 
     133          10 :   SourceIdAssigner assigner(2);
     134           5 :   const int source_id1 = assigner.GetIdFor(shared1);
     135           5 :   const int source_id2 = assigner.GetIdFor(shared2);
     136             : 
     137           5 :   CHECK_EQ(source_id1, source_id2);
     138           5 :   CHECK_EQ(source_id1, assigner.GetIdAt(0));
     139           5 :   CHECK_EQ(source_id2, assigner.GetIdAt(1));
     140           5 : }
     141             : 
     142             : }  // namespace compiler
     143             : }  // namespace internal
     144       79917 : }  // namespace v8

Generated by: LCOV version 1.10