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

Unified Diff: runtime/lib/async_patch.dart

Issue 1274133002: Don't zone-register async callbacks for every await call in the VM. (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
« no previous file with comments | « no previous file | runtime/vm/ast_transformer.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 682ee8b10a4ec2d6b8496a5f06496f428819a00e..99c02eeb05cd72c736f398389fc9566fefd11e16 100644
--- a/runtime/lib/async_patch.dart
+++ b/runtime/lib/async_patch.dart
@@ -4,3 +4,28 @@
import "dart:_internal";
+// We need to pass the value as first argument and leave the second and third
+// arguments empty (used for error handling).
+// See vm/ast_transformer.cc for usage.
+Function _asyncThenWrapperHelper(continuation) {
+ return Zone.current.registerUnaryCallback((x) => continuation(x, null, null));
+}
+
+// We need to pass the exception and stack trace objects as second and third
+// parameter to the continuation. See vm/ast_transformer.cc for usage.
+Function _asyncErrorWrapperHelper(continuation) {
+ return Zone.current.registerBinaryCallback(
+ (e, s) => continuation(null, e, s));
+}
+
+Future _awaitHelper(
+ var future, Function thenCallback, Function errorCallback) {
Lasse Reichstein Nielsen 2015/08/06 14:19:58 remove the "var", rename "future" to "result" (it
floitsch 2015/08/11 15:27:50 changed to 'expression'. "Result" would be the res
floitsch 2015/08/11 15:28:37 Actually changed to "object".
+ if (future is! Future) {
+ future = new Future.value(future);
+ }
Lasse Reichstein Nielsen 2015/08/06 14:19:58 if (result is! Future) { result = new _Future(
floitsch 2015/08/11 15:27:50 Done.
+ if (future is _Future) {
+ return future._thenNoZoneRegistration(thenCallback, errorCallback);
+ } else {
+ return future.then(thenCallback, onError: errorCallback);
+ }
+}
« no previous file with comments | « no previous file | runtime/vm/ast_transformer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698