Skip to content

Make compilation order deterministic - #1366

Merged
Frotty merged 1 commit into
masterfrom
split/determinism
Oct 6, 2026
Merged

Frotty merged 1 commit into
masterfrom
split/determinism

Conversation

@Frotty

@Frotty Frotty commented Oct 6, 2026

Copy link
Copy Markdown
Member

Split out of #1353.

Sorts everything whose order came from the file system, hash iteration or discovery order: directory listings, compilation units, packages, IM functions/globals/classes and type ids. Optimizer sets that feed ordering are insertion-ordered. In ImToJassTranslator, all globals are registered before initialisers are translated; the new alphabetical global order otherwise puts bj_DEGTORAD before bj_PI.

Behaviour change: compile-time functions of packages that do not import each other now run in package-name order instead of file order. This matches the runtime init order. Auto-allocated ids from a shared counter may shift on upgrade.

Tests: functionAndGlobalSortOrderIsDeterministic and compilationUnitAndPackageOrderingIsDeterministic fail on master and pass here. multiPackageShuffledCompilationUnitOrderIsBitExact is a regression guard. countedLoopsEmitNumericFor accepts i1 now that locals are numbered in sorted order.

Not covered: the language-server model is still in edit order (mergeCompilationUnits only runs for parseFiles), and the CU sort itself has no unit test because in-memory test units have no path.

Sort directory listings, compilation units, packages, IM functions/globals/classes
and type ids by stable keys, keep optimizer sets insertion-ordered, and declare
BJ globals before initialisers that read them in ImToJassTranslator.

Compile-time functions of packages that do not import each other now run in
package-name order instead of file order, which matches the runtime init order.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T09:41:29.359762Z b73b645 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Frotty
Frotty merged commit 577f7b4 into master Oct 6, 2026
3 checks passed
@Frotty
Frotty deleted the split/determinism branch November 25, 2026 08:54
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.

1 participant