Repository navigation
fix(native): retain image base across entry pointer changes - #2485
Conversation
Loading an attached image allocated an owned copy of its machine code before copying it again into executable memory. Retain immutable mapped code with Arc ownership and use aligned file pages directly on Linux x86-64. Unsupported or unaligned mappings retain the anonymous executable allocation path. Align newly attached code to 4 KiB, or 2 MiB for large images. A checksummed optional prefix descriptor records the original runtime length so replacement across Postcard length boundaries cannot accumulate padding. The Postcard payload, generic Serde representation and container version remain compatible. Validation: 20 native units, 625 x86 backend units, 36 native image/cache consumer tests, 68 VPI unit/API tests, 10 cocotb integrations, 330 native common cases (including wide, four-state and parallel execution), affected-target clippy with warnings denied, and formatting. Regressions cover retained owner lifetimes, legacy payload encoding, bounded replacement and corrupt padding. Change-Id: Idc33e7f4db1b90e2cf48d03f0fd39049aebda302
JitCode exposes a mutable fn_ptr. Deriving image() and entry_ptr() from that field could return a slice or pointer into another allocation after safe callers swapped entries and dropped the other JitCode. Retain a private immutable image base alongside the backing owner. Keep public entry mutation compatible while resolving image bytes and offsets against the retained allocation. Store the base as the existing function-pointer type to preserve Send/Sync without adding unsafe trait implementations. Cover both owned and externally retained executable mappings with entry-swap, owner-drop, bounds, byte-content and retained-entry execution regressions. Validation: x86 backend unit tests, native image unit tests, shared_jit_cache integration tests, seven native/native_parallel common language groups, x86 all-target Clippy with warnings denied, and workspace formatting. Change-Id: Idd3ca7e78576cd40a0c6b231e78b24a2c3c20bb6
Contributor
Author
|
This pull request is part of a Mergify stack:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
tignear
force-pushed
the
stack/tignear/perf/native-mapped-code/keep-attached-machine-code-file-mappings--dc33e7f4
branch
from
October 28, 2026 19:41
11e6b51 to
943ba42
Compare
tignear
deleted the
stack/tignear/perf/native-mapped-code/retain-image-base-across-entry-pointer-changes--dd3ca7e7
branch
October 28, 2026 19:41
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.
JitCode exposes a mutable fn_ptr. Deriving image() and entry_ptr() from that
field could return a slice or pointer into another allocation after safe callers
swapped entries and dropped the other JitCode.
Retain a private immutable image base alongside the backing owner. Keep public
entry mutation compatible while resolving image bytes and offsets against the
retained allocation. Store the base as the existing function-pointer type to
preserve Send/Sync without adding unsafe trait implementations.
Cover both owned and externally retained executable mappings with entry-swap,
owner-drop, bounds, byte-content and retained-entry execution regressions.
Validation: x86 backend unit tests, native image unit tests, shared_jit_cache
integration tests, seven native/native_parallel common language groups,
x86 all-target Clippy with warnings denied, and workspace formatting.
Depends-On: #2480