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

Unified Diff: src/debug/debug-coverage.cc

Issue 2764073004: [debug] do not report unnecessary coverage data. (Closed)
Patch Set: Created 3 years, 9 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/debug/debug-coverage.h ('k') | test/inspector/cpu-profiler/coverage.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug/debug-coverage.cc
diff --git a/src/debug/debug-coverage.cc b/src/debug/debug-coverage.cc
index 1489f4168b428f66986944634a08111b96f07a12..c60062ff3f2d8fec95485515f8d5b905b688a884 100644
--- a/src/debug/debug-coverage.cc
+++ b/src/debug/debug-coverage.cc
@@ -119,7 +119,7 @@ Coverage* Coverage::Collect(Isolate* isolate, bool reset_count) {
// Create and add new script data.
Handle<Script> script_handle(script, isolate);
- result->emplace_back(isolate, script_handle);
+ result->emplace_back(script_handle);
std::vector<CoverageFunction>* functions = &result->back().functions;
std::vector<SharedFunctionInfo*> sorted;
@@ -133,6 +133,9 @@ Coverage* Coverage::Collect(Isolate* isolate, bool reset_count) {
std::sort(sorted.begin(), sorted.end(), CompareSharedFunctionInfo);
}
+ // Stack to track nested functions, referring function by index.
+ std::vector<size_t> nesting;
caseq 2017/03/23 00:09:56 nit: perhaps std::vector<const CoverageFunction*>
Yang 2017/03/23 07:43:16 I considered that. However, std::vector reallocate
+
// Use sorted list to reconstruct function nesting.
for (SharedFunctionInfo* info : sorted) {
int start = StartPosition(info);
@@ -142,9 +145,22 @@ Coverage* Coverage::Collect(Isolate* isolate, bool reset_count) {
count = info->has_reported_binary_coverage() ? 0 : 1;
info->set_has_reported_binary_coverage(true);
}
- Handle<String> name(info->DebugName(), isolate);
- functions->emplace_back(start, end, count, name);
+ // Find the correct outer function based on start position.
+ while (!nesting.empty() && functions->at(nesting.back()).end <= start) {
+ nesting.pop_back();
+ }
+ if (count > 0 ||
+ (!nesting.empty() && functions->at(nesting.back()).count > 0)) {
+ // Only include a function range if it has a non-0 count, or
+ // if it is directly nested inside a function with non-0 count.
+ Handle<String> name(info->DebugName(), isolate);
+ nesting.push_back(functions->size());
+ functions->emplace_back(start, end, count, name);
+ }
}
+
+ // Remove entries for scripts that have no coverage.
+ if (functions->empty()) result->pop_back();
}
return result;
}
« no previous file with comments | « src/debug/debug-coverage.h ('k') | test/inspector/cpu-profiler/coverage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698