Repository navigation
Conversation
A global that is not a constant (`PARTITION_KIND_GLOBAL` in the world of the
code) is read and written through its binding's `value` field, as Julia's
code generator does (`emit_globalop`):
- reads are an unordered load (`jtbaa_binding`) with a null check that
throws `UndefVarError` through `ijl_undefined_var_error`;
- assignments of globals of type `Any` are a release store and the
binding's write barrier.
This also covers `getglobal` and `setglobal!` (default order) with constant
arguments. Other bindings (imported, unresolved) and assignments of typed
globals, which convert the value, still go through the runtime.
GPUCompiler's validation recognizes these accesses ("use of a non-constant
global"); calls of `getglobal` it reports as dynamic invocations.
Assisted-by: Claude Code (Opus 5.5)
vchuravy
force-pushed
the
vc/jc-20-target-layouts
branch
from
October 19, 2026 17:35
bd35ca5 to
81d56e6
Compare
vchuravy
force-pushed
the
vc/jc-21-globals
branch
from
October 19, 2026 17:35
f8c04fc to
a9ab90b
Compare
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.
Stacked on #21. GPUCompiler's suite with
codegen=:juliacodegenfound this gap.A global that is not a constant (
PARTITION_KIND_GLOBALin the code's world) is now read and written through its binding'svaluefield, as Julia's code generator does inemit_globalop:jtbaa_binding), with a null check that throwsUndefVarErrorthroughijl_undefined_var_error(sym, mod). The result has the binding's declared type.Any-typed globals: a release store plus the binding's write barrier (object form on 1.12, field form from 1.13 on).getglobalandsetglobal!with constant module and name (and default order) take the same paths.Other bindings (imported, unresolved) and assignments of typed globals, which convert the value, still go through the runtime.
GPUCompiler's validation recognizes these accesses and reports "use of a non-constant global" (with the binding's name), as it does for native code. Through
getglobalcalls it reported dynamic invocations instead.Tests (
test/exceptions.jl):UndefVarError);Tested locally with
julia +1.12,+1.13and+nightly: 5943, 5949 and 5948 tests pass.🤖 Generated with Claude Code