authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-06-02 19:05:21+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-06-09 00:22:34-04:00
log057d97c093c81150a3761b50a1f646703b6cfd1b
tree572444c8f22e18e24375a8599aabcc0d8d337a27
parent3f0a3cea6e0369c24ba0303b58da5d7154ad7ace

Return should be i32 due to error signaling in memory.grow

Also, fix tests.

2 files changed, 5 insertions(+), 5 deletions(-)

src/ir.cpp+2-2
......@@ -4997,7 +4997,7 @@ static IrInstSrc *ir_build_wasm_memory_size_src(IrBuilderSrc *irb, Scope *scope,
49974997static IrInstGen *ir_build_wasm_memory_size_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *index) {
49984998 IrInstGenWasmMemorySize *instruction = ir_build_inst_gen<IrInstGenWasmMemorySize>(&ira->new_irb,
49994999 source_instr->scope, source_instr->source_node);
5000 instruction->base.value->type = ira->codegen->builtin_types.entry_u32;
5000 instruction->base.value->type = ira->codegen->builtin_types.entry_i32;
50015001 instruction->index = index;
50025002
50035003 ir_ref_inst_gen(index);
......@@ -5019,7 +5019,7 @@ static IrInstSrc *ir_build_wasm_memory_grow_src(IrBuilderSrc *irb, Scope *scope,
50195019static IrInstGen *ir_build_wasm_memory_grow_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *index, IrInstGen *delta) {
50205020 IrInstGenWasmMemoryGrow *instruction = ir_build_inst_gen<IrInstGenWasmMemoryGrow>(&ira->new_irb,
50215021 source_instr->scope, source_instr->source_node);
5022 instruction->base.value->type = ira->codegen->builtin_types.entry_u32;
5022 instruction->base.value->type = ira->codegen->builtin_types.entry_i32;
50235023 instruction->index = index;
50245024 instruction->delta = delta;
50255025
test/stage1/behavior/wasm.zig+3-3
......@@ -2,7 +2,7 @@ const std = @import("std");
22const expect = std.testing.expect;
33
44test "memory size and grow" {
5 var prev = @wasmMemorySize();
6 expect(prev == @wasmMemoryGrow(1));
7 expect(prev + 1 == @wasmMemorySize());
5 var prev = @wasmMemorySize(0);
6 expect(prev == @wasmMemoryGrow(0, 1));
7 expect(prev + 1 == @wasmMemorySize(0));
88}