Perf: Restore core optimizations and stabilize VM execution

This commit restores and enhances several high-performance features that
were
previously lost, while fixing critical bugs in scope management.

Performance Optimizations:
- Zero-Copy TCO: Refactored TailCallRequest to use (Rc, usize), moving
  arguments
  directly on the VM stack via drain/resize instead of heap-allocating
  Vecs.
- Slice-based Calls: Native functions and field accessors now operate
  directly
  on stack slices, significantly reducing memory churn.
- SoA Push Fast-Path: Restored specialized 'push' intrinsic for
  RecordSeries.
  Matches layouts via Arc::ptr_eq to distribute values directly into
  columns
  without keyword lookups.

Architectural Improvements:
- Static Stack Frames (max_slots): The Binder now calculates the maximum

  required slots per lambda. The VM pre-resizes the stack frame,
  preventing
  collisions between local variables and temporary call arguments.
- Macro Hygiene: Fixed a bug where macro-internal variables could
  overwrite
  outer call arguments due to stack overlap.
- Trait Refactoring: Unified series operations via a polymorphic
  'push_value'
  on the Series trait, with a generic implementation for
  ScalarSeries<T>.

Code Quality:
- Resolved all 'cargo clippy' warnings (collapsible ifs, redundant
  borrows, etc).
- Restored 100% test pass rate (64/64 tests).
- Verified stability of all examples and benchmarks.
This commit is contained in:
Michael Schimmel
2026-03-10 13:06:56 +01:00
parent beb693a068
commit 260669cba1
16 changed files with 237 additions and 260 deletions
+6 -6
View File
@@ -505,24 +505,23 @@ impl Optimizer {
block_changed = true;
}
if !block_changed {
if !block_changed && Rc::ptr_eq(&new_result, result) {
return node_rc;
}
if self.enabled {
if new_statements.is_empty() {
return new_result;
}
if self.enabled && new_statements.is_empty() {
return new_result;
}
(BoundKind::Block { statements: new_statements, result: new_result }, node.ty.clone())
}
}
BoundKind::Lambda {
params,
upvalues,
body,
positional_count,
max_slots,
} => {
let mut info = UsageInfo::default();
info.collect(node);
@@ -590,6 +589,7 @@ impl Optimizer {
upvalues: new_upvalues,
body: reindexed_body,
positional_count: *positional_count,
max_slots: *max_slots,
},
node.ty.clone(),
)