Define some additional memory codewords

This commit is contained in:
2026-02-28 13:10:45 +00:00
parent 95d82a91c2
commit b06f32bbe3

View File

@@ -518,6 +518,49 @@
call $push call $push
call $next) call $next)
(func $atomic-store
call $pop
call $pop
i32.atomic.store
call $next)
(func $atomic-fetch
call $pop
i32.atomic.load
call $push
call $next)
(func $atomic-storebyte
call $pop
call $pop
i32.atomic.store8
call $next)
(func $atomic-fetchbyte
call $pop
i32.atomic.load8_u
call $push
call $next)
(func $copy (local $src i32) (local $dst i32) (local $n i32)
call $pop local.tee $dst
call $pop local.tee $src
call $pop local.tee $n
block $done (param i32 i32 i32)
loop $loop (param i32 i32 i32) (result i32 i32 i32)
i32.eqz br_if $done
i32.load8_u i32.store8
local.get $dst i32.const 1 i32.add local.tee $dst
local.get $src i32.const 1 i32.add local.tee $src
local.get $n i32.const 1 i32.sub local.tee $n
br $loop
end
drop drop drop
end
call $next)
;; Core utility words ;; Core utility words
(func $exit (func $exit
@@ -1674,6 +1717,38 @@
"\07EXECUTE" "\07EXECUTE"
"\38\00\00\00") "\38\00\00\00")
;; Some extra codewords I forgot to define earlier
(elem (i32.const 0x39) $atomic-store)
(data (i32.const 0x0bc0)
"\b0\0b\00\00"
"\02A!\00"
"\39\00\00\00")
(elem (i32.const 0x3a) $atomic-fetch)
(data (i32.const 0x0bcc)
"\c0\0b\00\00"
"\02A@\00"
"\3a\00\00\00")
(elem (i32.const 0x3b) $atomic-storebyte)
(data (i32.const 0x0bd8)
"\c0\0b\00\00"
"\03AC!"
"\3b\00\00\00")
(elem (i32.const 0x3c) $atomic-fetchbyte)
(data (i32.const 0x0be4)
"\d8\0b\00\00"
"\03AC@"
"\3c\00\00\00")
(elem (i32.const 0x3d) $copy)
(data (i32.const 0x0bf0)
"\e4\0b\00\00"
"\04COPY\00\00\00"
"\3d\00\00\00")
;; The trampoline is a workaround for WebAssembly's lack of indirect ;; The trampoline is a workaround for WebAssembly's lack of indirect
;; jumps and code addresses. Instead of jumping into the next ;; jumps and code addresses. Instead of jumping into the next
;; codeword, NEXT sets the $fn global to the function index of the ;; codeword, NEXT sets the $fn global to the function index of the