Remove a few deopts already #4311
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've started digging through the codebase on wins with regards to performance, I've seen a lot of them.... However, some of them also come down to our ... weird usage of TypeScript.
Let's take the
Tokenas an example, we did a great thing in creating it as a class as it enforced consistent monomorphic backing shapes, however we do a non-null assertion, for the reason thatvaluecan actually be undefined. When we useTokenwe always assume thatvalueis defined which makes all of this deopt as we will call functions withstring | undefinedthe whole thing while our code is geared forstring.I've attempted to make
valuethe correct type which resulted in a lot more issues.In addition to that we have a lot of call-sites for the
.slicemethod, we however do polymorphic access on it as adjacent call-sites will invokeString.sliceright next toArray.slicewhich makes.slicenot optimizeable, instead we can resort to convertingString.sliceintoString.substringto avoid this issue all together.The last noLocation parse bailout remaining is the
.slicecase ofblockstring.tsThe improvements on the parser benchmark are currently minimal, I am trying to discover the deopts and how we can have a way forward.