Propagate Lua target to compiletime interpreter - #1215
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb5abfa8ad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
cb5abfa to
db672b6
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a47851f196
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 293d5d7e74
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 181aa19010
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 637f4ebc96
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f4406c845
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f23f12a851
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 439c74b1fc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0332ef4e61
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 840fcca323
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fdbfb27b6b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!writesAreTracked()) { | ||
| setArrayValUntracked(v, indexes, val); | ||
| return; |
There was a problem hiding this comment.
Track suppressed global-array writes
When a lazy initializer writes a global array before branching on it, this path applies the value without recording that the array was written while suppression was active. The runtime probe only checks the scalar-only wasWrittenWhileSuppressed, so it reconstructs the array from its declaration and may falsely classify the branch as runtime-divergent; for example, guard[0] = 1; if guard[0] == 1; counter++ persists counter and then increments it again during runtime initialization, producing 2. Fresh evidence beyond the earlier scalar prior-write report is that the new suppression marker does not cover arrays.
AGENTS.md reference: AGENTS.md:L75-L80
Useful? React with 👍 / 👎.
| private static @Nullable ILconstBool evaluateRuntimeBooleanExpression(ImExpr expression, | ||
| ProgramState globalState, | ||
| LocalState localState) { | ||
| SideEffectAnalyzer effects = new SideEffectAnalyzer(globalState.getProg()); |
There was a problem hiding this comment.
Cache side-effect analysis for runtime probes
Every suppressed if or exitwhen reaches this method, and each invocation creates a fresh SideEffectAnalyzer; the following calledNatives and usedVariables calls rebuild program-wide call-relation and used-global data. Consequently, a lazy initializer with N branch evaluations or loop iterations repeatedly scans the entire P-sized program, introducing O(NP) compile-time work where condition evaluation was previously local. Reuse analysis for the same ImProg rather than reconstructing it per condition.
AGENTS.md reference: AGENTS.md:L88-L91
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 077589985a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!effects.calledNatives(expression).isEmpty()) { | ||
| return null; | ||
| } | ||
| Set<ImVar> usedVariables = effects.usedVariables(expression); |
There was a problem hiding this comment.
Preserve global initializer evaluation order
When a short-circuited runtime operand reads multiple lazily initialized globals whose initializers share state—for example, a = next(), b = next(), followed by compiletime or a < b—collecting the globals into an unordered Set and eagerly preparing them can initialize b before a, unlike the runtime's source/access order. The probe can consequently predict the opposite branch, persist its writes as compiletime-only, and then have runtime repeat those writes. Preserve deterministic initializer order, ideally by retaining lazy expression evaluation.
AGENTS.md reference: AGENTS.md:L77-L80
Useful? React with 👍 / 👎.
| if (sourceState.wasWrittenWhileSuppressed(variable)) { | ||
| return false; |
There was a problem hiding this comment.
Scope suppressed-write markers to each initializer
When an earlier lazy initializer performs an ordinary write such as guard = true, this permanent marker makes every later runtime probe involving guard unresolved. A later initializer using if compiletime or not guard therefore suppresses writes from its compiletime-selected arm even though runtime skips that arm, losing the migrated state. Fresh evidence beyond the prior-write report is that suppressedWrites persists across independent lazy initializers rather than representing only the runtime-equivalent state of the initializer currently being analyzed.
AGENTS.md reference: AGENTS.md:L77-L80
Useful? React with 👍 / 👎.
What changed
MagicFunctions_isLuain the compiletime interpreter from the translator target.Supported migration boundary
Compiletime-to-runtime state migration covers writes performed explicitly by compiletime functions.
Side effects encountered only while lazily evaluating a global initializer are intentionally not recorded for migration, because runtime executes that initializer again. Compiletime-only side effects hidden inside a lazy initializer are therefore unsupported; persistent mutation should be performed by an explicit compiletime function after initialization.
This boundary avoids speculative runtime re-execution and keeps initializer ordering and side-effect behavior deterministic.
Why
-luacorrectly reachedRunArgsandImTranslator, but the compiletime interpreter lazily evaluated the source declaration ofMagicFunctions.isLua, whose Jass-safe default isfalse. Compiletime functions therefore observed Jass mode even for Lua builds.Separately, tracking side effects produced by lazy initializer evaluation caused those writes to be replayed before runtime repeated the initializer, duplicating state.
Validation
LuaBackendAuditTests.compiletimeInterpreterSeesLuaTargetCompiletimeTestsLuaBackendAuditTestsgit diff --check