Switch let/const to var in the scanner & parser for top-levelish variables.#52832
Switch let/const to var in the scanner & parser for top-levelish variables.#52832DanielRosenwasser merged 2 commits intomainfrom
Conversation
|
@typescript-bot perf test this faster |
|
Heya @DanielRosenwasser, I've started to run the abridged perf test suite on this PR at 450cfe1. You can monitor the build here. |
|
@typescript-bot perf test this faster |
|
Heya @DanielRosenwasser, I've started to run the abridged perf test suite on this PR at cd8b3a6. You can monitor the build here. Update: The results are in! |
|
@DanielRosenwasser Here they are:Comparison Report - main..52832
System
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yay!!! |
|
Aside: is it just the scanner? Can we revert parser and test only the scanner? Is it a specific variable? That would be very interesting to know. |
| scanRange, | ||
| }; | ||
|
|
||
| /* eslint-disable no-var */ |
There was a problem hiding this comment.
Drive-by - was this maybe supposed to be eslint-enable? It's already disabled above, and below there's no new vars.
This pull request regains some of the performance we lost in #51387 when we switched our emit from ES5 to ES2018 - a significant part due to TDZ checks that engines need to perform. These TDZ checks can often be eliminated, but engines probably have a hard time knowing whether a function can eliminate these checks.
By switching many of the top-level shared closure variables in the parser and scanner from
let/consttovar, we're able to eliminate those checks. Doing so should be fairly safe, since our functions follow the same initialization mechanism of declaring variables, and then calling the "workhorse" function afterwards.