This CL improves the stack traces that accompany exceptions. Whenever an
async function is entered, we remember how we got there. This is similar
in spirit to package:stack_trace but the implementation is more efficient
and memory usage can be more easily reasoned about.
Tracking causal stack traces:
- [x] Upon entry to an async function, capture the synchronous stack trace prefix and store it into the closure.
- [x] Upon entry to an async* function, capture the synchronous stack trace prefix and store it into the closure.
- [x] Before returning from an async function, clear the Thread's asynchronous stack trace.
- [x] After resuming an async function, load the sychronous stack trace prefix into the Thread.
- [x] Filter stack traces to remove async machinery.
Service protocol changes:
- [x] Send causal async stack trace.
Observatory changes:
- [x] Display causal async stack trace below async functions.
Fixes https://github.com/dart-lang/sdk/issues/27661R=asiva@google.com, rmacnak@google.com
Comparisons: https://docs.google.com/a/google.com/document/d/10r6jEqr8OCiDZ4y9SYU_uOimcHiOGAZMly2ghTErALI/edit?usp=sharing
Review-Url: https://codereview.chromium.org/2646443005 .
The call sequence is very similar to a classic IC call, except the guarded class and the target are loaded indirectly from the constant pool instead of as immediates. In the monomorphic case, we call directly to the expected target with a class check in the callee. In the unlinked, polymorphic and megamorphic cases, we call a stub; these case are now call-through instead of call-and-return.
Every code, except stubs involved in switchable calls, includes the class check sequence at the beginning. So we now distinguish between a checked and an unchecked entry point. Generated code except the switchable call continues to use the unchecked entry point.
PC offsets are calculated relative to the beginning of the instruction stream, rather than either entry point.
BUG=
R=fschneider@google.com
Review URL: https://codereview.chromium.org/2226893002 .
It used to be:
#0 getCurrentStackTrace (file:///tmp/junk.dart:3:5)
#0 func1 (file:///tmp/junk.dart:10:29)
#1 func2 (file:///tmp/junk.dart:14:8)
#2 func3 (file:///tmp/junk.dart:18:8)
#3 func4 (file:///tmp/junk.dart:22:8)
#4 main (file:///tmp/junk.dart:26:8)
(Notice the two #0 frames on top).
Now it will print this as:
#0 getCurrentStackTrace (file:///tmp/junk.dart:3:5)
#1 func1 (file:///tmp/junk.dart:10:29)
#2 func2 (file:///tmp/junk.dart:14:8)
#3 func3 (file:///tmp/junk.dart:18:8)
#4 func4 (file:///tmp/junk.dart:22:8)
#5 main (file:///tmp/junk.dart:26:8)
Review URL: https://codereview.chromium.org//12381030
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19272 260f80e4-7a28-3924-810f-c04153c831b5