Skip to content

feat(regex): execute embedded callbacks in vendored Joni - #965

Merged
fglock merged 2 commits into
masterfrom
feature/joni-callout-fork
Aug 16, 2026
Merged

feat(regex): execute embedded callbacks in vendored Joni#965
fglock merged 2 commits into
masterfrom
feature/joni-callout-fork

Conversation

@fglock

@fglock fglock commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • vendor Joni 2.2.7 in this repository and replace the stock Joni dependency
  • preserve upstream source packages and notices while relocating Joni and JCodings to org.perlonjava.internal in the standalone JAR
  • execute parser-created (?{ ... }) closures and callback conditions inside Joni with provisional captures, $^R, and exact backtracking unwind
  • preserve callback tables through interpolation and embedded qr// values on both JVM and interpreter backends
  • route every structured executable callback to Joni, including constant-bodied closures
  • retain constant (??{ ... }) folding and defer runtime-dependent dynamic patterns until nested alternatives can join outer backtracking

Design decisions

The history-free architecture and acceptance contract are in docs/design/joni-callout-fork.md.

The complete RegexPreprocessor is not moved into the fork. Perl source policy, security, diagnostics, and backend selection remain in PerlOnJava; matcher semantics move into Joni incrementally. The missing regex features in docs/reference/feature-matrix.md are the Joni routing roadmap.

Original Joni copyright, authorship, MIT license, tests, and modification notices are retained. Packaging checks verify namespace isolation, notices, and SBOM metadata.

Verification

  • make: passes after rebase onto origin/master
  • upstream Joni suite: passes through the root build
  • standalone packaging, relocation, notices, and SBOM checks: pass
  • executable_callbacks.t: 18/18 under system Perl, JVM backend, and interpreter backend
  • post-rebase thread qr validation: 2/2
  • qr overload suite: 23/23
  • perl dev/tools/perl_test_runner.pl perl5_t/t/re/: 80 files, 94,827 assertions, zero outer timeouts, 50,458 passing in the full run

Compared file-by-file with ../PerlOnJava/logs/test_20260815_080000_958.log:

  • full run: net +185 passing assertions
  • focused speed_thr.t: 26/59 on both this branch and clean origin/master; the full-run 25/59 observation was its internal watchdog under shared CPU contention
  • semantic acceptance: no per-file regression
  • notable gains: pat.t and pat_thr.t +32 each; advanced variants +5 each; rxcode.t +39; substitution variants +2 each

Deferred

  • runtime-dependent (??{ ... }) nested-pattern execution
  • remaining condition forms and missing-regex roadmap items
  • evidence-based evaluation of Joni as the default backend for non-executable patterns

fglock and others added 2 commits August 15, 2026 19:58
Import the official Joni 2.2.7 source snapshot from tag joni-2.2.7 at
57fd57b4f977813a7b4b35e0179943b1f06f51d7. Retain its source packages,
tests, MIT license, copyright headers, and authorship notices unchanged
except for the generic callout extension maintained here.

Replace the binary Joni dependency with the vendored source and retain
JCodings 1.0.64 as the upstream binary dependency. Its license was copied
from tag jcodings-1.0.64 at
996ae0f72c5cc6bb28ef92f29bbd5ef0f63d5250.

Add matcher-local callout handlers, provisional capture views, a callout
opcode, and matcher-stack unwind tokens. Cleanup now covers backtracking,
success, failure, handler exceptions, interruption, and timeout in reverse
execution order. Matcher-local handlers keep shared compiled regexes safe
for runtime-local callback state.

Relocate Joni and JCodings into org.perlonjava.internal in the standalone
JAR, package all upstream license and modification notices, and record the
vendored component and JCodings relationship in the combined SBOM.

Add the history-free design contract in docs/design/joni-callout-fork.md,
the imported upstream Joni suite, focused callout tests, and an automated
packaging verifier.

Verification: full make passes, including the upstream Joni suite, focused
callout tests, five PerlOnJava unit shards, standalone JAR relocation and
notice checks, and SBOM validation.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Implement phases 36.2 through 36.4 of the vendored Joni callout design.

Phase 36.2 represents literal (?{...}) bodies and callback conditions as
parser-created lexical closures. Structured regex templates preserve those
closures and callback tables across interpolation, qr embedding, JVM codegen,
and interpreter bytecode without exposing internal callout syntax to runtime
strings.

Phase 36.3 makes every structured executable callback select Joni, including
constant-bodied callbacks. The runtime bridge publishes provisional captures,
executes closures in scalar context, maintains $^R, checkpoints regex and
dynamic-local state, and restores state exactly once on backtracking, failure,
exceptions, or successful completion.

Phase 36.4 adds callback-selected conditional branches and callback-table ID
remapping for embedded regex values. Preserve literal CALL-like pattern text,
retain the compatibility no-op for eval groups introduced only as runtime
text, and keep dynamic (??{...}) patterns gated until nested alternatives can
participate in outer backtracking.

Stabilize literal match-target scalar identity for /g call sites and fix
undefining a typeglob scalar slot that aliases a read-only callback value while
preserving immediate DESTROY behavior for mutable referents.

Track runtime regex interpolation explicitly so compile-time transforms such as
\Q...\E keep eager qr validation. Preserve a lone interpolated value's runtime
type for qr overloading and already-compiled callback regexes.

Keep Perl source policy and Java-only rewrites in PerlOnJava rather than moving
the whole RegexPreprocessor into Joni. Move only matcher semantics incrementally
and use the missing-regex feature matrix as the Joni routing roadmap. Original
Joni copyright, authorship, license, and modification notices remain intact.

Verification:
- full make passes, including Joni tests, five unit shards, packaging, notices,
  relocation, and SBOM checks
- executable_callbacks.t passes 18/18 under system Perl, the JVM backend, and
  the interpreter backend
- perl5_t/t/re completes 80 files with zero timeouts and 50458/94827 passing
- versus test_20260815_080000_958.log: 17 files improve, 63 are unchanged,
  none regress, and the net gain is 185 passing assertions

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
@fglock
fglock merged commit 23507ac into master Aug 16, 2026
2 checks passed
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