Repository navigation
feature(Bytecode DSL): share one constant-pool slot for null constant operands - #14538
Open
The-Alchemist wants to merge 1 commit into
Open
The-Alchemist wants to merge 1 commit into
The-Alchemist wants to merge 1 commit into
Conversation
The-Alchemist
force-pushed
the
truffle/constants-buffer-shared-null
branch
from
September 26, 2026 23:14
8425478 to
67f3bbf
Compare
The-Alchemist
marked this pull request as ready for review
September 27, 2026 11:53
Reference constants can be null without reserving a fresh patchable slot on every call. Signed-off-by: The-Alchemist <kap4020@gmail.com>
The-Alchemist
force-pushed
the
truffle/constants-buffer-shared-null
branch
from
October 28, 2026 23:51
67f3bbf to
1e978a8
Compare
This branch has not been deployed
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.
Motivation
A language sometimes needs a reference constant operand whose value is
null, for example an optional type or a missing default.ConstantsBuffer.add(null)threwNullPointerExceptionbecause it started withObjects.requireNonNull. Serialization already records null withCODE_$CREATE_NULL, but the builder rejected the value before it reached the pool.addNull()is not a substitute. Its reserved slots are meant to be patched after materialization, and each call allocates a new slot. Using it for a real null constant grows the pool and can later alias a patched value. We've worked around the rejection in our Cloffle project with a sentinel value instead of passingnull.Summary
null.ConstantsBuffer.add(null)stores that null in one shared constant-pool slot.addNull()still reserves a distinct empty slot on each call so the slot can be patched after materialization.LoadConstantstill rejectsnull; useLoadNullfor a null dynamic value. Local accessors still rejectnull.