porffor 0.14.0-4e46400a9 → 0.14.0-5951093a3
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 +12 -1
- package/compiler/builtins/array.ts +6 -4
- package/compiler/builtins/boolean.ts +1 -1
- package/compiler/builtins/set.ts +5 -6
- package/compiler/builtins/symbol.ts +61 -0
- package/compiler/builtins.js +13 -6
- package/compiler/codegen.js +316 -136
- package/compiler/decompile.js +1 -1
- package/compiler/generated_builtins.js +76 -31
- package/compiler/index.js +3 -8
- package/compiler/precompile.js +1 -1
- package/compiler/prefs.js +6 -2
- package/compiler/prototype.js +180 -157
- package/compiler/wrap.js +82 -40
- package/package.json +1 -1
- package/runner/repl.js +18 -2
package/compiler/decompile.js
CHANGED
|
@@ -119,7 +119,7 @@ export const highlightAsm = asm => asm
|
|
|
119
119
|
.replace(/(local|global|memory)\.[^\s]*/g, _ => `\x1B[31m${_}\x1B[0m`)
|
|
120
120
|
.replace(/(i(8|16|32|64)x[0-9]+|v128)(\.[^\s]*)?/g, _ => `\x1B[34m${_}\x1B[0m`)
|
|
121
121
|
.replace(/(i32|i64|f32|f64|drop)(\.[^\s]*)?/g, _ => `\x1B[36m${_}\x1B[0m`)
|
|
122
|
-
.replace(/(return_call|call|br_if|br|return|rethrow|throw)/g, _ => `\x1B[35m${_}\x1B[0m`)
|
|
122
|
+
.replace(/(return_call|call_indirect|call|br_if|br|return|rethrow|throw)/g, _ => `\x1B[35m${_}\x1B[0m`)
|
|
123
123
|
.replace(/(block|loop|if|end|else|try|catch_all|catch|delegate)/g, _ => `\x1B[95m${_}\x1B[0m`)
|
|
124
124
|
.replace(/unreachable/g, _ => `\x1B[91m${_}\x1B[0m`)
|
|
125
125
|
.replace(/ \-?[0-9\.]+/g, _ => ` \x1B[33m${_.slice(1)}\x1B[0m`)
|
|
@@ -228,7 +228,7 @@ export const BuiltinFuncs = function() {
|
|
|
228
228
|
localNames: ["x","x#type"],
|
|
229
229
|
};
|
|
230
230
|
this.__Array_prototype_slice = {
|
|
231
|
-
wasm: (scope, {allocPage,builtin,}) => [[32,0],[252,3],[40,1,0],[184],[33,6],[32,4],[65,0],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[97],[4,64],[32,6],[33,4],[11],[32,2],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,2],[32,4],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,4],[32,2],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,6],[32,2],[160],[34,2],[68,0,0,0,0,0,0,0,0],[99],[4,64],[68,0,0,0,0,0,0,0,0],[33,2],[11],[11],[32,2],[32,6],[100],[4,64],[32,6],[33,2],[11],[32,4],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,6],[32,4],[160],[34,4],[68,0,0,0,0,0,0,0,0],[99],[4,64],[68,0,0,0,0,0,0,0,0],[33,4],[11],[11],[32,4],[32,6],[100],[4,64],[32,6],[33,4],[11],...number(allocPage(scope, 'array: __Array_prototype_slice/out', 'f64') * pageSize, 124),[34,7],[252,3],[34,8],[65,0],[54,1,0],[32,2],[32,4],[100],[4,64],[32,7],[65,16],[15],[11],[32,7],[33,9],[32,0],[34,10],[32,4],[68,0,0,0,0,0,0,
|
|
231
|
+
wasm: (scope, {allocPage,builtin,}) => [[32,0],[252,3],[40,1,0],[184],[33,6],[32,4],[65,0],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[97],[4,64],[32,6],[33,4],[11],[32,2],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,2],[32,4],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,4],[32,2],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,6],[32,2],[160],[34,2],[68,0,0,0,0,0,0,0,0],[99],[4,64],[68,0,0,0,0,0,0,0,0],[33,2],[11],[11],[32,2],[32,6],[100],[4,64],[32,6],[33,2],[11],[32,4],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,6],[32,4],[160],[34,4],[68,0,0,0,0,0,0,0,0],[99],[4,64],[68,0,0,0,0,0,0,0,0],[33,4],[11],[11],[32,4],[32,6],[100],[4,64],[32,6],[33,4],[11],...number(allocPage(scope, 'array: __Array_prototype_slice/out', 'f64') * pageSize, 124),[34,7],[252,3],[34,8],[65,0],[54,1,0],[32,2],[32,4],[100],[4,64],[32,7],[65,16],[15],[11],[32,7],[33,9],[32,0],[34,10],[32,4],[68,0,0,0,0,0,0,34,64],[162],[160],[33,11],[32,10],[32,2],[68,0,0,0,0,0,0,34,64],[162],[160],[33,10],[3,64],[32,10],[32,11],[99],[4,64],[32,9],[252,2],[32,10],[252,2],[43,0,4],[57,0,4],[32,9],[68,0,0,0,0,0,0,32,64],[160],[252,2],[32,10],[68,0,0,0,0,0,0,32,64],[160],[252,2],[45,0,4],[58,0,4],[32,10],[68,0,0,0,0,0,0,34,64],[160],[33,10],[32,9],[68,0,0,0,0,0,0,34,64],[160],[33,9],[12,1],[11],[11],[32,7],[252,3],[32,4],[32,2],[161],[34,12],[252,3],[54,1,0],[32,7],[65,16],[15]],
|
|
232
232
|
params: [124,127,124,127,124,127],
|
|
233
233
|
typedParams: true,
|
|
234
234
|
returns: [124,127],
|
|
@@ -237,34 +237,34 @@ export const BuiltinFuncs = function() {
|
|
|
237
237
|
localNames: ["_this","_this#type","start","start#type","end","end#type","len","out","#makearray_pointer_tmp","outPtr","thisPtr","thisPtrEnd","__length_setter_tmp"],
|
|
238
238
|
};
|
|
239
239
|
this.__Array_prototype_indexOf = {
|
|
240
|
-
wasm: (scope, {builtin,}) => [[32,0],[252,3],[40,1,0],[184],[33,6],[32,4],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[32,6],[100],[4,64],[32,6],[33,4],[5],[32,4],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,4],[11],[5],[68,0,0,0,0,0,0,0,0],[33,4],[11],[32,4],[33,7],[3,64],[32,7],[32,6],[99],[4,64],[32,7],[252,3],[65,
|
|
240
|
+
wasm: (scope, {builtin,}) => [[32,0],[252,3],[40,1,0],[184],[33,6],[32,4],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[32,6],[100],[4,64],[32,6],[33,4],[5],[32,4],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,4],[11],[5],[68,0,0,0,0,0,0,0,0],[33,4],[11],[32,4],[33,7],[3,64],[32,7],[32,6],[99],[4,64],[32,7],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,8],[43,0,4],[32,8],[45,0,12],[26],[32,2],[97],[4,64],[32,7],[65,0],[15],[11],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[12,1],[11],[11],[68,0,0,0,0,0,0,240,191],[65,0],[15]],
|
|
241
241
|
params: [124,127,124,127,124,127],
|
|
242
242
|
typedParams: true,
|
|
243
243
|
returns: [124,127],
|
|
244
244
|
typedReturns: true,
|
|
245
|
-
locals: [124,124,127],
|
|
246
|
-
localNames: ["_this","_this#type","searchElement","searchElement#type","position","position#type","len","i","#last_type"],
|
|
245
|
+
locals: [124,124,127,127],
|
|
246
|
+
localNames: ["_this","_this#type","searchElement","searchElement#type","position","position#type","len","i","#loadArray_offset","#last_type"],
|
|
247
247
|
};
|
|
248
248
|
this.__Array_prototype_lastIndexOf = {
|
|
249
|
-
wasm: (scope, {builtin,}) => [[32,0],[252,3],[40,1,0],[184],[33,6],[32,4],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[32,6],[100],[4,64],[32,6],[33,4],[5],[32,4],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,4],[11],[5],[68,0,0,0,0,0,0,0,0],[33,4],[11],[32,6],[68,0,0,0,0,0,0,240,63],[161],[33,7],[3,64],[32,7],[32,4],[102],[4,64],[32,7],[252,3],[65,
|
|
249
|
+
wasm: (scope, {builtin,}) => [[32,0],[252,3],[40,1,0],[184],[33,6],[32,4],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[32,6],[100],[4,64],[32,6],[33,4],[5],[32,4],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,4],[11],[5],[68,0,0,0,0,0,0,0,0],[33,4],[11],[32,6],[68,0,0,0,0,0,0,240,63],[161],[33,7],[3,64],[32,7],[32,4],[102],[4,64],[32,7],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,8],[43,0,4],[32,8],[45,0,12],[26],[32,2],[97],[4,64],[32,7],[65,0],[15],[11],[32,7],[68,0,0,0,0,0,0,240,63],[161],[33,7],[12,1],[11],[11],[68,0,0,0,0,0,0,240,191],[65,0],[15]],
|
|
250
250
|
params: [124,127,124,127,124,127],
|
|
251
251
|
typedParams: true,
|
|
252
252
|
returns: [124,127],
|
|
253
253
|
typedReturns: true,
|
|
254
|
-
locals: [124,124,127],
|
|
255
|
-
localNames: ["_this","_this#type","searchElement","searchElement#type","position","position#type","len","i","#last_type"],
|
|
254
|
+
locals: [124,124,127,127],
|
|
255
|
+
localNames: ["_this","_this#type","searchElement","searchElement#type","position","position#type","len","i","#loadArray_offset","#last_type"],
|
|
256
256
|
};
|
|
257
257
|
this.__Array_prototype_includes = {
|
|
258
|
-
wasm: (scope, {builtin,}) => [[32,0],[252,3],[40,1,0],[184],[33,6],[32,4],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[32,6],[100],[4,64],[32,6],[33,4],[5],[32,4],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,4],[11],[5],[68,0,0,0,0,0,0,0,0],[33,4],[11],[32,4],[33,7],[3,64],[32,7],[32,6],[99],[4,64],[32,7],[252,3],[65,
|
|
258
|
+
wasm: (scope, {builtin,}) => [[32,0],[252,3],[40,1,0],[184],[33,6],[32,4],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[32,6],[100],[4,64],[32,6],[33,4],[5],[32,4],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,4],[11],[5],[68,0,0,0,0,0,0,0,0],[33,4],[11],[32,4],[33,7],[3,64],[32,7],[32,6],[99],[4,64],[32,7],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,8],[43,0,4],[32,8],[45,0,12],[26],[32,2],[97],[4,64],[68,0,0,0,0,0,0,240,63],[65,1],[15],[11],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,1],[15]],
|
|
259
259
|
params: [124,127,124,127,124,127],
|
|
260
260
|
typedParams: true,
|
|
261
261
|
returns: [124,127],
|
|
262
262
|
typedReturns: true,
|
|
263
|
-
locals: [124,124,127],
|
|
264
|
-
localNames: ["_this","_this#type","searchElement","searchElement#type","position","position#type","len","i","#last_type"],
|
|
263
|
+
locals: [124,124,127,127],
|
|
264
|
+
localNames: ["_this","_this#type","searchElement","searchElement#type","position","position#type","len","i","#loadArray_offset","#last_type"],
|
|
265
265
|
};
|
|
266
266
|
this.__Array_prototype_with = {
|
|
267
|
-
wasm: (scope, {allocPage,builtin,internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,6],[32,2],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,6],[32,2],[160],[34,2],[68,0,0,0,0,0,0,0,0],[99],[4,64],...internalThrow(scope, 'RangeError', `Invalid index`),[11],[11],[32,2],[32,6],[100],[4,64],...internalThrow(scope, 'RangeError', `Invalid index`),[11],...number(allocPage(scope, 'array: __Array_prototype_with/out', 'f64') * pageSize, 124),[34,7],[252,3],[34,8],[65,0],[54,1,0],[32,0],[32,7],[16, builtin('__Porffor_clone')],[32,7],[252,3],[32,2],[252,3],[65,
|
|
267
|
+
wasm: (scope, {allocPage,builtin,internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,6],[32,2],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,6],[32,2],[160],[34,2],[68,0,0,0,0,0,0,0,0],[99],[4,64],...internalThrow(scope, 'RangeError', `Invalid index`),[11],[11],[32,2],[32,6],[100],[4,64],...internalThrow(scope, 'RangeError', `Invalid index`),[11],...number(allocPage(scope, 'array: __Array_prototype_with/out', 'f64') * pageSize, 124),[34,7],[252,3],[34,8],[65,0],[54,1,0],[32,0],[32,7],[16, builtin('__Porffor_clone')],[32,7],[252,3],[32,2],[252,3],[65,9],[108],[106],[32,4],[34,9],[57,0,4],[32,7],[65,16],[15]],
|
|
268
268
|
params: [124,127,124,127,124,127],
|
|
269
269
|
typedParams: true,
|
|
270
270
|
returns: [124,127],
|
|
@@ -273,22 +273,22 @@ export const BuiltinFuncs = function() {
|
|
|
273
273
|
localNames: ["_this","_this#type","index","index#type","value","value#type","len","out","#makearray_pointer_tmp","__member_setter_val_tmp"],
|
|
274
274
|
};
|
|
275
275
|
this.__Array_prototype_reverse = {
|
|
276
|
-
wasm: (scope, {}) => [[32,0],[252,3],[40,1,0],[184],[33,2],[68,0,0,0,0,0,0,0,0],[33,3],[32,2],[68,0,0,0,0,0,0,240,63],[161],[33,4],[3,64],[32,3],[32,4],[99],[4,64],[32,3],[252,3],[65,
|
|
276
|
+
wasm: (scope, {}) => [[32,0],[252,3],[40,1,0],[184],[33,2],[68,0,0,0,0,0,0,0,0],[33,3],[32,2],[68,0,0,0,0,0,0,240,63],[161],[33,4],[3,64],[32,3],[32,4],[99],[4,64],[32,3],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,6],[43,0,4],[32,6],[45,0,12],[26],[33,5],[32,0],[252,3],[32,3],[32,3],[68,0,0,0,0,0,0,240,63],[160],[33,3],[252,3],[65,9],[108],[106],[32,4],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,6],[43,0,4],[32,6],[45,0,12],[26],[34,8],[57,0,4],[32,0],[252,3],[32,4],[32,4],[68,0,0,0,0,0,0,240,63],[161],[33,4],[252,3],[65,9],[108],[106],[32,5],[34,8],[57,0,4],[12,1],[11],[11],[32,0],[65,16],[15]],
|
|
277
277
|
params: [124,127],
|
|
278
278
|
typedParams: true,
|
|
279
279
|
returns: [124,127],
|
|
280
280
|
typedReturns: true,
|
|
281
|
-
locals: [124,124,124,124,127,124],
|
|
282
|
-
localNames: ["_this","_this#type","len","start","end","tmp","#last_type","__member_setter_val_tmp"],
|
|
281
|
+
locals: [124,124,124,124,127,127,124],
|
|
282
|
+
localNames: ["_this","_this#type","len","start","end","tmp","#loadArray_offset","#last_type","__member_setter_val_tmp"],
|
|
283
283
|
};
|
|
284
284
|
this.__Array_prototype_toReversed = {
|
|
285
|
-
wasm: (scope, {allocPage,}) => [[32,0],[252,3],[40,1,0],[184],[33,2],[68,0,0,0,0,0,0,0,0],[33,3],[32,2],[68,0,0,0,0,0,0,240,63],[161],[33,4],...number(allocPage(scope, 'array: __Array_prototype_toReversed/out', 'f64') * pageSize, 124),[34,5],[252,3],[34,6],[65,0],[54,1,0],[32,5],[252,3],[32,2],[34,7],[252,3],[54,1,0],[3,64],[32,3],[32,4],[99],[4,64],[32,5],[252,3],[32,3],[252,3],[65,
|
|
285
|
+
wasm: (scope, {allocPage,}) => [[32,0],[252,3],[40,1,0],[184],[33,2],[68,0,0,0,0,0,0,0,0],[33,3],[32,2],[68,0,0,0,0,0,0,240,63],[161],[33,4],...number(allocPage(scope, 'array: __Array_prototype_toReversed/out', 'f64') * pageSize, 124),[34,5],[252,3],[34,6],[65,0],[54,1,0],[32,5],[252,3],[32,2],[34,7],[252,3],[54,1,0],[3,64],[32,3],[32,4],[99],[4,64],[32,5],[252,3],[32,3],[252,3],[65,9],[108],[106],[32,4],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,9],[43,0,4],[32,9],[45,0,12],[26],[34,8],[57,0,4],[32,5],[252,3],[32,4],[32,4],[68,0,0,0,0,0,0,240,63],[161],[33,4],[252,3],[65,9],[108],[106],[32,3],[32,3],[68,0,0,0,0,0,0,240,63],[160],[33,3],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,9],[43,0,4],[32,9],[45,0,12],[26],[34,8],[57,0,4],[12,1],[11],[11],[32,5],[65,16],[15]],
|
|
286
286
|
params: [124,127],
|
|
287
287
|
typedParams: true,
|
|
288
288
|
returns: [124,127],
|
|
289
289
|
typedReturns: true,
|
|
290
|
-
locals: [124,124,124,124,127,124,124,127],
|
|
291
|
-
localNames: ["_this","_this#type","len","start","end","out","#makearray_pointer_tmp","__length_setter_tmp","__member_setter_val_tmp","#last_type"],
|
|
290
|
+
locals: [124,124,124,124,127,124,124,127,127],
|
|
291
|
+
localNames: ["_this","_this#type","len","start","end","out","#makearray_pointer_tmp","__length_setter_tmp","__member_setter_val_tmp","#loadArray_offset","#last_type"],
|
|
292
292
|
};
|
|
293
293
|
this.__Array_prototype_valueOf = {
|
|
294
294
|
wasm: (scope, {}) => [[32,0],[65,16],[15]],
|
|
@@ -1225,7 +1225,7 @@ export const BuiltinFuncs = function() {
|
|
|
1225
1225
|
locals: [127],
|
|
1226
1226
|
localNames: ["_this","_this#type","index","index#type","value","value#type","offset"],
|
|
1227
1227
|
};
|
|
1228
|
-
this.__Set_prototype_size = {
|
|
1228
|
+
this.__Set_prototype_size$get = {
|
|
1229
1229
|
wasm: (scope, {}) => [[32,0],[252,2],[40,0,0],[183],[65,0],[15]],
|
|
1230
1230
|
params: [124,127],
|
|
1231
1231
|
typedParams: true,
|
|
@@ -1235,13 +1235,13 @@ export const BuiltinFuncs = function() {
|
|
|
1235
1235
|
localNames: ["_this","_this#type"],
|
|
1236
1236
|
};
|
|
1237
1237
|
this.__Set_prototype_values = {
|
|
1238
|
-
wasm: (scope, {builtin,}) => [[32,0],[
|
|
1238
|
+
wasm: (scope, {builtin,}) => [[32,0],[252,2],[40,0,0],[183],[33,2],[16, builtin('__Porffor_allocate')],[33,3],[68,0,0,0,0,0,0,0,0],[33,4],[3,64],[32,4],[32,2],[99],[4,64],[32,0],[65,20],[32,4],[65,0],[16, builtin('__Porffor_set_read')],[33,7],[33,5],[32,7],[33,6],[32,3],[252,3],[34,9],[40,1,0],[34,8],[65,9],[108],[32,9],[106],[34,10],[32,5],[57,0,4],[32,10],[32,6],[58,0,12],[32,9],[32,8],[65,1],[106],[54,1,0],[32,4],[68,0,0,0,0,0,0,240,63],[160],[33,4],[12,1],[11],[11],[32,3],[65,16],[15]],
|
|
1239
1239
|
params: [124,127],
|
|
1240
1240
|
typedParams: true,
|
|
1241
1241
|
returns: [124,127],
|
|
1242
1242
|
typedReturns: true,
|
|
1243
|
-
locals: [124,
|
|
1244
|
-
localNames: ["_this","_this#type","size","
|
|
1243
|
+
locals: [124,124,124,124,127,127,127,127,127],
|
|
1244
|
+
localNames: ["_this","_this#type","size","out","i","val","val#type","#last_type","__proto_length_cache","__proto_pointer_cache","__push_tmp"],
|
|
1245
1245
|
};
|
|
1246
1246
|
this.__Set_prototype_keys = {
|
|
1247
1247
|
wasm: (scope, {builtin,}) => [[32,0],[65,20],[16, builtin('__Set_prototype_values')],[34,2],[15]],
|
|
@@ -1253,31 +1253,31 @@ export const BuiltinFuncs = function() {
|
|
|
1253
1253
|
localNames: ["_this","_this#type","#last_type"],
|
|
1254
1254
|
};
|
|
1255
1255
|
this.__Set_prototype_has = {
|
|
1256
|
-
wasm: (scope, {builtin,}) => [[32,0],[
|
|
1256
|
+
wasm: (scope, {builtin,}) => [[32,0],[252,2],[40,0,0],[183],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[2,64],[2,127,"string_only"],[32,0],[65,20],[32,5],[65,0],[16, builtin('__Porffor_set_read')],[33,6],[34,7,"string_only"],[32,2],[34,8,"string_only"],[32,6,"string_only|start"],[65,2],[70],[32,3],[65,2],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[65,2],[108],[33,13],[3,64],[32,12],[32,9],[106],[47,0,4],[32,12],[32,11],[106],[47,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,2],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11],[32,6],[65,18],[70],[32,3],[65,18],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[33,13],[3,64],[32,12],[32,9],[106],[45,0,4],[32,12],[32,11],[106],[45,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,1],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11,"string_only|end"],[97],[11,"string_only"],[32,6],[32,3],[70],[113],[4,64],[68,0,0,0,0,0,0,240,63],[65,1],[15],[11],[11],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,1],[15]],
|
|
1257
1257
|
params: [124,127,124,127],
|
|
1258
1258
|
typedParams: true,
|
|
1259
1259
|
returns: [124,127],
|
|
1260
1260
|
typedReturns: true,
|
|
1261
|
-
locals: [124,127,124],
|
|
1262
|
-
localNames: ["_this","_this#type","value","value#type","size","#last_type","
|
|
1261
|
+
locals: [124,124,127,124,124,127,127,127,127,127],
|
|
1262
|
+
localNames: ["_this","_this#type","value","value#type","size","i","#last_type","__tmpop_left","__tmpop_right","compare_left_pointer","compare_left_length","compare_right_pointer","compare_index","compare_index_end"],
|
|
1263
1263
|
};
|
|
1264
1264
|
this.__Set_prototype_add = {
|
|
1265
|
-
wasm: (scope, {builtin,}) => [[32,0],[
|
|
1265
|
+
wasm: (scope, {builtin,}) => [[32,0],[252,2],[40,0,0],[183],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[2,64],[2,127,"string_only"],[32,0],[65,20],[32,5],[65,0],[16, builtin('__Porffor_set_read')],[33,6],[34,7,"string_only"],[32,2],[34,8,"string_only"],[32,6,"string_only|start"],[65,2],[70],[32,3],[65,2],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[65,2],[108],[33,13],[3,64],[32,12],[32,9],[106],[47,0,4],[32,12],[32,11],[106],[47,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,2],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11],[32,6],[65,18],[70],[32,3],[65,18],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[33,13],[3,64],[32,12],[32,9],[106],[45,0,4],[32,12],[32,11],[106],[45,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,1],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11,"string_only|end"],[97],[11,"string_only"],[32,6],[32,3],[70],[113],[4,64],[32,0],[65,20],[15],[11],[11],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[12,1],[11],[11],[32,0],[252,2],[32,4],[68,0,0,0,0,0,0,240,63],[160],[252,2],[54,0,0],[32,0],[65,20],[32,4],[65,0],[32,2],[32,3],[16, builtin('__Porffor_set_write')],[26],[32,0],[65,20],[15]],
|
|
1266
1266
|
params: [124,127,124,127],
|
|
1267
1267
|
typedParams: true,
|
|
1268
1268
|
returns: [124,127],
|
|
1269
1269
|
typedReturns: true,
|
|
1270
|
-
locals: [124,127,124],
|
|
1271
|
-
localNames: ["_this","_this#type","value","value#type","size","#last_type","
|
|
1270
|
+
locals: [124,124,127,124,124,127,127,127,127,127],
|
|
1271
|
+
localNames: ["_this","_this#type","value","value#type","size","i","#last_type","__tmpop_left","__tmpop_right","compare_left_pointer","compare_left_length","compare_right_pointer","compare_index","compare_index_end"],
|
|
1272
1272
|
};
|
|
1273
1273
|
this.__Set_prototype_delete = {
|
|
1274
|
-
wasm: (scope, {builtin,}) => [[32,0],[
|
|
1274
|
+
wasm: (scope, {builtin,}) => [[32,0],[252,2],[40,0,0],[183],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[2,64],[2,127,"string_only"],[32,0],[65,20],[32,5],[65,0],[16, builtin('__Porffor_set_read')],[33,6],[34,7,"string_only"],[32,2],[34,8,"string_only"],[32,6,"string_only|start"],[65,2],[70],[32,3],[65,2],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[65,2],[108],[33,13],[3,64],[32,12],[32,9],[106],[47,0,4],[32,12],[32,11],[106],[47,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,2],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11],[32,6],[65,18],[70],[32,3],[65,18],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[33,13],[3,64],[32,12],[32,9],[106],[45,0,4],[32,12],[32,11],[106],[45,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,1],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11,"string_only|end"],[97],[11,"string_only"],[32,6],[32,3],[70],[113],[4,64],[32,0],[252,2],[32,4],[68,0,0,0,0,0,0,240,63],[161],[252,2],[54,0,0],[32,5],[252,3],[65,9],[108],[32,0],[252,3],[106],[65,4],[106],[34,14],[32,14],[65,9],[106],[32,4],[32,5],[161],[252,3],[65,1],[107],[65,9],[108],[252,10,0,0],[68,0,0,0,0,0,0,240,63],[65,1],[15],[11],[11],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,1],[15]],
|
|
1275
1275
|
params: [124,127,124,127],
|
|
1276
1276
|
typedParams: true,
|
|
1277
1277
|
returns: [124,127],
|
|
1278
1278
|
typedReturns: true,
|
|
1279
|
-
locals: [124,127,124,127],
|
|
1280
|
-
localNames: ["_this","_this#type","value","value#type","size","#last_type","
|
|
1279
|
+
locals: [124,124,127,124,124,127,127,127,127,127,127],
|
|
1280
|
+
localNames: ["_this","_this#type","value","value#type","size","i","#last_type","__tmpop_left","__tmpop_right","compare_left_pointer","compare_left_length","compare_right_pointer","compare_index","compare_index_end","offset"],
|
|
1281
1281
|
};
|
|
1282
1282
|
this.__Set_prototype_clear = {
|
|
1283
1283
|
wasm: (scope, {}) => [[32,0],[252,2],[65,0],[54,0,0],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
|
|
@@ -1298,7 +1298,7 @@ export const BuiltinFuncs = function() {
|
|
|
1298
1298
|
localNames: [],
|
|
1299
1299
|
};
|
|
1300
1300
|
this.Set$constructor = {
|
|
1301
|
-
wasm: (scope, {builtin,internalThrow,}) => [[16, builtin('__Porffor_allocate')],[33,2],[32,0],[32,1],[16, builtin('__Porffor_rawType')],[34,3],[68,0,0,0,0,0,0,48,64],[97],[32,3],[68,0,0,0,0,0,0,0,64],[97],[114],[32,3],[68,0,0,0,0,0,0,50,64],[97],[114],[32,3],[68,0,0,0,0,0,0,52,64],[97],[114],[4,64],[32,0],[252,3],[33,4],[65,0],[33,6],[32,4],[40,1,0],[33,5],[32,1],[33,10],[2,64],[32,10],[65,2],[70],[4,64,"TYPESWITCH|String"],[65,2],[33,8],[3,64],[65,0],[32,4],[47,0,4],[59,0,3],[68,0,0,0,0,0,0,240,191],[33,7],[2,64],[32,2],[65,20],[32,7],[32,8],[16, builtin('__Set_prototype_add')],[26],[26],[32,4],[65,2],[106],[33,4],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[12,1],[11],[32,10],[65,16],[70],[4,64,"TYPESWITCH|Array"],[
|
|
1301
|
+
wasm: (scope, {builtin,internalThrow,}) => [[16, builtin('__Porffor_allocate')],[33,2],[32,0],[32,1],[16, builtin('__Porffor_rawType')],[34,3],[68,0,0,0,0,0,0,48,64],[97],[32,3],[68,0,0,0,0,0,0,0,64],[97],[114],[32,3],[68,0,0,0,0,0,0,50,64],[97],[114],[32,3],[68,0,0,0,0,0,0,52,64],[97],[114],[4,64],[32,0],[252,3],[33,4],[65,0],[33,6],[32,4],[40,1,0],[33,5],[32,1],[33,10],[2,64],[32,10],[65,2],[70],[4,64,"TYPESWITCH|String"],[65,2],[33,8],[3,64],[65,0],[32,4],[47,0,4],[59,0,3],[68,0,0,0,0,0,0,240,191],[33,7],[2,64],[32,2],[65,20],[32,7],[32,8],[16, builtin('__Set_prototype_add')],[26],[26],[32,4],[65,2],[106],[33,4],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[12,1],[11],[32,10],[65,16],[70],[4,64,"TYPESWITCH|Array"],[3,64],[32,4],[43,0,4],[32,4],[45,0,12],[33,8],[33,7],[2,64],[32,2],[65,20],[32,7],[32,8],[16, builtin('__Set_prototype_add')],[26],[26],[32,4],[65,9],[106],[33,4],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[12,1],[11],[32,10],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[65,18],[33,8],[3,64],[65,0],[32,4],[32,6],[106],[45,0,4],[58,0,3],[68,0,0,0,0,0,0,240,191],[33,7],[2,64],[32,2],[65,20],[32,7],[32,8],[16, builtin('__Set_prototype_add')],[26],[26],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `Tried for..of on non-iterable type`),[11,"TYPESWITCH_end"],[11],[32,2],[15]],
|
|
1302
1302
|
params: [124,127],
|
|
1303
1303
|
typedParams: true,
|
|
1304
1304
|
returns: [124],
|
|
@@ -1622,4 +1622,49 @@ export const BuiltinFuncs = function() {
|
|
|
1622
1622
|
locals: [],
|
|
1623
1623
|
localNames: ["_this","_this#type"],
|
|
1624
1624
|
};
|
|
1625
|
+
this.__Porffor_symbol_descStore = {
|
|
1626
|
+
wasm: (scope, {allocPage,builtin,}) => [...number(allocPage(scope, 'bytestring: __Porffor_symbol_descStore/ptr', 'i8') * pageSize, 124),[33,4],[32,0],[252,3],[4,64],[32,4],[252,2],[40,0,0],[183],[33,5],[32,4],[252,2],[32,5],[68,0,0,0,0,0,0,240,63],[160],[252,2],[54,0,0],[32,4],[65,18],[32,5],[65,0],[32,2],[32,3],[16, builtin('__Porffor_set_write')],[26],[32,5],[65,0],[15],[5],[32,4],[65,18],[32,2],[32,3],[16, builtin('__Porffor_set_read')],[34,6],[15],[11],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
|
|
1627
|
+
params: [124,127,124,127],
|
|
1628
|
+
typedParams: true,
|
|
1629
|
+
returns: [124,127],
|
|
1630
|
+
typedReturns: true,
|
|
1631
|
+
locals: [124,124,127],
|
|
1632
|
+
localNames: ["op","op#type","value","value#type","ptr","size","#last_type"],
|
|
1633
|
+
};
|
|
1634
|
+
this.Symbol = {
|
|
1635
|
+
wasm: (scope, {builtin,}) => [[68,0,0,0,0,0,0,240,63],[65,1],[32,0],[32,1],[16, builtin('__Porffor_symbol_descStore')],[33,2],[68,0,0,0,0,0,0,240,63],[160],[15]],
|
|
1636
|
+
params: [124,127],
|
|
1637
|
+
typedParams: true,
|
|
1638
|
+
returns: [124],
|
|
1639
|
+
returnType: 6,
|
|
1640
|
+
locals: [127],
|
|
1641
|
+
localNames: ["description","description#type","#last_type"],
|
|
1642
|
+
};
|
|
1643
|
+
this.__Symbol_prototype_description$get = {
|
|
1644
|
+
wasm: (scope, {builtin,}) => [[68,0,0,0,0,0,0,0,0],[65,1],[32,0],[68,0,0,0,0,0,0,240,63],[161],[65,0],[16, builtin('__Porffor_symbol_descStore')],[33,3],[34,2],[65,18],[15]],
|
|
1645
|
+
params: [124,127],
|
|
1646
|
+
typedParams: true,
|
|
1647
|
+
returns: [124,127],
|
|
1648
|
+
typedReturns: true,
|
|
1649
|
+
locals: [124,127],
|
|
1650
|
+
localNames: ["_this","_this#type","description","#last_type"],
|
|
1651
|
+
};
|
|
1652
|
+
this.__Symbol_prototype_toString = {
|
|
1653
|
+
wasm: (scope, {allocPage,builtin,}) => [...number(allocPage(scope, 'bytestring: __Symbol_prototype_toString/out', 'i8') * pageSize, 124),[34,2],[252,2],[65,211,0],[58,0,4],[32,2],[252,2],[65,249,0],[58,0,5],[32,2],[252,2],[65,237,0],[58,0,6],[32,2],[252,2],[65,226,0],[58,0,7],[32,2],[252,2],[65,239,0],[58,0,8],[32,2],[252,2],[65,236,0],[58,0,9],[32,2],[252,2],[65,40],[58,0,10],[68,0,0,0,0,0,0,0,0],[65,1],[32,0],[68,0,0,0,0,0,0,240,63],[161],[65,0],[16, builtin('__Porffor_symbol_descStore')],[33,4],[34,3],[252,3],[40,1,0],[184],[33,5],[32,2],[68,0,0,0,0,0,0,28,64],[160],[33,6],[32,3],[34,7],[32,5],[160],[33,8],[3,64],[32,7],[32,8],[99],[4,64],[32,6],[32,6],[68,0,0,0,0,0,0,240,63],[160],[33,6],[252,2],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[252,2],[45,0,4],[58,0,4],[12,1],[11],[11],[32,2],[32,5],[160],[252,2],[65,41],[58,0,11],[32,2],[252,3],[68,0,0,0,0,0,0,32,64],[32,5],[160],[34,9],[252,3],[54,1,0],[32,2],[65,18],[15]],
|
|
1654
|
+
params: [124,127],
|
|
1655
|
+
typedParams: true,
|
|
1656
|
+
returns: [124,127],
|
|
1657
|
+
typedReturns: true,
|
|
1658
|
+
locals: [124,124,127,124,124,124,124,124],
|
|
1659
|
+
localNames: ["_this","_this#type","out","description","#last_type","descLen","outPtr","descPtr","descPtrEnd","__length_setter_tmp"],
|
|
1660
|
+
};
|
|
1661
|
+
this.__Symbol_prototype_valueOf = {
|
|
1662
|
+
wasm: (scope, {}) => [[32,0],[65,6],[15]],
|
|
1663
|
+
params: [124,127],
|
|
1664
|
+
typedParams: true,
|
|
1665
|
+
returns: [124,127],
|
|
1666
|
+
typedReturns: true,
|
|
1667
|
+
locals: [],
|
|
1668
|
+
localNames: ["_this","_this#type"],
|
|
1669
|
+
};
|
|
1625
1670
|
};
|
package/compiler/index.js
CHANGED
|
@@ -12,14 +12,7 @@ globalThis.decompile = decompile;
|
|
|
12
12
|
const logFuncs = (funcs, globals, exceptions) => {
|
|
13
13
|
console.log('\n' + underline(bold('funcs')));
|
|
14
14
|
|
|
15
|
-
const startIndex = funcs.sort((a, b) => a.index - b.index)[0].index;
|
|
16
15
|
for (const f of funcs) {
|
|
17
|
-
console.log(`${underline(f.name)} (${f.index - startIndex})`);
|
|
18
|
-
|
|
19
|
-
console.log(`params: ${f.params.map((_, i) => Object.keys(f.locals)[Object.values(f.locals).indexOf(Object.values(f.locals).find(x => x.idx === i))]).join(', ')}`);
|
|
20
|
-
console.log(`returns: ${f.returns.length > 0 ? true : false}`);
|
|
21
|
-
console.log(`locals: ${Object.keys(f.locals).sort((a, b) => f.locals[a].idx - f.locals[b].idx).map(x => `${x} (${f.locals[x].idx})`).join(', ')}`);
|
|
22
|
-
console.log();
|
|
23
16
|
console.log(decompile(f.wasm, f.name, f.index, f.locals, f.params, f.returns, funcs, globals, exceptions));
|
|
24
17
|
}
|
|
25
18
|
|
|
@@ -44,12 +37,14 @@ export default (code, flags) => {
|
|
|
44
37
|
opt(funcs, globals, pages, tags, exceptions);
|
|
45
38
|
if (Prefs.profileCompiler) console.log(`3. optimized in ${(performance.now() - t2).toFixed(2)}ms`);
|
|
46
39
|
|
|
47
|
-
if (Prefs.optFuncs) logFuncs(funcs, globals, exceptions);
|
|
40
|
+
// if (Prefs.optFuncs) logFuncs(funcs, globals, exceptions);
|
|
48
41
|
|
|
49
42
|
const t3 = performance.now();
|
|
50
43
|
const wasm = assemble(funcs, globals, tags, pages, data, flags);
|
|
51
44
|
if (Prefs.profileCompiler) console.log(`4. assembled in ${(performance.now() - t3).toFixed(2)}ms`);
|
|
52
45
|
|
|
46
|
+
if (Prefs.optFuncs) logFuncs(funcs, globals, exceptions);
|
|
47
|
+
|
|
53
48
|
if (Prefs.allocLog) {
|
|
54
49
|
const wasmPages = Math.ceil((pages.size * pageSize) / 65536);
|
|
55
50
|
const bytes = wasmPages * 65536;
|
package/compiler/precompile.js
CHANGED
|
@@ -18,7 +18,7 @@ const compile = async (file, [ _funcs, _globals ]) => {
|
|
|
18
18
|
first = source.slice(0, source.indexOf('\n'));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
let args = ['--bytestring', '--todo-time=compile', '--no-
|
|
21
|
+
let args = ['--bytestring', '--todo-time=compile', '--no-indirect-calls', '--no-treeshake-wasm-imports', '--no-rm-unused-types', '--scoped-page-names', '--funsafe-no-unlikely-proto-checks', '--fast-length', '--parse-types', '--opt-types'];
|
|
22
22
|
if (first.startsWith('// @porf')) {
|
|
23
23
|
args = args.concat(first.slice('// @porf '.length).split(' '));
|
|
24
24
|
}
|
package/compiler/prefs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const onByDefault = [ 'bytestring', '
|
|
1
|
+
const onByDefault = [ 'bytestring', 'treeshakeWasmImports', 'alwaysMemory', 'indirectCalls', 'optUnused' ];
|
|
2
2
|
|
|
3
3
|
let cache = {};
|
|
4
4
|
const obj = new Proxy({}, {
|
|
@@ -6,7 +6,7 @@ const obj = new Proxy({}, {
|
|
|
6
6
|
// intentionally misses with undefined values cached
|
|
7
7
|
if (cache[p]) return cache[p];
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const ret = (() => {
|
|
10
10
|
// fooBar -> foo-bar
|
|
11
11
|
const name = p[0] === '_' ? p : p.replace(/[A-Z]/g, c => `-${c.toLowerCase()}`);
|
|
12
12
|
const prefix = name.length === 1 ? '-' : '--';
|
|
@@ -19,6 +19,10 @@ const obj = new Proxy({}, {
|
|
|
19
19
|
if (onByDefault.includes(p)) return true;
|
|
20
20
|
return undefined;
|
|
21
21
|
})();
|
|
22
|
+
|
|
23
|
+
// do not cache in web demo as args are changed live
|
|
24
|
+
if (!globalThis.document) cache[p] = ret;
|
|
25
|
+
return ret;
|
|
22
26
|
}
|
|
23
27
|
});
|
|
24
28
|
|