Fix register forwarding when the right operand mutates the left local - #5457
Open
dev-willbird1936 wants to merge 3 commits into
Open
Fix register forwarding when the right operand mutates the left local#5457dev-willbird1936 wants to merge 3 commits into
dev-willbird1936 wants to merge 3 commits into
Conversation
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 #5457 +/- ##
===========================================
+ Coverage 47.24% 62.93% +15.68%
===========================================
Files 476 530 +54
Lines 46892 59119 +12227
===========================================
+ Hits 22154 37205 +15051
+ Misses 24738 21914 -2824 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
This Pull Request fixes/closes #5456.
The bytecode compiler can forward the register of a mutable local into a binary operation. It compiles the right operand before it copies the left value into the destination register. When the right operand mutates that local, the generated operation reads the mutated value instead of the value that left-to-right JavaScript evaluation captured, so
let a = 1; a = a + (a = 5);produces10instead of the specified6.This change snapshots mutable local identifiers into a temporary register before the other operand is compiled, and keeps the existing fast path for immutable locals and cached constants. The regression test covers four mutating right-hand operands across arithmetic, bitwise, strict-equality, and relational operators. The existing
boa_enginesuite is the negative control for unchanged behaviour on ordinary binary expressions.Validation on current
main:cargo test -p boa_engine binary_operands_preserve_left_to_right_evaluationcargo fmt --all -- --check