The stage 2 compiler fixes some bugs that prevent using .always_tail with a return value. As a workaround I had been doing the error returns by passing a pointer to an error as an argument to the recursive functions.
This PR moves the WasmError into its rightly place: the function return value. The added benefit is we get to use try again!
But there's more! This change also gives us a 9% speed increase!
hyperfine ./fib ./fib-try
Benchmark 1: ./fib
Time (mean ± σ): 11.271 s ± 0.100 s [User: 11.212 s, System: 0.005 s]
Range (min … max): 11.146 s … 11.416 s 10 runs
Benchmark 2: ./fib-try
Time (mean ± σ): 10.374 s ± 0.097 s [User: 10.317 s, System: 0.005 s]
Range (min … max): 10.217 s … 10.554 s 10 runs
Summary
'./fib-try' ran
1.09 ± 0.01 times faster than './fib'
Description
This is the one I've been looking forward to!
The stage 2 compiler fixes some bugs that prevent using
.always_tail
with a return value. As a workaround I had been doing the error returns by passing a pointer to an error as an argument to the recursive functions.This PR moves the
WasmError
into its rightly place: the function return value. The added benefit is we get to usetry
again!E.g.
Becomes:
Beautiful!
But there's more! This change also gives us a 9% speed increase!
fib
ismaster
,fib-try
is this PR.