Commit a11aeeb
committed
[dart2js] Annotation for exception stacks with shorter prefix
Dart's `throw` expression does not correspond exactly to JavaScript's `throw` statement. To implement Dart semantics, and to reduce code size, dart2js uses the functions `wrapException` and `throwExpression` from the dart2js runtime. As a result, these functions appear in the stack trace (one or both).
A consequence of this is that a fixed prefix of an error stack is less useful, as potentially interesting frames are forced out of the prefix by these 'noise' frames.
This change ensures only one of the helpers on the stack trace.
It is also possible to get rid of the helper frame by an annotation.
The annotation `@pragma('dart2js:stack-starts-at-throw')` causes the stack to be captured in the current JavaScript function rather than in a helper. The cost is more code at the call site, about 12 bytes per `throw` expression in minified code. The annotation can be placed on a method, class or library, and applies to all `throw` expression in the scope of the annotated element.
This change uses the annotation to remove noise frames from type errors and some other errors in the runtime.
Change-Id: If15184a5963fb054199177bb4526b32f25e53fe9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406684
Reviewed-by: Mayank Patke <[email protected]>
Reviewed-by: Nate Biggs <[email protected]>1 parent e038d8a commit a11aeeb
File tree
14 files changed
+139
-54
lines changed- pkg/compiler
- doc
- lib/src
- common
- js_backend
- ssa
- test
- impact/data
- sourcemaps
- sdk/lib/_internal
- js_runtime/lib
14 files changed
+139
-54
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
217 | 233 | | |
218 | 234 | | |
219 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
898 | 898 | | |
899 | 899 | | |
900 | 900 | | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
901 | 904 | | |
902 | 905 | | |
903 | 906 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
360 | 367 | | |
361 | 368 | | |
362 | 369 | | |
| |||
645 | 652 | | |
646 | 653 | | |
647 | 654 | | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
648 | 671 | | |
649 | 672 | | |
650 | 673 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2529 | 2529 | | |
2530 | 2530 | | |
2531 | 2531 | | |
2532 | | - | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
2533 | 2540 | | |
2534 | 2541 | | |
2535 | 2542 | | |
| |||
7759 | 7766 | | |
7760 | 7767 | | |
7761 | 7768 | | |
| 7769 | + | |
| 7770 | + | |
7762 | 7771 | | |
7763 | 7772 | | |
7764 | 7773 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2994 | 2994 | | |
2995 | 2995 | | |
2996 | 2996 | | |
2997 | | - | |
2998 | | - | |
2999 | | - | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
3000 | 3007 | | |
3001 | 3008 | | |
3002 | 3009 | | |
3003 | 3010 | | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
3004 | 3015 | | |
3005 | 3016 | | |
3006 | 3017 | | |
| |||
3185 | 3196 | | |
3186 | 3197 | | |
3187 | 3198 | | |
| 3199 | + | |
3188 | 3200 | | |
3189 | 3201 | | |
3190 | 3202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3417 | 3417 | | |
3418 | 3418 | | |
3419 | 3419 | | |
| 3420 | + | |
3420 | 3421 | | |
3421 | 3422 | | |
3422 | 3423 | | |
3423 | | - | |
3424 | | - | |
| 3424 | + | |
| 3425 | + | |
| 3426 | + | |
3425 | 3427 | | |
3426 | 3428 | | |
3427 | 3429 | | |
| |||
3466 | 3468 | | |
3467 | 3469 | | |
3468 | 3470 | | |
| 3471 | + | |
3469 | 3472 | | |
3470 | 3473 | | |
3471 | 3474 | | |
3472 | 3475 | | |
| 3476 | + | |
3473 | 3477 | | |
3474 | 3478 | | |
3475 | 3479 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
362 | | - | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
363 | 366 | | |
364 | 367 | | |
365 | 368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
| 427 | + | |
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
0 commit comments