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

Unified Diff: pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart

Issue 1288593002: dart2js: add function coverage tracking in dart2js output, dumpinfo, and (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
Index: pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
index 254a0f7cfe078cad4187e72c3701bf321475cbac..deec2b902efbf7fc6586c1f036a9e1e466f25557 100644
--- a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
@@ -1438,6 +1438,21 @@ class Emitter implements js_emitter.Emitter {
};
}
+ if (#hasInstrumentation) {
+ var __record_buffer = []; // TODO(sigmund): define as a proper global.
+ function __record_use(id, name) {
+ if (__record_buffer.length == 0) {
+ window.setTimeout(function () {
+ var xhr = new XMLHttpRequest();
+ xhr.open("POST", "/coverage_uri_to_amend_by_server");
+ xhr.send(JSON.stringify(__record_buffer));
+ __record_buffer = [];
+ }, 1000);
+ }
+ __record_buffer.push([id, name]);
+ }
+ }
+
if (#isProgramSplit) {
/// We collect all the global state, so it can be passed to the
/// initializer of deferred files.
@@ -1530,6 +1545,9 @@ class Emitter implements js_emitter.Emitter {
""", {
"disableVariableRenaming": js.comment("/* ::norenaming:: */"),
"hasIncrementalSupport": compiler.hasIncrementalSupport,
+ // TODO(sigmund): add flag
+ "hasInstrumentation": const bool.fromEnvironment('instrumentForCoverage')
+ && compiler.dumpInfo,
"helper": js('this.#', [namer.incrementalHelperName]),
"schemaChange": buildSchemaChangeFunction(),
"addMethod": buildIncrementalAddMethod(),

Powered by Google App Engine
This is Rietveld 408576698