Skip to content

fix(native): retain image base across entry pointer changes - #2485

Closed
tignear wants to merge 2 commits into
stack/tignear/perf/native-mapped-code/keep-attached-machine-code-file-mappings--dc33e7f4from
stack/tignear/perf/native-mapped-code/retain-image-base-across-entry-pointer-changes--dd3ca7e7
Closed

tignear wants to merge 2 commits into
stack/tignear/perf/native-mapped-code/keep-attached-machine-code-file-mappings--dc33e7f4from
stack/tignear/perf/native-mapped-code/retain-image-base-across-entry-pointer-changes--dd3ca7e7

Conversation

@tignear

@tignear tignear commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

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

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
@tignear

tignear commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 perf(native): keep attached machine code in file mappings #2480
2 fix(native): retain image base across entry pointer changes #2485 👈

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T19:39:39.742636Z bdbef58 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tignear
tignear force-pushed the stack/tignear/perf/native-mapped-code/keep-attached-machine-code-file-mappings--dc33e7f4 branch from 11e6b51 to 943ba42 Compare October 28, 2026 19:41
@tignear tignear closed this Oct 28, 2026
@tignear
tignear deleted the stack/tignear/perf/native-mapped-code/retain-image-base-across-entry-pointer-changes--dd3ca7e7 branch October 28, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant