Making a WebAssembly interpreter in Ruby, part 12: locals, loops, blocks and branches

Опубликовано: 19 Октябрь 2024
на канале: Tom Stuart
139
3

https://github.com/tomstuart/wasminna...

00:00:00 — Waiting to start
00:00:32 — Hello
00:01:30 — Retro
00:06:10 — Move `PAGE_SIZE` constant into Memory class
00:19:40 — Extract Memory#load and #store
00:25:01 — Extract Memory.for
00:30:54 — Extract Memory.size_of helper
00:35:46 — Reimplement Memory.size_of to be clearer
00:39:27 — Extract Memory.size_of into SizeOfHelper module
00:54:48 — Reimplement Memory#load with String#getbyte
00:59:15 — Reimplement Memory#store with String#setbyte
00:59:15 — Extract Interpreter#mask into MaskHelper module
01:08:51 — Rename Memory::PAGE_SIZE to BYTES_PER_PAGE
01:15:40 — Extract MaskHelper and SignHelper into helpers.rb
01:18:23 — Remove unused `require 'bigdecimal'`
01:20:28 — Restore original encoding in #parse_string instead of hardcoding Encoding::UTF_8
01:23:20 — Be explicit about Integer#chr encoding in #parse_string
01:24:35 — Rename Memory.for to Memory.from_string
01:47:29 — Implement `(memory 1 1)` and similar
01:48:35 — Add locals to function definitions
02:09:07 — Implement the `block` instruction
02:26:04 — Implement the `loop` instruction
02:26:40 — Extract #invoke_function helper
02:30:51 — Combine parameters and locals when invoking a function
02:35:16 — Implement the `local.set` instruction
02:42:06 — Implement the `br_if` instruction
03:18:11 — Implement the `select` instruction
03:36:11 — Implement the `if` instruction
03:36:31 — Store function body as a list of instructions, not just one
03:37:32 — Support multiple instructions in function bodies
03:53:19 — Support numeric branch label in `br_if` and `block`
03:54:05 — Support multiple strings in data segments
04:02:14 — Support missing expected value in `assert_return`
04:02:39 — Move `*.load` and `*.store` instructions out of block that automatically evaluates arguments
04:20:36 — Add support for static offsets in `*.load` and `*.store` instructions
04:52:54 — Implement the `local.tee` instruction
04:54:25 — Support unnamed function parameters
04:56:18 — Correctly preserve canonical NaN when promoting and demoting
05:08:20 — Support multiple anonymous locals in function definition
05:18:00 — Wrapping up
05:20:23 — Bye