Repository navigation
Add feedback recording (for FIR) - #20
Merged
Merged
Conversation
The rsh side split the opcode helpers out of runtime.h into opcodes.h and opcodes_internals.h, so the stencil translation units can include only the parts they need.
Matches the RELOC_RCP_SMC_VARIANT_SIZE naming used on the compiler side.
It dispatched through RECCONST_VARIANT_INERT, the constant of the plain RECCONST lattice, instead of BRIFNOT_VARIANT_INERT.
The stack slot type and eq_val() only need R_bcstack_t from Rinternals.h; using it directly (behind a StackVal typedef) frees the shared stencil macros from runtime.h's Value and ALWAYS_INLINE.
…arations (split helper)
stencils.c grew into one 1.4k-line file holding the shared stencil macros, the bytecode ops, the counter/recording/type-tracing stencils and the ABI declarations. It is now split into stencils_internals.h (shared macros and declarations) plus stencils_bc.c, stencils_extra.c, stencils_recording.c and stencils_typetrace.c, each including that header. No code changes: every line here comes verbatim from stencils.c, apart from the per-file include preambles. Each new file was derived on its own branch by a 100% rename of stencils.c followed by a reduction to the block it keeps, and those branches are merged here, so plain 'git blame' (no -C) follows each moved line back to the commit that wrote it. The Makefile now compiles every *.c in the directory separately and merges the objects with 'ld -r' into the single stencils.o the extractor consumes.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a runtime “feedback recording” facility (branch counts, getvar/call type bitmaps, and getfun monomorphic/ambiguous constant capture) intended to support FIR, including an R API to export the recording as a plain serializable object.
Changes:
- Introduces a self-modifying-code (SMC) variant-group framework for stencils and adds recording-related stencil helpers (bitmap + constant lattices).
- Attaches and exports per-function recording buffers from the compiler and exposes
rcp_export_recording()in the R API. - Adds an R-level test suite covering structure, counters, type bitmaps, getfun constants, and empty/never-executed cases.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| rcp/tests/recording/Makefile | Adds a simple harness to run recording tests via Rscript. |
| rcp/tests/recording/basic.R | Adds end-to-end tests for exported recording structure and semantics. |
| rcp/src/stencils/stencils_typetrace.c | Adds stencil hooks for argument/return type tracing (entry/exit hooks). |
| rcp/src/stencils/stencils_recording.c | Adds recording bitmap logic and SMC lattices for constant recording (RECCONST/RECFUN). |
| rcp/src/stencils/stencils_internals.h | Centralizes shared stencil ABI/macros and adds SMC relocation helpers. |
| rcp/src/stencils/stencils_extra.c | Adds counter stencils for REL32/ABS64 custom data addressing. |
| rcp/src/stencils/stencils_bc.c | Refactors stencil TU to use shared internals and adds BRIFNOT SMC recording variant. |
| rcp/src/stencils/Makefile | Builds all stencil TUs into a single relocatable object for extraction. |
| rcp/src/stencils-runtime.c | Adds runtime helper rcp_smc_copy intended to implement SMC copying + continuation. |
| rcp/src/rcp_init.c | Registers rcp_export_recording as a callable C entry point. |
| rcp/src/rcp_common.h | Adds relocation kinds and shared structs for SMC group/site metadata. |
| rcp/src/extractor/extract_stencils.cpp | Adds extractor support for SMC groups and new relocation/hole kinds. |
| rcp/src/compile.c | Implements recording attachment/export and allocates SMC pools + per-site blocks. |
| rcp/R/compile.R | Adds exported R wrapper rcp_export_recording(). |
| rcp/NAMESPACE | Exports rcp_export_recording. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
No description provided.