Skip to content

Interpreter: return and exitwhen by a flag, locals in a small array, plain stores without an address - #1450

Merged
Frotty merged 2 commits into
masterfrom
claude/interpreter-return-flags
Oct 13, 2026
Merged

Frotty merged 2 commits into
masterfrom
claude/interpreter-return-flags

Conversation

@Frotty

@Frotty Frotty commented Oct 13, 2026

Copy link
Copy Markdown
Member

Per-call costs of the compile-time interpreter which remained after #1442:

  • A return threw a ReturnException which unwound through the interpreter's frames (statement lists, ifs, loops) to runFunc, and an exitwhen an ExitwhenException to its loop. They set a flag on the call's LocalState now: RunStatement.run(ImStmts) stops when it is set, a loop ends on an exitwhen (a return stays set), a vararg loop stops and leaves the flag to the loop around it as the exception did, and the call ends on a return. A return or exitwhen inside a statement expression cannot stop the expression around it by a flag, so it still leaves by the exception, which runFunc and ImLoop still catch. An exitwhen outside any loop fails as before.
  • Every call allocated a fastutil hash map for its locals. LocalState keeps them in a small array compared by identity (ImVar has no equals), and a function with more than 16 locals goes over to the map of State.
  • An assignment to a variable allocated an ILaddress to store through. ImSet stores directly when the left side is a variable; finding the variable's state evaluates nothing, so the order of evaluation is unchanged.

Compile-time functions of a large map (Jass, thousands of compile-time functions), execute phase against master: cold 2075 to 1916 ms, warm first build 1890 to 1641 ms, warm later builds 890 to 840 ms (medians of alternating runs). A modest gain; the exceptions and maps cost less than the samples suggested. Jass output and exported object data identical.

InterpreterTests.returnAndExitwhenLeaveTheRightStatements covers a return from nested loops and ifs, an exitwhen in an if in an inner loop, a return from a vararg loop and an early return from a void function. Run locally: InterpreterTests, CompiletimeTests, CompiletimeNativesTest, CompiletimeHashtableTests, ClassesTests, ClassesExtTests, InterfaceTests, GenericsTests, GenericsWithTypeclassesTests, TypeClassTests, ClosureTests, ModuleTests, NewFeatureTests, BugTests, StdLibStringTests, StdLibOwnTests, OptimizerTests, VarargTests, TupleTests, ArrayTests.

…plain stores without an address

- A return threw a Java exception which unwound through the interpreter's
  frames to the call, and an exitwhen one to its loop. They set a flag on the
  call's local state now; a statement list stops when it is set, a loop ends
  on an exitwhen and the call on a return. Inside a statement expression,
  which cannot stop the expression around it, they still leave by the
  exception, which the call and the loop still catch.
- Every call allocated a hash map for its locals. They are kept in a small
  array compared by identity, and a function with more than 16 locals goes
  over to the map.
- An assignment to a variable allocated an address object to store through.
  It stores directly; finding the variable's state evaluates nothing.

A large map: compile-time functions execute about 5 % to 12 % faster
(cold 2075 to 1916 ms, warm first build 1890 to 1641 ms, warm later builds
890 to 840 ms, medians). Output and object data identical.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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-13T08:39:26.021412Z 463c1dc 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 cd114db into master Oct 13, 2026
2 checks passed
@Frotty
Frotty deleted the claude/interpreter-return-flags branch October 13, 2026 08:52
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