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

Unified Diff: runtime/vm/coverage.cc

Issue 1310083003: Do less work while computing call site info. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/coverage.cc
diff --git a/runtime/vm/coverage.cc b/runtime/vm/coverage.cc
index 207f83193d87905889101a29707544b0fe7c0451..d18ce19b9d0294e9617b9a0832aa464b8cc9dd72 100644
--- a/runtime/vm/coverage.cc
+++ b/runtime/vm/coverage.cc
@@ -103,32 +103,33 @@ void CodeCoverage::CompileAndAdd(const Function& function,
if ((token_pos < begin_pos) || (token_pos > end_pos)) {
continue;
}
- intptr_t line = pos_to_line[token_pos];
-#if defined(DEBUG)
- const Script& script = Script::Handle(zone, function.script());
- intptr_t test_line = -1;
- script.GetTokenLocation(token_pos, &test_line, NULL);
- ASSERT(test_line == line);
-#endif
- // Merge hit data where possible.
- if (last_line == line) {
- last_count += ic_data->AggregateCount();
- } else {
- if ((last_line != -1) && !as_call_sites) {
- hits_or_sites.AddValue(last_line);
- hits_or_sites.AddValue(last_count);
- }
- last_count = ic_data->AggregateCount();
- last_line = line;
- }
if (as_call_sites) {
bool is_static_call = iter.Kind() == RawPcDescriptors::kUnoptStaticCall;
ic_data->PrintToJSONArray(hits_or_sites, token_pos, is_static_call);
+ } else {
+ intptr_t line = pos_to_line[token_pos];
+#if defined(DEBUG)
+ const Script& script = Script::Handle(zone, function.script());
+ intptr_t test_line = -1;
+ script.GetTokenLocation(token_pos, &test_line, NULL);
+ ASSERT(test_line == line);
+#endif
+ // Merge hit data where possible.
+ if (last_line == line) {
+ last_count += ic_data->AggregateCount();
+ } else {
+ if ((last_line != -1)) {
+ hits_or_sites.AddValue(last_line);
+ hits_or_sites.AddValue(last_count);
+ }
+ last_count = ic_data->AggregateCount();
+ last_line = line;
+ }
}
}
}
// Write last hit value if needed.
- if ((last_line != -1) && !as_call_sites) {
+ if (!as_call_sites && (last_line != -1)) {
hits_or_sites.AddValue(last_line);
hits_or_sites.AddValue(last_count);
}
@@ -164,7 +165,9 @@ void CodeCoverage::PrintClass(const Library& lib,
i++;
continue;
}
- ComputeTokenPosToLineNumberMap(script, &pos_to_line);
+ if (!as_call_sites) {
+ ComputeTokenPosToLineNumberMap(script, &pos_to_line);
+ }
JSONObject jsobj(&jsarr);
jsobj.AddProperty("source", saved_url.ToCString());
jsobj.AddProperty("script", script);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698