Performance: replace the boxed ArrayDeque operand stack with a flat Object[] stack - #555
Merged
bertysentry merged 2 commits intoAug 14, 2026
Conversation
Commit 8788dfe stored mvnw.cmd with CRLF in the blob while .gitattributes declares *.cmd as text (LF in repo, CRLF on checkout), making the file show as permanently modified on Windows checkouts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Every opcode paid ArrayDeque head-index wraparound math plus a NULL_OPERAND sentinel mapping on each push/pop. The operand stack is now a plain Object[] with an explicit top index, so push/pop/clear are single array accesses the JIT can inline, null operands are stored directly, and popArguments() bulk-copies its slice with System.arraycopy instead of popping one element at a time. The array starts at 64 slots and doubles on demand; depth is bounded by expression nesting, so it rarely grows. JMH (2 forks, JDK 25): tightArithmeticLoop 9358 -> 8091 us/op (-13.5%); AVMExpressionBenchmark cases improve 5-14% across the board. Closes #536 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
@codex please review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
bertysentry
deleted the
536-performance-replace-the-boxed-arraydeque-operand-stack-with-a-flat-object-stack
branch
August 14, 2026 13:20
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.
Fixes #536
Changes
Deque<Object> operandStack(ArrayDeque) inAVMwith a plainObject[]plus an explicit top-of-stack index:push/pop/clearare now single array accesses the JIT can fully inline, with no head-index wraparound math.NULL_OPERANDsentinel: the AVM owns all stack accesses, sonulloperands are stored directly.popArguments()now bulk-copies its argument slice withSystem.arraycopyinstead of popping one element at a time (the hot-path note from the issue).ArrayDeque).Also renormalized
mvnw.cmdline endings: commit 8788dfe stored the blob with CRLF while.gitattributesdeclares*.cmd text eol=crlf, which made the file show as permanently modified on Windows checkouts.No user-visible behavior change, so no
behavior-changes.mdentry.Benchmarks
JMH, 2 forks, JDK 25, Windows 11 (baseline = branch HEAD before this change):
Verification
mvn test: 752 tests, 0 failuresmvn clean verify site: BUILD SUCCESS, 0 checkstyle / pmd / spotbugs findings🤖 Generated with Claude Code