OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_BASIC_BLOCK_PROFILER_H_ | 5 #ifndef V8_BASIC_BLOCK_PROFILER_H_ |
6 #define V8_BASIC_BLOCK_PROFILER_H_ | 6 #define V8_BASIC_BLOCK_PROFILER_H_ |
7 | 7 |
| 8 #include <iosfwd> |
8 #include <list> | 9 #include <list> |
| 10 #include <string> |
9 | 11 |
10 #include "src/v8.h" | 12 #include "src/v8.h" |
11 | 13 |
12 namespace v8 { | 14 namespace v8 { |
13 namespace internal { | 15 namespace internal { |
14 | 16 |
15 class Schedule; | 17 class Schedule; |
16 class Graph; | 18 class Graph; |
17 | 19 |
18 class BasicBlockProfiler { | 20 class BasicBlockProfiler { |
19 public: | 21 public: |
20 class Data { | 22 class Data { |
21 public: | 23 public: |
22 size_t n_blocks() const { return n_blocks_; } | 24 size_t n_blocks() const { return n_blocks_; } |
23 const uint32_t* counts() const { return &counts_[0]; } | 25 const uint32_t* counts() const { return &counts_[0]; } |
24 | 26 |
25 void SetCode(OStringStream* os); | 27 void SetCode(std::ostringstream* os); |
26 void SetFunctionName(OStringStream* os); | 28 void SetFunctionName(std::ostringstream* os); |
27 void SetSchedule(OStringStream* os); | 29 void SetSchedule(std::ostringstream* os); |
28 void SetBlockId(size_t offset, size_t block_id); | 30 void SetBlockId(size_t offset, size_t block_id); |
29 uint32_t* GetCounterAddress(size_t offset); | 31 uint32_t* GetCounterAddress(size_t offset); |
30 | 32 |
31 private: | 33 private: |
32 friend class BasicBlockProfiler; | 34 friend class BasicBlockProfiler; |
33 friend OStream& operator<<(OStream& os, const BasicBlockProfiler::Data& s); | 35 friend std::ostream& operator<<(std::ostream& os, |
| 36 const BasicBlockProfiler::Data& s); |
34 | 37 |
35 explicit Data(size_t n_blocks); | 38 explicit Data(size_t n_blocks); |
36 ~Data(); | 39 ~Data(); |
37 | 40 |
38 void ResetCounts(); | 41 void ResetCounts(); |
39 | 42 |
40 const size_t n_blocks_; | 43 const size_t n_blocks_; |
41 std::vector<size_t> block_ids_; | 44 std::vector<size_t> block_ids_; |
42 std::vector<uint32_t> counts_; | 45 std::vector<uint32_t> counts_; |
43 std::string function_name_; | 46 std::string function_name_; |
44 std::string schedule_; | 47 std::string schedule_; |
45 std::string code_; | 48 std::string code_; |
46 DISALLOW_COPY_AND_ASSIGN(Data); | 49 DISALLOW_COPY_AND_ASSIGN(Data); |
47 }; | 50 }; |
48 | 51 |
49 typedef std::list<Data*> DataList; | 52 typedef std::list<Data*> DataList; |
50 | 53 |
51 BasicBlockProfiler(); | 54 BasicBlockProfiler(); |
52 ~BasicBlockProfiler(); | 55 ~BasicBlockProfiler(); |
53 | 56 |
54 Data* NewData(size_t n_blocks); | 57 Data* NewData(size_t n_blocks); |
55 void ResetCounts(); | 58 void ResetCounts(); |
56 | 59 |
57 const DataList* data_list() { return &data_list_; } | 60 const DataList* data_list() { return &data_list_; } |
58 | 61 |
59 private: | 62 private: |
60 friend OStream& operator<<(OStream& os, const BasicBlockProfiler& s); | 63 friend std::ostream& operator<<(std::ostream& os, |
| 64 const BasicBlockProfiler& s); |
61 | 65 |
62 DataList data_list_; | 66 DataList data_list_; |
63 | 67 |
64 DISALLOW_COPY_AND_ASSIGN(BasicBlockProfiler); | 68 DISALLOW_COPY_AND_ASSIGN(BasicBlockProfiler); |
65 }; | 69 }; |
66 | 70 |
67 OStream& operator<<(OStream& os, const BasicBlockProfiler& s); | 71 std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler& s); |
68 OStream& operator<<(OStream& os, const BasicBlockProfiler::Data& s); | 72 std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler::Data& s); |
69 | 73 |
70 } // namespace internal | 74 } // namespace internal |
71 } // namespace v8 | 75 } // namespace v8 |
72 | 76 |
73 #endif // V8_BASIC_BLOCK_PROFILER_H_ | 77 #endif // V8_BASIC_BLOCK_PROFILER_H_ |
OLD | NEW |