Skip to content

[GR-73325] Template and Top of Stack optimization#13108

Open
graalvmbot wants to merge 1 commit intomasterfrom
yz/GR-73325
Open

[GR-73325] Template and Top of Stack optimization#13108
graalvmbot wants to merge 1 commit intomasterfrom
yz/GR-73325

Conversation

@graalvmbot
Copy link
Collaborator

This PR introduces support for template-based specialization and top-of-stack (TOS) optimization in the Graal/Truffle interpreter's "one compilation per bytecode handler" infrastructure. It enables generating multiple handler stub variants (templates), each specialized for different TOS state, by marking an expanded @Argument field as the template variable. The PR also adds framework integration for managing handler tables keyed by template index, ensuring correct handler selection in interpreter threading.

Key Changes:

  • Expanded the @HostCompilerDirectives.BytecodeInterpreterHandlerConfig.Argument.Field annotation with a templateVariable property to designate an int field as the template selector for handler specialization.
  • Added a new templates parameter to @HostCompilerDirectives.BytecodeInterpreterHandlerConfig to specify the number of template variants.
  • Modified TruffleBytecodeHandlerCallsite, handler stub generation, and stub lowering to inject a compile-time constant template variable, enabling specialization based on TOS or similar state.
  • Refactored handler dispatch and handler table construction to use both opcode and template index, ensuring correct selection of specialized handler stubs.
  • Updated relevant host and substrate modules for the new template-aware handler stubs

See detail documentation at OneCompilationPerBytecodeHandler.md

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants