Repository navigation
fix: apply interpreter register limit to JIT backends - #54
Merged
Merged
Conversation
Enforce the same per-function 256-slot register ceiling on INTERP, TCC, and GCC. The check measures peak concurrent register slots from the shared AllocLocal/AllocReg/FreeTo/EnsureStack walk, which includes parameters, semantic temporaries, and expression temps rather than counting user locals or generated C variables. JIT-only compiles run CheckRegisterLimit without emitting bytecode, constant pools, or FuncProto. When INTERP is enabled, Build still runs once; RegisterAndInit stays after TCC/GCC so __fakelua_init order is unchanged. Boundary tests cover exact 256/257 slots, adjacent complex multi-assign/call/table-constructor cases, constants beyond 256, and a nested function overflow.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #54 +/- ##
==========================================
+ Coverage 89.77% 90.00% +0.22%
==========================================
Files 125 125
Lines 27317 28601 +1284
==========================================
+ Hits 24523 25741 +1218
- Misses 2794 2860 +66 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ValidateGotoInBlock already rejected continue when loop_depth is 0, but break was left to a later backend. After interpreter Build ran before TCC/GCC, InterpCodegen threw "break not inside loop", and exception.test_break_error failed on macOS and Windows because it looked for "compile" (a C compiler diagnostic, or a Linux stack frame path under src/compile/). Diagnose the same language rule in semantic analysis, with a stable source location, so every backend agrees. The test now asserts that message instead of a platform-dependent substring.
Validate the shared register peak in SemanticAnalysis::Analyze with FunctionRegisterUsage Alloc* lifetime rules, so all backends share one compile-module check and compiler.cpp no longer couples JIT gating to interpreter codegen.
Remove compile/register_limit.h and the shared FunctionRegisterUsage abstraction. SemanticAnalysis::Analyze calls CheckRegisterLimits, an internal alloc-only peak checker in semantic_analysis.cpp (no bytecode, FuncProto, InterpUnit, or State string intern). InterpCodegen again owns interpreter codegen. Constants stay uncapped; 256/257 and 234/235 boundaries are unchanged.
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.
The interpreter already rejects a function whose peak register usage exceeds 255. JIT backends (TCC/GCC) previously could compile the same source, so INTERP and JIT could disagree on the same input. This change enforces the same per-function ceiling on every backend.
The shared check walks the same
AllocLocal/AllocReg/FreeTo/EnsureStackrules used by interpreter codegen. The measured resource is peak concurrent register slots: parameters, semantic temporaries, and expression temporaries together, not a count of user locals or of generated C variables.When INTERP is enabled, bytecode is still built once. JIT-only compiles run
CheckRegisterLimitinstead, so they do not emit bytecode, constant pools, orFuncProto.RegisterAndInitstill runs after TCC/GCC registration so__fakelua_initside-effect order is unchanged.Tests cover: