perf(core): typed calling convention for words with a known stack effect
Such a word now compiles to a fast entry (i32 x p) -> (i32 x q) carrying its stack items as WASM values, plus the usual ( -- ) wrapper that keeps the table slot, so EXECUTE / interpreter / host words / CATCH see the unchanged memory ABI. Fib(25) 1035 -> 366 us, 4.3x slower than sf64 -> 1.2x; the default guards-on config 1740 -> 361 us. WS-006.
This commit is contained in:
@@ -344,3 +344,32 @@ fn compliance_tools() {
|
||||
let errors = run_suite(&mut vm, "toolstest.fth");
|
||||
assert_eq!(errors, 0, "Programming-Tools: {errors} test failures");
|
||||
}
|
||||
|
||||
/// The Forth 2012 Core suite against consolidated code.
|
||||
///
|
||||
/// `CONSOLIDATE` recompiles the whole dictionary into one WASM module, which
|
||||
/// is where cross-word typed calls live: a word with a known stack effect
|
||||
/// gets a fast entry taking and returning its stack items as WASM values,
|
||||
/// and its `() -> ()` wrapper keeps the table slot. Nothing else covers that
|
||||
/// path for correctness, so run the suite on top of it.
|
||||
#[test]
|
||||
fn compliance_core_after_consolidate() {
|
||||
let mut vm = ForthVM::<NativeRuntime>::new().expect("Failed to create ForthVM");
|
||||
let tester_path = format!("{SUITE_DIR}/tester.fr");
|
||||
let f1 = load_file(&mut vm, &tester_path);
|
||||
assert_load_fails_within_baseline(&tester_path, f1);
|
||||
|
||||
vm.evaluate("CONSOLIDATE").expect("CONSOLIDATE failed");
|
||||
vm.take_output();
|
||||
|
||||
let core_path = format!("{SUITE_DIR}/core.fr");
|
||||
let f2 = load_file(&mut vm, &core_path);
|
||||
assert_load_fails_within_baseline(&core_path, f2);
|
||||
|
||||
let _ = vm.evaluate("DECIMAL #ERRORS @");
|
||||
let errors = vm.data_stack().first().copied().unwrap_or(-1);
|
||||
assert_eq!(
|
||||
errors, 0,
|
||||
"Core word set after CONSOLIDATE: {errors} failures"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user