https://github.com/santhsecurity/dfajit
JIT compilation of DFA transition tables to native x86_64 jump tables
https://github.com/santhsecurity/dfajit
Last synced: 2 months ago
JSON representation
JIT compilation of DFA transition tables to native x86_64 jump tables
- Host: GitHub
- URL: https://github.com/santhsecurity/dfajit
- Owner: santhsecurity
- License: mit
- Created: 2026-04-08T23:51:59.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-04-25T23:04:29.000Z (3 months ago)
- Last Synced: 2026-04-26T01:12:13.614Z (3 months ago)
- Language: Rust
- Homepage: https://santh.dev
- Size: 84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Audit: AUDIT_REPORT.md
Awesome Lists containing this project
README
# dfajit
JIT compilation of DFA transition tables to native x86_64 machine code.
## Quick Start
```rust
use dfajit::{JitDfa, TransitionTable};
let mut table = TransitionTable::new(3, 256);
table.set_transition(0, b'a', 1);
table.set_transition(1, b'b', 2);
table.add_accept(2, 0);
table.set_pattern_length(0, 2);
let jit = JitDfa::compile(&table).unwrap();
let mut matches = Vec::new();
assert_eq!(jit.scan(b"xabxab", &mut matches), 2);
```
## Features
- Real x86_64 machine code emission (not interpreted)
- W^X memory safety (RW → RX via mprotect)
- Hopcroft DFA minimization
- Range analysis for multi-byte stride optimization
- Serialization (to_bytes / from_bytes)
- Convenience builders: `from_patterns`, `from_regex_patterns`
- scan_count, scan_first, has_match fast paths
- Interpreted fallback for large DFAs (>4096 states)
## License
MIT