Repository navigation
test: differential replacement/split parity suite; fix DFA_UNROLLED findBoundsFrom match truncation - #145
Conversation
…dsFrom
The skippable-accepting-state optimization was statically unsound: any
accepting state can be the greedy scan's terminal state, and a terminal
skippable state never recorded, truncating matches (b{0,2}b on "bb" gave
[0,1) instead of [0,2)), corrupting split/replaceAll. Also delegate
anchor-conditioned acceptance to findLongestMatchEnd and drop the dead
assertion path (unreachable since delegation covers all assertion-bearing
DFAs). JMH A/B: the fix is faster on affected patterns (16-35%).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #145 +/- ##
=========================================
+ Coverage 84.9% 85.1% +0.2%
Complexity 1 1
=========================================
Files 163 163
Lines 48981 48847 -134
Branches 7000 6970 -30
=========================================
- Hits 41594 41588 -6
+ Misses 5378 5258 -120
+ Partials 2009 2001 -8
... and 7 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
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. |
There was a problem hiding this comment.
What does this PR do?
Adds a differential parity suite pinning the replacement/collection ops of
ReggieMatcher—replaceAll(String,String),replaceFirst, functionalreplaceAll,split(String,int)— againstjava.util.regexas the oracle (curated + 400-case seeded randomized inputs), and fixes a real bug the suite caught: the DFA_UNROLLED generatedfindBoundsFromgreedy scan skipped itslastAcceptingPosrecord at "skippable" accepting states, which truncated matches and corruptedsplit/replaceAllresults (e.g.cbb|b{0,2}bon"bb"reported[0,1)instead of[0,2)).The optimization was statically unsound — any accepting state can be the scan's terminal state, and a terminal skippable state never records — so it is removed entirely: every accepting state records unconditionally. The scan now also delegates to the anchor-aware
findLongestMatchEndpath when any state carries acceptance anchor conditions, and the unreachable assertion-handling path (dead since delegation already covers all assertion-bearing DFAs) is deleted.Six intentional divergences from the JDK are documented in the suite and pinned on both engines (JDK drift fails the test too): no backslash-escape processing in replacement strings,
$$accepted as literal$, out-of-range/trailing$group references appended literally instead of throwing, and functionalreplaceAllusing the replacer result verbatim.Motivation
The profiling-backend wave-3 migration relies on these ops per operation; the engine-level semantic contract had no differential coverage (only backend per-site parity), which is why the
findBoundsFromtruncation survived.Related Issue(s)
Draft source:
.issue-drafts/2-replacement-ops-parity.md. Note the draft's premise that reggie treats$literally inreplaceAllwas wrong (verified empirically) — reggie expands$n; the real divergences are the ones documented in the suite.Change Type
Checklist
./gradlew build)Performance Impact
JMH A/B (pre 967e525 vs post, 3 interleaved runs, medians):
replaceAll(b{0,2}b)−31%,replaceAll(b{0,4}bc?)−16%,split(b{0,2}b)−35%; control pattern within noise. The pre-fix truncation caused more, shorter match scans; the unconditional 2-instruction record is free.Additional Notes
Full in-depth review already performed by independent fresh-context reviewers (bytecode-trace verified removal, no sibling generator carries the pattern, all 6 divergences confirmed against JDK 26). Reviewer-flagged follow-up: none open in this diff. Gate evidence:
:reggie-runtime:test+:reggie-integration-tests:test= 3281 tests, 0 failures;spotlessCheckgreen.