From 057d97c093c81150a3761b50a1f646703b6cfd1b Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 2 Jun 2020 19:05:21 +0200 Subject: [PATCH] Return should be i32 due to error signaling in memory.grow Also, fix tests. --- src/ir.cpp | 4 ++-- test/stage1/behavior/wasm.zig | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index 3cd861700b..86304ff448 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4997,7 +4997,7 @@ static IrInstSrc *ir_build_wasm_memory_size_src(IrBuilderSrc *irb, Scope *scope, static IrInstGen *ir_build_wasm_memory_size_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *index) { IrInstGenWasmMemorySize *instruction = ir_build_inst_gen(&ira->new_irb, source_instr->scope, source_instr->source_node); - instruction->base.value->type = ira->codegen->builtin_types.entry_u32; + instruction->base.value->type = ira->codegen->builtin_types.entry_i32; instruction->index = index; ir_ref_inst_gen(index); @@ -5019,7 +5019,7 @@ static IrInstSrc *ir_build_wasm_memory_grow_src(IrBuilderSrc *irb, Scope *scope, static IrInstGen *ir_build_wasm_memory_grow_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *index, IrInstGen *delta) { IrInstGenWasmMemoryGrow *instruction = ir_build_inst_gen(&ira->new_irb, source_instr->scope, source_instr->source_node); - instruction->base.value->type = ira->codegen->builtin_types.entry_u32; + instruction->base.value->type = ira->codegen->builtin_types.entry_i32; instruction->index = index; instruction->delta = delta; diff --git a/test/stage1/behavior/wasm.zig b/test/stage1/behavior/wasm.zig index c55700c7c0..24557ee19b 100644 --- a/test/stage1/behavior/wasm.zig +++ b/test/stage1/behavior/wasm.zig @@ -2,7 +2,7 @@ const std = @import("std"); const expect = std.testing.expect; test "memory size and grow" { - var prev = @wasmMemorySize(); - expect(prev == @wasmMemoryGrow(1)); - expect(prev + 1 == @wasmMemorySize()); + var prev = @wasmMemorySize(0); + expect(prev == @wasmMemoryGrow(0, 1)); + expect(prev + 1 == @wasmMemorySize(0)); }