Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: src/basic-block-profiler.cc

Issue 593563005: [turbofan] basic block profiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/basic-block-profiler.h ('k') | src/compiler/basic-block-instrumentor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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/basic-block-profiler.h"
6
7 namespace v8 {
8 namespace internal {
9
10 BasicBlockProfiler::Data::Data(size_t n_blocks)
11 : n_blocks_(n_blocks), block_ids_(n_blocks_, -1), counts_(n_blocks_, 0) {}
12
13
14 BasicBlockProfiler::Data::~Data() {}
15
16
17 static void InsertIntoString(OStringStream* os, std::string* string) {
18 string->insert(string->begin(), os->c_str(), &os->c_str()[os->size()]);
19 }
20
21
22 void BasicBlockProfiler::Data::SetCode(OStringStream* os) {
23 InsertIntoString(os, &code_);
24 }
25
26
27 void BasicBlockProfiler::Data::SetFunctionName(OStringStream* os) {
28 InsertIntoString(os, &function_name_);
29 }
30
31
32 void BasicBlockProfiler::Data::SetSchedule(OStringStream* os) {
33 InsertIntoString(os, &schedule_);
34 }
35
36
37 void BasicBlockProfiler::Data::SetBlockId(size_t offset, int block_id) {
38 DCHECK(offset < n_blocks_);
39 block_ids_[offset] = block_id;
40 }
41
42
43 uint32_t* BasicBlockProfiler::Data::GetCounterAddress(size_t offset) {
44 DCHECK(offset < n_blocks_);
45 return &counts_[offset];
46 }
47
48
49 void BasicBlockProfiler::Data::ResetCounts() {
50 for (size_t i = 0; i < n_blocks_; ++i) {
51 counts_[i] = 0;
52 }
53 }
54
55
56 BasicBlockProfiler::BasicBlockProfiler() {}
57
58
59 BasicBlockProfiler::Data* BasicBlockProfiler::NewData(size_t n_blocks) {
60 Data* data = new Data(n_blocks);
61 data_list_.push_back(data);
62 return data;
63 }
64
65
66 BasicBlockProfiler::~BasicBlockProfiler() {
67 for (DataList::iterator i = data_list_.begin(); i != data_list_.end(); ++i) {
68 delete (*i);
69 }
70 }
71
72
73 void BasicBlockProfiler::ResetCounts() {
74 for (DataList::iterator i = data_list_.begin(); i != data_list_.end(); ++i) {
75 (*i)->ResetCounts();
76 }
77 }
78
79
80 OStream& operator<<(OStream& os, const BasicBlockProfiler& p) {
81 os << "---- Start Profiling Data ----" << endl;
82 typedef BasicBlockProfiler::DataList::const_iterator iterator;
83 for (iterator i = p.data_list_.begin(); i != p.data_list_.end(); ++i) {
84 os << **i;
85 }
86 os << "---- End Profiling Data ----" << endl;
87 return os;
88 }
89
90
91 OStream& operator<<(OStream& os, const BasicBlockProfiler::Data& d) {
92 const char* name = "unknown function";
93 if (!d.function_name_.empty()) {
94 name = d.function_name_.c_str();
95 }
96 if (!d.schedule_.empty()) {
97 os << "schedule for " << name << endl;
98 os << d.schedule_.c_str() << endl;
99 }
100 os << "block counts for " << name << ":" << endl;
101 for (size_t i = 0; i < d.n_blocks_; ++i) {
102 os << "block " << d.block_ids_[i] << " : " << d.counts_[i] << endl;
103 }
104 os << endl;
105 if (!d.code_.empty()) {
106 os << d.code_.c_str() << endl;
107 }
108 return os;
109 }
110
111 } // namespace internal
112 } // namespace v8
OLDNEW
« no previous file with comments | « src/basic-block-profiler.h ('k') | src/compiler/basic-block-instrumentor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698