[wasm] test disassembler for Wasm MVP features
Tests the disassembler output for all instructions and section types from Wasm MVP (extensions such as reference types, SIMD, name section, etc. will come in separate CL(s) and module(s), since they contain a lot of additional instructions). Also fixes a small issue in `MultiLineStringBuilder` found by ASAN. The test checks the output of the disassembler against the text input given to `wat2wasm` which generates the module given to the disassembler. The module in this test includes all non-extension instructions from https://webassembly.github.io/spec/core/appendix/index-instructions.html and module sections from https://webassembly.github.io/spec/core/text/modules.html at least once (and sometimes multiple times in case there are variants). Change-Id: Iaa8791cfc51431fb436f42b98604e83cd9258d06 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4001769 Auto-Submit: Daniel Lehmann <dlehmann@chromium.org> Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/main@{#84050}
This commit is contained in:
parent
7ab1dc6a9a
commit
9e06d4dd53
@ -92,7 +92,7 @@ class MultiLineStringBuilder : public StringBuilder {
|
||||
// Write the unfinished line into its new location.
|
||||
start_here();
|
||||
char* new_location = allocate(unfinished_length);
|
||||
memcpy(new_location, unfinished_start, unfinished_length);
|
||||
memmove(new_location, unfinished_start, unfinished_length);
|
||||
if (label_source >= unfinished_start &&
|
||||
label_source < unfinished_start + unfinished_length) {
|
||||
label_source = new_location + (label_source - unfinished_start);
|
||||
|
@ -2,21 +2,34 @@
|
||||
0x01, 0x00, 0x00, 0x00, // wasm version
|
||||
|
||||
0x01, // section kind: Type
|
||||
0x0c, // section length 12
|
||||
0x03, // types count 3
|
||||
0x60, // kind: func
|
||||
0x1d, // section length 29
|
||||
0x07, // types count 7
|
||||
0x60, // type #0 $type0 kind: func
|
||||
0x00, // param count 0
|
||||
0x00, // return count 0
|
||||
0x60, // type #1 $type1 kind: func
|
||||
0x01, 0x7f, // param count 1: i32
|
||||
0x00, // return count 0
|
||||
0x60, // kind: func
|
||||
0x60, // type #2 $type2 kind: func
|
||||
0x00, // param count 0
|
||||
0x01, 0x7f, // return count 1: i32
|
||||
0x60, // kind: func
|
||||
0x60, // type #3 $type3 kind: func
|
||||
0x00, // param count 0
|
||||
0x00, // return count 0
|
||||
0x01, 0x7e, // return count 1: i64
|
||||
0x60, // type #4 $type4 kind: func
|
||||
0x00, // param count 0
|
||||
0x01, 0x7d, // return count 1: f32
|
||||
0x60, // type #5 $type5 kind: func
|
||||
0x00, // param count 0
|
||||
0x01, 0x7c, // return count 1: f64
|
||||
0x60, // type #6 $type6 kind: func
|
||||
0x01, 0x7e, // param count 1: i64
|
||||
0x01, 0x7c, // return count 1: f64
|
||||
|
||||
0x02, // section kind: Import
|
||||
0x18, // section length 24
|
||||
0x01, // imports count 1: import #0
|
||||
0x30, // section length 48
|
||||
0x02, // imports count 2
|
||||
// import #0
|
||||
0x03, // module name length: 3
|
||||
0x65, 0x6e, 0x76, // module name: env
|
||||
0x0f, // field name length: 15
|
||||
@ -24,13 +37,37 @@
|
||||
0x5f, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c,
|
||||
// field name: imported_global
|
||||
0x03, 0x7f, 0x00, // kind: global i32 immutable
|
||||
// import #1
|
||||
0x03, // module name length: 3
|
||||
0x65, 0x6e, 0x76, // module name: env
|
||||
0x11, // field name length: 17
|
||||
0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64,
|
||||
0x5f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, // field name: imported_function
|
||||
0x00, 0x00, // kind: function
|
||||
|
||||
0x03, // section kind: Function
|
||||
0x09, // section length 9
|
||||
0x08, // functions count 8
|
||||
0x01, // 1 $func1 (param i32)
|
||||
0x02, // 2 $func2 (result i32)
|
||||
0x03, // 3 $func3 (result i64)
|
||||
0x04, // 4 $func4 (result f32)
|
||||
0x05, // 5 $func5 (result f64)
|
||||
0x00, // 6 $func6
|
||||
0x00, // 7 $func7
|
||||
0x00, // 8 $exported_function
|
||||
|
||||
0x04, // section kind: Table
|
||||
0x04, // section length 4
|
||||
0x03, // functions count 3
|
||||
0x00, // 0 $func0 (param i32)
|
||||
0x01, // 1 $func1 (result i32)
|
||||
0x02, // 2 $func2
|
||||
0x01, 0x70, 0x00, // table count 1: funcref no maximum
|
||||
0x04, // initial size 4
|
||||
|
||||
0x05, // section kind: Memory
|
||||
0x04, // section length 4
|
||||
0x01, 0x01, // memory count 1: with maximum
|
||||
0x00, // initial size 0
|
||||
0x01, // maximum size 1
|
||||
|
||||
0x06, // section kind: Global
|
||||
0x10, // section length 16
|
||||
@ -43,18 +80,35 @@
|
||||
0x42, 0x00, 0x0b, // i64.const 0
|
||||
|
||||
0x07, // section kind: Export
|
||||
0x13, // section length 19
|
||||
0x01, // exports count 1: export # 0
|
||||
0x27, // section length 39
|
||||
0x02, // exports count 2
|
||||
// export # 0
|
||||
0x0f, // field name length: 15
|
||||
0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64,
|
||||
0x5f, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c,
|
||||
// field name: exported_global
|
||||
0x03, 0x03, // kind: global index: 3
|
||||
// export # 1
|
||||
0x11, // field name length: 17
|
||||
0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64,
|
||||
0x5f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, // field name: exported_function
|
||||
0x00, 0x08, // kind: function index: 8
|
||||
|
||||
0x09, // section kind: Element
|
||||
0x0a, // section length 10
|
||||
0x01, 0x00, // segment count 1: flag: active, offset:
|
||||
0x41, 0x00, 0x0b, // i32.const 0
|
||||
0x04, // number of elements 4
|
||||
0x00, // index: 0
|
||||
0x01, // index: 1
|
||||
0x01, // index: 1
|
||||
0x03, // index: 3
|
||||
|
||||
0x0a, // section kind: Code
|
||||
0x71, // section length 113
|
||||
0x03, // functions count 3
|
||||
// function #0 $func0
|
||||
0xdc, 0x07, // section length 988
|
||||
0x08, // functions count 8
|
||||
// function #1 $func1
|
||||
0x14, // body size 20
|
||||
0x01, // 1 entries in locals list
|
||||
0x01, 0x7e, // 1 local of type i64
|
||||
@ -67,8 +121,8 @@
|
||||
0x23, 0x01, // global.get $global1
|
||||
0x24, 0x01, // global.set $global1
|
||||
0x0b, // end
|
||||
// function #1 $func1
|
||||
0x55, // body size 85
|
||||
// function #2 $func2
|
||||
0x8c, 0x01, // body size 140
|
||||
0x00, // 0 entries in locals list
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x45, // i32.eqz
|
||||
@ -76,9 +130,9 @@
|
||||
0x46, // i32.eq
|
||||
0x41, 0x7f, // i32.const -1
|
||||
0x47, // i32.ne
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x41, 0xff, 0xff, 0xff, 0xff, 0x07, // i32.const 2147483647
|
||||
0x48, // i32.lt_s
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x41, 0x80, 0x80, 0x80, 0x80, 0x78, // i32.const -2147483648
|
||||
0x49, // i32.lt_u
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x4a, // i32.gt_s
|
||||
@ -125,12 +179,390 @@
|
||||
0x77, // i32.rotl
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x78, // i32.rotr
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0xa7, // i32.wrap_i64
|
||||
0x1a, // drop
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0xa8, // i32.trunc_f32_s
|
||||
0x1a, // drop
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0xa9, // i32.trunc_f32_u
|
||||
0x1a, // drop
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xaa, // i32.trunc_f64_s
|
||||
0x1a, // drop
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xab, // i32.trunc_f64_u
|
||||
0x1a, // drop
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0xbc, // i32.reinterpret_f32
|
||||
0xc0, // i32.extend8_s
|
||||
0xc1, // i32.extend16_s
|
||||
0x0b, // end
|
||||
// function #2 $func2
|
||||
// function #3 $func3
|
||||
0xc0, 0x01, // body size 192
|
||||
0x00, // 0 entries in locals list
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x50, // i64.eqz
|
||||
0x1a, // drop
|
||||
0x42, 0x01, // i64.const 1
|
||||
0x42, 0x7f, // i64.const -1
|
||||
0x51, // i64.eq
|
||||
0x1a, // drop
|
||||
0x42, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x7f, // i64.const -9223372036854775808
|
||||
0x42, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, // i64.const 9223372036854775807
|
||||
0x52, // i64.ne
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x53, // i64.lt_s
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x54, // i64.lt_u
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x55, // i64.gt_s
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x56, // i64.gt_u
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x57, // i64.le_s
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x58, // i64.le_u
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x59, // i64.ge_s
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x5a, // i64.ge_u
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x79, // i64.clz
|
||||
0x7a, // i64.ctz
|
||||
0x7b, // i64.popcnt
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x7c, // i64.add
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x7d, // i64.sub
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x7e, // i64.mul
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x7f, // i64.div_s
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x80, // i64.div_u
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x81, // i64.rem_s
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x82, // i64.rem_u
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x83, // i64.and
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x84, // i64.or
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x85, // i64.xor
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x86, // i64.shl
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x87, // i64.shr_s
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x88, // i64.shr_u
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x89, // i64.rotl
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x8a, // i64.rotr
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0xac, // i64.extend_i32_s
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0xad, // i64.extend_i32_u
|
||||
0x1a, // drop
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0xae, // i64.trunc_f32_s
|
||||
0x1a, // drop
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0xaf, // i64.trunc_f32_u
|
||||
0x1a, // drop
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xb0, // i64.trunc_f64_s
|
||||
0x1a, // drop
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xb1, // i64.trunc_f64_u
|
||||
0x1a, // drop
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xbd, // i64.reinterpret_f64
|
||||
0xc2, // i64.extend8_s
|
||||
0xc3, // i64.extend16_s
|
||||
0xc4, // i64.extend32_s
|
||||
0x0b, // end
|
||||
// function #4 $func4
|
||||
0x9f, 0x01, // body size 159
|
||||
0x00, // 0 entries in locals list
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0x43, 0x00, 0x00, 0x00, 0x80, // f32.const -0.0
|
||||
0x5b, // f32.eq
|
||||
0x1a, // drop
|
||||
0x43, 0x00, 0x00, 0x80, 0x3f, // f32.const 1
|
||||
0x43, 0x00, 0x00, 0x80, 0xbf, // f32.const -1
|
||||
0x5c, // f32.ne
|
||||
0x1a, // drop
|
||||
0x43, 0x00, 0x00, 0x80, 0x7f, // f32.const inf
|
||||
0x43, 0x00, 0x00, 0x80, 0xff, // f32.const -inf
|
||||
0x5d, // f32.lt
|
||||
0x1a, // drop
|
||||
0x43, 0x00, 0x00, 0xc0, 0x7f, // f32.const nan
|
||||
0x43, 0x00, 0x00, 0xc0, 0xff, // f32.const -nan
|
||||
0x5e, // f32.gt
|
||||
0x1a, // drop
|
||||
0x43, 0x01, 0x00, 0x80, 0x7f, // f32.const +nan:0x1
|
||||
0x43, 0xff, 0xff, 0x8f, 0x7f, // f32.const +nan:0xfffff
|
||||
0x5f, // f32.le
|
||||
0x1a, // drop
|
||||
0x43, 0xcd, 0xcc, 0xcc, 0x3d, // f32.const 0.1
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0x60, // f32.ge
|
||||
0x1a, // drop
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0x8b, // f32.abs
|
||||
0x8c, // f32.neg
|
||||
0x8d, // f32.ceil
|
||||
0x8e, // f32.floor
|
||||
0x8f, // f32.trunc
|
||||
0x90, // f32.nearest
|
||||
0x91, // f32.sqrt
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0x92, // f32.add
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0x93, // f32.sub
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0x94, // f32.mul
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0x95, // f32.div
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0x96, // f32.min
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0x97, // f32.max
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0x98, // f32.copysign
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0xb2, // f32.convert_i32_s
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0xb3, // f32.convert_i32_u
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0xb4, // f32.convert_i64_s
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0xb5, // f32.convert_i64_u
|
||||
0x1a, // drop
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xb6, // f32.demote_f64
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0xbe, // f32.reinterpret_i32
|
||||
0x0b, // end
|
||||
// function #5 $func5
|
||||
0xeb, 0x01, // body size 235
|
||||
0x00, // 0 entries in locals list
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, // f64.const -0.0
|
||||
0x61, // f64.eq
|
||||
0x1a, // drop
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, // f64.const 1
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xbf, // f64.const -1
|
||||
0x62, // f64.ne
|
||||
0x1a, // drop
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, // f64.const inf
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, // f64.const -inf
|
||||
0x63, // f64.lt
|
||||
0x1a, // drop
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f, // f64.const nan
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, // f64.const -nan
|
||||
0x64, // f64.gt
|
||||
0x1a, // drop
|
||||
0x44, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, // f64.const +nan:0x1
|
||||
0x44, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, // f64.const +nan:0xfffffffffffff
|
||||
0x65, // f64.le
|
||||
0x1a, // drop
|
||||
0x44, 0x9a, 0x99, 0x99, 0x99, 0x99, 0x99, 0xb9, 0x3f, // f64.const 0.1
|
||||
0x44, 0x00, 0x00, 0x00, 0x80, 0x87, 0xd6, 0x32, 0x41, // f64.const 1234567.5
|
||||
0x66, // f64.ge
|
||||
0x1a, // drop
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0x99, // f64.abs
|
||||
0x9a, // f64.neg
|
||||
0x9b, // f64.ceil
|
||||
0x9c, // f64.floor
|
||||
0x9d, // f64.trunc
|
||||
0x9e, // f64.nearest
|
||||
0x9f, // f64.sqrt
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xa0, // f64.add
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xa1, // f64.sub
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xa2, // f64.mul
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xa3, // f64.div
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xa4, // f64.min
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xa5, // f64.max
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0xa6, // f64.copysign
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0xb7, // f64.convert_i32_s
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0xb8, // f64.convert_i32_u
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0xb9, // f64.convert_i64_s
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0xba, // f64.convert_i64_u
|
||||
0x1a, // drop
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0xbb, // f64.promote_f32
|
||||
0x1a, // drop
|
||||
0x42, 0x00, // i64.const 0
|
||||
0xbf, // f64.reinterpret_i64
|
||||
0x0b, // end
|
||||
// function #6 $func6
|
||||
0x3c, // body size 60
|
||||
0x00, // 0 entries in locals list
|
||||
0x10, 0x07, // call $func7
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x11, 0x06, 0x00, // call_indirect (param i64) (result f64)
|
||||
0x0f, // return
|
||||
0x02, 0x40, // block $label0
|
||||
0x03, 0x40, // loop $label1
|
||||
0x02, 0x7e, // block (result i64)
|
||||
0x03, 0x7e, // loop (result i64) $label2
|
||||
0x0c, 0x03, // br $label0
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x0d, 0x02, // br_if $label1
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x0e, 0x03, 0x03, 0x02, 0x02, 0x00, // br_table $label0 $label1 $label1 $label2
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x0b, // end $label2
|
||||
0x0b, // end
|
||||
0x1a, // drop
|
||||
0x0b, // end $label1
|
||||
0x0b, // end $label0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x42, 0x01, // i64.const 1
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x1b, // select
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x04, 0x7e, // if (result i64)
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x05, // else
|
||||
0x42, 0x01, // i64.const 1
|
||||
0x0b, // end
|
||||
0x1a, // drop
|
||||
0x0b, // end
|
||||
// function #7 $func7
|
||||
0xa4, 0x01, // body size 164
|
||||
0x00, // 0 entries in locals list
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x28, 0x02, 0x00, // i32.load
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x29, 0x03, 0x03, // i64.load offset=3
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x2a, 0x01, 0x00, // f32.load align=2
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x2b, 0x02, 0x03, // f64.load offset=3 align=4
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x2c, 0x00, 0x00, // i32.load8_s
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x2d, 0x00, 0x00, // i32.load8_u
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x2e, 0x01, 0x00, // i32.load16_s
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x2f, 0x01, 0x00, // i32.load16_u
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x30, 0x00, 0x00, // i64.load8_s
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x31, 0x00, 0x00, // i64.load8_u
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x32, 0x01, 0x00, // i64.load16_s
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x33, 0x01, 0x00, // i64.load16_u
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x34, 0x02, 0x00, // i64.load32_s
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x35, 0x02, 0x00, // i64.load32_u
|
||||
0x1a, // drop
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x36, 0x02, 0x00, // i32.store
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x37, 0x03, 0x00, // i64.store
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x43, 0x00, 0x00, 0x00, 0x00, // f32.const 0.0
|
||||
0x38, 0x02, 0x00, // f32.store
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f64.const 0.0
|
||||
0x39, 0x03, 0x00, // f64.store
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x3a, 0x00, 0x00, // i32.store8
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x3b, 0x01, 0x00, // i32.store16
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x3c, 0x00, 0x00, // i64.store8
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x3d, 0x01, 0x00, // i64.store16
|
||||
0x41, 0x00, // i32.const 0
|
||||
0x42, 0x00, // i64.const 0
|
||||
0x3e, 0x02, 0x00, // i64.store32
|
||||
0x3f, 0x00, // memory.size
|
||||
0x40, 0x00, // memory.grow
|
||||
0x1a, // drop
|
||||
0x0b, // end
|
||||
// function #8 $exported_function
|
||||
0x04, // body size 4
|
||||
0x00, // 0 entries in locals list
|
||||
0x01, // nop
|
||||
0x00, // unreachable
|
||||
0x0b, // end
|
||||
|
||||
0x0b, // section kind: Data
|
||||
0x0b, // section length 11
|
||||
0x01, 0x00, // data segments count 1: flag: active no index
|
||||
0x23, 0x00, 0x0b, // global.get $env.imported_global
|
||||
0x05, // source size 5
|
||||
0x66, 0x6f, 0x6f, 0x0a, 0x00, // segment data
|
||||
|
@ -1,13 +1,20 @@
|
||||
;; expected = R"---(;; This is a polyglot C++/WAT file.
|
||||
;; Comment lines are ignored and not expected in the disassembler output.
|
||||
(module
|
||||
;; Globals: mutable, non-mutable, imported, exported.
|
||||
;; Imports.
|
||||
(global $env.imported_global (;0;) (import "env" "imported_global") i32)
|
||||
(func $env.imported_function (;0;) (import "env" "imported_function"))
|
||||
;; Table and memory sections.
|
||||
(table $table0 4 funcref)
|
||||
(memory $memory0 0 1)
|
||||
;; Non-imported globals: mutable, non-mutable, exported.
|
||||
(global $global1 (mut i32) (i32.const 0))
|
||||
(global $global2 i32 (global.get $env.imported_global))
|
||||
(global $exported_global (;3;) (export "exported_global") i64 (i64.const 0))
|
||||
;; Element section for table initialization.
|
||||
(elem $elem0 (i32.const 0) funcref (ref.func $env.imported_function) (ref.func $func1) (ref.func $func1) (ref.func $func3))
|
||||
;; Instructions on globals, locals, parameters.
|
||||
(func $func0 (param $var0 i32)
|
||||
(func $func1 (param $var0 i32)
|
||||
(local $var1 i64)
|
||||
local.get $var0
|
||||
local.tee $var0
|
||||
@ -19,16 +26,17 @@
|
||||
global.set $global1
|
||||
)
|
||||
;; i32 operations.
|
||||
(func $func1 (result i32)
|
||||
(func $func2 (result i32)
|
||||
;; Comparisons and constant literals.
|
||||
i32.const 0
|
||||
i32.eqz
|
||||
i32.const 1
|
||||
i32.eq
|
||||
i32.const -1
|
||||
i32.ne
|
||||
i32.const 0
|
||||
i32.const 2147483647
|
||||
i32.lt_s
|
||||
i32.const 0
|
||||
i32.const -2147483648
|
||||
i32.lt_u
|
||||
i32.const 0
|
||||
i32.gt_s
|
||||
@ -42,9 +50,11 @@
|
||||
i32.ge_s
|
||||
i32.const 0
|
||||
i32.ge_u
|
||||
;; Bitcounting.
|
||||
i32.clz
|
||||
i32.ctz
|
||||
i32.popcnt
|
||||
;; Arithmetic and logic.
|
||||
i32.const 0
|
||||
i32.add
|
||||
i32.const 0
|
||||
@ -75,18 +85,411 @@
|
||||
i32.rotl
|
||||
i32.const 0
|
||||
i32.rotr
|
||||
drop
|
||||
;; Conversions.
|
||||
i64.const 0
|
||||
i32.wrap_i64
|
||||
drop
|
||||
f32.const 0.0
|
||||
i32.trunc_f32_s
|
||||
drop
|
||||
f32.const 0.0
|
||||
i32.trunc_f32_u
|
||||
drop
|
||||
f64.const 0.0
|
||||
i32.trunc_f64_s
|
||||
drop
|
||||
f64.const 0.0
|
||||
i32.trunc_f64_u
|
||||
drop
|
||||
f32.const 0.0
|
||||
i32.reinterpret_f32
|
||||
i32.extend8_s
|
||||
i32.extend16_s
|
||||
)
|
||||
;; Other instructions.
|
||||
(func $func2
|
||||
;; i64 operations.
|
||||
(func $func3 (result i64)
|
||||
;; Comparisons and constant literals.
|
||||
i64.const 0
|
||||
i64.eqz
|
||||
drop
|
||||
i64.const 1
|
||||
i64.const -1
|
||||
i64.eq
|
||||
drop
|
||||
i64.const -9223372036854775808
|
||||
i64.const 9223372036854775807
|
||||
i64.ne
|
||||
drop
|
||||
i64.const 0
|
||||
i64.const 0
|
||||
i64.lt_s
|
||||
drop
|
||||
i64.const 0
|
||||
i64.const 0
|
||||
i64.lt_u
|
||||
drop
|
||||
i64.const 0
|
||||
i64.const 0
|
||||
i64.gt_s
|
||||
drop
|
||||
i64.const 0
|
||||
i64.const 0
|
||||
i64.gt_u
|
||||
drop
|
||||
i64.const 0
|
||||
i64.const 0
|
||||
i64.le_s
|
||||
drop
|
||||
i64.const 0
|
||||
i64.const 0
|
||||
i64.le_u
|
||||
drop
|
||||
i64.const 0
|
||||
i64.const 0
|
||||
i64.ge_s
|
||||
drop
|
||||
i64.const 0
|
||||
i64.const 0
|
||||
i64.ge_u
|
||||
drop
|
||||
;; Bitcounting.
|
||||
i64.const 0
|
||||
i64.clz
|
||||
i64.ctz
|
||||
i64.popcnt
|
||||
;; Arithmetic and logic.
|
||||
i64.const 0
|
||||
i64.add
|
||||
i64.const 0
|
||||
i64.sub
|
||||
i64.const 0
|
||||
i64.mul
|
||||
i64.const 0
|
||||
i64.div_s
|
||||
i64.const 0
|
||||
i64.div_u
|
||||
i64.const 0
|
||||
i64.rem_s
|
||||
i64.const 0
|
||||
i64.rem_u
|
||||
i64.const 0
|
||||
i64.and
|
||||
i64.const 0
|
||||
i64.or
|
||||
i64.const 0
|
||||
i64.xor
|
||||
i64.const 0
|
||||
i64.shl
|
||||
i64.const 0
|
||||
i64.shr_s
|
||||
i64.const 0
|
||||
i64.shr_u
|
||||
i64.const 0
|
||||
i64.rotl
|
||||
i64.const 0
|
||||
i64.rotr
|
||||
drop
|
||||
;; Conversions.
|
||||
i32.const 0
|
||||
i64.extend_i32_s
|
||||
drop
|
||||
i32.const 0
|
||||
i64.extend_i32_u
|
||||
drop
|
||||
f32.const 0.0
|
||||
i64.trunc_f32_s
|
||||
drop
|
||||
f32.const 0.0
|
||||
i64.trunc_f32_u
|
||||
drop
|
||||
f64.const 0.0
|
||||
i64.trunc_f64_s
|
||||
drop
|
||||
f64.const 0.0
|
||||
i64.trunc_f64_u
|
||||
drop
|
||||
f64.const 0.0
|
||||
i64.reinterpret_f64
|
||||
i64.extend8_s
|
||||
i64.extend16_s
|
||||
i64.extend32_s
|
||||
)
|
||||
;; f32 operations.
|
||||
(func $func4 (result f32)
|
||||
;; Comparisons and constant literals.
|
||||
f32.const 0.0
|
||||
f32.const -0.0
|
||||
f32.eq
|
||||
drop
|
||||
;; TODO(dlehmann): Check after fixing bug below again if this shall be `1`
|
||||
;; or `1.0`.
|
||||
f32.const 1
|
||||
f32.const -1
|
||||
f32.ne
|
||||
drop
|
||||
f32.const inf
|
||||
f32.const -inf
|
||||
f32.lt
|
||||
drop
|
||||
f32.const nan
|
||||
f32.const -nan
|
||||
f32.gt
|
||||
drop
|
||||
;; Non-canonical NaN encodings.
|
||||
f32.const +nan:0x1
|
||||
f32.const +nan:0xfffff
|
||||
f32.le
|
||||
drop
|
||||
f32.const 0.1
|
||||
;; TODO(dlehmann): This fails the test because the disassembler produces
|
||||
;; `12345678`, even though this literal is representable exactly as an f32.
|
||||
;; I also double-checked the binary encoding, which is the IEEE754 encoding
|
||||
;; of the correct value (and thus wat2wasm is not the culprit).
|
||||
;; f32.const 1234567.5
|
||||
;; Include this constant again, once the `ImmediatePrinter` is fixed.
|
||||
f32.const 0.0
|
||||
f32.ge
|
||||
drop
|
||||
;; Arithmetic.
|
||||
f32.const 0.0
|
||||
f32.abs
|
||||
f32.neg
|
||||
f32.ceil
|
||||
f32.floor
|
||||
f32.trunc
|
||||
f32.nearest
|
||||
f32.sqrt
|
||||
f32.const 0.0
|
||||
f32.add
|
||||
f32.const 0.0
|
||||
f32.sub
|
||||
f32.const 0.0
|
||||
f32.mul
|
||||
f32.const 0.0
|
||||
f32.div
|
||||
f32.const 0.0
|
||||
f32.min
|
||||
f32.const 0.0
|
||||
f32.max
|
||||
f32.const 0.0
|
||||
f32.copysign
|
||||
drop
|
||||
;; Conversions.
|
||||
i32.const 0
|
||||
f32.convert_i32_s
|
||||
drop
|
||||
i32.const 0
|
||||
f32.convert_i32_u
|
||||
drop
|
||||
i64.const 0
|
||||
f32.convert_i64_s
|
||||
drop
|
||||
i64.const 0
|
||||
f32.convert_i64_u
|
||||
drop
|
||||
f64.const 0.0
|
||||
f32.demote_f64
|
||||
drop
|
||||
i32.const 0
|
||||
f32.reinterpret_i32
|
||||
)
|
||||
;; f64 operations.
|
||||
(func $func5 (result f64)
|
||||
;; Comparisons and constant literals.
|
||||
f64.const 0.0
|
||||
f64.const -0.0
|
||||
f64.eq
|
||||
drop
|
||||
f64.const 1
|
||||
f64.const -1
|
||||
f64.ne
|
||||
drop
|
||||
f64.const inf
|
||||
f64.const -inf
|
||||
f64.lt
|
||||
drop
|
||||
f64.const nan
|
||||
f64.const -nan
|
||||
f64.gt
|
||||
drop
|
||||
;; Non-canonical NaN encodings.
|
||||
f64.const +nan:0x1
|
||||
f64.const +nan:0xfffffffffffff
|
||||
f64.le
|
||||
drop
|
||||
f64.const 0.1
|
||||
f64.const 1234567.5
|
||||
f64.ge
|
||||
drop
|
||||
;; Arithmetic.
|
||||
f64.const 0.0
|
||||
f64.abs
|
||||
f64.neg
|
||||
f64.ceil
|
||||
f64.floor
|
||||
f64.trunc
|
||||
f64.nearest
|
||||
f64.sqrt
|
||||
f64.const 0.0
|
||||
f64.add
|
||||
f64.const 0.0
|
||||
f64.sub
|
||||
f64.const 0.0
|
||||
f64.mul
|
||||
f64.const 0.0
|
||||
f64.div
|
||||
f64.const 0.0
|
||||
f64.min
|
||||
f64.const 0.0
|
||||
f64.max
|
||||
f64.const 0.0
|
||||
f64.copysign
|
||||
drop
|
||||
;; Conversions.
|
||||
i32.const 0
|
||||
f64.convert_i32_s
|
||||
drop
|
||||
i32.const 0
|
||||
f64.convert_i32_u
|
||||
drop
|
||||
i64.const 0
|
||||
f64.convert_i64_s
|
||||
drop
|
||||
i64.const 0
|
||||
f64.convert_i64_u
|
||||
drop
|
||||
f32.const 0.0
|
||||
f64.promote_f32
|
||||
drop
|
||||
i64.const 0
|
||||
f64.reinterpret_i64
|
||||
)
|
||||
;; Control-flow.
|
||||
(func $func6
|
||||
;; Calls and return.
|
||||
call $func7
|
||||
i64.const 0
|
||||
i32.const 0
|
||||
call_indirect (param i64) (result f64)
|
||||
return
|
||||
;; Blocks and loops, with and without block type.
|
||||
block $label0
|
||||
loop $label1
|
||||
block (result i64)
|
||||
loop $label2 (result i64)
|
||||
;; Branches
|
||||
br $label0
|
||||
i32.const 0
|
||||
br_if $label1
|
||||
i32.const 0
|
||||
br_table $label0 $label1 $label1 $label2
|
||||
i64.const 0
|
||||
end $label2
|
||||
end
|
||||
drop
|
||||
end $label1
|
||||
end $label0
|
||||
;; Select and if.
|
||||
i64.const 0
|
||||
i64.const 1
|
||||
i32.const 0
|
||||
select
|
||||
drop
|
||||
i32.const 0
|
||||
if (result i64)
|
||||
i64.const 0
|
||||
else
|
||||
i64.const 1
|
||||
end
|
||||
drop
|
||||
)
|
||||
;; Memory operations.
|
||||
(func $func7
|
||||
;; Loads.
|
||||
i32.const 0
|
||||
i32.load
|
||||
drop
|
||||
i32.const 0
|
||||
;; Non-default memargs.
|
||||
i64.load offset=3
|
||||
drop
|
||||
i32.const 0
|
||||
f32.load align=2
|
||||
drop
|
||||
i32.const 0
|
||||
f64.load offset=3 align=4
|
||||
drop
|
||||
i32.const 0
|
||||
i32.load8_s
|
||||
drop
|
||||
i32.const 0
|
||||
i32.load8_u
|
||||
drop
|
||||
i32.const 0
|
||||
i32.load16_s
|
||||
drop
|
||||
i32.const 0
|
||||
i32.load16_u
|
||||
drop
|
||||
i32.const 0
|
||||
i64.load8_s
|
||||
drop
|
||||
i32.const 0
|
||||
i64.load8_u
|
||||
drop
|
||||
i32.const 0
|
||||
i64.load16_s
|
||||
drop
|
||||
i32.const 0
|
||||
i64.load16_u
|
||||
drop
|
||||
i32.const 0
|
||||
i64.load32_s
|
||||
drop
|
||||
i32.const 0
|
||||
i64.load32_u
|
||||
drop
|
||||
;; Stores.
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store
|
||||
i32.const 0
|
||||
i64.const 0
|
||||
i64.store
|
||||
i32.const 0
|
||||
f32.const 0.0
|
||||
f32.store
|
||||
i32.const 0
|
||||
f64.const 0.0
|
||||
f64.store
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store8
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store16
|
||||
i32.const 0
|
||||
i64.const 0
|
||||
i64.store8
|
||||
i32.const 0
|
||||
i64.const 0
|
||||
i64.store16
|
||||
i32.const 0
|
||||
i64.const 0
|
||||
i64.store32
|
||||
;; Other memory instructions.
|
||||
memory.size
|
||||
memory.grow
|
||||
drop
|
||||
)
|
||||
;; Other instructions. (Also an exported function.)
|
||||
(func $exported_function (;8;) (export "exported_function")
|
||||
nop
|
||||
unreachable
|
||||
)
|
||||
;; TODO(dlehmann): i64, f32, f64 operations.
|
||||
;; TODO(dlehmann): select, blocks, loops, branches.
|
||||
;; TODO(dlehmann): calls, call_indirect, table, element section.
|
||||
;; TODO(dlehmann): memory and data section.
|
||||
;; TODO(dlehmann): name and extended name section.
|
||||
;; Data and element sections.
|
||||
(data (global.get $env.imported_global) "foo\0a\00")
|
||||
;; TODO(dlehmann): Wasm extensions, name and extended name section.
|
||||
)
|
||||
;;)---";
|
||||
|
Loading…
Reference in New Issue
Block a user