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

Unified Diff: sdk/lib/developer/timeline.dart

Issue 1985813002: Add an intrinsified early out path for Dart timeline calls (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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/developer/timeline.dart
diff --git a/sdk/lib/developer/timeline.dart b/sdk/lib/developer/timeline.dart
index fbdad8bef73f81375aaf5980233af052d7717919..b6118af6eabf3a337c7f9a5b1a36b864e1e7798d 100644
--- a/sdk/lib/developer/timeline.dart
+++ b/sdk/lib/developer/timeline.dart
@@ -23,6 +23,11 @@ class Timeline {
'name',
'Must be a String');
}
+ if (!_isDartStreamEnabled()) {
+ // Push a null onto the stack and return.
+ _stack.add(null);
+ return;
+ }
var block = new _SyncBlock._(name, _getTraceClock(), _getThreadCpuClock());
if (arguments is Map) {
block._appendArguments(arguments);
@@ -41,6 +46,10 @@ class Timeline {
}
// Pop top item off of stack.
var block = _stack.removeLast();
+ if (block == null) {
+ // Dart stream was disabled when startSync was called.
+ return;
+ }
// Finish it.
block.finish();
}
@@ -55,6 +64,10 @@ class Timeline {
'name',
'Must be a String');
}
+ if (!_isDartStreamEnabled()) {
+ // Stream is disabled.
+ return;
+ }
Map instantArguments;
if (arguments is Map) {
instantArguments = new Map.from(arguments);
@@ -278,6 +291,9 @@ String _argumentsAsJson(Map arguments) {
return JSON.encode(arguments);
}
+/// Returns true if the Dart Timeline stream is enabled.
+external bool _isDartStreamEnabled();
+
/// Returns the next async task id.
external int _getNextAsyncId();
« runtime/vm/intrinsifier_mips.cc ('K') | « sdk/lib/_internal/js_runtime/lib/developer_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698