LCOV - code coverage report
Current view: top level - src - basic-block-profiler.h (source / functions) Hit Total Coverage
Test: app.info Lines: 1 2 50.0 %
Date: 2019-04-19 Functions: 0 1 0.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             : #ifndef V8_BASIC_BLOCK_PROFILER_H_
       6             : #define V8_BASIC_BLOCK_PROFILER_H_
       7             : 
       8             : #include <iosfwd>
       9             : #include <list>
      10             : #include <string>
      11             : #include <vector>
      12             : 
      13             : #include "src/base/macros.h"
      14             : #include "src/base/platform/mutex.h"
      15             : #include "src/globals.h"
      16             : 
      17             : namespace v8 {
      18             : namespace internal {
      19             : 
      20             : class BasicBlockProfiler {
      21             :  public:
      22             :   class Data {
      23             :    public:
      24             :     size_t n_blocks() const { return n_blocks_; }
      25             :     const uint32_t* counts() const { return &counts_[0]; }
      26             : 
      27             :     void SetCode(std::ostringstream* os);
      28             :     void SetFunctionName(std::unique_ptr<char[]> name);
      29             :     void SetSchedule(std::ostringstream* os);
      30             :     void SetBlockRpoNumber(size_t offset, int32_t block_rpo);
      31             :     intptr_t GetCounterAddress(size_t offset);
      32             : 
      33             :    private:
      34             :     friend class BasicBlockProfiler;
      35             :     friend std::ostream& operator<<(std::ostream& os,
      36             :                                     const BasicBlockProfiler::Data& s);
      37             : 
      38             :     explicit Data(size_t n_blocks);
      39           0 :     ~Data() = default;
      40             : 
      41             :     V8_EXPORT_PRIVATE void ResetCounts();
      42             : 
      43             :     const size_t n_blocks_;
      44             :     std::vector<int32_t> block_rpo_numbers_;
      45             :     std::vector<uint32_t> counts_;
      46             :     std::string function_name_;
      47             :     std::string schedule_;
      48             :     std::string code_;
      49             :     DISALLOW_COPY_AND_ASSIGN(Data);
      50             :   };
      51             : 
      52             :   typedef std::list<Data*> DataList;
      53             : 
      54           8 :   BasicBlockProfiler() = default;
      55             :   ~BasicBlockProfiler();
      56             : 
      57             :   V8_EXPORT_PRIVATE static BasicBlockProfiler* Get();
      58             :   Data* NewData(size_t n_blocks);
      59             :   V8_EXPORT_PRIVATE void ResetCounts();
      60             : 
      61             :   const DataList* data_list() { return &data_list_; }
      62             : 
      63             :  private:
      64             :   friend V8_EXPORT_PRIVATE std::ostream& operator<<(
      65             :       std::ostream& os, const BasicBlockProfiler& s);
      66             : 
      67             :   DataList data_list_;
      68             :   base::Mutex data_list_mutex_;
      69             : 
      70             :   DISALLOW_COPY_AND_ASSIGN(BasicBlockProfiler);
      71             : };
      72             : 
      73             : V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
      74             :                                            const BasicBlockProfiler& s);
      75             : std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler::Data& s);
      76             : 
      77             : }  // namespace internal
      78             : }  // namespace v8
      79             : 
      80             : #endif  // V8_BASIC_BLOCK_PROFILER_H_

Generated by: LCOV version 1.10