From b48e4de5ea13434ded315b2bc99a713db0361f63 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Mon, 7 Nov 2022 12:45:01 -0800 Subject: Implement `array.new_data` and `array.new_elem` (#5214) In order to test them, fix the binary and text parsers to accept passive data segments even if a module has no memory. In addition to parsing and emitting the new instructions, also implement their validation and interpretation. Test the interpretation directly with wasm-shell tests adapted from the upstream spec tests. Running the upstream spec tests directly would require fixing too many bugs in the legacy text parser, so it will have to wait for the new text parser to be ready. --- src/wasm-builder.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/wasm-builder.h') diff --git a/src/wasm-builder.h b/src/wasm-builder.h index df036b3b4..1eb31157d 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -935,6 +935,20 @@ public: ret->finalize(); return ret; } + ArrayNewSeg* makeArrayNewSeg(ArrayNewSegOp op, + HeapType type, + Index seg, + Expression* offset, + Expression* size) { + auto* ret = wasm.allocator.alloc(); + ret->op = op; + ret->segment = seg; + ret->offset = offset; + ret->size = size; + ret->type = Type(type, NonNullable); + ret->finalize(); + return ret; + } ArrayInit* makeArrayInit(HeapType type, const std::vector& values) { auto* ret = wasm.allocator.alloc(); -- cgit v1.2.3