Skip to content

feat: Runtime and JVM compiler improvements for context and regex handling#208

Closed
fglock wants to merge 1 commit into
masterfrom
feature/runtime-jvm-compiler
Closed

feat: Runtime and JVM compiler improvements for context and regex handling#208
fglock wants to merge 1 commit into
masterfrom
feature/runtime-jvm-compiler

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Feb 18, 2026

Summary

This PR consolidates runtime and JVM compiler enhancements, providing net improvements across regex and other test suites with no new regressions.

Features Added

  • ✅ escapeInvalidQuantifierBraces function for Perl regex compatibility (disabled pending refinement)
  • ✅ DEBUG_REGEX environment variable support for regex debugging

Fixes

  • ✅ Preserve RUNTIME context for RHS of logical operators in JVM compiler
  • ✅ Evaluate LHS of logical operators in SCALAR context (for boolean test)
  • ✅ Add debug logging to RuntimeRegex.compile() and matchRegexDirect()

Implementation Details

EmitLogicalOperator: Changed context handling for logical operators

  • LHS evaluated in SCALAR context for boolean test
  • RHS preserves RUNTIME context when in RUNTIME mode
  • Prevents context loss at subroutine exits

RegexPreprocessor: Added escapeInvalidQuantifierBraces()

  • Handles Perl-style quantifier braces like {1}, {,3}, {2,5}
  • Escapes invalid braces that would cause Java Pattern.compile() errors
  • Currently disabled (line 82-84) due to edge case regressions
  • Function ready for future refinement and re-enabling

RuntimeRegex: Added DEBUG_REGEX support

  • Set DEBUG_REGEX=1 environment variable to enable regex debug output
  • Logs pattern compilation, cache hits/misses, and matching operations
  • Helps diagnose regex preprocessing and matching issues

Files Modified

  • EmitLogicalOperator.java: +17/-12 lines
  • RegexPreprocessor.java: +212/-0 lines
  • RegexPreprocessorHelper.java: +123/-71 lines (refactored)
  • RuntimeRegex.java: +41/-13 lines

Total: 4 files changed, 323 insertions(+), 70 deletions(-)

Test Results (vs master)

Regex Tests

  • re/regexp.t: 1788/2210 (+2)
  • re/pat.t: 896/1296 (+1)
  • re/pat_rt_report.t: 2384/2514 (+3)
  • re/reg_mesg.t: 1642/2479 (no change)

Other Tests

  • io/open.t: 181/216 (+2)
  • op/filetest.t: 227/436 (+1)
  • op/signatures.t: 594/908 (no change)
  • test_pl/examples.t: 7/17 (no change)

Net result: +9 improvements, 0 new regressions

Test Plan

  • Run make to verify build and unit tests
  • Run regex test suite
  • Verify no new regressions
  • Merge after approval and CI passes

🤖 Generated with Claude Code

…dling

This commit consolidates runtime and JVM compiler enhancements:

Features:
- Add escapeInvalidQuantifierBraces function for Perl regex compatibility
  (currently disabled due to test regressions - needs more work)
- Add DEBUG_REGEX environment variable support for regex debugging

Fixes:
- Preserve RUNTIME context for RHS of logical operators in JVM compiler
- Evaluate LHS of logical operators in SCALAR context (for boolean test)
- Add debug logging to RuntimeRegex.compile() and matchRegexDirect()

Implementation Details:
- EmitLogicalOperator: Changed context handling for logical operators
  - LHS evaluated in SCALAR context for boolean test
  - RHS preserves RUNTIME context when in RUNTIME mode
  - Prevents context loss at subroutine exits

- RegexPreprocessor: Added escapeInvalidQuantifierBraces()
  - Handles Perl-style quantifier braces like {1}, {,3}, {2,5}
  - Escapes invalid braces that would cause Java Pattern.compile() errors
  - Currently disabled (line 82-84) due to edge case regressions
  - Function ready for future refinement and re-enabling

- RuntimeRegex: Added DEBUG_REGEX support
  - Set DEBUG_REGEX=1 environment variable to enable regex debug output
  - Logs pattern compilation, cache hits/misses, and matching operations
  - Helps diagnose regex preprocessing and matching issues

Files Modified:
- EmitLogicalOperator.java: +17/-12 lines
- RegexPreprocessor.java: +212/-0 lines
- RegexPreprocessorHelper.java: +123/-71 lines (refactored)
- RuntimeRegex.java: +41/-13 lines

Test Results (vs master):
- re/regexp.t: 1788/2210 (+2)
- re/pat.t: 896/1296 (+1)
- re/pat_rt_report.t: 2384/2514 (+3)
- re/reg_mesg.t: 1642/2479 (no change)
- Net: +6 improvements, 0 regressions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fglock fglock closed this Feb 18, 2026
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