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

Unified Diff: src/profiler/profile-generator.cc

Issue 1631043002: Add CollectSample API function to CpuProfiler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix tests. Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/profiler/profile-generator.h ('k') | src/profiler/sampler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/profiler/profile-generator.cc
diff --git a/src/profiler/profile-generator.cc b/src/profiler/profile-generator.cc
index 890f341e895b10f5b645417b75b3b2208f2d3948..4c4205290fd0f677a4b8b876637fcc0f4fbffad0 100644
--- a/src/profiler/profile-generator.cc
+++ b/src/profiler/profile-generator.cc
@@ -274,9 +274,8 @@ unsigned ProfileTree::GetFunctionId(const ProfileNode* node) {
return static_cast<unsigned>(reinterpret_cast<uintptr_t>(entry->value));
}
-
ProfileNode* ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path,
- int src_line) {
+ int src_line, bool update_stats) {
ProfileNode* node = root_;
CodeEntry* last_entry = NULL;
for (CodeEntry** entry = path.start() + path.length() - 1;
@@ -290,9 +289,11 @@ ProfileNode* ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path,
if (last_entry && last_entry->has_deopt_info()) {
node->CollectDeoptInfo(last_entry);
}
- node->IncrementSelfTicks();
- if (src_line != v8::CpuProfileNode::kNoLineNumberInfo) {
- node->IncrementLineTicks(src_line);
+ if (update_stats) {
+ node->IncrementSelfTicks();
+ if (src_line != v8::CpuProfileNode::kNoLineNumberInfo) {
+ node->IncrementLineTicks(src_line);
+ }
}
return node;
}
@@ -354,10 +355,11 @@ CpuProfile::CpuProfile(Isolate* isolate, const char* title, bool record_samples)
start_time_(base::TimeTicks::HighResolutionNow()),
top_down_(isolate) {}
-
void CpuProfile::AddPath(base::TimeTicks timestamp,
- const Vector<CodeEntry*>& path, int src_line) {
- ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path, src_line);
+ const Vector<CodeEntry*>& path, int src_line,
+ bool update_stats) {
+ ProfileNode* top_frame_node =
+ top_down_.AddPathFromEnd(path, src_line, update_stats);
if (record_samples_) {
timestamps_.Add(timestamp);
samples_.Add(top_frame_node);
@@ -522,15 +524,15 @@ void CpuProfilesCollection::RemoveProfile(CpuProfile* profile) {
UNREACHABLE();
}
-
void CpuProfilesCollection::AddPathToCurrentProfiles(
- base::TimeTicks timestamp, const Vector<CodeEntry*>& path, int src_line) {
+ base::TimeTicks timestamp, const Vector<CodeEntry*>& path, int src_line,
+ bool update_stats) {
// As starting / stopping profiles is rare relatively to this
// method, we don't bother minimizing the duration of lock holding,
// e.g. copying contents of the list to a local vector.
current_profiles_semaphore_.Wait();
for (int i = 0; i < current_profiles_.length(); ++i) {
- current_profiles_[i]->AddPath(timestamp, path, src_line);
+ current_profiles_[i]->AddPath(timestamp, path, src_line, update_stats);
}
current_profiles_semaphore_.Signal();
}
@@ -670,7 +672,8 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
}
}
- profiles_->AddPathToCurrentProfiles(sample.timestamp, entries, src_line);
+ profiles_->AddPathToCurrentProfiles(sample.timestamp, entries, src_line,
+ sample.update_stats);
}
« no previous file with comments | « src/profiler/profile-generator.h ('k') | src/profiler/sampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698