Repository navigation
Check unused cppia casts to classes and interfaces under the JIT - #501
Merged
Merged
Conversation
The JIT compiled a cast whose value goes unused, such as cast(o, I) as a statement, as its value alone, for every kind of cast. A cast to a class or interface is a check that can fail, so one that failed ran on under the JIT, where the interpreter and compiled code throw. It was so in jitted methods before, and Haxe's unit suite met it once the JIT compiled local functions: TestCasts.testInterfaces makes such casts in closures, as exc(function() cast(v, I2)), and failed three assertions under the JIT on this branch while passing on main. Only the unused casts that cannot fail, to Dynamic and the unchecked Int, Float, Bool and String conversions, are left out now. A cast to a class or interface checks, and an array conversion runs, as the interpreter's do. CppiaJitUnusedCasts casts to an interface and to a class, passing and failing, as statements in closures and in methods, used, and before a statement that must not run, as compiled code and as a script interpreted and jitted, and checks that all three agree. Without the fix the jitted run let every failing cast through. Tests: CppiaJitUnusedCasts
dimensionscape
added a commit
that referenced
this pull request
Nov 29, 2026
main adds the host_statics cppia workload, which joins the shared workload table here, so the cppia and HashLink harnesses both run it. This branch's Changes.md lines move under libhxcpp 6.1.0, and main has the unused cppia cast fix (#501) under 6.0.3.
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.
For 6.0.3.
Under the cppia JIT, a cast whose value goes unused, such as
cast(o, SomeInterface);as a statement, checked nothing, so a failing cast ran on where the interpreter and compiled code throw:It was so in jitted methods on main. It showed once the JIT compiled local functions on the branch of #500: Haxe's
TestCasts.testInterfacesmakes such casts in closures, asexc(function() cast(v, I2)), and failed three assertions there.Cause and change
CastExpr::genCodeinsrc/hx/cppia/Cppia.cppcompiled an unused cast as its value alone, whatever the kind of cast. Now only the unused casts that cannot fail are left out: to Dynamic, and the unchecked Int, Float, Bool and String conversions. A cast to a class or interface checks, and an array conversion runs, as the interpreter's do.Tests
test/regression/CppiaJitUnusedCastscasts to an interface and to a class, passing and failing, as statements in closures and in methods, used, and before a statement that must not run. It runs them as compiled code and as a script, interpreted and jitted, and checks that all three agree. Without the fix the jitted run let every failing cast through.The fix was found and tested on the #500 branch, where it is commit d74ecf2, and cherry-picked onto main here with only its
Changes.mdline.