| 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 #include "src/basic-block-profiler.h" | 5 #include "src/basic-block-profiler.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 | 9 |
| 10 BasicBlockProfiler::Data::Data(size_t n_blocks) | 10 BasicBlockProfiler::Data::Data(size_t n_blocks) |
| 11 : n_blocks_(n_blocks), block_ids_(n_blocks_, -1), counts_(n_blocks_, 0) {} | 11 : n_blocks_(n_blocks), block_ids_(n_blocks_), counts_(n_blocks_, 0) {} |
| 12 | 12 |
| 13 | 13 |
| 14 BasicBlockProfiler::Data::~Data() {} | 14 BasicBlockProfiler::Data::~Data() {} |
| 15 | 15 |
| 16 | 16 |
| 17 static void InsertIntoString(OStringStream* os, std::string* string) { | 17 static void InsertIntoString(OStringStream* os, std::string* string) { |
| 18 string->insert(string->begin(), os->c_str(), &os->c_str()[os->size()]); | 18 string->insert(string->begin(), os->c_str(), &os->c_str()[os->size()]); |
| 19 } | 19 } |
| 20 | 20 |
| 21 | 21 |
| 22 void BasicBlockProfiler::Data::SetCode(OStringStream* os) { | 22 void BasicBlockProfiler::Data::SetCode(OStringStream* os) { |
| 23 InsertIntoString(os, &code_); | 23 InsertIntoString(os, &code_); |
| 24 } | 24 } |
| 25 | 25 |
| 26 | 26 |
| 27 void BasicBlockProfiler::Data::SetFunctionName(OStringStream* os) { | 27 void BasicBlockProfiler::Data::SetFunctionName(OStringStream* os) { |
| 28 InsertIntoString(os, &function_name_); | 28 InsertIntoString(os, &function_name_); |
| 29 } | 29 } |
| 30 | 30 |
| 31 | 31 |
| 32 void BasicBlockProfiler::Data::SetSchedule(OStringStream* os) { | 32 void BasicBlockProfiler::Data::SetSchedule(OStringStream* os) { |
| 33 InsertIntoString(os, &schedule_); | 33 InsertIntoString(os, &schedule_); |
| 34 } | 34 } |
| 35 | 35 |
| 36 | 36 |
| 37 void BasicBlockProfiler::Data::SetBlockId(size_t offset, int block_id) { | 37 void BasicBlockProfiler::Data::SetBlockId(size_t offset, size_t block_id) { |
| 38 DCHECK(offset < n_blocks_); | 38 DCHECK(offset < n_blocks_); |
| 39 block_ids_[offset] = block_id; | 39 block_ids_[offset] = block_id; |
| 40 } | 40 } |
| 41 | 41 |
| 42 | 42 |
| 43 uint32_t* BasicBlockProfiler::Data::GetCounterAddress(size_t offset) { | 43 uint32_t* BasicBlockProfiler::Data::GetCounterAddress(size_t offset) { |
| 44 DCHECK(offset < n_blocks_); | 44 DCHECK(offset < n_blocks_); |
| 45 return &counts_[offset]; | 45 return &counts_[offset]; |
| 46 } | 46 } |
| 47 | 47 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 103 } |
| 104 os << endl; | 104 os << endl; |
| 105 if (!d.code_.empty()) { | 105 if (!d.code_.empty()) { |
| 106 os << d.code_.c_str() << endl; | 106 os << d.code_.c_str() << endl; |
| 107 } | 107 } |
| 108 return os; | 108 return os; |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace internal | 111 } // namespace internal |
| 112 } // namespace v8 | 112 } // namespace v8 |
| OLD | NEW |