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

Side by Side Diff: pkg/kernel/lib/transformations/continuation.dart

Issue 2690873005: Enable causal stacktrace in kernel (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/kernel_to_il.cc » ('j') | runtime/vm/kernel_to_il.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library kernel.transformations.continuation; 5 library kernel.transformations.continuation;
6 6
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 8
9 import '../ast.dart'; 9 import '../ast.dart';
10 import '../core_types.dart'; 10 import '../core_types.dart';
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 191 }
192 } 192 }
193 193
194 abstract class AsyncRewriterBase extends ContinuationRewriterBase { 194 abstract class AsyncRewriterBase extends ContinuationRewriterBase {
195 final VariableDeclaration nestedClosureVariable = 195 final VariableDeclaration nestedClosureVariable =
196 new VariableDeclaration(":async_op"); 196 new VariableDeclaration(":async_op");
197 final VariableDeclaration thenContinuationVariable = 197 final VariableDeclaration thenContinuationVariable =
198 new VariableDeclaration(":async_op_then"); 198 new VariableDeclaration(":async_op_then");
199 final VariableDeclaration catchErrorContinuationVariable = 199 final VariableDeclaration catchErrorContinuationVariable =
200 new VariableDeclaration(":async_op_error"); 200 new VariableDeclaration(":async_op_error");
201 final VariableDeclaration asyncStackTrace =
202 new VariableDeclaration(":async_stack_trace");
201 203
202 LabeledStatement labeledBody; 204 LabeledStatement labeledBody;
203 205
204 ExpressionLifter expressionRewriter; 206 ExpressionLifter expressionRewriter;
205 207
206 AsyncRewriterBase(helper, enclosingFunction) 208 AsyncRewriterBase(helper, enclosingFunction)
207 : super(helper, enclosingFunction) {} 209 : super(helper, enclosingFunction) {}
208 210
209 void setupAsyncContinuations(List<Statement> statements) { 211 void setupAsyncContinuations(List<Statement> statements) {
210 expressionRewriter = new ExpressionLifter(this); 212 expressionRewriter = new ExpressionLifter(this);
211 213
212 // var :async_op_then; 214 // var :async_op_then;
213 statements.add(thenContinuationVariable); 215 statements.add(thenContinuationVariable);
214 216
215 // var :async_op_error; 217 // var :async_op_error;
216 statements.add(catchErrorContinuationVariable); 218 statements.add(catchErrorContinuationVariable);
217 219
220 // var :async_stack_trace;
221 statements.add(asyncStackTrace);
222
218 // :async_op([:result, :exception, :stack_trace]) { 223 // :async_op([:result, :exception, :stack_trace]) {
219 // modified <node.body>; 224 // modified <node.body>;
220 // } 225 // }
221 final parameters = <VariableDeclaration>[ 226 final parameters = <VariableDeclaration>[
222 expressionRewriter.asyncResult, 227 expressionRewriter.asyncResult,
223 new VariableDeclaration(':exception'), 228 new VariableDeclaration(':exception'),
224 new VariableDeclaration(':stack_trace'), 229 new VariableDeclaration(':stack_trace'),
225 ]; 230 ];
226 final function = new FunctionNode(buildWrappedBody(), 231 final function = new FunctionNode(buildWrappedBody(),
227 positionalParameters: parameters, 232 positionalParameters: parameters,
(...skipping 23 matching lines...) Expand all
251 statements.add(thenClosureVariableAssign); 256 statements.add(thenClosureVariableAssign);
252 257
253 // :async_op_error = _asyncErrorWrapperHelper(asyncBody); 258 // :async_op_error = _asyncErrorWrapperHelper(asyncBody);
254 final boundCatchErrorClosure = new StaticInvocation( 259 final boundCatchErrorClosure = new StaticInvocation(
255 helper.asyncErrorWrapper, 260 helper.asyncErrorWrapper,
256 new Arguments(<Expression>[new VariableGet(nestedClosureVariable)])); 261 new Arguments(<Expression>[new VariableGet(nestedClosureVariable)]));
257 final catchErrorClosureVariableAssign = new ExpressionStatement( 262 final catchErrorClosureVariableAssign = new ExpressionStatement(
258 new VariableSet( 263 new VariableSet(
259 catchErrorContinuationVariable, boundCatchErrorClosure)); 264 catchErrorContinuationVariable, boundCatchErrorClosure));
260 statements.add(catchErrorClosureVariableAssign); 265 statements.add(catchErrorClosureVariableAssign);
266
267 // :async_stack_trace = _asyncStackTraceHelper();
kustermann 2017/02/14 14:45:53 nit: double space after =
jensj 2017/02/15 11:29:53 Done.
268 final boundAsyncStackTrace = new StaticInvocation(
269 helper.asyncStackTraceHelper, new Arguments.empty());
270 final asyncStackTraceVariableAssign = new ExpressionStatement(
271 new VariableSet(asyncStackTrace, boundAsyncStackTrace));
272 statements.add(asyncStackTraceVariableAssign);
261 } 273 }
262 274
263 Statement buildWrappedBody() { 275 Statement buildWrappedBody() {
264 ++currentTryDepth; 276 ++currentTryDepth;
265 labeledBody = new LabeledStatement(null); 277 labeledBody = new LabeledStatement(null);
266 labeledBody.body = visitDelimited(enclosingFunction.body) 278 labeledBody.body = visitDelimited(enclosingFunction.body)
267 ..parent = labeledBody; 279 ..parent = labeledBody;
268 --currentTryDepth; 280 --currentTryDepth;
269 281
270 var exceptionVariable = new VariableDeclaration(":exception"); 282 var exceptionVariable = new VariableDeclaration(":exception");
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 final Class futureClass; 879 final Class futureClass;
868 final Class completerClass; 880 final Class completerClass;
869 final Procedure printProcedure; 881 final Procedure printProcedure;
870 final Procedure completerConstructor; 882 final Procedure completerConstructor;
871 final Procedure futureMicrotaskConstructor; 883 final Procedure futureMicrotaskConstructor;
872 final Constructor streamControllerConstructor; 884 final Constructor streamControllerConstructor;
873 final Constructor syncIterableConstructor; 885 final Constructor syncIterableConstructor;
874 final Constructor streamIteratorConstructor; 886 final Constructor streamIteratorConstructor;
875 final Procedure asyncThenWrapper; 887 final Procedure asyncThenWrapper;
876 final Procedure asyncErrorWrapper; 888 final Procedure asyncErrorWrapper;
889 final Procedure asyncStackTraceHelper;
877 final Procedure awaitHelper; 890 final Procedure awaitHelper;
878 final CoreTypes coreTypes; 891 final CoreTypes coreTypes;
879 892
880 HelperNodes( 893 HelperNodes(
881 this.asyncLibrary, 894 this.asyncLibrary,
882 this.coreLibrary, 895 this.coreLibrary,
883 this.iteratorClass, 896 this.iteratorClass,
884 this.futureClass, 897 this.futureClass,
885 this.completerClass, 898 this.completerClass,
886 this.printProcedure, 899 this.printProcedure,
887 this.completerConstructor, 900 this.completerConstructor,
888 this.syncIterableConstructor, 901 this.syncIterableConstructor,
889 this.streamIteratorConstructor, 902 this.streamIteratorConstructor,
890 this.futureMicrotaskConstructor, 903 this.futureMicrotaskConstructor,
891 this.streamControllerConstructor, 904 this.streamControllerConstructor,
892 this.asyncThenWrapper, 905 this.asyncThenWrapper,
893 this.asyncErrorWrapper, 906 this.asyncErrorWrapper,
907 this.asyncStackTraceHelper,
894 this.awaitHelper, 908 this.awaitHelper,
895 this.coreTypes); 909 this.coreTypes);
896 910
897 factory HelperNodes.fromProgram(Program program) { 911 factory HelperNodes.fromProgram(Program program) {
898 Library findLibrary(String name) { 912 Library findLibrary(String name) {
899 Uri uri = Uri.parse(name); 913 Uri uri = Uri.parse(name);
900 for (var library in program.libraries) { 914 for (var library in program.libraries) {
901 if (library.importUri == uri) return library; 915 if (library.importUri == uri) return library;
902 } 916 }
903 throw 'Library "$name" not found'; 917 throw 'Library "$name" not found';
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 futureClass, 980 futureClass,
967 completerClass, 981 completerClass,
968 findProcedure(coreLibrary, 'print'), 982 findProcedure(coreLibrary, 'print'),
969 findFactoryConstructor(completerClass, 'sync'), 983 findFactoryConstructor(completerClass, 'sync'),
970 findConstructor(syncIterableClass, ''), 984 findConstructor(syncIterableClass, ''),
971 findConstructor(streamIteratorClass, ''), 985 findConstructor(streamIteratorClass, ''),
972 findFactoryConstructor(futureClass, 'microtask'), 986 findFactoryConstructor(futureClass, 'microtask'),
973 findConstructor(streamControllerClass, ''), 987 findConstructor(streamControllerClass, ''),
974 findProcedure(asyncLibrary, '_asyncThenWrapperHelper'), 988 findProcedure(asyncLibrary, '_asyncThenWrapperHelper'),
975 findProcedure(asyncLibrary, '_asyncErrorWrapperHelper'), 989 findProcedure(asyncLibrary, '_asyncErrorWrapperHelper'),
990 findProcedure(asyncLibrary, '_asyncStackTraceHelper'),
976 findProcedure(asyncLibrary, '_awaitHelper'), 991 findProcedure(asyncLibrary, '_awaitHelper'),
977 new CoreTypes(program)); 992 new CoreTypes(program));
978 } 993 }
979 } 994 }
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/kernel_to_il.cc » ('j') | runtime/vm/kernel_to_il.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698