Repository navigation
[cppia] Load this for member increments in JIT code - #1459
Merged
Merged
Conversation
MemReferenceCrement addressed `this` fields through the raw `this` register, which doesn't mark the function as using `this`. If the increment was the only access to `this`, the register was never loaded in the function prologue and the increment was lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
That repro looks a bit too simple to be real... |
Member
It seems it does actually fail on master: I don't know about the implications of using |
Member
Author
|
I'm mildly shocked that our tests miss this... And in theory the value and block-level could take quite different code paths, so it won't hurt to test that. |
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.
In JIT-compiled cppia code,
++/--on a member field is lost if it is the only access tothisin the function:MemReferenceCrement::genCodeaddressed the field assJitThis.star() + offset. That reads through thethisregister directly, but onlyjposThisoperands (JitThisPos) setusesThis, and the prologue only loads the registerif (usesThis). So when nothing else in the function touchesthis, the increment goes through a register that was never set up.n += 1,n = n + 1and increments on other objects are not affected, and neither is the interpreter.The fix uses
JitThisPos(offset)like the other member references do. This adds a client test case covering pre/post increment and decrement, as statements and as values.Found via a new Haxe unit test in HaxeFoundation/haxe#13111, which fails on the cppia JIT run on all platforms without this change.
🤖 Generated with Claude Code