porffor 0.57.12 → 0.57.13
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/compiler/builtins/array.ts +1 -1
- package/compiler/builtins/arraybuffer.ts +1 -1
- package/compiler/builtins/atomics.js +169 -0
- package/compiler/builtins/typedarray.js +3 -4
- package/compiler/builtins_objects.js +1 -1
- package/compiler/builtins_precompiled.js +778 -707
- package/compiler/codegen.js +7 -3
- package/compiler/disassemble.js +1 -3
- package/compiler/types.js +1 -1
- package/compiler/wasmSpec.js +51 -1
- package/foo.js +10 -0
- package/foo.ts +10 -3
- package/package.json +1 -1
- package/runtime/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -206,6 +206,10 @@ const generate = (scope, decl, global = false, name = undefined, valueUnused = f
|
|
206
206
|
case 'ArrowFunctionExpression':
|
207
207
|
case 'FunctionDeclaration':
|
208
208
|
case 'FunctionExpression':
|
209
|
+
// ignore body-less function definitions, likely ts overload signatures
|
210
|
+
if (!decl.body) {
|
211
|
+
return cacheAst(decl, [ number(UNDEFINED) ]);
|
212
|
+
}
|
209
213
|
return cacheAst(decl, generateFunc(scope, decl)[1]);
|
210
214
|
|
211
215
|
case 'BlockStatement':
|
@@ -1934,10 +1938,10 @@ const typeIsIterable = wasm => [
|
|
1934
1938
|
...typeIsOneOf(wasm, [ TYPES.array, TYPES.set, TYPES.map, TYPES.string, TYPES.bytestring, TYPES.__porffor_generator ]),
|
1935
1939
|
// typed array
|
1936
1940
|
...wasm,
|
1937
|
-
number(TYPES.
|
1941
|
+
number(TYPES.uint8clampedarray, Valtype.i32),
|
1938
1942
|
[ Opcodes.i32_ge_s ],
|
1939
1943
|
...wasm,
|
1940
|
-
number(TYPES.
|
1944
|
+
number(TYPES.float64array, Valtype.i32),
|
1941
1945
|
[ Opcodes.i32_le_s ],
|
1942
1946
|
[ Opcodes.i32_and ],
|
1943
1947
|
[ Opcodes.i32_or ],
|
@@ -6388,7 +6392,7 @@ const generateTaggedTemplate = (scope, decl, global = false, name = undefined, v
|
|
6388
6392
|
continue;
|
6389
6393
|
}
|
6390
6394
|
|
6391
|
-
let inst = Opcodes[asm[0].
|
6395
|
+
let inst = Opcodes[asm[0].replaceAll('.', '_')];
|
6392
6396
|
if (inst == null) throw new Error(`inline asm: inst ${asm[0]} not found`);
|
6393
6397
|
if (!Array.isArray(inst)) inst = [ inst ];
|
6394
6398
|
|
package/compiler/disassemble.js
CHANGED
@@ -37,9 +37,7 @@ export default (wasm, name = '', ind = 0, locals = {}, params = [], returns = []
|
|
37
37
|
if (inst[0] === 0xfd) { // simd inst prefix
|
38
38
|
if (inst[1] >= 128) inst = [ [ inst[0], inst[1], inst[2] ], ...inst.slice(3) ];
|
39
39
|
else inst = [ [ inst[0], inst[1] ], ...inst.slice(2) ];
|
40
|
-
}
|
41
|
-
|
42
|
-
if (inst[0] === 0xfc) { // misc inst prefix
|
40
|
+
} else if (inst[0] > 0xf0) { // other multi-byte insts
|
43
41
|
inst = [ [ inst[0], inst[1] ], ...inst.slice(2) ];
|
44
42
|
}
|
45
43
|
|
package/compiler/types.js
CHANGED
@@ -56,7 +56,7 @@ registerInternalType('ArrayBuffer');
|
|
56
56
|
registerInternalType('SharedArrayBuffer');
|
57
57
|
registerInternalType('DataView');
|
58
58
|
|
59
|
-
for (const x of [ '
|
59
|
+
for (const x of [ 'Uint8Clamped', 'Uint8', 'Int8', 'Uint16', 'Int16', 'Uint32', 'Int32', 'BigUint64', 'BigInt64', 'Float32', 'Float64' ])
|
60
60
|
registerInternalType(`${x}Array`, ['iterable', 'length']);
|
61
61
|
|
62
62
|
registerInternalType('WeakRef');
|
package/compiler/wasmSpec.js
CHANGED
@@ -252,5 +252,55 @@ export const Opcodes = {
|
|
252
252
|
|
253
253
|
v128_or: [ 0xfd, 80 ],
|
254
254
|
v128_xor: [ 0xfd, 81 ],
|
255
|
-
v128_any_true: [ 0xfd, 83 ]
|
255
|
+
v128_any_true: [ 0xfd, 83 ],
|
256
|
+
|
257
|
+
// Atomic memory operations
|
258
|
+
memory_atomic_notify: [ 0xfe, 0x00 ],
|
259
|
+
memory_atomic_wait32: [ 0xfe, 0x01 ],
|
260
|
+
memory_atomic_wait64: [ 0xfe, 0x02 ],
|
261
|
+
atomic_fence: [ 0xfe, 0x03, 0x00 ],
|
262
|
+
|
263
|
+
i32_atomic_load: [ 0xfe, 0x10 ],
|
264
|
+
i64_atomic_load: [ 0xfe, 0x11 ],
|
265
|
+
i32_atomic_load8: [ 0xfe, 0x12 ],
|
266
|
+
i32_atomic_load16: [ 0xfe, 0x13 ],
|
267
|
+
i32_atomic_store: [ 0xfe, 0x17 ],
|
268
|
+
i64_atomic_store: [ 0xfe, 0x18 ],
|
269
|
+
i32_atomic_store8: [ 0xfe, 0x19 ],
|
270
|
+
i32_atomic_store16: [ 0xfe, 0x1a ],
|
271
|
+
|
272
|
+
i32_atomic_rmw_add: [ 0xfe, 0x1e ],
|
273
|
+
i64_atomic_rmw_add: [ 0xfe, 0x1f ],
|
274
|
+
i32_atomic_rmw_add8: [ 0xfe, 0x20 ],
|
275
|
+
i32_atomic_rmw_add16: [ 0xfe, 0x21 ],
|
276
|
+
|
277
|
+
i32_atomic_rmw_sub: [ 0xfe, 0x25 ],
|
278
|
+
i64_atomic_rmw_sub: [ 0xfe, 0x26 ],
|
279
|
+
i32_atomic_rmw_sub8: [ 0xfe, 0x27 ],
|
280
|
+
i32_atomic_rmw_sub16: [ 0xfe, 0x28 ],
|
281
|
+
|
282
|
+
i32_atomic_rmw_and: [ 0xfe, 0x2c ],
|
283
|
+
i64_atomic_rmw_and: [ 0xfe, 0x2d ],
|
284
|
+
i32_atomic_rmw_and8: [ 0xfe, 0x2e ],
|
285
|
+
i32_atomic_rmw_and16: [ 0xfe, 0x2f ],
|
286
|
+
|
287
|
+
i32_atomic_rmw_or: [ 0xfe, 0x33 ],
|
288
|
+
i64_atomic_rmw_or: [ 0xfe, 0x34 ],
|
289
|
+
i32_atomic_rmw_or8: [ 0xfe, 0x35 ],
|
290
|
+
i32_atomic_rmw_or16: [ 0xfe, 0x36 ],
|
291
|
+
|
292
|
+
i32_atomic_rmw_xor: [ 0xfe, 0x3a ],
|
293
|
+
i64_atomic_rmw_xor: [ 0xfe, 0x3b ],
|
294
|
+
i32_atomic_rmw_xor8: [ 0xfe, 0x3c ],
|
295
|
+
i32_atomic_rmw_xor16: [ 0xfe, 0x3d ],
|
296
|
+
|
297
|
+
i32_atomic_rmw_xchg: [ 0xfe, 0x41 ],
|
298
|
+
i64_atomic_rmw_xchg: [ 0xfe, 0x42 ],
|
299
|
+
i32_atomic_rmw_xchg8: [ 0xfe, 0x43 ],
|
300
|
+
i32_atomic_rmw_xchg16: [ 0xfe, 0x44 ],
|
301
|
+
|
302
|
+
i32_atomic_rmw_cmpxchg: [ 0xfe, 0x48 ],
|
303
|
+
i64_atomic_rmw_cmpxchg: [ 0xfe, 0x49 ],
|
304
|
+
i32_atomic_rmw_cmpxchg8: [ 0xfe, 0x4a ],
|
305
|
+
i32_atomic_rmw_cmpxchg16: [ 0xfe, 0x4b ]
|
256
306
|
};
|
package/foo.js
ADDED
package/foo.ts
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
-
namespace wasm {
|
2
|
-
|
1
|
+
// namespace wasm {
|
2
|
+
// export declare function imported_wasm_func(a: number): void;
|
3
|
+
// }
|
4
|
+
|
5
|
+
// wasm.imported_wasm_func(1337);
|
6
|
+
|
7
|
+
class Vector {
|
8
|
+
foo(x: number): number
|
3
9
|
}
|
4
10
|
|
5
|
-
|
11
|
+
const foo = new Vector()
|
12
|
+
console.log(foo.foo(""))
|
package/package.json
CHANGED