Skip to content

Add feedback recording (for FIR) - #20

Merged
MatejKocourek merged 29 commits into
mainfrom
matej-recording
Aug 3, 2026
Merged

MatejKocourek merged 29 commits into
mainfrom
matej-recording

Conversation

@MatejKocourek

Copy link
Copy Markdown
Collaborator

No description provided.

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.
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread rcp/src/stencils-runtime.c Resolved
Comment thread rcp/src/compile.c Resolved
Comment thread rcp/src/extractor/extract_stencils.cpp Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@MatejKocourek
MatejKocourek merged commit 2cb0daa into main Aug 3, 2026
9 of 11 checks passed
@MatejKocourek
MatejKocourek deleted the matej-recording branch August 3, 2026 10:17
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.

2 participants