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

Side by Side Diff: src/compilation-statistics.cc

Issue 2572713003: [turbofan] Add a mutex for recording compilation statistics (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « src/compilation-statistics.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <ostream> // NOLINT(readability/streams) 5 #include <ostream> // NOLINT(readability/streams)
6 #include <vector> 6 #include <vector>
7 7
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/compilation-statistics.h" 9 #include "src/compilation-statistics.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 void CompilationStatistics::RecordPhaseStats(const char* phase_kind_name, 14 void CompilationStatistics::RecordPhaseStats(const char* phase_kind_name,
15 const char* phase_name, 15 const char* phase_name,
16 const BasicStats& stats) { 16 const BasicStats& stats) {
17 base::LockGuard<base::Mutex> guard(&record_mutex_);
18
17 std::string phase_name_str(phase_name); 19 std::string phase_name_str(phase_name);
18 auto it = phase_map_.find(phase_name_str); 20 auto it = phase_map_.find(phase_name_str);
19 if (it == phase_map_.end()) { 21 if (it == phase_map_.end()) {
20 PhaseStats phase_stats(phase_map_.size(), phase_kind_name); 22 PhaseStats phase_stats(phase_map_.size(), phase_kind_name);
21 it = phase_map_.insert(std::make_pair(phase_name_str, phase_stats)).first; 23 it = phase_map_.insert(std::make_pair(phase_name_str, phase_stats)).first;
22 } 24 }
23 it->second.Accumulate(stats); 25 it->second.Accumulate(stats);
24 } 26 }
25 27
26 28
27 void CompilationStatistics::RecordPhaseKindStats(const char* phase_kind_name, 29 void CompilationStatistics::RecordPhaseKindStats(const char* phase_kind_name,
28 const BasicStats& stats) { 30 const BasicStats& stats) {
31 base::LockGuard<base::Mutex> guard(&record_mutex_);
32
29 std::string phase_kind_name_str(phase_kind_name); 33 std::string phase_kind_name_str(phase_kind_name);
30 auto it = phase_kind_map_.find(phase_kind_name_str); 34 auto it = phase_kind_map_.find(phase_kind_name_str);
31 if (it == phase_kind_map_.end()) { 35 if (it == phase_kind_map_.end()) {
32 PhaseKindStats phase_kind_stats(phase_kind_map_.size()); 36 PhaseKindStats phase_kind_stats(phase_kind_map_.size());
33 it = phase_kind_map_.insert(std::make_pair(phase_kind_name_str, 37 it = phase_kind_map_.insert(std::make_pair(phase_kind_name_str,
34 phase_kind_stats)).first; 38 phase_kind_stats)).first;
35 } 39 }
36 it->second.Accumulate(stats); 40 it->second.Accumulate(stats);
37 } 41 }
38 42
39 43
40 void CompilationStatistics::RecordTotalStats(size_t source_size, 44 void CompilationStatistics::RecordTotalStats(size_t source_size,
41 const BasicStats& stats) { 45 const BasicStats& stats) {
46 base::LockGuard<base::Mutex> guard(&record_mutex_);
47
42 source_size += source_size; 48 source_size += source_size;
43 total_stats_.Accumulate(stats); 49 total_stats_.Accumulate(stats);
44 } 50 }
45 51
46 52
47 void CompilationStatistics::BasicStats::Accumulate(const BasicStats& stats) { 53 void CompilationStatistics::BasicStats::Accumulate(const BasicStats& stats) {
48 delta_ += stats.delta_; 54 delta_ += stats.delta_;
49 total_allocated_bytes_ += stats.total_allocated_bytes_; 55 total_allocated_bytes_ += stats.total_allocated_bytes_;
50 if (stats.absolute_max_allocated_bytes_ > absolute_max_allocated_bytes_) { 56 if (stats.absolute_max_allocated_bytes_ > absolute_max_allocated_bytes_) {
51 absolute_max_allocated_bytes_ = stats.absolute_max_allocated_bytes_; 57 absolute_max_allocated_bytes_ = stats.absolute_max_allocated_bytes_;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 153 }
148 154
149 if (!ps.machine_output) WriteFullLine(os); 155 if (!ps.machine_output) WriteFullLine(os);
150 WriteLine(os, ps.machine_output, "totals", s.total_stats_, s.total_stats_); 156 WriteLine(os, ps.machine_output, "totals", s.total_stats_, s.total_stats_);
151 157
152 return os; 158 return os;
153 } 159 }
154 160
155 } // namespace internal 161 } // namespace internal
156 } // namespace v8 162 } // namespace v8
OLDNEW
« no previous file with comments | « src/compilation-statistics.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698