diff options
59 files changed, 359 insertions, 55 deletions
diff --git a/src/sexpr-wasm.c b/src/sexpr-wasm.c index 5a76e46a..921e64a0 100644 --- a/src/sexpr-wasm.c +++ b/src/sexpr-wasm.c @@ -158,6 +158,9 @@ static void parse_options(int argc, char** argv) { } } + if (s_dump_module && s_spec) + FATAL("--dump-module flag incompatible with --spec flag\n"); + if (optind < argc) { s_infile = argv[optind]; } else { @@ -178,18 +181,25 @@ int main(int argc, char** argv) { result = result || parser.errors; wasm_free_scanner(scanner); + WasmScript* script = &parser.script; + if (result != WASM_OK) { - wasm_destroy_script(&parser.script); + wasm_destroy_script(script); return result; } - result = wasm_check_script(&parser.script); + result = wasm_check_script(script); if (result != WASM_OK) { - wasm_destroy_script(&parser.script); + wasm_destroy_script(script); return result; } - WasmFileWriter writer = {}; + WasmMemoryWriter writer = {}; + if (wasm_init_mem_writer(&writer) != WASM_OK) { + wasm_destroy_script(script); + FATAL("unable to open memory writer for writing\n"); + } + WasmWriteBinaryOptions options = {}; if (s_spec) options.spec = 1; @@ -198,19 +208,35 @@ int main(int argc, char** argv) { if (s_verbose) options.log_writes = 1; + result = wasm_write_binary(&writer.base, script, &options); + wasm_destroy_script(script); + + if (result != WASM_OK) { + wasm_close_mem_writer(&writer); + return result; + } + + if (s_dump_module) { + if (s_verbose) + printf(";; dump\n"); + wasm_print_memory(writer.buf.start, writer.buf.size, 0, 0, NULL); + } + if (s_outfile) { - if (wasm_init_file_writer(&writer, s_outfile) != WASM_OK) { - wasm_destroy_script(&parser.script); + FILE* f = fopen(s_outfile, "wb"); + if (!f) { + wasm_close_mem_writer(&writer); FATAL("unable to open %s for writing\n", s_outfile); } - result = wasm_write_binary(&writer.base, &parser.script, &options); - wasm_close_file_writer(&writer); - } else if (s_verbose) { - /* don't write file output, but we still write the verbose output */ - result = wasm_write_binary(&writer.base, &parser.script, &options); + ssize_t bytes = fwrite(writer.buf.start, 1, writer.buf.size, f); + if (bytes != writer.buf.size) { + wasm_close_mem_writer(&writer); + FATAL("failed to write %zd bytes to %s\n", writer.buf.size, s_outfile); + } + fclose(f); } - wasm_destroy_script(&parser.script); + wasm_close_mem_writer(&writer); return result; } diff --git a/src/wasm-binary-writer.c b/src/wasm-binary-writer.c index 168a1b41..80a254e6 100644 --- a/src/wasm-binary-writer.c +++ b/src/wasm-binary-writer.c @@ -1,6 +1,5 @@ #include <alloca.h> #include <assert.h> -#include <ctype.h> #include <math.h> #include <memory.h> #include <stdarg.h> @@ -12,7 +11,6 @@ #define DEFAULT_MEMORY_EXPORT 1 #define DUMP_OCTETS_PER_LINE 16 -#define DUMP_OCTETS_PER_GROUP 2 #define SEGMENT_SIZE 13 #define SEGMENT_OFFSET_OFFSET 4 @@ -390,44 +388,6 @@ static WasmTypeV8 wasm_type_to_v8_type(WasmType type) { } } -static void dump_memory(const void* start, - size_t size, - size_t offset, - int print_chars, - const char* desc) { - /* mimic xxd output */ - const uint8_t* p = start; - const uint8_t* end = p + size; - while (p < end) { - const uint8_t* line = p; - const uint8_t* line_end = p + DUMP_OCTETS_PER_LINE; - printf("%07x: ", (int)((void*)p - start + offset)); - while (p < line_end) { - int i; - for (i = 0; i < DUMP_OCTETS_PER_GROUP; ++i, ++p) { - if (p < end) { - printf("%02x", *p); - } else { - putchar(' '); - putchar(' '); - } - } - putchar(' '); - } - - putchar(' '); - p = line; - int i; - for (i = 0; i < DUMP_OCTETS_PER_LINE && p < end; ++i, ++p) - if (print_chars) - printf("%c", isprint(*p) ? *p : '.'); - /* if there are multiple lines, only print the desc on the last one */ - if (p >= end && desc) - printf(" ; %s", desc); - putchar('\n'); - } -} - static void print_header(WasmWriteContext* ctx, const char* name, int index) { if (ctx->options->log_writes) printf("; %s %d\n", name, index); @@ -441,7 +401,7 @@ static void out_data_at(WasmWriterState* writer_state, if (*writer_state->result != WASM_OK) return; if (writer_state->log_writes) - dump_memory(src, size, offset, 0, desc); + wasm_print_memory(src, size, offset, 0, desc); if (writer_state->writer->write_data) *writer_state->result = writer_state->writer->write_data( offset, src, size, writer_state->writer->user_data); diff --git a/src/wasm-internal.h b/src/wasm-internal.h index 97376685..285b22ca 100644 --- a/src/wasm-internal.h +++ b/src/wasm-internal.h @@ -56,5 +56,10 @@ typedef union WasmToken { #define YYLTYPE WASM_LTYPE int wasm_lex(WasmToken*, WasmLocation*, WasmScanner, WasmParser*); +void wasm_print_memory(const void* start, + size_t size, + size_t offset, + int print_chars, + const char* desc); #endif /* WASM_INTERNAL_H */ @@ -1,9 +1,13 @@ #include "wasm.h" #include <assert.h> +#include <ctype.h> #include <memory.h> #include <stdlib.h> +#define DUMP_OCTETS_PER_LINE 16 +#define DUMP_OCTETS_PER_GROUP 2 + DEFINE_VECTOR(type, WasmType) DEFINE_VECTOR(var, WasmVar); DEFINE_VECTOR(expr_ptr, WasmExprPtr); @@ -422,3 +426,41 @@ void wasm_destroy_command_vector_and_elements(WasmCommandVector* commands) { void wasm_destroy_script(WasmScript* script) { DESTROY_VECTOR_AND_ELEMENTS(script->commands, command); } + +void wasm_print_memory(const void* start, + size_t size, + size_t offset, + int print_chars, + const char* desc) { + /* mimic xxd output */ + const uint8_t* p = start; + const uint8_t* end = p + size; + while (p < end) { + const uint8_t* line = p; + const uint8_t* line_end = p + DUMP_OCTETS_PER_LINE; + printf("%07x: ", (int)((void*)p - start + offset)); + while (p < line_end) { + int i; + for (i = 0; i < DUMP_OCTETS_PER_GROUP; ++i, ++p) { + if (p < end) { + printf("%02x", *p); + } else { + putchar(' '); + putchar(' '); + } + } + putchar(' '); + } + + putchar(' '); + p = line; + int i; + for (i = 0; i < DUMP_OCTETS_PER_LINE && p < end; ++i, ++p) + if (print_chars) + printf("%c", isprint(*p) ? *p : '.'); + /* if there are multiple lines, only print the desc on the last one */ + if (p >= end && desc) + printf(" ; %s", desc); + putchar('\n'); + } +} @@ -545,7 +545,6 @@ typedef struct WasmScript { typedef void* WasmScanner; typedef struct WasmParser { - WasmScanner scanner; WasmScript script; int errors; } WasmParser; diff --git a/test/dump/basic.txt b/test/dump/basic.txt index 973407f0..78bb1a37 100644 --- a/test/dump/basic.txt +++ b/test/dump/basic.txt @@ -44,4 +44,8 @@ 0000013: 2600 0000 ; FIXUP func name offset 0000026: 66 ; export name 0000027: 00 ; \0 +;; dump +0000000: 0301 0000 0000 0400 0101 0201 0101 0201 +0000010: 0900 0026 0000 000c 0011 0040 1000 0901 +0000020: 400e 000e 0106 6600 ;;; STDOUT ;;) diff --git a/test/dump/binary.txt b/test/dump/binary.txt index e18c4994..fb2d6b57 100644 --- a/test/dump/binary.txt +++ b/test/dump/binary.txt @@ -233,4 +233,25 @@ 0000135: 0000 0000 0000 0000 ; f64 literal 0000009: 3201 ; FIXUP func body size 000013d: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0032 0140 4142 4344 +0000010: 4546 4748 494a 4b4c 0900 0900 0900 0900 +0000020: 0900 0900 0900 0900 0900 0900 0900 0900 +0000030: 0900 0900 5b5c 5d5e 5f60 6162 6364 6566 +0000040: 670b 0000 0000 0000 0000 0b00 0000 0000 +0000050: 0000 000b 0000 0000 0000 0000 0b00 0000 +0000060: 0000 0000 000b 0000 0000 0000 0000 0b00 +0000070: 0000 0000 0000 000b 0000 0000 0000 0000 +0000080: 0b00 0000 0000 0000 000b 0000 0000 0000 +0000090: 0000 0b00 0000 0000 0000 000b 0000 0000 +00000a0: 0000 0000 0b00 0000 0000 0000 000b 0000 +00000b0: 0000 0000 0000 0b00 0000 0000 0000 0075 +00000c0: 7677 7879 7a7d 0d00 0000 000d 0000 0000 +00000d0: 0d00 0000 000d 0000 0000 0d00 0000 000d +00000e0: 0000 0000 0d00 0000 000d 0000 0000 898a +00000f0: 8b8c 8d8e 910c 0000 0000 0000 0000 0c00 +0000100: 0000 0000 0000 000c 0000 0000 0000 0000 +0000110: 0c00 0000 0000 0000 000c 0000 0000 0000 +0000120: 0000 0c00 0000 0000 0000 000c 0000 0000 +0000130: 0000 0000 0c00 0000 0000 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/block.txt b/test/dump/block.txt index 475f069a..0f4cfeb0 100644 --- a/test/dump/block.txt +++ b/test/dump/block.txt @@ -40,4 +40,7 @@ 000001a: 01 ; u8 literal 0000015: 0400 ; FIXUP func body size 000001b: 06 ; WASM_SECTION_END +;; dump +0000000: 0102 0000 0001 0202 0000 0005 0001 0300 +0000010: 0000 0001 0004 0001 0109 0106 ;;; STDOUT ;;) diff --git a/test/dump/break-block-named.txt b/test/dump/break-block-named.txt index 1bbcc142..fc2016f9 100644 --- a/test/dump/break-block-named.txt +++ b/test/dump/break-block-named.txt @@ -38,4 +38,7 @@ 000001a: 00 ; OPCODE_NOP 0000009: 1000 ; FIXUP func body size 000001b: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0010 0001 0102 0101 +0000010: 0209 0001 0206 0000 0604 0006 ;;; STDOUT ;;) diff --git a/test/dump/break-block.txt b/test/dump/break-block.txt index 070eb81c..d38d004f 100644 --- a/test/dump/break-block.txt +++ b/test/dump/break-block.txt @@ -46,4 +46,8 @@ 0000020: 00 ; OPCODE_NOP 0000009: 1600 ; FIXUP func body size 0000021: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0016 0001 0102 0101 +0000010: 0209 0001 0406 0000 0600 0006 0200 0604 +0000020: 0006 ;;; STDOUT ;;) diff --git a/test/dump/break-label.txt b/test/dump/break-label.txt index d9ba0d57..e2ec939e 100644 --- a/test/dump/break-label.txt +++ b/test/dump/break-label.txt @@ -31,4 +31,7 @@ 0000015: 00 ; OPCODE_NOP 0000009: 0b00 ; FIXUP func body size 0000016: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 000b 0001 0101 0200 +0000010: 0309 0106 0100 06 ;;; STDOUT ;;) diff --git a/test/dump/break-loop-inner-expr.txt b/test/dump/break-loop-inner-expr.txt index 199cade4..5b964583 100644 --- a/test/dump/break-loop-inner-expr.txt +++ b/test/dump/break-loop-inner-expr.txt @@ -38,4 +38,7 @@ 000001b: 05 ; u8 literal 0000009: 1100 ; FIXUP func body size 000001c: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0001 0201 0000 0011 0002 0303 0901 +0000010: 0600 0003 0903 0601 0904 0905 06 ;;; STDOUT ;;) diff --git a/test/dump/break-loop-inner.txt b/test/dump/break-loop-inner.txt index a12fe21b..e5c0cd5b 100644 --- a/test/dump/break-loop-inner.txt +++ b/test/dump/break-loop-inner.txt @@ -34,4 +34,7 @@ 0000018: 00 ; OPCODE_NOP 0000009: 0e00 ; FIXUP func body size 0000019: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 000e 0002 0203 0901 +0000010: 0601 0003 0902 0600 0006 ;;; STDOUT ;;) diff --git a/test/dump/break-loop.txt b/test/dump/break-loop.txt index 7dd63b53..b8f40790 100644 --- a/test/dump/break-loop.txt +++ b/test/dump/break-loop.txt @@ -26,4 +26,7 @@ 0000012: 00 ; OPCODE_NOP 0000009: 0800 ; FIXUP func body size 0000013: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0008 0002 0103 0901 +0000010: 0600 0006 ;;; STDOUT ;;) diff --git a/test/dump/brif-loop.txt b/test/dump/brif-loop.txt index a4259a6b..2a8f0d85 100644 --- a/test/dump/brif-loop.txt +++ b/test/dump/brif-loop.txt @@ -24,4 +24,7 @@ 0000011: 00 ; OPCODE_NOP 0000009: 0700 ; FIXUP func body size 0000012: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0007 0002 0107 0009 +0000010: 0000 06 ;;; STDOUT ;;) diff --git a/test/dump/brif.txt b/test/dump/brif.txt index c96473ba..c390f614 100644 --- a/test/dump/brif.txt +++ b/test/dump/brif.txt @@ -24,4 +24,7 @@ 0000011: 00 ; OPCODE_NOP 0000009: 0700 ; FIXUP func body size 0000012: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0007 0001 0107 0009 +0000010: 0100 06 ;;; STDOUT ;;) diff --git a/test/dump/call.txt b/test/dump/call.txt index aead56fa..65497f63 100644 --- a/test/dump/call.txt +++ b/test/dump/call.txt @@ -21,4 +21,7 @@ 000000f: 01 ; u8 literal 000000a: 0400 ; FIXUP func body size 0000010: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0100 0102 0100 0000 0400 1200 0901 +0000010: 06 ;;; STDOUT ;;) diff --git a/test/dump/callimport.txt b/test/dump/callimport.txt index c67775e9..ca97527c 100644 --- a/test/dump/callimport.txt +++ b/test/dump/callimport.txt @@ -44,4 +44,8 @@ 000000d: 2200 0000 ; FIXUP import name offset 0000022: 6261 72 ; import name 0000025: 00 ; \0 +;; dump +0000000: 0102 0201 0103 0001 0202 0300 0022 0000 +0000010: 0000 0100 0b00 1200 0901 0d00 0000 4012 +0000020: 0106 6261 7200 ;;; STDOUT ;;) diff --git a/test/dump/callindirect.txt b/test/dump/callindirect.txt index 3f48ba0f..dd2085e9 100644 --- a/test/dump/callindirect.txt +++ b/test/dump/callindirect.txt @@ -28,4 +28,7 @@ 0000013: 01 ; num function table entries 0000014: 0000 ; function table entry 0000016: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0100 0102 0100 0000 0600 1300 0900 +0000010: 0900 0501 0000 06 ;;; STDOUT ;;) diff --git a/test/dump/cast.txt b/test/dump/cast.txt index 2bfd7899..b691c61d 100644 --- a/test/dump/cast.txt +++ b/test/dump/cast.txt @@ -32,4 +32,8 @@ 0000020: 0000 0000 0000 0000 ; f64 literal 0000009: 1d00 ; FIXUP func body size 0000028: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 001d 00ad 0900 b40d +0000010: 0000 0000 b30b 0000 0000 0000 0000 b50c +0000020: 0000 0000 0000 0000 06 ;;; STDOUT ;;) diff --git a/test/dump/compare.txt b/test/dump/compare.txt index 1aac5f32..eecf110f 100644 --- a/test/dump/compare.txt +++ b/test/dump/compare.txt @@ -205,4 +205,31 @@ 0000195: 0000 0000 0000 0000 ; f64 literal 0000009: 9201 ; FIXUP func body size 000019d: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0092 014d 4e4f 5150 +0000010: 5253 5554 5609 0009 0009 0009 0009 0009 +0000020: 0009 0009 0009 0009 0009 0068 0b00 0000 +0000030: 0000 0000 000b 0000 0000 0000 0000 690b +0000040: 0000 0000 0000 0000 0b00 0000 0000 0000 +0000050: 006a 0b00 0000 0000 0000 000b 0000 0000 +0000060: 0000 0000 6c0b 0000 0000 0000 0000 0b00 +0000070: 0000 0000 0000 006b 0b00 0000 0000 0000 +0000080: 000b 0000 0000 0000 0000 6d0b 0000 0000 +0000090: 0000 0000 0b00 0000 0000 0000 006e 0b00 +00000a0: 0000 0000 0000 000b 0000 0000 0000 0000 +00000b0: 700b 0000 0000 0000 0000 0b00 0000 0000 +00000c0: 0000 006f 0b00 0000 0000 0000 000b 0000 +00000d0: 0000 0000 0000 710b 0000 0000 0000 0000 +00000e0: 0b00 0000 0000 0000 0083 0d00 0000 000d +00000f0: 0000 0000 840d 0000 0000 0d00 0000 0085 +0000100: 0d00 0000 000d 0000 0000 860d 0000 0000 +0000110: 0d00 0000 0087 0d00 0000 000d 0000 0000 +0000120: 880d 0000 0000 0d00 0000 0097 0c00 0000 +0000130: 0000 0000 000c 0000 0000 0000 0000 980c +0000140: 0000 0000 0000 0000 0c00 0000 0000 0000 +0000150: 0099 0c00 0000 0000 0000 000c 0000 0000 +0000160: 0000 0000 9a0c 0000 0000 0000 0000 0c00 +0000170: 0000 0000 0000 009b 0c00 0000 0000 0000 +0000180: 000c 0000 0000 0000 0000 9c0c 0000 0000 +0000190: 0000 0000 0c00 0000 0000 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/const.txt b/test/dump/const.txt index a2d26319..177c2140 100644 --- a/test/dump/const.txt +++ b/test/dump/const.txt @@ -132,4 +132,22 @@ 0000104: 182d 4454 fb21 1940 ; f64 literal 0000009: 0101 ; FIXUP func body size 000010c: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0001 0109 000a 0000 +0000010: 0080 09ff 0a00 0000 8009 ff0b 0000 0000 +0000020: 0000 0000 0b00 0000 0000 0000 800b ffff +0000030: ffff ffff ffff 0b00 0000 0000 0000 800b +0000040: ffff ffff ffff ffff 0d00 0000 000d 1668 +0000050: a965 0d40 204f 370d 0000 c07f 0d00 00c0 +0000060: ff0d 0000 c07f 0dbc 0a80 7f0d bc0a 80ff +0000070: 0dbc 0a80 7f0d 0000 807f 0d00 0080 ff0d +0000080: 0000 807f 0d00 0000 bf0d db0f c940 0c00 +0000090: 0000 0000 0000 000c b856 0e3c dd9a efbf +00000a0: 0c18 2d44 54fb 2119 400c 0000 0000 0000 +00000b0: f87f 0c00 0000 0000 00f8 ff0c 0000 0000 +00000c0: 0000 f87f 0cbc 0a00 0000 00f0 7f0c bc0a +00000d0: 0000 0000 f0ff 0cbc 0a00 0000 00f0 7f0c +00000e0: 0000 0000 0000 f07f 0c00 0000 0000 00f0 +00000f0: ff0c 0000 0000 0000 f07f 0c00 0000 0000 +0000100: 00e0 bf0c 182d 4454 fb21 1940 06 ;;; STDOUT ;;) diff --git a/test/dump/convert.txt b/test/dump/convert.txt index 07d9cbd9..7a9575bc 100644 --- a/test/dump/convert.txt +++ b/test/dump/convert.txt @@ -65,4 +65,8 @@ 0000025: 0000 0000 ; f32 literal 0000009: 1e00 ; FIXUP func body size 0000029: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 001e 00a1 a79d a89f +0000010: a99e aea0 af09 00a2 aaa4 aba3 b0a5 b1a6 +0000020: 0900 acb2 0d00 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/dedupe-sig.txt b/test/dump/dedupe-sig.txt index 9f0eeb47..38c5b532 100644 --- a/test/dump/dedupe-sig.txt +++ b/test/dump/dedupe-sig.txt @@ -28,4 +28,8 @@ 000000a: 1d00 0000 ; FIXUP import name offset 000001d: 6261 72 ; import name 0000020: 00 ; \0 +;; dump +0000000: 0101 0102 0102 0203 0000 1d00 0000 0000 +0000010: 0009 000b 0000 0000 0000 0000 0662 6172 +0000020: 00 ;;; STDOUT ;;) diff --git a/test/dump/expr-break.txt b/test/dump/expr-break.txt index dd67440e..a11b7b51 100644 --- a/test/dump/expr-break.txt +++ b/test/dump/expr-break.txt @@ -23,4 +23,7 @@ 0000010: 01 ; u8 literal 0000009: 0600 ; FIXUP func body size 0000011: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0001 0201 0000 0006 0001 0106 0009 +0000010: 0106 ;;; STDOUT ;;) diff --git a/test/dump/expr-brif.txt b/test/dump/expr-brif.txt index 8d2bf804..4fa49945 100644 --- a/test/dump/expr-brif.txt +++ b/test/dump/expr-brif.txt @@ -28,4 +28,7 @@ 0000014: 1d ; u8 literal 0000009: 0a00 ; FIXUP func body size 0000015: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0001 0201 0000 000a 0001 0207 0009 +0000010: 0009 2a09 1d06 ;;; STDOUT ;;) diff --git a/test/dump/func-exported.txt b/test/dump/func-exported.txt index b094646d..81babf0e 100644 --- a/test/dump/func-exported.txt +++ b/test/dump/func-exported.txt @@ -21,4 +21,7 @@ 0000009: 1000 0000 ; FIXUP func name offset 0000010: 666f 6f ; export name 0000013: 00 ; \0 +;; dump +0000000: 0101 0000 0201 0900 0010 0000 0000 0006 +0000010: 666f 6f00 ;;; STDOUT ;;) diff --git a/test/dump/func-multi.txt b/test/dump/func-multi.txt index 374f7d16..f3a61ae2 100644 --- a/test/dump/func-multi.txt +++ b/test/dump/func-multi.txt @@ -27,4 +27,7 @@ 0000013: 0000 ; func body size 0000013: 0000 ; FIXUP func body size 0000015: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0203 0000 0000 0000 0000 0000 +0000010: 0000 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/func-named.txt b/test/dump/func-named.txt index d3079af3..cb9e2151 100644 --- a/test/dump/func-named.txt +++ b/test/dump/func-named.txt @@ -15,4 +15,6 @@ 0000009: 0000 ; func body size 0000009: 0000 ; FIXUP func body size 000000b: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/getlocal-param.txt b/test/dump/getlocal-param.txt index d3ec6238..e9c2cf65 100644 --- a/test/dump/getlocal-param.txt +++ b/test/dump/getlocal-param.txt @@ -44,4 +44,8 @@ 0000020: 05 ; remapped local index 0000013: 0c00 ; FIXUP func body size 0000021: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0200 0103 0201 0400 0001 0001 0002 +0000010: 0000 000c 000e 000e 010e 030e 040e 020e +0000020: 0506 ;;; STDOUT ;;) diff --git a/test/dump/getlocal.txt b/test/dump/getlocal.txt index d55b79f3..8c71b8ac 100644 --- a/test/dump/getlocal.txt +++ b/test/dump/getlocal.txt @@ -48,4 +48,8 @@ 0000022: 03 ; remapped local index 0000011: 1000 ; FIXUP func body size 0000023: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0400 0002 0002 0002 0002 +0000010: 0010 000e 060e 040e 020e 000e 010e 050e +0000020: 070e 0306 ;;; STDOUT ;;) diff --git a/test/dump/global-multi.txt b/test/dump/global-multi.txt index 3e652a44..6004ce4e 100644 --- a/test/dump/global-multi.txt +++ b/test/dump/global-multi.txt @@ -21,4 +21,7 @@ 0000018: 09 ; global mem type 0000019: 00 ; export global 000001a: 06 ; WASM_SECTION_END +;; dump +0000000: 0304 0000 0000 0400 0000 0000 0600 0000 +0000010: 0000 0800 0000 0000 0900 06 ;;; STDOUT ;;) diff --git a/test/dump/if.txt b/test/dump/if.txt index 4831a0c7..a5351628 100644 --- a/test/dump/if.txt +++ b/test/dump/if.txt @@ -40,4 +40,8 @@ 0000025: 14 ; OPCODE_RETURN 000001f: 0500 ; FIXUP func body size 0000026: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0202 0000 0011 0003 0901 0004 +0000010: 0900 0d00 0080 3f0d 0000 0040 0000 0005 +0000020: 0004 0901 1414 06 ;;; STDOUT ;;) diff --git a/test/dump/import.txt b/test/dump/import.txt index 0e40c2e9..a9783538 100644 --- a/test/dump/import.txt +++ b/test/dump/import.txt @@ -36,4 +36,8 @@ 0000017: 2100 0000 ; FIXUP import name offset 0000021: 7465 7374 32 ; import name 0000026: 00 ; \0 +;; dump +0000000: 0102 0400 0102 0304 0101 0102 0203 0000 +0000010: 1c00 0000 0301 0021 0000 0006 7465 7374 +0000020: 0074 6573 7432 00 ;;; STDOUT ;;) diff --git a/test/dump/load-aligned.txt b/test/dump/load-aligned.txt index 6d5b003a..e672a05a 100644 --- a/test/dump/load-aligned.txt +++ b/test/dump/load-aligned.txt @@ -161,4 +161,13 @@ 000007a: 00 ; u8 literal 0000009: 7000 ; FIXUP func body size 000007b: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0070 0020 0009 0020 +0000010: 0009 0020 0009 0020 0009 0022 0009 0022 +0000020: 0009 0022 0009 0022 0009 002a 0009 002a +0000030: 0009 002a 0009 002a 0009 002b 0009 002b +0000040: 0009 002b 0009 002b 0009 0024 0009 0024 +0000050: 0009 0024 0009 0024 0009 0026 0009 0026 +0000060: 0009 0026 0009 0026 0009 0028 0009 0028 +0000070: 0009 0028 0009 0028 0009 0006 ;;; STDOUT ;;) diff --git a/test/dump/load.txt b/test/dump/load.txt index 617ad804..8be7060c 100644 --- a/test/dump/load.txt +++ b/test/dump/load.txt @@ -85,4 +85,10 @@ 0000042: 00 ; u8 literal 0000009: 3800 ; FIXUP func body size 0000043: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0038 002a 0009 0020 +0000010: 0009 0022 0009 0021 0009 0023 0009 002b +0000020: 0009 0024 0009 0026 0009 0028 0009 0025 +0000030: 0009 0027 0009 0029 0009 002c 0009 002d +0000040: 0009 0006 ;;; STDOUT ;;) diff --git a/test/dump/loadglobal.txt b/test/dump/loadglobal.txt index 87615528..8cc6f454 100644 --- a/test/dump/loadglobal.txt +++ b/test/dump/loadglobal.txt @@ -46,4 +46,8 @@ 000002c: 03 ; global index 0000023: 0800 ; FIXUP func body size 000002d: 06 ; WASM_SECTION_END +;; dump +0000000: 0304 0000 0000 0400 0000 0000 0600 0000 +0000010: 0000 0800 0000 0000 0900 0101 0000 0201 +0000020: 0000 0008 0010 0010 0110 0210 0306 ;;; STDOUT ;;) diff --git a/test/dump/locals.txt b/test/dump/locals.txt index 27de417d..b2e5c965 100644 --- a/test/dump/locals.txt +++ b/test/dump/locals.txt @@ -19,4 +19,7 @@ 0000011: 0000 ; func body size 0000011: 0000 ; FIXUP func body size 0000013: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0400 0001 0002 0003 0004 +0000010: 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/loop.txt b/test/dump/loop.txt index e6c87138..8ccf5982 100644 --- a/test/dump/loop.txt +++ b/test/dump/loop.txt @@ -22,4 +22,6 @@ 000000e: 00 ; OPCODE_NOP 0000009: 0400 ; FIXUP func body size 000000f: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0004 0002 0200 0006 ;;; STDOUT ;;) diff --git a/test/dump/memory-data-size.txt b/test/dump/memory-data-size.txt index 7c61bb47..d39c0494 100644 --- a/test/dump/memory-data-size.txt +++ b/test/dump/memory-data-size.txt @@ -1,4 +1,4 @@ -;;; FLAGS: -dv --spec +;;; FLAGS: -v --spec (module (memory 128)) (module (memory 256)) (module (memory 512)) diff --git a/test/dump/memory-hex.txt b/test/dump/memory-hex.txt index 47305a88..e5bd39ac 100644 --- a/test/dump/memory-hex.txt +++ b/test/dump/memory-hex.txt @@ -18,4 +18,7 @@ ; segment data 0 000000a: 1400 0000 ; FIXUP segment data offset 0000014: 0001 0203 0405 0607 0809 0a ; segment data +;; dump +0000000: 0007 0701 0401 0000 0000 1400 0000 0b00 +0000010: 0000 0106 0001 0203 0405 0607 0809 0a ;;; STDOUT ;;) diff --git a/test/dump/memory-size.txt b/test/dump/memory-size.txt index 5108201f..74ce0301 100644 --- a/test/dump/memory-size.txt +++ b/test/dump/memory-size.txt @@ -22,4 +22,7 @@ 000000f: 3b ; OPCODE_MEMORY_SIZE 000000d: 0100 ; FIXUP func body size 0000010: 06 ; WASM_SECTION_END +;; dump +0000000: 000a 0a01 0101 0001 0201 0000 0001 003b +0000010: 06 ;;; STDOUT ;;) diff --git a/test/dump/memory.txt b/test/dump/memory.txt index 81112147..2b80eb3a 100644 --- a/test/dump/memory.txt +++ b/test/dump/memory.txt @@ -25,4 +25,8 @@ ; segment data 1 0000017: 2600 0000 ; FIXUP segment data offset 0000026: 676f 6f64 6279 65 ; segment data +;; dump +0000000: 0007 0701 0402 0a00 0000 2100 0000 0500 +0000010: 0000 0114 0000 0026 0000 0007 0000 0001 +0000020: 0668 656c 6c6f 676f 6f64 6279 65 ;;; STDOUT ;;) diff --git a/test/dump/nop.txt b/test/dump/nop.txt index 2f67dfae..50e94b6a 100644 --- a/test/dump/nop.txt +++ b/test/dump/nop.txt @@ -16,4 +16,6 @@ 000000b: 00 ; OPCODE_NOP 0000009: 0100 ; FIXUP func body size 000000c: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0001 0000 06 ;;; STDOUT ;;) diff --git a/test/dump/param-multi.txt b/test/dump/param-multi.txt index 0bd6975c..9afe0c7f 100644 --- a/test/dump/param-multi.txt +++ b/test/dump/param-multi.txt @@ -19,4 +19,6 @@ 000000d: 0000 ; func body size 000000d: 0000 ; FIXUP func body size 000000f: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0400 0102 0304 0201 0000 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/resize-memory.txt b/test/dump/resize-memory.txt index eeb528f1..d3858b08 100644 --- a/test/dump/resize-memory.txt +++ b/test/dump/resize-memory.txt @@ -25,4 +25,7 @@ 0000012: 00 ; remapped local index 000000e: 0300 ; FIXUP func body size 0000013: 06 ; WASM_SECTION_END +;; dump +0000000: 0008 0a01 0101 0100 0102 0100 0000 0300 +0000010: 390e 0006 ;;; STDOUT ;;) diff --git a/test/dump/result.txt b/test/dump/result.txt index 896bf287..9afa68e8 100644 --- a/test/dump/result.txt +++ b/test/dump/result.txt @@ -50,4 +50,9 @@ 0000031: 0000 0000 0000 0000 ; f64 literal 000002e: 0900 ; FIXUP func body size 0000039: 06 ; WASM_SECTION_END +;; dump +0000000: 0104 0001 0002 0003 0004 0204 0000 0002 +0000010: 0009 0000 0100 0900 0b00 0000 0000 0000 +0000020: 0000 0200 0500 0d00 0000 0000 0300 0900 +0000030: 0c00 0000 0000 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/return.txt b/test/dump/return.txt index 88721172..bfa39ee6 100644 --- a/test/dump/return.txt +++ b/test/dump/return.txt @@ -29,4 +29,7 @@ 0000015: 14 ; OPCODE_RETURN 0000013: 0100 ; FIXUP func body size 0000016: 06 ; WASM_SECTION_END +;; dump +0000000: 0102 0001 0000 0202 0000 0003 0014 092a +0000010: 0001 0001 0014 06 ;;; STDOUT ;;) diff --git a/test/dump/select.txt b/test/dump/select.txt index c6d172c2..8d13ec84 100644 --- a/test/dump/select.txt +++ b/test/dump/select.txt @@ -47,4 +47,10 @@ 0000041: 0000 0000 0000 0840 ; f64 literal 0000009: 3e00 ; FIXUP func body size 0000049: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 003e 0005 0901 0902 +0000010: 0903 0509 010b 0200 0000 0000 0000 0b03 +0000020: 0000 0000 0000 0005 0901 0d00 0000 400d +0000030: 0000 4040 0509 010c 0000 0000 0000 0040 +0000040: 0c00 0000 0000 0008 4006 ;;; STDOUT ;;) diff --git a/test/dump/setlocal-param.txt b/test/dump/setlocal-param.txt index 090194fb..bdc19109 100644 --- a/test/dump/setlocal-param.txt +++ b/test/dump/setlocal-param.txt @@ -56,4 +56,9 @@ 0000039: 0000 0000 ; f32 literal 0000013: 2800 ; FIXUP func body size 000003d: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0200 0103 0201 0400 0001 0001 0002 +0000010: 0000 0028 000f 0009 000f 010d 0000 0000 +0000020: 0f03 0b00 0000 0000 0000 000f 040d 0000 +0000030: 0000 0f02 0900 0f05 0d00 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/setlocal.txt b/test/dump/setlocal.txt index 1a88a5d0..80c68b6b 100644 --- a/test/dump/setlocal.txt +++ b/test/dump/setlocal.txt @@ -64,4 +64,11 @@ 000004d: 0000 0000 0000 0000 ; u64 literal 0000011: 4200 ; FIXUP func body size 0000055: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0400 0002 0002 0002 0002 +0000010: 0042 000f 060c 0000 0000 0000 0000 0f04 +0000020: 0d00 0000 000f 020b 0000 0000 0000 0000 +0000030: 0f00 0900 0f01 0900 0f05 0d00 0000 000f +0000040: 070c 0000 0000 0000 0000 0f03 0b00 0000 +0000050: 0000 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/signatures.txt b/test/dump/signatures.txt index 387428a8..5d7b7cf5 100644 --- a/test/dump/signatures.txt +++ b/test/dump/signatures.txt @@ -47,4 +47,7 @@ 0000017: 04 ; result_type 0000018: 01 ; param type 0000019: 06 ; WASM_SECTION_END +;; dump +0000000: 0109 0100 0101 0002 0100 0301 0004 0001 +0000010: 0002 0003 0004 0104 0106 ;;; STDOUT ;;) diff --git a/test/dump/store-aligned.txt b/test/dump/store-aligned.txt index 8dd5ab5c..4c0f0400 100644 --- a/test/dump/store-aligned.txt +++ b/test/dump/store-aligned.txt @@ -217,4 +217,24 @@ 000011b: 0000 0000 0000 0000 ; u64 literal 0000009: 1801 ; FIXUP func body size 0000123: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0018 012e 0009 0009 +0000010: 002e 0009 0009 002e 0009 0009 002e 0009 +0000020: 0009 002f 0009 0009 002f 0009 0009 002f +0000030: 0009 0009 002f 0009 0009 0033 0009 0009 +0000040: 0033 0009 0009 0033 0009 0009 0033 0009 +0000050: 0009 0034 0009 000b 0000 0000 0000 0000 +0000060: 3400 0900 0b00 0000 0000 0000 0034 0009 +0000070: 000b 0000 0000 0000 0000 3400 0900 0b00 +0000080: 0000 0000 0000 0030 0009 000b 0000 0000 +0000090: 0000 0000 3000 0900 0b00 0000 0000 0000 +00000a0: 0030 0009 000b 0000 0000 0000 0000 3000 +00000b0: 0900 0b00 0000 0000 0000 0031 0009 000b +00000c0: 0000 0000 0000 0000 3100 0900 0b00 0000 +00000d0: 0000 0000 0031 0009 000b 0000 0000 0000 +00000e0: 0000 3100 0900 0b00 0000 0000 0000 0034 +00000f0: 0009 000b 0000 0000 0000 0000 3400 0900 +0000100: 0b00 0000 0000 0000 0034 0009 000b 0000 +0000110: 0000 0000 0000 3400 0900 0b00 0000 0000 +0000120: 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/store.txt b/test/dump/store.txt index 367ac486..71f8a3fb 100644 --- a/test/dump/store.txt +++ b/test/dump/store.txt @@ -78,4 +78,12 @@ 000005f: 0000 0000 0000 0000 ; f64 literal 0000009: 5c00 ; FIXUP func body size 0000067: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 005c 002e 0009 0009 +0000010: 002f 0009 0009 0033 0009 0009 0034 0009 +0000020: 000b 0000 0000 0000 0000 3000 0900 0b00 +0000030: 0000 0000 0000 0031 0009 000b 0000 0000 +0000040: 0000 0000 3200 0900 0b00 0000 0000 0000 +0000050: 0035 0009 000d 0000 0000 3600 0900 0c00 +0000060: 0000 0000 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/storeglobal.txt b/test/dump/storeglobal.txt index 8917eeea..9c814622 100644 --- a/test/dump/storeglobal.txt +++ b/test/dump/storeglobal.txt @@ -54,4 +54,10 @@ 000003e: 0000 0000 0000 0840 ; f64 literal 0000023: 2100 ; FIXUP func body size 0000046: 06 ; WASM_SECTION_END +;; dump +0000000: 0304 0000 0000 0400 0000 0000 0600 0000 +0000010: 0000 0800 0000 0000 0900 0101 0000 0201 +0000020: 0000 0021 0011 0009 0011 010b 0100 0000 +0000030: 0000 0000 1102 0d00 0000 4011 030c 0000 +0000040: 0000 0000 0840 06 ;;; STDOUT ;;) diff --git a/test/dump/table.txt b/test/dump/table.txt index f0b9968e..8858ede4 100644 --- a/test/dump/table.txt +++ b/test/dump/table.txt @@ -46,4 +46,8 @@ 000002b: 0100 ; function table entry 000002d: 0200 ; function table entry 000002f: 06 ; WASM_SECTION_END +;; dump +0000000: 0103 0100 0102 0001 0200 0402 0300 0000 +0000010: 0000 0001 0000 0000 0200 0900 0c00 0000 +0000020: 0000 0000 0005 0400 0000 0001 0002 0006 ;;; STDOUT ;;) diff --git a/test/dump/tableswitch.txt b/test/dump/tableswitch.txt index 3bcf894c..3d621eab 100644 --- a/test/dump/tableswitch.txt +++ b/test/dump/tableswitch.txt @@ -40,4 +40,8 @@ 0000022: 03 ; u8 literal 0000009: 1800 ; FIXUP func body size 0000023: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0018 0001 0108 0300 +0000010: 0300 0000 0100 0180 0900 0102 0901 0902 +0000020: 0009 0306 ;;; STDOUT ;;) diff --git a/test/dump/unary.txt b/test/dump/unary.txt index bf6a9208..271e242c 100644 --- a/test/dump/unary.txt +++ b/test/dump/unary.txt @@ -68,4 +68,9 @@ 0000031: 0000 0000 0000 0000 ; f64 literal 0000009: 2e00 ; FIXUP func body size 0000039: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 002e 005a 5758 5909 +0000010: 0072 7374 0b00 0000 0000 0000 007c 7b82 +0000020: 7e7f 8081 0d00 0000 0090 8f96 9293 9495 +0000030: 0c00 0000 0000 0000 0006 ;;; STDOUT ;;) diff --git a/test/dump/unreachable.txt b/test/dump/unreachable.txt index e34fd5a1..5c549e49 100644 --- a/test/dump/unreachable.txt +++ b/test/dump/unreachable.txt @@ -17,4 +17,6 @@ 000000b: 15 ; OPCODE_UNREACHABLE 0000009: 0100 ; FIXUP func body size 000000c: 06 ; WASM_SECTION_END +;; dump +0000000: 0101 0000 0201 0000 0001 0015 06 ;;; STDOUT ;;) |