mirror of
https://github.com/gorules/zen.git
synced 2026-11-28 08:06:20 +00:00
* feat(expression): lane VM and typed-mask engine for batch and columnar evaluation Adds a register-based lane VM (core/expression/src/lane) and a typed-mask engine (core/expression/src/typed) that evaluate ZEN expressions over batches and columns, matching the stack VM's results. zen-types gains shape-backed objects and dot-path helpers; existing public APIs only grow. The lane VM has no expression size limit: deep and wide expressions are compiled and run with the same stack growth the parser uses. ZEN_EXPRESSION_CONFIG.lane (off by default) switches Isolate::run_standard and run_unary to the lane VM at runtime. Lane internals and the typed module are doc(hidden); the documented entry points are LaneProgram, LaneRunner, Session, Columns and Output. Includes an executable specification of the expression language (core/expression/tests/spec, 28,852 cases) with differential tests that run every lane path against the stack VM. zen-expression and zen-types now declare rust-version 1.88. * refactor(types): remove the shape transition cap Shapes are freed when nothing uses them, so the 4,096-children cap per shape no longer bounds memory. Shape::with, Shape::of and Shape::without now always return a shape; objects only switch to a hash map past SPILL_AT keys, as on master. * fix(expression): debug-profile stack safety and Windows test build CI runs tests in the debug profile, where frames are larger and tail recursion is not optimised. Recursive lane, typed and parser helpers now grow the stack like the rest (Const::number, the kernel builder, typed lowering and lookup, lane compile helpers, Node::member_key). The parser's closure depth counter is u32 instead of u8, so 256 nested closures no longer wrap. median([]) and empty templates no longer overflow in debug builds; release results are unchanged. The deep/wide test runs on a 256 KiB stack so unprotected recursion fails quickly in any profile. The conformance helper compares with as_str(), which is unambiguous on Windows. * fix(expression): stack checks in the lane executor, LF test data on Windows In x86-64 debug builds Executor::cold has a ~93 KB frame, so nested closures (execute -> cold -> body) could use more stack between two checks than the stack-growth margin and overflow. execute and cold now check the stack themselves; both run per instruction batch, not per row. The expression test data is checked out with LF on every platform. Windows runners converted it to CRLF, which broke multi-line spec cases.
82 lines
2.4 KiB
Rust
82 lines
2.4 KiB
Rust
mod conformance;
|
|
|
|
use conformance::{Note, Spec};
|
|
use std::collections::BTreeMap;
|
|
|
|
#[derive(Default)]
|
|
struct Tally {
|
|
total: usize,
|
|
failed: usize,
|
|
bugs: usize,
|
|
questions: usize,
|
|
}
|
|
|
|
#[test]
|
|
#[cfg_attr(
|
|
feature = "regex-lite",
|
|
ignore = "the spec assumes the full regex engine (Unicode classes and case folding)"
|
|
)]
|
|
fn spec_matches_stack_vm() {
|
|
Spec::prepare();
|
|
let (cases, problems) = Spec::cases();
|
|
let mut failures = Vec::new();
|
|
let mut bugs = Vec::new();
|
|
let mut files: BTreeMap<String, Tally> = BTreeMap::new();
|
|
for case in &cases {
|
|
let tally = files.entry(case.file.clone()).or_default();
|
|
tally.total += 1;
|
|
let verdict = case.verdict(&case.stack());
|
|
match (&case.note, verdict) {
|
|
(Note::Bug(note), Some(failure)) => {
|
|
tally.bugs += 1;
|
|
bugs.push(format!("{failure} | bug: {note}"));
|
|
}
|
|
(Note::Bug(note), None) => {
|
|
tally.failed += 1;
|
|
failures.push(format!(
|
|
"{} | {} | passes now, drop the bug note ({note})",
|
|
case.location(),
|
|
case.expression
|
|
));
|
|
}
|
|
(note, Some(failure)) => {
|
|
tally.failed += 1;
|
|
tally.questions += matches!(note, Note::Question(_)) as usize;
|
|
failures.push(failure);
|
|
}
|
|
(note, None) => tally.questions += matches!(note, Note::Question(_)) as usize,
|
|
}
|
|
}
|
|
for (file, t) in &files {
|
|
eprintln!(
|
|
"{file}: {} cases, {} failed, {} known bugs, {} questions",
|
|
t.total, t.failed, t.bugs, t.questions
|
|
);
|
|
}
|
|
eprintln!(
|
|
"spec: {} cases, {} failed, {} known bugs, {} malformed",
|
|
cases.len(),
|
|
failures.len(),
|
|
bugs.len(),
|
|
problems.len()
|
|
);
|
|
if std::env::var("SPEC_BUGS").is_ok() {
|
|
eprintln!("known bugs:\n{}", bugs.join("\n"));
|
|
}
|
|
let limit: usize = std::env::var("SPEC_SHOW")
|
|
.ok()
|
|
.and_then(|v| v.parse().ok())
|
|
.unwrap_or(60);
|
|
assert!(
|
|
problems.is_empty() && failures.is_empty(),
|
|
"malformed:\n{}\nfailures:\n{}",
|
|
problems.join("\n"),
|
|
failures
|
|
.iter()
|
|
.take(limit)
|
|
.cloned()
|
|
.collect::<Vec<_>>()
|
|
.join("\n")
|
|
);
|
|
}
|