watr 2.1.4 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/readme.md +8 -2
- package/src/compile.js +16 -4
- package/src/const.js +2 -2
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -96,9 +96,15 @@ parse(`(func (export "double") (param f64) (result f64) (f64.mul (local.get 0) (
|
|
|
96
96
|
// ]
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
##
|
|
99
|
+
## Status
|
|
100
|
+
|
|
101
|
+
* [x] wasm core
|
|
102
|
+
* [ ] floating HEX support, eg. `(f32.const 0x1.fffffep+127)`.
|
|
103
|
+
* [x] multiple values
|
|
104
|
+
* [x] bulk memory ops (0 index)
|
|
105
|
+
* [ ] func/ref types
|
|
106
|
+
* [ ] multiple memories
|
|
100
107
|
|
|
101
|
-
No floating HEX support, eg. `(f32.const 0x1.fffffep+127)`.
|
|
102
108
|
|
|
103
109
|
<!--
|
|
104
110
|
## Projects using watr
|
package/src/compile.js
CHANGED
|
@@ -122,7 +122,7 @@ const build = {
|
|
|
122
122
|
// NOTE: numeric comparison is faster than generic hash lookup
|
|
123
123
|
|
|
124
124
|
// binary/unary - just consume immed
|
|
125
|
-
if (opCode >= 69) { }
|
|
125
|
+
if (opCode >= 69 && opCode <= 252) { }
|
|
126
126
|
|
|
127
127
|
// (i32.store align=n offset=m at value)
|
|
128
128
|
else if (opCode >= 40 && opCode <= 62) {
|
|
@@ -237,8 +237,20 @@ const build = {
|
|
|
237
237
|
while (args.length) consume(args, out)
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
// ignore (then) and other unknown instructions
|
|
241
|
-
if (opCode >= 0)
|
|
240
|
+
// ignore (then) and other unknown (-1) instructions
|
|
241
|
+
if (opCode >= 0) {
|
|
242
|
+
// bulk memory: (memory.init) (memory.copy) etc
|
|
243
|
+
// https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md#instruction-encoding
|
|
244
|
+
if (opCode >= 252) {
|
|
245
|
+
opCode %= 252
|
|
246
|
+
out.push(0xfc)
|
|
247
|
+
immed = [0]
|
|
248
|
+
// even opCodes (memory.init, memory.copy, table.init, table.copy) have 2 immediates
|
|
249
|
+
if (!(opCode % 2)) immed.push(0)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
out.push(opCode)
|
|
253
|
+
}
|
|
242
254
|
if (immed) out.push(...immed)
|
|
243
255
|
}
|
|
244
256
|
|
|
@@ -340,7 +352,7 @@ const iinit = ([op, literal], ctx) => op[0] === 'f' ?
|
|
|
340
352
|
[op[1] === '3' ? OP_F32_CONST : OP_F64_CONST, ...(op[1] === '3' ? f32 : f64)(literal), OP_END] :
|
|
341
353
|
[op[1] === '3' ? OP_I32_CONST : OP_I64_CONST, ...(op[1] === '3' ? leb : bigleb)(literal[0] === '$' ? ctx.global[literal] : literal), OP_END]
|
|
342
354
|
|
|
343
|
-
const escape = { n: 10, r: 13, t: 9, v: 1 }
|
|
355
|
+
const escape = { n: 10, r: 13, t: 9, v: 1, '\\': 92 }
|
|
344
356
|
|
|
345
357
|
// build string binary
|
|
346
358
|
const str = str => {
|
package/src/const.js
CHANGED
|
@@ -25,7 +25,7 @@ export const OP = [
|
|
|
25
25
|
'i64.trunc_f32_s', 'i64.trunc_f32_u', 'i64.trunc_f64_s', 'i64.trunc_f64_u',
|
|
26
26
|
'f32.convert_i32_s', 'f32.convert_i32_u', 'f32.convert_i64_s', 'f32.convert_i64_u', 'f32.demote_f64',
|
|
27
27
|
'f64.convert_i32_s', 'f64.convert_i32_u', 'f64.convert_i64_s', 'f64.convert_i64_u', 'f64.promote_f32',
|
|
28
|
-
'i32.reinterpret_f32', 'i64.reinterpret_f64', 'f32.reinterpret_i32', 'f64.reinterpret_i64',
|
|
28
|
+
'i32.reinterpret_f32', 'i64.reinterpret_f64', 'f32.reinterpret_i32', 'f64.reinterpret_i64', , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 'memory.init', 'data.drop', 'memory.copy', 'memory.fill', 'table.init', 'elem.drop', 'table.copy'
|
|
29
29
|
],
|
|
30
30
|
SECTION = { type: 1, import: 2, func: 3, table: 4, memory: 5, global: 6, export: 7, start: 8, elem: 9, code: 10, data: 11 },
|
|
31
31
|
TYPE = { i32: 0x7f, i64: 0x7e, f32: 0x7d, f64: 0x7c, void: 0x40, func: 0x60, funcref: 0x70 },
|
|
@@ -39,4 +39,4 @@ export const OP = [
|
|
|
39
39
|
},
|
|
40
40
|
BLOCK = {
|
|
41
41
|
loop: 1, block: 1, if: 1, end: -1, return: -1
|
|
42
|
-
}
|
|
42
|
+
}
|