Skip to content

Access component-model flags via their VmType alias region in adapters - #14116

Merged
fitzgen merged 2 commits into
bytecodealliance:mainfrom
fitzgen:alias-regions-for-component-model-flags
Aug 20, 2026
Merged

Access component-model flags via their VmType alias region in adapters#14116
fitzgen merged 2 commits into
bytecodealliance:mainfrom
fitzgen:alias-regions-for-component-model-flags

Conversation

@fitzgen

@fitzgen fitzgen commented Aug 10, 2026

Copy link
Copy Markdown
Member

These flags were imported by adapters and accessed with the PublicGlobal alias
region, but this led to ambiguity between loads and stores to different
flags. The flags are stored in the VMComponentContext and we generally know
when we are importing flags as globals unambiguously, so do the same thing we do
to get precise alias regions for defined globals for component-model flags, but
use the AliasRegionKey::Vm { ty: VMComponentContext, .. } alias region.

A final wrinkle: core Wasm does not have the enclosing VMComponentContext's
offsets on hand, so we move task_may_block ahead of may_leave so both flags
are before every component-shape-dependent field and the flags' offsets are a
function of the pointer size alone.

Depends on #14115

@fitzgen
fitzgen requested review from a team as code owners August 10, 2026 22:39
@fitzgen
fitzgen requested review from alexcrichton and removed request for a team August 10, 2026 22:39
@github-actions github-actions Bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. labels Aug 10, 2026
These flags were imported by adapters and accessed with the `PublicGlobal` alias
region, but this led to ambiguity between loads and stores to different
flags. The flags are stored in the `VMComponentContext` and we generally know
when we are importing flags as globals unambiguously, so do the same thing we do
to get precise alias regions for defined globals for component-model flags, but
use the `AliasRegionKey::Vm { ty: VMComponentContext, .. }` alias region.

A final wrinkle: core Wasm does not have the enclosing `VMComponentContext`'s
offsets on hand, so we move `task_may_block` ahead of `may_leave` so both flags
are before every component-shape-dependent field and the flags' offsets are a
function of the pointer size alone.
Avoid defining new `AliasRegions` helpers and use macro-generated helpers
instead.
@fitzgen
fitzgen force-pushed the alias-regions-for-component-model-flags branch from 5e85339 to 1831d57 Compare August 20, 2026 19:49
@fitzgen

fitzgen commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

@alexcrichton mind taking another look? when rebasing this, it went across the vmctx macro stuff, so I added another commit that makes it avoid defining new AliasRegions helpers in crates/cranelift and instead use macro-generated helpers, but this required some minor surgery to the macro to support accessing fields that are dynamic based on the target pointer size, but not the full VMOffsets.

@fitzgen
fitzgen added this pull request to the merge queue Aug 20, 2026
Merged via the queue into bytecodealliance:main with commit 897fb1a Aug 20, 2026
53 checks passed
@fitzgen
fitzgen deleted the alias-regions-for-component-model-flags branch August 20, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants