diff options
-rw-r--r-- | src/binary-reader-objdump.c | 80 | ||||
-rw-r--r-- | src/binary-reader.c | 4 | ||||
-rw-r--r-- | src/binary-reader.h | 2 | ||||
-rw-r--r-- | src/literal.c | 4 | ||||
-rw-r--r-- | src/literal.h | 4 | ||||
-rw-r--r-- | test/dump/binary.txt | 32 | ||||
-rw-r--r-- | test/dump/callimport.txt | 2 | ||||
-rw-r--r-- | test/dump/cast.txt | 4 | ||||
-rw-r--r-- | test/dump/compare.txt | 48 | ||||
-rw-r--r-- | test/dump/const.txt | 56 | ||||
-rw-r--r-- | test/dump/convert.txt | 2 | ||||
-rw-r--r-- | test/dump/debug-names.txt | 22 | ||||
-rw-r--r-- | test/dump/hexfloat_f32.txt | 34 | ||||
-rw-r--r-- | test/dump/hexfloat_f64.txt | 34 | ||||
-rw-r--r-- | test/dump/if.txt | 4 | ||||
-rw-r--r-- | test/dump/import.txt | 10 | ||||
-rw-r--r-- | test/dump/nocheck.txt | 4 | ||||
-rw-r--r-- | test/dump/result.txt | 4 | ||||
-rw-r--r-- | test/dump/select.txt | 8 | ||||
-rw-r--r-- | test/dump/setglobal.txt | 2 | ||||
-rw-r--r-- | test/dump/setlocal-param.txt | 6 | ||||
-rw-r--r-- | test/dump/setlocal.txt | 8 | ||||
-rw-r--r-- | test/dump/store.txt | 4 | ||||
-rw-r--r-- | test/dump/table.txt | 2 | ||||
-rw-r--r-- | test/dump/unary.txt | 4 |
25 files changed, 223 insertions, 161 deletions
diff --git a/src/binary-reader-objdump.c b/src/binary-reader-objdump.c index 3a3825ba..084e4e2c 100644 --- a/src/binary-reader-objdump.c +++ b/src/binary-reader-objdump.c @@ -22,6 +22,7 @@ #include <stdio.h> #include "binary-reader.h" +#include "literal.h" typedef struct Context { const WasmObjdumpOptions* options; @@ -35,6 +36,11 @@ typedef struct Context { WasmBool print_details; WasmBool header_printed; int section_found; + + WasmStringSlice import_module_name; + WasmStringSlice import_field_name; + + int function_index; } Context; @@ -265,6 +271,26 @@ static WasmResult on_opcode_uint64(WasmBinaryReaderContext* ctx, return WASM_OK; } +static WasmResult on_opcode_f32(WasmBinaryReaderContext* ctx, + uint32_t value) { + Context* context = ctx->user_data; + size_t immediate_len = ctx->offset - context->current_opcode_offset; + char buffer[WASM_MAX_FLOAT_HEX]; + wasm_write_float_hex(buffer, sizeof(buffer), value); + log_opcode(context, ctx->data, immediate_len, buffer); + return WASM_OK; +} + +static WasmResult on_opcode_f64(WasmBinaryReaderContext* ctx, + uint64_t value) { + Context* context = ctx->user_data; + size_t immediate_len = ctx->offset - context->current_opcode_offset; + char buffer[WASM_MAX_DOUBLE_HEX]; + wasm_write_double_hex(buffer, sizeof(buffer), value); + log_opcode(context, ctx->data, immediate_len, buffer); + return WASM_OK; +} + WasmResult on_br_table_expr(WasmBinaryReaderContext* ctx, uint32_t num_targets, uint32_t* target_depths, @@ -346,7 +372,10 @@ static WasmResult on_signature(uint32_t index, static WasmResult on_function_signature(uint32_t index, uint32_t sig_index, void* user_data) { - print_details(user_data, " - [%d] sig=%d\n", index, sig_index); + Context* ctx = user_data; + + print_details(user_data, " - func[%d] sig=%d\n", ctx->function_index, sig_index); + ctx->function_index++; return WASM_OK; } @@ -366,16 +395,22 @@ static WasmResult on_import(uint32_t index, WasmStringSlice module_name, WasmStringSlice field_name, void* user_data) { - print_details(user_data, " - " PRIstringslice " " PRIstringslice "\n", - WASM_PRINTF_STRING_SLICE_ARG(module_name), - WASM_PRINTF_STRING_SLICE_ARG(field_name)); + Context* ctx = user_data; + ctx->import_module_name = module_name; + ctx->import_field_name = field_name; return WASM_OK; } static WasmResult on_import_func(uint32_t index, uint32_t sig_index, void* user_data) { - print_details(user_data, " - func sig=%d\n", sig_index); + Context* ctx = user_data; + print_details(user_data, + " - " PRIstringslice "." PRIstringslice " -> func[%d] sig=%d\n", + WASM_PRINTF_STRING_SLICE_ARG(ctx->import_module_name), + WASM_PRINTF_STRING_SLICE_ARG(ctx->import_field_name), + ctx->function_index, sig_index); + ctx->function_index++; return WASM_OK; } @@ -383,18 +418,24 @@ static WasmResult on_import_table(uint32_t index, WasmType elem_type, const WasmLimits* elem_limits, void* user_data) { - print_details(user_data, - " - table elem_type=%s init=%" PRId64 " max=%" PRId64 "\n", - wasm_get_type_name(elem_type), - elem_limits->initial, - elem_limits->max); + Context* ctx = user_data; + print_details( + user_data, " - " PRIstringslice "." PRIstringslice + " -> table elem_type=%s init=%" PRId64 " max=%" PRId64 "\n", + WASM_PRINTF_STRING_SLICE_ARG(ctx->import_module_name), + WASM_PRINTF_STRING_SLICE_ARG(ctx->import_field_name), + wasm_get_type_name(elem_type), elem_limits->initial, elem_limits->max); return WASM_OK; } static WasmResult on_import_memory(uint32_t index, const WasmLimits* page_limits, void* user_data) { - print_details(user_data, " - memory\n"); + Context* ctx = user_data; + print_details(user_data, + " - " PRIstringslice "." PRIstringslice " -> memory\n", + WASM_PRINTF_STRING_SLICE_ARG(ctx->import_module_name), + WASM_PRINTF_STRING_SLICE_ARG(ctx->import_field_name)); return WASM_OK; } @@ -402,7 +443,12 @@ static WasmResult on_import_global(uint32_t index, WasmType type, WasmBool mutable_, void* user_data) { - print_details(user_data, " - global\n"); + Context* ctx = user_data; + print_details(user_data, " - " PRIstringslice "." PRIstringslice + " -> global %s mutable=%d\n", + WASM_PRINTF_STRING_SLICE_ARG(ctx->import_module_name), + WASM_PRINTF_STRING_SLICE_ARG(ctx->import_field_name), + wasm_get_type_name(type), mutable_); return WASM_OK; } @@ -489,7 +535,7 @@ static WasmResult on_init_expr_i64_const_expr(uint32_t index, static WasmResult on_function_name(uint32_t index, WasmStringSlice name, void* user_data) { - print_details(user_data, " - func:%d " PRIstringslice "\n", index, + print_details(user_data, " - func[%d] " PRIstringslice "\n", index, WASM_PRINTF_STRING_SLICE_ARG(name)); return WASM_OK; } @@ -498,8 +544,10 @@ static WasmResult on_local_name(uint32_t func_index, uint32_t local_index, WasmStringSlice name, void* user_data) { - print_details(user_data, " - local:%d " PRIstringslice "\n", local_index, - WASM_PRINTF_STRING_SLICE_ARG(name)); + if (name.length) { + print_details(user_data, " - local[%d] " PRIstringslice "\n", local_index, + WASM_PRINTF_STRING_SLICE_ARG(name)); + } return WASM_OK; } @@ -609,6 +657,8 @@ WasmResult wasm_read_binary_objdump(struct WasmAllocator* allocator, reader.on_opcode_uint32 = on_opcode_uint32; reader.on_opcode_uint32_uint32 = on_opcode_uint32_uint32; reader.on_opcode_uint64 = on_opcode_uint64; + reader.on_opcode_f32 = on_opcode_f32; + reader.on_opcode_f64 = on_opcode_f64; reader.on_opcode_block_sig = on_opcode_block_sig; reader.on_end_expr = on_end_expr; reader.on_br_table_expr = on_br_table_expr; diff --git a/src/binary-reader.c b/src/binary-reader.c index 8edec68e..d102ec08 100644 --- a/src/binary-reader.c +++ b/src/binary-reader.c @@ -1403,7 +1403,7 @@ static void read_function_body(Context* ctx, uint32_t value_bits = 0; in_f32(ctx, &value_bits, "f32.const value"); CALLBACK(on_f32_const_expr, value_bits); - CALLBACK_CTX(on_opcode_uint32, value_bits); + CALLBACK_CTX(on_opcode_f32, value_bits); break; } @@ -1411,7 +1411,7 @@ static void read_function_body(Context* ctx, uint64_t value_bits = 0; in_f64(ctx, &value_bits, "f64.const value"); CALLBACK(on_f64_const_expr, value_bits); - CALLBACK_CTX(on_opcode_uint64, value_bits); + CALLBACK_CTX(on_opcode_f64, value_bits); break; } diff --git a/src/binary-reader.h b/src/binary-reader.h index 617dec4c..bf928d61 100644 --- a/src/binary-reader.h +++ b/src/binary-reader.h @@ -175,6 +175,8 @@ typedef struct WasmBinaryReader { uint32_t value, uint32_t value2); WasmResult (*on_opcode_uint64)(WasmBinaryReaderContext* ctx, uint64_t value); + WasmResult (*on_opcode_f32)(WasmBinaryReaderContext* ctx, uint32_t value); + WasmResult (*on_opcode_f64)(WasmBinaryReaderContext* ctx, uint64_t value); WasmResult (*on_opcode_block_sig)(WasmBinaryReaderContext* ctx, uint32_t num_types, WasmType* sig_types); diff --git a/src/literal.c b/src/literal.c index 7a15aa32..04ae6ac3 100644 --- a/src/literal.c +++ b/src/literal.c @@ -418,7 +418,7 @@ void wasm_write_float_hex(char* out, size_t size, uint32_t bits) { /* -0x#.######p-### */ /* -nan:0x###### */ /* -infinity */ - char buffer[20]; + char buffer[WASM_MAX_FLOAT_HEX]; char* p = buffer; WasmBool is_neg = (bits >> F32_SIGN_SHIFT); int exp = ((bits >> F32_SIG_BITS) & F32_EXP_MASK) - F32_EXP_BIAS; @@ -748,7 +748,7 @@ void wasm_write_double_hex(char* out, size_t size, uint64_t bits) { /* -0x#.#############p-#### */ /* -nan:0x############# */ /* -infinity */ - char buffer[40]; + char buffer[WASM_MAX_DOUBLE_HEX]; char* p = buffer; WasmBool is_neg = (bits >> F64_SIGN_SHIFT); int exp = ((bits >> F64_SIG_BITS) & F64_EXP_MASK) - F64_EXP_BIAS; diff --git a/src/literal.h b/src/literal.h index 696eca24..e8b71d9c 100644 --- a/src/literal.h +++ b/src/literal.h @@ -33,6 +33,10 @@ typedef enum WasmParseIntType { WASM_PARSE_SIGNED_AND_UNSIGNED = 1, } WasmParseIntType; +/* Size of char buffer required to hold hex representation of a float/double */ +#define WASM_MAX_FLOAT_HEX 20 +#define WASM_MAX_DOUBLE_HEX 40 + WASM_EXTERN_C_BEGIN WasmResult wasm_parse_hexdigit(char c, uint32_t* out); WasmResult wasm_parse_int32(const char* s, diff --git a/test/dump/binary.txt b/test/dump/binary.txt index e043a17f..df2aa918 100644 --- a/test/dump/binary.txt +++ b/test/dump/binary.txt @@ -343,36 +343,36 @@ func 0 000075: 42 00 | i64.const 0 000077: 7c | i64.add 000078: 1a | drop - 000079: 43 00 00 00 00 | f32.const 0 - 00007e: 43 00 00 00 00 | f32.const 0 + 000079: 43 00 00 00 00 | f32.const 0x0p+0 + 00007e: 43 00 00 00 00 | f32.const 0x0p+0 000083: 98 | f32.copysign - 000084: 43 00 00 00 00 | f32.const 0 + 000084: 43 00 00 00 00 | f32.const 0x0p+0 000089: 97 | f32.max - 00008a: 43 00 00 00 00 | f32.const 0 + 00008a: 43 00 00 00 00 | f32.const 0x0p+0 00008f: 96 | f32.min - 000090: 43 00 00 00 00 | f32.const 0 + 000090: 43 00 00 00 00 | f32.const 0x0p+0 000095: 95 | f32.div - 000096: 43 00 00 00 00 | f32.const 0 + 000096: 43 00 00 00 00 | f32.const 0x0p+0 00009b: 94 | f32.mul - 00009c: 43 00 00 00 00 | f32.const 0 + 00009c: 43 00 00 00 00 | f32.const 0x0p+0 0000a1: 93 | f32.sub - 0000a2: 43 00 00 00 00 | f32.const 0 + 0000a2: 43 00 00 00 00 | f32.const 0x0p+0 0000a7: 92 | f32.add 0000a8: 1a | drop - 0000a9: 44 00 00 00 00 00 00 00 00 | f64.const 0 - 0000b2: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000a9: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 + 0000b2: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 0000bb: a6 | f64.copysign - 0000bc: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000bc: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 0000c5: a5 | f64.max - 0000c6: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000c6: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 0000cf: a4 | f64.min - 0000d0: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000d0: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 0000d9: a3 | f64.div - 0000da: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000da: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 0000e3: a2 | f64.mul - 0000e4: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000e4: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 0000ed: a1 | f64.sub - 0000ee: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000ee: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 0000f7: a0 | f64.add 0000f8: 1a | drop ;;; STDOUT ;;) diff --git a/test/dump/callimport.txt b/test/dump/callimport.txt index de8b7290..e1a7a102 100644 --- a/test/dump/callimport.txt +++ b/test/dump/callimport.txt @@ -72,7 +72,7 @@ callimport.wasm: file format wasm 0x00000d Code Disassembly: func 0 00002b: 41 01 | i32.const 0x1 - 00002d: 43 00 00 00 40 | f32.const 0x40000000 + 00002d: 43 00 00 00 40 | f32.const 0x1p+1 000032: 10 00 | call 0 000034: 1a | drop 000035: 10 01 | call 0x1 diff --git a/test/dump/cast.txt b/test/dump/cast.txt index 32af2226..3fc6dc0c 100644 --- a/test/dump/cast.txt +++ b/test/dump/cast.txt @@ -65,13 +65,13 @@ func 0 000017: 41 00 | i32.const 0 000019: be | f32.reinterpret/i32 00001a: 1a | drop - 00001b: 43 00 00 00 00 | f32.const 0 + 00001b: 43 00 00 00 00 | f32.const 0x0p+0 000020: bc | i32.reinterpret/f32 000021: 1a | drop 000022: 42 00 | i64.const 0 000024: bf | f64.reinterpret/i64 000025: 1a | drop - 000026: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 000026: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 00002f: bd | i64.reinterpret/f64 000030: 1a | drop ;;; STDOUT ;;) diff --git a/test/dump/compare.txt b/test/dump/compare.txt index 42f7d617..09e871dd 100644 --- a/test/dump/compare.txt +++ b/test/dump/compare.txt @@ -376,52 +376,52 @@ func 0 000072: 42 00 | i64.const 0 000074: 5a | i64.ge_u 000075: 1a | drop - 000076: 43 00 00 00 00 | f32.const 0 - 00007b: 43 00 00 00 00 | f32.const 0 + 000076: 43 00 00 00 00 | f32.const 0x0p+0 + 00007b: 43 00 00 00 00 | f32.const 0x0p+0 000080: 5b | f32.eq 000081: 1a | drop - 000082: 43 00 00 00 00 | f32.const 0 - 000087: 43 00 00 00 00 | f32.const 0 + 000082: 43 00 00 00 00 | f32.const 0x0p+0 + 000087: 43 00 00 00 00 | f32.const 0x0p+0 00008c: 5c | f32.ne 00008d: 1a | drop - 00008e: 43 00 00 00 00 | f32.const 0 - 000093: 43 00 00 00 00 | f32.const 0 + 00008e: 43 00 00 00 00 | f32.const 0x0p+0 + 000093: 43 00 00 00 00 | f32.const 0x0p+0 000098: 5d | f32.lt 000099: 1a | drop - 00009a: 43 00 00 00 00 | f32.const 0 - 00009f: 43 00 00 00 00 | f32.const 0 + 00009a: 43 00 00 00 00 | f32.const 0x0p+0 + 00009f: 43 00 00 00 00 | f32.const 0x0p+0 0000a4: 5f | f32.le 0000a5: 1a | drop - 0000a6: 43 00 00 00 00 | f32.const 0 - 0000ab: 43 00 00 00 00 | f32.const 0 + 0000a6: 43 00 00 00 00 | f32.const 0x0p+0 + 0000ab: 43 00 00 00 00 | f32.const 0x0p+0 0000b0: 5e | f32.gt 0000b1: 1a | drop - 0000b2: 43 00 00 00 00 | f32.const 0 - 0000b7: 43 00 00 00 00 | f32.const 0 + 0000b2: 43 00 00 00 00 | f32.const 0x0p+0 + 0000b7: 43 00 00 00 00 | f32.const 0x0p+0 0000bc: 60 | f32.ge 0000bd: 1a | drop - 0000be: 44 00 00 00 00 00 00 00 00 | f64.const 0 - 0000c7: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000be: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 + 0000c7: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 0000d0: 61 | f64.eq 0000d1: 1a | drop - 0000d2: 44 00 00 00 00 00 00 00 00 | f64.const 0 - 0000db: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000d2: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 + 0000db: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 0000e4: 62 | f64.ne 0000e5: 1a | drop - 0000e6: 44 00 00 00 00 00 00 00 00 | f64.const 0 - 0000ef: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000e6: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 + 0000ef: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 0000f8: 63 | f64.lt 0000f9: 1a | drop - 0000fa: 44 00 00 00 00 00 00 00 00 | f64.const 0 - 000103: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000fa: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 + 000103: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 00010c: 65 | f64.le 00010d: 1a | drop - 00010e: 44 00 00 00 00 00 00 00 00 | f64.const 0 - 000117: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 00010e: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 + 000117: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 000120: 64 | f64.gt 000121: 1a | drop - 000122: 44 00 00 00 00 00 00 00 00 | f64.const 0 - 00012b: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 000122: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 + 00012b: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 000134: 66 | f64.ge 000135: 1a | drop ;;; STDOUT ;;) diff --git a/test/dump/const.txt b/test/dump/const.txt index f226f7e7..944a4cb6 100644 --- a/test/dump/const.txt +++ b/test/dump/const.txt @@ -246,60 +246,60 @@ func 0 00004d: 1a | drop 00004e: 42 7f | i64.const -1 000050: 1a | drop - 000051: 43 00 00 00 00 | f32.const 0 + 000051: 43 00 00 00 00 | f32.const 0x0p+0 000056: 1a | drop - 000057: 43 16 68 a9 65 | f32.const 0x65a96816 + 000057: 43 16 68 a9 65 | f32.const 0x1.52d02cp+76 00005c: 1a | drop - 00005d: 43 40 20 4f 37 | f32.const 0x374f2040 + 00005d: 43 40 20 4f 37 | f32.const 0x1.9e408p-17 000062: 1a | drop - 000063: 43 00 00 c0 7f | f32.const 0x7fc00000 + 000063: 43 00 00 c0 7f | f32.const nan 000068: 1a | drop - 000069: 43 00 00 c0 ff | f32.const 0xffc00000 + 000069: 43 00 00 c0 ff | f32.const -nan 00006e: 1a | drop - 00006f: 43 00 00 c0 7f | f32.const 0x7fc00000 + 00006f: 43 00 00 c0 7f | f32.const nan 000074: 1a | drop - 000075: 43 bc 0a 80 7f | f32.const 0x7f800abc + 000075: 43 bc 0a 80 7f | f32.const nan:0xabc 00007a: 1a | drop - 00007b: 43 bc 0a 80 ff | f32.const 0xff800abc + 00007b: 43 bc 0a 80 ff | f32.const -nan:0xabc 000080: 1a | drop - 000081: 43 bc 0a 80 7f | f32.const 0x7f800abc + 000081: 43 bc 0a 80 7f | f32.const nan:0xabc 000086: 1a | drop - 000087: 43 00 00 80 7f | f32.const 0x7f800000 + 000087: 43 00 00 80 7f | f32.const infinity 00008c: 1a | drop - 00008d: 43 00 00 80 ff | f32.const 0xff800000 + 00008d: 43 00 00 80 ff | f32.const -infinity 000092: 1a | drop - 000093: 43 00 00 80 7f | f32.const 0x7f800000 + 000093: 43 00 00 80 7f | f32.const infinity 000098: 1a | drop - 000099: 43 00 00 00 bf | f32.const 0xbf000000 + 000099: 43 00 00 00 bf | f32.const -0x1p-1 00009e: 1a | drop - 00009f: 43 db 0f c9 40 | f32.const 0x40c90fdb + 00009f: 43 db 0f c9 40 | f32.const 0x1.921fb6p+2 0000a4: 1a | drop - 0000a5: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 0000a5: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 0000ae: 1a | drop - 0000af: 44 b8 56 0e 3c dd 9a ef bf | f64.const 1007572664 + 0000af: 44 b8 56 0e 3c dd 9a ef bf | f64.const -0x1.f9add3c0e56b8p-1 0000b8: 1a | drop - 0000b9: 44 18 2d 44 54 fb 21 19 40 | f64.const 1413754136 + 0000b9: 44 18 2d 44 54 fb 21 19 40 | f64.const 0x1.921fb54442d18p+2 0000c2: 1a | drop - 0000c3: 44 00 00 00 00 00 00 f8 7f | f64.const 0 + 0000c3: 44 00 00 00 00 00 00 f8 7f | f64.const nan 0000cc: 1a | drop - 0000cd: 44 00 00 00 00 00 00 f8 ff | f64.const 0 + 0000cd: 44 00 00 00 00 00 00 f8 ff | f64.const -nan 0000d6: 1a | drop - 0000d7: 44 00 00 00 00 00 00 f8 7f | f64.const 0 + 0000d7: 44 00 00 00 00 00 00 f8 7f | f64.const nan 0000e0: 1a | drop - 0000e1: 44 bc 0a 00 00 00 00 f0 7f | f64.const 2748 + 0000e1: 44 bc 0a 00 00 00 00 f0 7f | f64.const nan:0xabc 0000ea: 1a | drop - 0000eb: 44 bc 0a 00 00 00 00 f0 ff | f64.const 2748 + 0000eb: 44 bc 0a 00 00 00 00 f0 ff | f64.const -nan:0xabc 0000f4: 1a | drop - 0000f5: 44 bc 0a 00 00 00 00 f0 7f | f64.const 2748 + 0000f5: 44 bc 0a 00 00 00 00 f0 7f | f64.const nan:0xabc 0000fe: 1a | drop - 0000ff: 44 00 00 00 00 00 00 f0 7f | f64.const 0 + 0000ff: 44 00 00 00 00 00 00 f0 7f | f64.const infinity 000108: 1a | drop - 000109: 44 00 00 00 00 00 00 f0 ff | f64.const 0 + 000109: 44 00 00 00 00 00 00 f0 ff | f64.const -infinity 000112: 1a | drop - 000113: 44 00 00 00 00 00 00 f0 7f | f64.const 0 + 000113: 44 00 00 00 00 00 00 f0 7f | f64.const infinity 00011c: 1a | drop - 00011d: 44 00 00 00 00 00 00 e0 bf | f64.const 0 + 00011d: 44 00 00 00 00 00 00 e0 bf | f64.const -0x1p-1 000126: 1a | drop - 000127: 44 18 2d 44 54 fb 21 19 40 | f64.const 1413754136 + 000127: 44 18 2d 44 54 fb 21 19 40 | f64.const 0x1.921fb54442d18p+2 000130: 1a | drop ;;; STDOUT ;;) diff --git a/test/dump/convert.txt b/test/dump/convert.txt index 6e0a0971..8f6a004e 100644 --- a/test/dump/convert.txt +++ b/test/dump/convert.txt @@ -116,7 +116,7 @@ func 0 00002d: b4 | f32.convert_s/i64 00002e: ae | i64.trunc_s/f32 00002f: 1a | drop - 000030: 43 00 00 00 00 | f32.const 0 + 000030: 43 00 00 00 00 | f32.const 0x0p+0 000035: bb | f64.promote/f32 000036: b6 | f32.demote/f64 000037: 1a | drop diff --git a/test/dump/debug-names.txt b/test/dump/debug-names.txt index f47d9e3f..fd860550 100644 --- a/test/dump/debug-names.txt +++ b/test/dump/debug-names.txt @@ -92,23 +92,21 @@ TYPE: - [0] (i32) -> nil - [1] (f32) -> nil FUNCTION: - - [0] sig=0 - - [1] sig=1 + - func[0] sig=0 + - func[1] sig=1 CODE: - func 0 - func 1 USER: - name: "name" - - func:0 $F1 - - local:0 $F1P0 - - local:1 $F1L1 - - local:2 $F1L2 - - local:3 - - func:1 $F2 - - local:0 $F2P0 - - local:1 $F2L1 - - local:2 - - local:3 $F2L3 + - func[0] $F1 + - local[0] $F1P0 + - local[1] $F1L1 + - local[2] $F1L2 + - func[1] $F2 + - local[0] $F2P0 + - local[1] $F2L1 + - local[3] $F2L3 Code Disassembly: func 0 diff --git a/test/dump/hexfloat_f32.txt b/test/dump/hexfloat_f32.txt index 3fb5f79b..dd684e5e 100644 --- a/test/dump/hexfloat_f32.txt +++ b/test/dump/hexfloat_f32.txt @@ -121,38 +121,38 @@ hexfloat_f32.wasm: file format wasm 0x00000d Code Disassembly: func 0 - 000017: 43 00 00 00 00 | f32.const 0 + 000017: 43 00 00 00 00 | f32.const 0x0p+0 00001c: 1a | drop - 00001d: 43 80 a2 91 48 | f32.const 0x4891a280 + 00001d: 43 80 a2 91 48 | f32.const 0x1.2345p+18 000022: 1a | drop - 000023: 43 00 00 80 59 | f32.const 0x59800000 + 000023: 43 00 00 80 59 | f32.const 0x1p+52 000028: 1a | drop - 000029: 43 00 00 00 7f | f32.const 0x7f000000 + 000029: 43 00 00 00 7f | f32.const 0x1p+127 00002e: 1a | drop - 00002f: 43 00 00 80 7c | f32.const 0x7c800000 + 00002f: 43 00 00 80 7c | f32.const 0x1p+122 000034: 1a | drop - 000035: 43 00 80 91 7d | f32.const 0x7d918000 + 000035: 43 00 80 91 7d | f32.const 0x1.23p+124 00003a: 1a | drop - 00003b: 43 f0 ff ff 7e | f32.const 0x7efffff0 + 00003b: 43 f0 ff ff 7e | f32.const 0x1.ffffep+126 000040: 1a | drop - 000041: 43 fe ff 7f 7e | f32.const 0x7e7ffffe + 000041: 43 fe ff 7f 7e | f32.const 0x1.fffffcp+125 000046: 1a | drop - 000047: 43 00 00 80 7f | f32.const 0x7f800000 + 000047: 43 00 00 80 7f | f32.const infinity 00004c: 1a | drop - 00004d: 43 c4 ff 7f 7f | f32.const 0x7f7fffc4 + 00004d: 43 c4 ff 7f 7f | f32.const 0x1.ffff88p+127 000052: 1a | drop - 000053: 43 f8 ff 7f 7f | f32.const 0x7f7ffff8 + 000053: 43 f8 ff 7f 7f | f32.const 0x1.fffffp+127 000058: 1a | drop - 000059: 43 fa ff ff 0a | f32.const 0xafffffa + 000059: 43 fa ff ff 0a | f32.const 0x1.fffff4p-106 00005e: 1a | drop - 00005f: 43 f8 ff ff 0a | f32.const 0xafffff8 + 00005f: 43 f8 ff ff 0a | f32.const 0x1.fffffp-106 000064: 1a | drop - 000065: 43 00 00 00 04 | f32.const 0x4000000 + 000065: 43 00 00 00 04 | f32.const 0x1p-119 00006a: 1a | drop - 00006b: 43 00 00 88 3f | f32.const 0x3f880000 + 00006b: 43 00 00 88 3f | f32.const 0x1.1p+0 000070: 1a | drop - 000071: 43 00 00 80 53 | f32.const 0x53800000 + 000071: 43 00 00 80 53 | f32.const 0x1p+40 000076: 1a | drop - 000077: 43 80 80 7f c0 | f32.const 0xc07f8080 + 000077: 43 80 80 7f c0 | f32.const -0x1.ff01p+1 00007c: 1a | drop ;;; STDOUT ;;) diff --git a/test/dump/hexfloat_f64.txt b/test/dump/hexfloat_f64.txt index c94f7ca5..a54e9f05 100644 --- a/test/dump/hexfloat_f64.txt +++ b/test/dump/hexfloat_f64.txt @@ -123,38 +123,38 @@ hexfloat_f64.wasm: file format wasm 0x00000d Code Disassembly: func 0 - 000019: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 000019: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 000022: 1a | drop - 000023: 44 00 00 00 00 50 34 12 41 | f64.const 0 + 000023: 44 00 00 00 00 50 34 12 41 | f64.const 0x1.2345p+18 00002c: 1a | drop - 00002d: 44 00 00 00 00 00 00 30 45 | f64.const 0 + 00002d: 44 00 00 00 00 00 00 30 45 | f64.const 0x1p+84 000036: 1a | drop - 000037: 44 00 00 00 00 00 00 e0 7f | f64.const 0 + 000037: 44 00 00 00 00 00 00 e0 7f | f64.const 0x1p+1023 000040: 1a | drop - 000041: 44 00 00 00 00 00 00 90 7f | f64.const 0 + 000041: 44 00 00 00 00 00 00 90 7f | f64.const 0x1p+1018 00004a: 1a | drop - 00004b: 44 00 00 00 00 00 30 c2 7f | f64.const 0 + 00004b: 44 00 00 00 00 00 30 c2 7f | f64.const 0x1.23p+1021 000054: 1a | drop - 000055: 44 00 e0 ff ff ff ff df 7f | f64.const -8192 + 000055: 44 00 e0 ff ff ff ff df 7f | f64.const 0x1.fffffffffep+1022 00005e: 1a | drop - 00005f: 44 c0 ff ff ff ff ff cf 7f | f64.const -64 + 00005f: 44 c0 ff ff ff ff ff cf 7f | f64.const 0x1.fffffffffffcp+1021 000068: 1a | drop - 000069: 44 00 00 00 00 00 00 f0 7f | f64.const 0 + 000069: 44 00 00 00 00 00 00 f0 7f | f64.const infinity 000072: 1a | drop - 000073: 44 fc ff ff ff ff ff ef 7f | f64.const -4 + 000073: 44 fc ff ff ff ff ff ef 7f | f64.const 0x1.ffffffffffffcp+1023 00007c: 1a | drop - 00007d: 44 fe ff ff ff ff ff ef 7f | f64.const -2 + 00007d: 44 fe ff ff ff ff ff ef 7f | f64.const 0x1.ffffffffffffep+1023 000086: 1a | drop - 000087: 44 f1 ff ff ff ff ff df 02 | f64.const -15 + 000087: 44 f1 ff ff ff ff ff df 02 | f64.const 0x1.ffffffffffff1p-978 000090: 1a | drop - 000091: 44 f3 ff ff ff ff ff df 02 | f64.const -13 + 000091: 44 f3 ff ff ff ff ff df 02 | f64.const 0x1.ffffffffffff3p-978 00009a: 1a | drop - 00009b: 44 00 00 00 00 00 00 80 01 | f64.const 0 + 00009b: 44 00 00 00 00 00 00 80 01 | f64.const 0x1p-999 0000a4: 1a | drop - 0000a5: 44 00 00 00 00 00 00 f1 3f | f64.const 0 + 0000a5: 44 00 00 00 00 00 00 f1 3f | f64.const 0x1.1p+0 0000ae: 1a | drop - 0000af: 44 00 00 00 00 00 00 70 42 | f64.const 0 + 0000af: 44 00 00 00 00 00 00 70 42 | f64.const 0x1p+40 0000b8: 1a | drop - 0000b9: 44 00 00 00 00 10 f0 0f c0 | f64.const 0 + 0000b9: 44 00 00 00 00 10 f0 0f c0 | f64.const -0x1.ff01p+1 0000c2: 1a | drop ;;; STDOUT ;;) diff --git a/test/dump/if.txt b/test/dump/if.txt index 6a5ebbaf..a9ff7f7b 100644 --- a/test/dump/if.txt +++ b/test/dump/if.txt @@ -89,9 +89,9 @@ func 0 00001d: 0b | end 00001e: 41 00 | i32.const 0 000020: 04 7d | if f32 - 000022: 43 00 00 80 3f | f32.const 0x3f800000 + 000022: 43 00 00 80 3f | f32.const 0x1p+0 000027: 05 | else - 000028: 43 00 00 00 40 | f32.const 0x40000000 + 000028: 43 00 00 00 40 | f32.const 0x1p+1 00002d: 0b | end 00002e: 1a | drop func 1 diff --git a/test/dump/import.txt b/test/dump/import.txt index 30d022c4..6db268d5 100644 --- a/test/dump/import.txt +++ b/test/dump/import.txt @@ -1,5 +1,5 @@ ;;; TOOL: run-wasmdump -;;; FLAGS: -v +;;; FLAGS: -v --dump-verbose (module (import "ignored" "test" (func (param i32 i64 f32 f64))) (import "ignored" "test2" (func (param i32) (result i32)))) @@ -46,5 +46,13 @@ 0000018: 20 ; FIXUP section size import.wasm: file format wasm 0x00000d +Section Details: +TYPE: + - [0] (i32, i64, f32, f64) -> nil + - [1] (i32) -> i32 +IMPORT: + - ignored.test -> func[0] sig=0 + - ignored.test2 -> func[1] sig=1 + Code Disassembly: ;;; STDOUT ;;) diff --git a/test/dump/nocheck.txt b/test/dump/nocheck.txt index f9f4442d..a8a139e7 100644 --- a/test/dump/nocheck.txt +++ b/test/dump/nocheck.txt @@ -53,7 +53,7 @@ nocheck.wasm: file format wasm 0x00000d Code Disassembly: func 0 - 000021: 43 00 00 80 3f | f32.const 0x3f800000 - 000026: 44 00 00 00 00 00 00 00 40 | f64.const 0 + 000021: 43 00 00 80 3f | f32.const 0x1p+0 + 000026: 44 00 00 00 00 00 00 00 40 | f64.const 0x1p+1 00002f: 6a | i32.add ;;; STDOUT ;;) diff --git a/test/dump/result.txt b/test/dump/result.txt index 8cba3d98..c5e450e2 100644 --- a/test/dump/result.txt +++ b/test/dump/result.txt @@ -87,7 +87,7 @@ func 0 func 1 00002c: 42 00 | i64.const 0 func 2 - 000031: 43 00 00 00 00 | f32.const 0 + 000031: 43 00 00 00 00 | f32.const 0x0p+0 func 3 - 000039: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 000039: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 ;;; STDOUT ;;) diff --git a/test/dump/select.txt b/test/dump/select.txt index 87deda5f..8e11a39c 100644 --- a/test/dump/select.txt +++ b/test/dump/select.txt @@ -96,13 +96,13 @@ func 0 000023: 41 01 | i32.const 0x1 000025: 1b | select 000026: 1a | drop - 000027: 43 00 00 00 40 | f32.const 0x40000000 - 00002c: 43 00 00 40 40 | f32.const 0x40400000 + 000027: 43 00 00 00 40 | f32.const 0x1p+1 + 00002c: 43 00 00 40 40 | f32.const 0x1.8p+1 000031: 41 01 | i32.const 0x1 000033: 1b | select 000034: 1a | drop - 000035: 44 00 00 00 00 00 00 00 40 | f64.const 0 - 00003e: 44 00 00 00 00 00 00 08 40 | f64.const 0 + 000035: 44 00 00 00 00 00 00 00 40 | f64.const 0x1p+1 + 00003e: 44 00 00 00 00 00 00 08 40 | f64.const 0x1.8p+1 000047: 41 01 | i32.const 0x1 000049: 1b | select 00004a: 1a | drop diff --git a/test/dump/setglobal.txt b/test/dump/setglobal.txt index f5c974aa..cde8ddb1 100644 --- a/test/dump/setglobal.txt +++ b/test/dump/setglobal.txt @@ -51,6 +51,6 @@ setglobal.wasm: file format wasm 0x00000d Code Disassembly: func 0 - 000022: 43 00 00 00 40 | f32.const 0x40000000 + 000022: 43 00 00 00 40 | f32.const 0x1p+1 000027: 24 00 | set_global 0 ;;; STDOUT ;;) diff --git a/test/dump/setlocal-param.txt b/test/dump/setlocal-param.txt index b942dc45..4d95867b 100644 --- a/test/dump/setlocal-param.txt +++ b/test/dump/setlocal-param.txt @@ -87,14 +87,14 @@ Code Disassembly: func 0 000021: 41 00 | i32.const 0 000023: 21 00 | set_local 0 - 000025: 43 00 00 00 00 | f32.const 0 + 000025: 43 00 00 00 00 | f32.const 0x0p+0 00002a: 21 01 | set_local 0x1 00002c: 42 00 | i64.const 0 00002e: 21 02 | set_local 0x2 - 000030: 43 00 00 00 00 | f32.const 0 + 000030: 43 00 00 00 00 | f32.const 0x0p+0 000035: 21 03 | set_local 0x3 000037: 41 00 | i32.const 0 000039: 21 04 | set_local 0x4 - 00003b: 43 00 00 00 00 | f32.const 0 + 00003b: 43 00 00 00 00 | f32.const 0x0p+0 000040: 21 05 | set_local 0x5 ;;; STDOUT ;;) diff --git a/test/dump/setlocal.txt b/test/dump/setlocal.txt index 8988f2b4..87136703 100644 --- a/test/dump/setlocal.txt +++ b/test/dump/setlocal.txt @@ -101,9 +101,9 @@ setlocal.wasm: file format wasm 0x00000d Code Disassembly: func 0 - 000025: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 000025: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 00002e: 21 00 | set_local 0 - 000030: 43 00 00 00 00 | f32.const 0 + 000030: 43 00 00 00 00 | f32.const 0x0p+0 000035: 21 01 | set_local 0x1 000037: 42 00 | i64.const 0 000039: 21 02 | set_local 0x2 @@ -111,9 +111,9 @@ func 0 00003d: 21 03 | set_local 0x3 00003f: 41 00 | i32.const 0 000041: 21 04 | set_local 0x4 - 000043: 43 00 00 00 00 | f32.const 0 + 000043: 43 00 00 00 00 | f32.const 0x0p+0 000048: 21 05 | set_local 0x5 - 00004a: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 00004a: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 000053: 21 06 | set_local 0x6 000055: 42 00 | i64.const 0 000057: 21 07 | set_local 0x7 diff --git a/test/dump/store.txt b/test/dump/store.txt index db3927f6..36a73c71 100644 --- a/test/dump/store.txt +++ b/test/dump/store.txt @@ -146,9 +146,9 @@ func 0 000043: 42 00 | i64.const 0 000045: 3e 02 00 | i64.store32 2 0 000048: 41 00 | i32.const 0 - 00004a: 43 00 00 00 00 | f32.const 0 + 00004a: 43 00 00 00 00 | f32.const 0x0p+0 00004f: 38 02 00 | f32.store 2 0 000052: 41 00 | i32.const 0 - 000054: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 000054: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 00005d: 39 03 00 | f64.store 3 0 ;;; STDOUT ;;) diff --git a/test/dump/table.txt b/test/dump/table.txt index 0f2fdb89..16cbc35b 100644 --- a/test/dump/table.txt +++ b/test/dump/table.txt @@ -92,5 +92,5 @@ Code Disassembly: func 0 func 1 func 2 - 00003c: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 00003c: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 ;;; STDOUT ;;) diff --git a/test/dump/unary.txt b/test/dump/unary.txt index 6b19aa55..2c82ef88 100644 --- a/test/dump/unary.txt +++ b/test/dump/unary.txt @@ -110,7 +110,7 @@ func 0 000021: 7a | i64.ctz 000022: 79 | i64.clz 000023: 1a | drop - 000024: 43 00 00 00 00 | f32.const 0 + 000024: 43 00 00 00 00 | f32.const 0x0p+0 000029: 90 | f32.nearest 00002a: 8f | f32.trunc 00002b: 8e | f32.floor @@ -119,7 +119,7 @@ func 0 00002e: 8b | f32.abs 00002f: 8c | f32.neg 000030: 1a | drop - 000031: 44 00 00 00 00 00 00 00 00 | f64.const 0 + 000031: 44 00 00 00 00 00 00 00 00 | f64.const 0x0p+0 00003a: 9e | f64.nearest 00003b: 9d | f64.trunc 00003c: 9c | f64.floor |