Skip to content

Commit

Permalink
Fix local/global set/get wat instruction encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Nov 5, 2024
1 parent 3158bcb commit 3d11288
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions crates/benches/wasm_opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,26 @@ fn bench_functions() -> Vec<WatBuilder> {
),
instruction,
},
GetLocal(_) | GetGlobal(_) | CurrentMemory(_) | I32Const(_)
| I64Const(_) | F32Const(_) | F64Const(_) => WatBuilder {
GetLocal(var) => WatBuilder {
wat: format!(
r#"
local.get {var}
drop
"#
),
instruction,
},
GetGlobal(var) => WatBuilder {
wat: format!(
r#"
global.get {var}
drop
"#
),
instruction,
},
CurrentMemory(_) | I32Const(_) | I64Const(_) | F32Const(_)
| F64Const(_) => WatBuilder {
wat: format!(
r#"
{instruction}
Expand All @@ -563,11 +581,20 @@ fn bench_functions() -> Vec<WatBuilder> {
),
instruction,
},
SetLocal(_) | SetGlobal(_) => WatBuilder {
SetLocal(var) => WatBuilder {
wat: format!(
r#"
i32.const 10
{instruction}
local.set {var}
"#
),
instruction,
},
SetGlobal(var) => WatBuilder {
wat: format!(
r#"
i32.const 10
global.set {var}
"#
),
instruction,
Expand Down

0 comments on commit 3d11288

Please sign in to comment.