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

Unified Diff: runtime/lib/async_patch.dart

Issue 2603383004: Sane asynchronous debugging and stack traces (Closed)
Patch Set: rebase Created 3 years, 11 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 | runtime/lib/stacktrace.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/async_patch.dart
diff --git a/runtime/lib/async_patch.dart b/runtime/lib/async_patch.dart
index 3e22fb044545fef55933c31361b6ea48c946e976..3db2220ae47f38a6fe7a3ef144d285e230763223 100644
--- a/runtime/lib/async_patch.dart
+++ b/runtime/lib/async_patch.dart
@@ -42,7 +42,10 @@ Function _asyncErrorWrapperHelper(continuation) {
///
/// Returns the result of registering with `.then`.
Future _awaitHelper(
- var object, Function thenCallback, Function errorCallback) {
+ var object,
+ Function thenCallback,
+ Function errorCallback,
+ var awaiter) {
if (object is! Future) {
object = new _Future().._setValue(object);
} else if (object is! _Future) {
@@ -56,9 +59,33 @@ Future _awaitHelper(
//
// We can only do this for our internal futures (the default implementation of
// all futures that are constructed by the `dart:async` library).
+ object._awaiter = awaiter;
return object._thenNoZoneRegistration(thenCallback, errorCallback);
}
+// Called as part of the 'await for (...)' construct.
+void _asyncStarListenHelper(var object,
+ var awaiter) {
+ if (object is! _StreamImpl) {
+ return;
+ }
+ // `object` is a `_StreamImpl`.
+ object._awaiter = awaiter;
+}
+
+// Called after the
+void _asyncStarMoveNextHelper(var object) {
+ if (object is! _StreamImpl) {
+ return;
+ }
+ // `object` is a `_StreamImpl`.
+ if (object._generator == null) {
+ // No generator registered, this isn't an async* Stream.
+ return;
+ }
+ _moveNextDebuggerStepCheck(object._generator);
+}
+
// _AsyncStarStreamController is used by the compiler to implement
// async* generator functions.
class _AsyncStarStreamController {
@@ -70,7 +97,11 @@ class _AsyncStarStreamController {
bool isSuspendedAtYield = false;
Completer cancellationCompleter = null;
- Stream get stream => controller.stream;
+ Stream get stream {
+ Stream local = controller.stream;
+ local._generator = asyncStarBody;
+ return local;
+ }
void runBody() {
isScheduled = false;
@@ -190,3 +221,30 @@ class _AsyncStarStreamController {
}
@patch void _rethrow(Object error, StackTrace stackTrace) native "Async_rethrow";
+
+@patch class _Future<T> {
+ Object _awaiter;
+}
+
+@patch class _StreamImpl<T> {
+ Object _awaiter;
+ Object _generator;
+}
+
+void _completeOnAsyncReturn(Object completer, [value]) {
+ completer.complete(value);
+}
+
+/// Returns a [StackTrace] object containing the synchronous prefix for this
+/// asynchronous method.
+Object _asyncStackTraceHelper(Object closure)
+ native "StackTrace_forAsyncMethod";
+
+void _clearAsyncThreadStackTrace()
+ native "StackTrace_clearAsyncThreadStackTrace";
+
+void _setAsyncThreadStackTrace(StackTrace stackTrace) native
+ "StackTrace_setAsyncThreadStackTrace";
+
+void _moveNextDebuggerStepCheck(async_op)
+ native "AsyncStarMoveNext_debuggerStepCheck";
« no previous file with comments | « no previous file | runtime/lib/stacktrace.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698