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.
5 #ifndef V8_BASIC_BLOCK_PROFILER_H_
6 #define V8_BASIC_BLOCK_PROFILER_H_
20 class BasicBlockProfiler {
24 size_t n_blocks() const { return n_blocks_; }
25 const uint32_t* counts() const { return &counts_[0]; }
27 void SetCode(std::ostringstream* os);
28 void SetFunctionName(std::ostringstream* os);
29 void SetSchedule(std::ostringstream* os);
30 void SetBlockId(size_t offset, size_t block_id);
31 uint32_t* GetCounterAddress(size_t offset);
34 friend class BasicBlockProfiler;
35 friend std::ostream& operator<<(std::ostream& os,
36 const BasicBlockProfiler::Data& s);
38 explicit Data(size_t n_blocks);
43 const size_t n_blocks_;
44 std::vector<size_t> block_ids_;
45 std::vector<uint32_t> counts_;
46 std::string function_name_;
47 std::string schedule_;
49 DISALLOW_COPY_AND_ASSIGN(Data);
52 typedef std::list<Data*> DataList;
55 ~BasicBlockProfiler();
57 Data* NewData(size_t n_blocks);
60 const DataList* data_list() { return &data_list_; }
63 friend std::ostream& operator<<(std::ostream& os,
64 const BasicBlockProfiler& s);
68 DISALLOW_COPY_AND_ASSIGN(BasicBlockProfiler);
71 std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler& s);
72 std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler::Data& s);
74 } // namespace internal
77 #endif // V8_BASIC_BLOCK_PROFILER_H_