porffor 0.34.7 → 0.34.8
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/assemble.js +8 -12
- package/compiler/builtins.js +9 -9
- package/compiler/builtins_objects.js +1 -2
- package/compiler/builtins_precompiled.js +230 -230
- package/compiler/codegen.js +257 -157
- package/compiler/decompile.js +1 -1
- package/compiler/precompile.js +3 -3
- package/compiler/wrap.js +3 -2
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/assemble.js
CHANGED
@@ -102,7 +102,6 @@ export default (funcs, globals, tags, pages, data, flags, noTreeshake = false) =
|
|
102
102
|
f.asmIndex = f.index - importDelta;
|
103
103
|
}
|
104
104
|
|
105
|
-
|
106
105
|
if (Prefs.optLog) log('assemble', `treeshake: using ${importFuncs.length}/${importedFuncs.length} imports`);
|
107
106
|
|
108
107
|
const importSection = importFuncs.length === 0 ? [] : createSection(
|
@@ -135,7 +134,7 @@ export default (funcs, globals, tags, pages, data, flags, noTreeshake = false) =
|
|
135
134
|
const offset = pages.get('func lut').ind * pageSize;
|
136
135
|
if (data.addedFuncArgcLut) {
|
137
136
|
// remove existing data
|
138
|
-
data = data.filter(x => x.
|
137
|
+
data = data.filter(x => x.page !== 'func lut');
|
139
138
|
}
|
140
139
|
|
141
140
|
// generate func lut data
|
@@ -149,8 +148,6 @@ export default (funcs, globals, tags, pages, data, flags, noTreeshake = false) =
|
|
149
148
|
if (func.constr) argc -= 4;
|
150
149
|
if (!func.internal || func.typedParams) argc = Math.floor(argc / 2);
|
151
150
|
|
152
|
-
if (name.startsWith('#')) name = '';
|
153
|
-
|
154
151
|
bytes.push(argc % 256, (argc / 256 | 0) % 256);
|
155
152
|
|
156
153
|
// userland exposed .length
|
@@ -165,6 +162,8 @@ export default (funcs, globals, tags, pages, data, flags, noTreeshake = false) =
|
|
165
162
|
if (func.constr) flags |= 0b10;
|
166
163
|
bytes.push(flags);
|
167
164
|
|
165
|
+
if (name.startsWith('#')) name = '';
|
166
|
+
|
168
167
|
// eg: __String_prototype_toLowerCase -> toLowerCase
|
169
168
|
if (name.startsWith('__')) name = name.split('_').pop();
|
170
169
|
|
@@ -281,8 +280,6 @@ export default (funcs, globals, tags, pages, data, flags, noTreeshake = false) =
|
|
281
280
|
|
282
281
|
if (typeCount !== 0) localDecl.push(encodeLocal(typeCount, lastType));
|
283
282
|
|
284
|
-
// todo: move const, call transforms here too?
|
285
|
-
|
286
283
|
const makeAssembled = Prefs.d;
|
287
284
|
let wasm = [], wasmNonFlat = [];
|
288
285
|
for (let i = 0; i < x.wasm.length; i++) {
|
@@ -294,26 +291,25 @@ export default (funcs, globals, tags, pages, data, flags, noTreeshake = false) =
|
|
294
291
|
o[1] > 127
|
295
292
|
) {
|
296
293
|
const n = o[1];
|
297
|
-
o = [
|
298
|
-
o.pop();
|
294
|
+
o = [ o[0] ];
|
299
295
|
unsignedLEB128_into(n, o);
|
300
296
|
}
|
301
297
|
|
302
298
|
// encode f64.const ops as ieee754 from raw number
|
303
299
|
if (o[0] === Opcodes.f64_const) {
|
304
300
|
const n = o[1];
|
305
|
-
o = [
|
306
|
-
o.pop();
|
301
|
+
o = [ o[0] ];
|
307
302
|
ieee754_binary64_into(n, o);
|
308
303
|
}
|
309
304
|
|
305
|
+
// encode call ops as unsigned leb128 from raw number
|
310
306
|
if ((o[0] === Opcodes.call || o[0] === Opcodes.return_call) && o[1] >= importedFuncs.length) {
|
311
307
|
const n = o[1] - importDelta;
|
312
|
-
o = [
|
313
|
-
o.pop();
|
308
|
+
o = [ o[0] ];
|
314
309
|
unsignedLEB128_into(n, o);
|
315
310
|
}
|
316
311
|
|
312
|
+
// encode call indirect ops as types from info
|
317
313
|
if (o[0] === Opcodes.call_indirect) {
|
318
314
|
o = [...o];
|
319
315
|
const params = [];
|
package/compiler/builtins.js
CHANGED
@@ -1016,7 +1016,7 @@ export const BuiltinFuncs = function() {
|
|
1016
1016
|
[ Opcodes.i32_mul ],
|
1017
1017
|
...number(4, Valtype.i32),
|
1018
1018
|
[ Opcodes.i32_add ],
|
1019
|
-
[ Opcodes.i32_load8_u, 0, ...unsignedLEB128(allocPage(scope, 'func lut')
|
1019
|
+
[ Opcodes.i32_load8_u, 0, ...unsignedLEB128(allocPage(scope, 'func lut')) ]
|
1020
1020
|
],
|
1021
1021
|
table: true
|
1022
1022
|
};
|
@@ -1031,7 +1031,7 @@ export const BuiltinFuncs = function() {
|
|
1031
1031
|
[ Opcodes.i32_mul ],
|
1032
1032
|
...number(2, Valtype.i32),
|
1033
1033
|
[ Opcodes.i32_add ],
|
1034
|
-
[ Opcodes.i32_load16_u, 0, ...unsignedLEB128(allocPage(scope, 'func lut')
|
1034
|
+
[ Opcodes.i32_load16_u, 0, ...unsignedLEB128(allocPage(scope, 'func lut')) ]
|
1035
1035
|
],
|
1036
1036
|
table: true
|
1037
1037
|
};
|
@@ -1046,7 +1046,7 @@ export const BuiltinFuncs = function() {
|
|
1046
1046
|
[ Opcodes.i32_mul ],
|
1047
1047
|
...number(5, Valtype.i32),
|
1048
1048
|
[ Opcodes.i32_add ],
|
1049
|
-
...number(allocPage(scope, 'func lut')
|
1049
|
+
...number(allocPage(scope, 'func lut'), Valtype.i32),
|
1050
1050
|
[ Opcodes.i32_add ]
|
1051
1051
|
],
|
1052
1052
|
table: true
|
@@ -1062,11 +1062,11 @@ export const BuiltinFuncs = function() {
|
|
1062
1062
|
...number(2, Valtype.i32),
|
1063
1063
|
[ Opcodes.i32_add ],
|
1064
1064
|
...number(0, Valtype.i32),
|
1065
|
-
[ Opcodes.i32_store16, 0, ...unsignedLEB128(allocPage(scope, 'func lut')
|
1065
|
+
[ Opcodes.i32_store16, 0, ...unsignedLEB128(allocPage(scope, 'func lut')) ],
|
1066
1066
|
|
1067
1067
|
[ Opcodes.local_get, 0 ],
|
1068
1068
|
...number(1, Valtype.i32),
|
1069
|
-
[ Opcodes.i32_store8, 0, ...unsignedLEB128(allocPage(scope, 'func length deletion table')
|
1069
|
+
[ Opcodes.i32_store8, 0, ...unsignedLEB128(allocPage(scope, 'func length deletion table')) ]
|
1070
1070
|
],
|
1071
1071
|
table: true
|
1072
1072
|
};
|
@@ -1081,11 +1081,11 @@ export const BuiltinFuncs = function() {
|
|
1081
1081
|
...number(5, Valtype.i32),
|
1082
1082
|
[ Opcodes.i32_add ],
|
1083
1083
|
...number(0, Valtype.i32),
|
1084
|
-
[ Opcodes.i32_store, 0, ...unsignedLEB128(allocPage(scope, 'func lut')
|
1084
|
+
[ Opcodes.i32_store, 0, ...unsignedLEB128(allocPage(scope, 'func lut')) ],
|
1085
1085
|
|
1086
1086
|
[ Opcodes.local_get, 0 ],
|
1087
1087
|
...number(1, Valtype.i32),
|
1088
|
-
[ Opcodes.i32_store8, 0, ...unsignedLEB128(allocPage(scope, 'func name deletion table')
|
1088
|
+
[ Opcodes.i32_store8, 0, ...unsignedLEB128(allocPage(scope, 'func name deletion table')) ],
|
1089
1089
|
],
|
1090
1090
|
table: true
|
1091
1091
|
};
|
@@ -1096,7 +1096,7 @@ export const BuiltinFuncs = function() {
|
|
1096
1096
|
returnType: TYPES.boolean,
|
1097
1097
|
wasm: (scope, { allocPage }) => [
|
1098
1098
|
[ Opcodes.local_get, 0 ],
|
1099
|
-
[ Opcodes.i32_load8_u, 0, ...unsignedLEB128(allocPage(scope, 'func length deletion table')
|
1099
|
+
[ Opcodes.i32_load8_u, 0, ...unsignedLEB128(allocPage(scope, 'func length deletion table')) ]
|
1100
1100
|
],
|
1101
1101
|
table: true
|
1102
1102
|
};
|
@@ -1107,7 +1107,7 @@ export const BuiltinFuncs = function() {
|
|
1107
1107
|
returnType: TYPES.boolean,
|
1108
1108
|
wasm: (scope, { allocPage }) => [
|
1109
1109
|
[ Opcodes.local_get, 0 ],
|
1110
|
-
[ Opcodes.i32_load8_u, 0, ...unsignedLEB128(allocPage(scope, 'func name deletion table')
|
1110
|
+
[ Opcodes.i32_load8_u, 0, ...unsignedLEB128(allocPage(scope, 'func name deletion table')) ]
|
1111
1111
|
],
|
1112
1112
|
table: true
|
1113
1113
|
};
|
@@ -29,8 +29,7 @@ export default function({ builtinFuncs }, Prefs) {
|
|
29
29
|
if (existingFunc) {
|
30
30
|
ptr = 1;
|
31
31
|
} else {
|
32
|
-
|
33
|
-
ptr = page === 0 ? 16 : page * PageSize;
|
32
|
+
ptr = allocPage(scope, `builtin object: ${name}`);
|
34
33
|
}
|
35
34
|
|
36
35
|
const out = [
|