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

Unified Diff: sdk/lib/_internal/js_runtime/lib/js_helper.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: sdk/lib/_internal/js_runtime/lib/js_helper.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index 7cd2c69d7300d5143bbe7e3412e1698208c5b41e..4c0ca1bb6c31b4072f782e2476dec64a4f1dc3c3 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -20,7 +20,8 @@ import 'dart:_js_embedded_names' show
JsGetName,
LEAF_TAGS,
NATIVE_SUPERCLASS_TAG_NAME,
- STATIC_FUNCTION_NAME_PROPERTY_NAME;
+ STATIC_FUNCTION_NAME_PROPERTY_NAME,
+ TRACE_BUFFER;
import 'dart:collection';
@@ -260,7 +261,7 @@ void throwInvalidReflectionError(String memberName) {
/// Helper to print the given method information to the console the first
/// time it is called with it.
@NoInline()
-void traceHelper(String method) {
+void consoleTraceHelper(String method) {
if (JS('bool', '!this.cache')) {
JS('', 'this.cache = Object.create(null)');
}
@@ -270,6 +271,29 @@ void traceHelper(String method) {
}
}
+List _traceBuffer;
+
+/// Helper to send coverage information as a POST request to a server.
+@NoInline()
+void postTraceHelper(int id, String name) {
+ // Note: we can't move this initialization to the declaration of
+ // [_traceBuffer] because [postTraceHelper] is called very early on functions
+ // that define constants, this happens before getters and setters are expanded
+ // and before main starts executing. This initialization here allows us to
+ // skip the lazy field initialization logic.
+ if (_traceBuffer == null) _traceBuffer = JS('JSArray', '[]');
+ if (JS('bool', '#.length == 0', _traceBuffer)) {
+ JS('', r'''
+ window.setTimeout(function () {
+ var xhr = new XMLHttpRequest();
+ xhr.open("POST", "/coverage_uri_to_amend_by_server");
+ xhr.send(JSON.stringify(#));
+ #.length = 0;
+ }, 1000)''', _traceBuffer, _traceBuffer);
sra1 2015/08/13 22:27:26 Don't use # inside a JS function. Use the a surrou
Siggi Cherem (dart-lang) 2015/08/13 23:40:21 Done.
+ }
+ JS('', '#.push([#, #])', _traceBuffer, id, name);
+}
+
class JSInvocationMirror implements Invocation {
static const METHOD = 0;
static const GETTER = 1;
« pkg/compiler/lib/src/info/info.dart ('K') | « pkg/compiler/tool/coverage_log_server.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698