1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 14:10:45 +00:00
serenity/Base
Tim Ledbetter 8892c25520 Base: Return the correct value for fib(0) in Wasm example
Previously, using `wasm-decompile` to decompile the Wasm bytecode on
the `wasm.html` example page gave this output:

```
export function fib(a:int):int {
  if (a < 2) { return 1 }
  return fib(a - 2) + fib(a - 1);
}
```

With this change the bytecode now decompiles to:

```
export function fib(a:int):int {
  if (a <= 0) { return 0 }
  if (a == 1) { return 1 }
  return fib(a - 2) + fib(a - 1);
}
```

This means that the example page now prints the correct answer of 55 to
the console for `fib(10)`. Previously, `fib(10)` returned 89.

I also used `wasm-opt -Oz`, which removed an unnecessary `return`
instruction, saving 1 byte!
2024-04-11 01:17:20 +02:00
..
etc Everywhere: Remove references to UserspaceEmulator 2024-01-29 20:20:55 +00:00
home/anon Base: Add more emoji 2024-03-19 06:51:04 -04:00
res Base: Return the correct value for fib(0) in Wasm example 2024-04-11 01:17:20 +02:00
root Everywhere: Remove references to UserspaceEmulator 2024-01-29 20:20:55 +00:00
usr/share man+tail: Bring the manpage of tail up to date 2024-04-05 15:30:41 -06:00
www Base: Improve default WebServer pages 2022-02-23 21:28:17 +00:00