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
..
2022-06-18 21:58:43 +04:30
2022-06-18 21:58:43 +04:30
2023-01-15 12:43:03 +01:00
2023-03-26 15:09:57 +02:00
2022-10-07 13:08:24 +01:00
2023-07-17 14:53:52 +01:00
2023-07-26 08:38:54 +02:00
2022-06-23 19:13:24 +01:00
2022-11-03 19:15:43 +00:00
2023-04-13 09:53:47 +02:00
2023-04-09 18:42:45 +02:00
2023-06-18 20:31:11 +02:00
2023-06-08 07:17:43 +02:00
2022-08-14 11:30:40 +02:00
2023-10-20 07:20:29 +02:00
2023-02-03 20:36:21 +01:00
2023-08-09 05:48:32 +02:00
2022-06-23 19:13:24 +01:00
2022-08-14 11:22:52 +02:00
2022-06-15 19:10:43 +01:00
2023-07-13 05:10:41 +02:00
2023-04-14 09:57:49 +02:00
2022-07-04 23:09:06 +02:00
2023-03-10 18:20:27 +01:00
2023-01-03 20:02:47 +01:00
2022-09-25 18:37:31 +02:00
2022-06-05 22:31:06 +01:00
2022-10-15 01:25:12 +02:00
2022-11-05 11:42:19 +01:00
2022-09-07 17:47:33 +02:00
2022-09-16 15:15:50 +02:00
2022-09-22 16:54:12 +02:00
2022-09-22 16:54:12 +02:00
2023-04-05 09:43:52 +01:00
2022-07-04 23:09:06 +02:00
2022-12-03 09:06:51 -05:00
2023-08-03 05:25:48 +02:00
2023-12-21 13:17:51 +01:00
2023-12-21 13:17:51 +01:00
2023-07-09 06:32:20 +02:00
2023-11-09 16:10:54 +01:00
2022-12-30 14:21:19 +01:00
2022-12-30 14:21:19 +01:00
2023-12-04 19:54:43 +00:00
2023-09-15 22:12:56 +02:00
2022-06-16 10:28:07 +01:00
2022-09-21 10:47:41 +01:00
2023-08-03 05:25:48 +02:00
2022-08-27 20:33:27 +01:00
2022-08-12 12:24:15 +02:00
2022-11-16 17:23:56 +00:00
2024-04-08 17:24:48 -04:00
2022-06-18 21:58:43 +04:30
2023-06-11 19:34:24 +02:00
2023-08-20 20:04:10 +02:00
2023-04-17 07:32:31 +02:00
2023-04-12 07:40:22 +02:00
2023-05-20 08:52:19 +02:00
2024-01-07 10:22:32 +01:00
2022-10-01 14:07:47 +02:00
2022-09-14 04:46:49 +00:00
2023-05-13 15:51:44 +02:00
2023-04-21 07:54:36 +02:00
2024-04-11 01:17:20 +02:00
2024-03-02 12:25:53 +01:00
2022-06-13 21:45:27 +01:00
2024-02-23 20:52:37 +01:00
2022-09-21 17:34:32 +01:00
2023-11-24 08:41:38 +01:00
2023-12-25 12:09:11 +01:00