LCOV - code coverage report
Current view: top level - src/compiler - compiler-source-position-table.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 19 30 63.3 %
Date: 2017-04-26 Functions: 6 9 66.7 %

          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/compiler-source-position-table.h"
       6             : #include "src/compiler/graph.h"
       7             : #include "src/compiler/node-aux-data.h"
       8             : 
       9             : namespace v8 {
      10             : namespace internal {
      11             : namespace compiler {
      12             : 
      13           0 : class SourcePositionTable::Decorator final : public GraphDecorator {
      14             :  public:
      15             :   explicit Decorator(SourcePositionTable* source_positions)
      16      395343 :       : source_positions_(source_positions) {}
      17             : 
      18    74116203 :   void Decorate(Node* node) final {
      19             :     source_positions_->SetSourcePosition(node,
      20    74116203 :                                          source_positions_->current_position_);
      21    74115789 :   }
      22             : 
      23             :  private:
      24             :   SourcePositionTable* source_positions_;
      25             : };
      26             : 
      27     1935476 : SourcePositionTable::SourcePositionTable(Graph* graph)
      28             :     : graph_(graph),
      29             :       decorator_(nullptr),
      30             :       current_position_(SourcePosition::Unknown()),
      31     1935476 :       table_(graph->zone()) {}
      32             : 
      33      395343 : void SourcePositionTable::AddDecorator() {
      34             :   DCHECK_NULL(decorator_);
      35      790686 :   decorator_ = new (graph_->zone()) Decorator(this);
      36      395343 :   graph_->AddDecorator(decorator_);
      37      395343 : }
      38             : 
      39      395302 : void SourcePositionTable::RemoveDecorator() {
      40             :   DCHECK_NOT_NULL(decorator_);
      41      395302 :   graph_->RemoveDecorator(decorator_);
      42      395302 :   decorator_ = nullptr;
      43      395302 : }
      44             : 
      45   324143232 : SourcePosition SourcePositionTable::GetSourcePosition(Node* node) const {
      46   324143232 :   return table_.Get(node);
      47             : }
      48             : 
      49      112143 : void SourcePositionTable::SetSourcePosition(Node* node,
      50             :                                             SourcePosition position) {
      51    74228346 :   table_.Set(node, position);
      52      112148 : }
      53             : 
      54           0 : void SourcePositionTable::Print(std::ostream& os) const {
      55           0 :   os << "{";
      56             :   bool needs_comma = false;
      57           0 :   for (auto i : table_) {
      58             :     SourcePosition pos = i.second;
      59           0 :     if (pos.IsKnown()) {
      60           0 :       if (needs_comma) {
      61           0 :         os << ",";
      62             :       }
      63           0 :       os << "\"" << i.first << "\""
      64           0 :          << ":" << pos.ScriptOffset();
      65             :       needs_comma = true;
      66             :     }
      67             :   }
      68           0 :   os << "}";
      69           0 : }
      70             : 
      71             : }  // namespace compiler
      72             : }  // namespace internal
      73             : }  // namespace v8

Generated by: LCOV version 1.10