Skip to content

Fix cppia JIT "Bad move target" on untyped register moves - #1366

Closed
MeguminBOT wants to merge 1 commit into
HaxeFoundation:masterfrom
MeguminBOT:fix-cppia-jit-untyped-register-move
Closed

Fix cppia JIT "Bad move target" on untyped register moves#1366
MeguminBOT wants to merge 1 commit into
HaxeFoundation:masterfrom
MeguminBOT:fix-cppia-jit-untyped-register-move

Conversation

@MeguminBOT

Copy link
Copy Markdown

Any binary subtraction inside a ternary that is converted to String or object triggers it.
Multiplication, division, unary minus and addition are unaffected, as is hoisting the subtraction into a local first.

CppiaCompiler::convert moved between two registers without giving either a type in three places.
move() decides what to emit from getCommonType(), and getCommonType(jtAny, jtAny) returns jtAny, which the
switch answers with setError("Bad move target").

All three sites are guarded by inSrc.uses(SLJIT_R1) or inSrc==sJitTemp1, so they are only reached when the source value happens to live in R1.
OpAdd::genCode leaves its int result in sJitTemp0 and misses the guard, while OpSub::genCode uses sJitTemp1 and hits it, which is why addition compiles and subtraction does not.

Reproducable steps

class Repro {
    static function f(a:Int, b:Int, flag:Bool):String {
        return "x" + (flag ? 0 : a - b);
    }
    public static function main() Sys.println(f(5, 3, false));
}

Run

haxe -main Repro -cppia repro.cppia
haxe -main cpp.cppia.Host -D scriptable -dce no -cpp host
host/Host.exe -jit repro.cppia    Error : Bad move target
host/Host.exe      repro.cppia    x2

@MeguminBOT
MeguminBOT marked this pull request as draft August 13, 2026 14:34
CppiaCompiler::convert moves between two untyped registers in three places.
getCommonType(jtAny, jtAny) returns jtAny, which move() rejects.

The cppia test suite covers it, run with -jit.
@MeguminBOT
MeguminBOT force-pushed the fix-cppia-jit-untyped-register-move branch from 78d8605 to 86d568d Compare August 13, 2026 16:02
@MeguminBOT

Copy link
Copy Markdown
Author

Closing, remaking commit

@MeguminBOT MeguminBOT closed this Aug 13, 2026
@tobil4sk

Copy link
Copy Markdown
Member

It's fine if you just force push your new commits here, without closing and opening an new PR

@MeguminBOT

Copy link
Copy Markdown
Author

gotcha will do in the future.
did it mostly to actually get the workflows to trigger as they didnt on this for some reason.

@tobil4sk

Copy link
Copy Markdown
Member

They should also run on push, but they might require approval for first time contributors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants