Repository navigation
Snapshot live code through its owner in the compiler adapter - #9450
Conversation
Extract the independent code-source, clone, co_code and fallible decoding foundation from RustPython#9439. Interpreter-local monitoring dispatch remains in the dependent original PR. Assisted-by: OpenAI Codex: model version unavailable
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Merging this PR will not alter performance
Comparing Footnotes
|
| pub struct CodeUnits { | ||
| // Construction provenance, never updated by runtime specialization. Keep | ||
| // original opcode identity: GET_ITER fixup does not apply to its specialized forms. | ||
| source: Box<[CodeUnit]>, |
There was a problem hiding this comment.
really? disagree to this approach
There was a problem hiding this comment.
Agreed—the immutable construction provenance and layout policy are broader than CPython requires. CPython reconstructs and caches public bytecode from execution state plus monitoring metadata; its marshal constructor validation does not introduce this provenance layer. I propose retaining that model and narrowing this change to fresh execution storage when copying live code, without carrying specialization caches or unresolved monitoring wrappers. External-bytecode rejection and frozen decoding should be considered separately rather than bundled into this change. This is a proposed direction, not an implemented revision.
There was a problem hiding this comment.
Implemented in e065e68. The provenance/layout framework, external-bytecode rejection policy, and frozen-decoding rewiring are removed. The replacement is confined to the existing _testinternalcapi compiler adapter: snapshot through the owning PyCode.get_code, then recursively snapshot nested code constants after releasing the owner lock; current filenames come from the owner getter.
The PR title/body now describe this narrower scope and the pinned CPython basis. Focused VM check and strict Clippy passed, and normal commit hooks passed (the final hook change was formatting-only, verified against the checked source). No runtime/C-API or full workspace tests were run locally; new-head CI is pending. This does not claim general live-code cloning, malformed-bytecode safety, constant-identity preservation, or a complete fix for the broader monitoring consumer paths.
Merge main and remove the construction provenance, external-bytecode policy, and frozen decode framework. Snapshot live code in the internal compiler adapter through its owning PyCode, recursively preserving access to monitoring metadata and current filenames. AI assistance: OpenAI Codex performed source research, implementation, review response drafting, and guarded static validation. Runtime and C-API tests were not run. Assisted-by: OpenAI Codex: model version unavailable
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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Address the design review by removing the immutable construction-provenance/layout framework, external-bytecode rejection policy, and frozen-decoding rewiring. Merge main as of preparation (
a20e9cdc284f70be0877dd41a8373f8d935479f3) without rewriting the original PR history.The replacement is limited to
_testinternalcapi's existing compiler adapter:PyCode's cached public bytecode and existing monitoring-wrapper resolution, constructing fresh execution storage without specialization caches.BasicBagmetadata conversion contract.CPython basis and scope
CPython reconstructs and caches public bytecode using owner monitoring metadata to resolve wrappers. Its constructor validation does not introduce the removed provenance policy.
This is not a general live-code clone API or a claim of malformed-bytecode safety/concurrency equivalence. The existing adapter reconstructs constants rather than preserving identities as CPython's
PyList_AsTupledoes. Unsupported arbitraryco_consts, existingBorrowedConstantcontainer leaks, and surrogate-bearing metadata limitations remain outside this change. No lossy string normalization is introduced. The earlier monitoring dependency claim should not be read as validated by this narrowed change.Validation
cargo check -p rustpython-vm --liband strict Clippy (-D warnings) passed withcompiler,codegen,threading,host_env,stdio,doc,importlib, locked/offline and defaults disabled.AI assistance
OpenAI Codex assisted with source research, implementation, review-response drafting, and guarded static validation. Commit messages include an
Assisted-bytrailer. Human runtime verification is not claimed.