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,...@@ -4997,7 +4997,7 @@ static IrInstSrc *ir_build_wasm_memory_size_src(IrBuilderSrc *irb, Scope *scope,
4997static IrInstGen *ir_build_wasm_memory_size_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *index) {4997static IrInstGen *ir_build_wasm_memory_size_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *index) {
4998 IrInstGenWasmMemorySize *instruction = ir_build_inst_gen<IrInstGenWasmMemorySize>(&ira->new_irb,4998 IrInstGenWasmMemorySize *instruction = ir_build_inst_gen<IrInstGenWasmMemorySize>(&ira->new_irb,
4999 source_instr->scope, source_instr->source_node);4999 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;
5001 instruction->index = index;5001 instruction->index = index;
50025002
5003 ir_ref_inst_gen(index);5003 ir_ref_inst_gen(index);
...@@ -5019,7 +5019,7 @@ static IrInstSrc *ir_build_wasm_memory_grow_src(IrBuilderSrc *irb, Scope *scope,...@@ -5019,7 +5019,7 @@ static IrInstSrc *ir_build_wasm_memory_grow_src(IrBuilderSrc *irb, Scope *scope,
5019static IrInstGen *ir_build_wasm_memory_grow_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *index, IrInstGen *delta) {5019static IrInstGen *ir_build_wasm_memory_grow_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *index, IrInstGen *delta) {
5020 IrInstGenWasmMemoryGrow *instruction = ir_build_inst_gen<IrInstGenWasmMemoryGrow>(&ira->new_irb,5020 IrInstGenWasmMemoryGrow *instruction = ir_build_inst_gen<IrInstGenWasmMemoryGrow>(&ira->new_irb,
5021 source_instr->scope, source_instr->source_node);5021 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;
5023 instruction->index = index;5023 instruction->index = index;
5024 instruction->delta = delta;5024 instruction->delta = delta;
50255025
test/stage1/behavior/wasm.zig+3-3
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const expect = std.testing.expect;2const expect = std.testing.expect;
33
4test "memory size and grow" {4test "memory size and grow" {
5 var prev = @wasmMemorySize();5 var prev = @wasmMemorySize(0);
6 expect(prev == @wasmMemoryGrow(1));6 expect(prev == @wasmMemoryGrow(0, 1));
7 expect(prev + 1 == @wasmMemorySize());7 expect(prev + 1 == @wasmMemorySize(0));
8}8}