perf(bytecompiler): avoid redundant Constant clone in IC initialization#5299
Open
tkshsbcue wants to merge 2 commits intoboa-dev:mainfrom
Open
perf(bytecompiler): avoid redundant Constant clone in IC initialization#5299tkshsbcue wants to merge 2 commits intoboa-dev:mainfrom
tkshsbcue wants to merge 2 commits intoboa-dev:mainfrom
Conversation
emit_get_property_by_name and emit_set_property_by_name were cloning the entire Constant enum just to extract the inner JsString, which was then cloned again for the InlineCache. Borrow the constant by reference instead and clone only the JsString once.
Test262 conformance changes
Tested main commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5299 +/- ##
===========================================
+ Coverage 47.24% 59.70% +12.45%
===========================================
Files 476 589 +113
Lines 46892 63490 +16598
===========================================
+ Hits 22154 37906 +15752
- Misses 24738 25584 +846 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
zhuzhu81998
reviewed
Apr 7, 2026
| unreachable!("there should be a string at index") | ||
| }; | ||
| self.ic.push(InlineCache::new(name.clone())); | ||
| let is_length = *name == StaticJsStrings::LENGTH; |
Contributor
There was a problem hiding this comment.
hmm do you really need to introduce this? doesnt look necessary if you dont override name below.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
perf(bytecompiler): avoid redundant Constant clone in IC initialization
Description
emit_get_property_by_nameandemit_set_property_by_namewere cloning the entireConstantenum to extract the innerJsString, which was then cloned again for theInlineCache. This meant twoJsStringclones per property access site during compilation when only one is needed.The fix borrows the constant by reference and clones only the
JsStringonce.Before
.clone()on theConstantenum clones the innerJsStringname.clone()clones theJsStringagain for theInlineCacheAfter
JsStringclone, moved directly into theInlineCache