Skip to content

Add plugin stencils, code coverage, compiling promises#11

Open
MatejKocourek wants to merge 18 commits intomainfrom
matej-code-coverage
Open

Add plugin stencils, code coverage, compiling promises#11
MatejKocourek wants to merge 18 commits intomainfrom
matej-code-coverage

Conversation

@MatejKocourek
Copy link
Collaborator

Add plugin stencils, code coverage, moved RCP prologue to R runtime, specialize promises and optional support compiling promises.

@MatejKocourek MatejKocourek self-assigned this Feb 26, 2026
@MatejKocourek MatejKocourek added bug Something isn't working enhancement New feature or request labels Feb 26, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds plugin stencil infrastructure for code instrumentation, implements code coverage tracking via srcref integration, moves RCP prologue handling to R runtime, and adds optional support for compiling promises to native code with specialization.

Changes:

  • Introduced plugin stencil system allowing injection of custom code at specific bytecode positions
  • Added code coverage infrastructure using srcref metadata and integration with the covr package
  • Implemented specialized MAKEPROM operations with optional promise compilation to native code
  • Refactored custom data handling (renamed PATCHED_VARIANTS to CUSTOM_DATA for general plugin use)

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
rcp/src/stencils/stencils.c Added plugin coverage stencil, refactored MAKEPROM with specialization support and promise compilation
rcp/src/stencils/Makefile Added compilation flags for MAKEPROM specialization and promise compilation
rcp/src/rcp_common.h Renamed RELOC_RCP_PATCHED_VARIANTS to RELOC_RCP_CUSTOM for generalized plugin data
rcp/src/extractor/extract_stencils.cpp Updated symbol extraction to use CUSTOM_DATA naming
rcp/src/compile.c Implemented plugin stencil infrastructure, coverage tracking, peephole goto optimization, and promise compilation
rcp/src/Makevars Added build flags for RCP_COMPILE_PROMISES and MAKEPROM_SPECIALIZE features
rcp/common.mk Added configuration options for promise compilation and MAKEPROM specialization
external/rsh Updated subproject commit reference

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 652 to 662
printf("Using specialized version of MAKEPROM_OP: BCODESXP\n");
return &stencil_set[1];
case EXTPTRSXP:
if (RSH_IS_CLOSURE_BODY(code))
{
printf("Using specialized version of MAKEPROM_OP: EXTPTRSXP\n");
return &stencil_set[2];
}
// Continue to the generic version if it's an external pointer but not ours
default:
printf("Using specialized version of MAKEPROM_OP: OTHER SEXPs\n");
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

These printf debug statements should be replaced with DEBUG_PRINT macros for consistency with the rest of the codebase, allowing them to be conditionally compiled based on DEBUG_MODE.

Suggested change
printf("Using specialized version of MAKEPROM_OP: BCODESXP\n");
return &stencil_set[1];
case EXTPTRSXP:
if (RSH_IS_CLOSURE_BODY(code))
{
printf("Using specialized version of MAKEPROM_OP: EXTPTRSXP\n");
return &stencil_set[2];
}
// Continue to the generic version if it's an external pointer but not ours
default:
printf("Using specialized version of MAKEPROM_OP: OTHER SEXPs\n");
DEBUG_PRINT("Using specialized version of MAKEPROM_OP: BCODESXP\n");
return &stencil_set[1];
case EXTPTRSXP:
if (RSH_IS_CLOSURE_BODY(code))
{
DEBUG_PRINT("Using specialized version of MAKEPROM_OP: EXTPTRSXP\n");
return &stencil_set[2];
}
// Continue to the generic version if it's an external pointer but not ours
default:
DEBUG_PRINT("Using specialized version of MAKEPROM_OP: OTHER SEXPs\n");

Copilot uses AI. Check for mistakes.
MatejKocourek and others added 4 commits February 26, 2026 15:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants