porffor 0.55.14 → 0.55.15
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/README.md +0 -1
- package/compiler/builtins/_internal_object.ts +10 -2
- package/compiler/builtins/number.ts +2 -0
- package/compiler/builtins.js +21 -89
- package/compiler/builtins_objects.js +1 -1
- package/compiler/builtins_precompiled.js +4 -4
- package/compiler/codegen.js +2 -3
- package/compiler/cyclone.js +1 -2
- package/compiler/encoding.js +10 -0
- package/compiler/opt.js +1 -2
- package/compiler/pgo.js +2 -2
- package/compiler/precompile.js +1 -1
- package/compiler/prototype.js +1 -1
- package/compiler/types.js +5 -19
- package/package.json +1 -1
- package/r.cjs +2 -9
- package/rhemyn/compile.js +2 -2
- package/runner/flamegraph.js +1 -1
- package/runner/index.js +1 -1
- package/.fails.cjs +0 -20
- package/all.json +0 -1
- package/compiler/cache.js +0 -44
- package/compiler/embedding.js +0 -11
package/README.md
CHANGED
@@ -108,7 +108,6 @@ Porffor can run Test262 via some hacks/transforms which remove unsupported featu
|
|
108
108
|
- `codegen.js`: code (wasm) generation, ast -> wasm. The bulk of the effort
|
109
109
|
- `cyclone.js`: wasm partial constant evaluator (it is fast and dangerous hence "cyclone")
|
110
110
|
- `disassemble.js`: wasm disassembler using internal debug info
|
111
|
-
- `embedding.js`: utils for embedding consts
|
112
111
|
- `encoding.js`: utils for encoding things as bytes as wasm expects
|
113
112
|
- `expression.js`: mapping most operators to an opcode (advanced are as built-ins eg `f64_%`)
|
114
113
|
- `havoc.js`: wasm rewrite library (it wreaks havoc upon wasm bytecode hence "havoc")
|
@@ -135,11 +135,16 @@ export const __Porffor_object_lookup = (obj: any, target: any): i32 => {
|
|
135
135
|
const size: i32 = Porffor.wasm.i32.load(obj, 0, 0);
|
136
136
|
const endPtr: i32 = ptr + size * 14;
|
137
137
|
|
138
|
+
let out: boolean = false;
|
138
139
|
if (targetType == Porffor.TYPES.symbol) {
|
139
140
|
const targetSym: symbol = target;
|
140
141
|
for (; ptr < endPtr; ptr += 14) {
|
141
142
|
const keyRaw: i32 = Porffor.wasm.i32.load(ptr, 0, 0);
|
142
|
-
if (keyRaw == 0)
|
143
|
+
if (keyRaw == 0) {
|
144
|
+
if (out) break; // ran out of keys
|
145
|
+
out = true;
|
146
|
+
}
|
147
|
+
|
143
148
|
if (keyRaw >>> 30 == 3) { // MSB 1 and 2 set, symbol
|
144
149
|
const keySym: symbol = keyRaw & 0x3FFFFFFF; // unset MSB
|
145
150
|
if (keySym == targetSym) return ptr;
|
@@ -148,7 +153,10 @@ export const __Porffor_object_lookup = (obj: any, target: any): i32 => {
|
|
148
153
|
} else {
|
149
154
|
for (; ptr < endPtr; ptr += 14) {
|
150
155
|
const keyRaw: i32 = Porffor.wasm.i32.load(ptr, 0, 0);
|
151
|
-
if (keyRaw == 0)
|
156
|
+
if (keyRaw == 0) {
|
157
|
+
if (out) break; // ran out of keys
|
158
|
+
out = true;
|
159
|
+
}
|
152
160
|
|
153
161
|
const msb: i32 = keyRaw >>> 30;
|
154
162
|
if (msb == 0) {
|
@@ -559,6 +559,8 @@ export const parseInt = (input: any, radix: any): f64 => {
|
|
559
559
|
|
560
560
|
let defaultRadix: boolean = false;
|
561
561
|
radix = ecma262.ToIntegerOrInfinity(radix);
|
562
|
+
if (!Number.isFinite(radix)) radix = 0; // infinity/NaN -> default
|
563
|
+
|
562
564
|
if (radix == 0) {
|
563
565
|
defaultRadix = true;
|
564
566
|
radix = 10;
|
package/compiler/builtins.js
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
import * as PrecompiledBuiltins from './builtins_precompiled.js';
|
2
2
|
import ObjectBuiltins from './builtins_objects.js';
|
3
3
|
import { Blocktype, Opcodes, Valtype, ValtypeSize } from './wasmSpec.js';
|
4
|
-
import { number } from './embedding.js';
|
5
4
|
import { TYPES, TYPE_NAMES } from './types.js';
|
5
|
+
import { number, unsignedLEB128 } from './encoding.js';
|
6
6
|
import './prefs.js';
|
7
|
-
import { unsignedLEB128 } from './encoding.js';
|
8
7
|
|
9
8
|
export const importedFuncs = [
|
10
9
|
{
|
@@ -230,90 +229,26 @@ export const BuiltinFuncs = function() {
|
|
230
229
|
};
|
231
230
|
|
232
231
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
]
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
[ Opcodes.f64_abs ]
|
254
|
-
]
|
255
|
-
};
|
256
|
-
|
257
|
-
this.__Math_sign = {
|
258
|
-
floatOnly: true,
|
259
|
-
params: [ valtypeBinary ],
|
260
|
-
locals: [],
|
261
|
-
returns: [ valtypeBinary ],
|
262
|
-
returnType: TYPES.number,
|
263
|
-
wasm: [
|
264
|
-
number(1),
|
265
|
-
[ Opcodes.local_get, 0 ],
|
266
|
-
[ Opcodes.f64_copysign ]
|
267
|
-
]
|
268
|
-
};
|
269
|
-
|
270
|
-
this.__Math_floor = {
|
271
|
-
floatOnly: true,
|
272
|
-
params: [ valtypeBinary ],
|
273
|
-
locals: [],
|
274
|
-
returns: [ valtypeBinary ],
|
275
|
-
returnType: TYPES.number,
|
276
|
-
wasm: [
|
277
|
-
[ Opcodes.local_get, 0 ],
|
278
|
-
[ Opcodes.f64_floor ]
|
279
|
-
]
|
280
|
-
};
|
281
|
-
|
282
|
-
this.__Math_ceil = {
|
283
|
-
floatOnly: true,
|
284
|
-
params: [ valtypeBinary ],
|
285
|
-
locals: [],
|
286
|
-
returns: [ valtypeBinary ],
|
287
|
-
returnType: TYPES.number,
|
288
|
-
wasm: [
|
289
|
-
[ Opcodes.local_get, 0 ],
|
290
|
-
[ Opcodes.f64_ceil ]
|
291
|
-
]
|
292
|
-
};
|
293
|
-
|
294
|
-
this.__Math_round = {
|
295
|
-
floatOnly: true,
|
296
|
-
params: [ valtypeBinary ],
|
297
|
-
locals: [],
|
298
|
-
returns: [ valtypeBinary ],
|
299
|
-
returnType: TYPES.number,
|
300
|
-
wasm: [
|
301
|
-
[ Opcodes.local_get, 0 ],
|
302
|
-
[ Opcodes.f64_nearest ]
|
303
|
-
]
|
304
|
-
};
|
305
|
-
|
306
|
-
this.__Math_trunc = {
|
307
|
-
floatOnly: true,
|
308
|
-
params: [ valtypeBinary ],
|
309
|
-
locals: [],
|
310
|
-
returns: [ valtypeBinary ],
|
311
|
-
returnType: TYPES.number,
|
312
|
-
wasm: [
|
313
|
-
[ Opcodes.local_get, 0 ],
|
314
|
-
[ Opcodes.f64_trunc ]
|
315
|
-
]
|
316
|
-
};
|
232
|
+
for (const [ name, op, prefix = [ [ Opcodes.local_get, 0 ] ] ] of [
|
233
|
+
[ 'sqrt', Opcodes.f64_sqrt ],
|
234
|
+
[ 'abs', Opcodes.f64_abs ],
|
235
|
+
[ 'sign', Opcodes.f64_copysign, [ number(1), [ Opcodes.local_get, 0 ] ] ],
|
236
|
+
[ 'floor', Opcodes.f64_floor ],
|
237
|
+
[ 'ceil', Opcodes.f64_ceil ],
|
238
|
+
[ 'round', Opcodes.f64_nearest ],
|
239
|
+
[ 'trunc', Opcodes.f64_trunc ]
|
240
|
+
]) {
|
241
|
+
this[`__Math_${name}`] = {
|
242
|
+
params: [ Valtype.f64 ],
|
243
|
+
locals: [],
|
244
|
+
returns: [ Valtype.f64 ],
|
245
|
+
returnType: TYPES.number,
|
246
|
+
wasm: [
|
247
|
+
...prefix,
|
248
|
+
[ op ]
|
249
|
+
]
|
250
|
+
};
|
251
|
+
}
|
317
252
|
|
318
253
|
// todo: does not follow spec with +-Infinity and values >2**32
|
319
254
|
this.__Math_clz32 = {
|
@@ -359,10 +294,7 @@ export const BuiltinFuncs = function() {
|
|
359
294
|
]
|
360
295
|
};
|
361
296
|
|
362
|
-
// this is an implementation of xorshift128+ (in wasm bytecode)
|
363
|
-
// fun fact: v8, SM, JSC also use this (you will need this fun fact to maintain your sanity reading this code)
|
364
297
|
const prngSeed0 = (Math.random() * (2 ** 30)) | 0, prngSeed1 = (Math.random() * (2 ** 30)) | 0;
|
365
|
-
|
366
298
|
const prng = ({
|
367
299
|
'lcg32': {
|
368
300
|
globals: [ Valtype.i32 ],
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Blocktype, Opcodes, PageSize, Valtype } from './wasmSpec.js';
|
2
2
|
import { TYPES } from './types.js';
|
3
|
-
import { number } from './
|
3
|
+
import { number } from './encoding.js';
|
4
4
|
|
5
5
|
export default function({ builtinFuncs }, Prefs) {
|
6
6
|
const makePrefix = name => (name.startsWith('__') ? '' : '__') + name + '_';
|
@@ -1,5 +1,5 @@
|
|
1
1
|
// autogenerated by compiler/precompile.js
|
2
|
-
import { number } from './
|
2
|
+
import { number } from './encoding.js';
|
3
3
|
|
4
4
|
export const BuiltinFuncs = function() {
|
5
5
|
this.__Porffor_object_underlying = {
|
@@ -56,9 +56,9 @@ params:[127,127],typedParams:1,returns:[127,127],typedReturns:1,
|
|
56
56
|
locals:[127],localNames:["entryPtr","entryPtr#type","out"],
|
57
57
|
}
|
58
58
|
this.__Porffor_object_lookup = {
|
59
|
-
wasm:(_,{t,builtin})=>[[32,0],[69],[4,64],[65,127],[65,1],[15],[26],[11],[32,1],[65,7],[71],[4,64],[32,0],[183],[32,1],[16,builtin('__Porffor_object_underlying')],[33,4],[252,2],[33,0],[32,4],[34,1],[65,7],[71],[4,64],[65,127],[65,1],[15],[26],[11],[11],[32,3],[33,5],[32,0],[65,5],[106],[33,6],[32,0],[40,0,0],[33,7],[32,6],[32,7],[65,14],[108],[106],[33,8],[32,5],[65,5],[70],[4,64],[32,2],[33,
|
59
|
+
wasm:(_,{t,builtin})=>[[32,0],[69],[4,64],[65,127],[65,1],[15],[26],[11],[32,1],[65,7],[71],[4,64],[32,0],[183],[32,1],[16,builtin('__Porffor_object_underlying')],[33,4],[252,2],[33,0],[32,4],[34,1],[65,7],[71],[4,64],[65,127],[65,1],[15],[26],[11],[11],[32,3],[33,5],[32,0],[65,5],[106],[33,6],[32,0],[40,0,0],[33,7],[32,6],[32,7],[65,14],[108],[106],[33,8],[65,0],[33,9],[32,5],[65,5],[70],[4,64],[32,2],[33,10],[3,64],[32,6],[32,8],[72],[4,64],[2,64],[32,6],[40,0,0],[34,11],[69],[4,64],[32,9],[4,64],[12,3],[26],[11],[65,1],[33,9],[11],[32,11],[65,30],[118],[65,3],[70],[4,64],[32,11],[65,255,255,255,255,3],[113],[34,12],[32,10],[70],[4,64],[32,6],[65,1],[15],[26],[11],[11],[11],[32,6],[65,14],[106],[33,6],[12,1],[11],[11],[5],[3,64],[32,6],[32,8],[72],[4,64],[2,64],[32,6],[40,0,0],[34,11],[69],[4,64],[32,9],[4,64],[12,3],[26],[11],[65,1],[33,9],[11],[32,11],[65,30],[118],[34,13],[69],[4,64],[32,11],[34,14],[65,195,1],[32,2],[32,3],[16,builtin('__Porffor_strcmp')],[33,4],[33,15],[32,4],[33,16],[2,127],...t([67,195],()=>[[32,16],[65,195,0],[70],[32,16],[65,195,1],[70],[114],[4,64],[32,15],[40,1,0],[12,1],[11]]),[32,15],[11],[4,64],[32,6],[65,1],[15],[26],[11],[5],[32,13],[65,2],[70],[4,64],[32,11],[65,255,255,255,255,7],[113],[34,14],[65,195,0],[32,2],[32,3],[16,builtin('__Porffor_strcmp')],[33,4],[33,15],[32,4],[33,16],[2,127],...t([67,195],()=>[[32,16],[65,195,0],[70],[32,16],[65,195,1],[70],[114],[4,64],[32,15],[40,1,0],[12,1],[11]]),[32,15],[11],[4,64],[32,6],[65,1],[15],[26],[11],[11],[11],[11],[32,6],[65,14],[106],[33,6],[12,1],[11],[11],[11],[65,127],[65,1],[15]],
|
60
60
|
params:[127,127,127,127],typedParams:1,returns:[127,127],typedReturns:1,
|
61
|
-
locals:[127,127,127,127,127,127,127,127,127,127,127,127],localNames:["obj","obj#type","target","target#type","#last_type","targetType","ptr","size","endPtr","targetSym","keyRaw","keySym","msb","keyStr","#logicinner_tmp","#typeswitch_tmp1"],
|
61
|
+
locals:[127,127,127,127,127,127,127,127,127,127,127,127,127],localNames:["obj","obj#type","target","target#type","#last_type","targetType","ptr","size","endPtr","out","targetSym","keyRaw","keySym","msb","keyStr","#logicinner_tmp","#typeswitch_tmp1"],
|
62
62
|
usedTypes:[5,195,67],
|
63
63
|
}
|
64
64
|
this.__Porffor_object_readValue = {
|
@@ -1981,7 +1981,7 @@ locals:[],localNames:["_this","_this#type"],
|
|
1981
1981
|
usesTag:1,
|
1982
1982
|
}
|
1983
1983
|
this.parseInt = {
|
1984
|
-
wasm:(_,{t,builtin,internalThrow})=>[[32,0],[32,1],[16,builtin('__ecma262_ToString')],[33,4],[33,5],[32,4],[33,6],[32,4],[33,7],[2,124],...t([39],()=>[[32,7],[65,39],[70],[4,64],[32,5],[252,2],[32,6],[16,builtin('__String_prototype_trim')],[33,4],[183],[12,1],[11]]),...t([67],()=>[[32,7],[65,195,0],[70],[4,64],[32,5],[252,2],[32,6],[16,builtin('__String_prototype_trim')],[33,4],[183],[12,1],[11]]),...t([195],()=>[[32,7],[65,195,1],[70],[4,64],[32,5],[252,2],[32,6],[16,builtin('__ByteString_prototype_trim')],[33,4],[183],[12,1],[11]]),...internalThrow(_,'TypeError',`'trim' proto func tried to be called on a type without an impl`),[68,0],[11],[33,0],[32,4],[33,1],[68,0],[33,8],[32,2],[32,3],[16,builtin('__ecma262_ToIntegerOrInfinity')],[34,4],[33,3],[34,2],[68,0],[97],[4,64],[68,1],[33,8],[68,10],[33,2],[65,1],[33,3],[11],[32,2],[68,2],[99],[34,9],[69],[4,127],[32,2],[68,36],[100],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[68,"NaN"],[65,1],[15],[26],[11],[68,58],[33,10],[32,2],[68,10],[99],[4,64],[68,48],[32,2],[160],[33,10],[11],[68,"NaN"],[33,11],[32,0],[34,12],[252,2],[40,0,0],[183],[33,13],[32,12],[33,14],[68,0],[33,15],[32,1],[184],[68,195],[97],[4,64],[32,14],[32,13],[160],[33,16],[32,14],[252,2],[45,0,4],[183],[34,17],[68,43],[97],[4,64],[32,14],[68,1],[160],[33,14],[11],[32,17],[68,45],[97],[4,64],[68,1],[33,15],[32,14],[68,1],[160],[33,14],[11],[32,8],[34,18],[68,0],[97],[4,124],[32,2],[68,16],[97],[184],[65,2],[33,4],[5],[32,18],[65,2],[33,4],[11],[34,18],[33,19],[32,4],[33,7],[2,127],...t([67,195],()=>[[32,7],[65,195,0],[70],[32,7],[65,195,1],[70],[114],[4,64],[32,19],[252,3],[40,1,0],[12,1],[11]]),[32,19],[252,3],[11],[4,124],[32,17],[68,48],[97],[184],[65,2],[33,4],[5],[32,18],[32,4],[33,4],[11],[33,19],[32,4],[33,7],[2,127],...t([67,195],()=>[[32,7],[65,195,0],[70],[32,7],[65,195,1],[70],[114],[4,64],[32,19],[252,3],[40,1,0],[12,1],[11]]),[32,19],[252,3],[11],[4,64],[32,14],[68,1],[160],[252,2],[45,0,4],[183],[34,20],[68,120],[97],[34,9],[69],[4,127],[32,20],[68,88],[97],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,14],[68,2],[160],[33,14],[68,16],[33,2],[65,1],[33,3],[11],[11],[3,64],[32,14],[32,16],[99],[4,64],[32,14],[32,14],[68,1],[160],[33,14],[252,2],[45,0,4],[183],[34,21],[68,48],[102],[34,9],[4,127],[32,21],[32,10],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,48],[161],[33,11],[5],[32,2],[68,10],[100],[4,64],[32,21],[68,97],[102],[34,9],[4,127],[32,21],[68,87],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,87],[161],[33,11],[5],[32,21],[68,65],[102],[34,9],[4,127],[32,21],[68,55],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,55],[161],[33,11],[5],[12,4],[26],[11],[11],[5],[12,2],[26],[11],[11],[12,1],[11],[11],[32,15],[252,3],[4,64],[32,11],[154],[65,1],[15],[26],[11],[32,11],[65,1],[15],[26],[11],[32,14],[32,13],[68,2],[162],[160],[33,16],[32,14],[252,2],[47,0,4],[183],[34,17],[68,43],[97],[4,64],[32,14],[68,2],[160],[33,14],[11],[32,17],[68,45],[97],[4,64],[68,1],[33,15],[32,14],[68,2],[160],[33,14],[11],[32,8],[34,18],[68,0],[97],[4,124],[32,2],[68,16],[97],[184],[65,2],[33,4],[5],[32,18],[65,2],[33,4],[11],[34,18],[33,19],[32,4],[33,7],[2,127],...t([67,195],()=>[[32,7],[65,195,0],[70],[32,7],[65,195,1],[70],[114],[4,64],[32,19],[252,3],[40,1,0],[12,1],[11]]),[32,19],[252,3],[11],[4,124],[32,17],[68,48],[97],[184],[65,2],[33,4],[5],[32,18],[32,4],[33,4],[11],[33,19],[32,4],[33,7],[2,127],...t([67,195],()=>[[32,7],[65,195,0],[70],[32,7],[65,195,1],[70],[114],[4,64],[32,19],[252,3],[40,1,0],[12,1],[11]]),[32,19],[252,3],[11],[4,64],[32,14],[68,2],[160],[252,2],[47,0,4],[183],[34,20],[68,120],[97],[34,9],[69],[4,127],[32,20],[68,88],[97],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,14],[68,4],[160],[33,14],[68,16],[33,2],[65,1],[33,3],[11],[11],[3,64],[32,14],[32,16],[99],[4,64],[32,14],[252,2],[47,0,4],[183],[33,21],[32,14],[68,2],[160],[33,14],[32,21],[68,48],[102],[34,9],[4,127],[32,21],[32,10],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,48],[161],[33,11],[5],[32,2],[68,10],[100],[4,64],[32,21],[68,97],[102],[34,9],[4,127],[32,21],[68,87],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,87],[161],[33,11],[5],[32,21],[68,65],[102],[34,9],[4,127],[32,21],[68,55],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,55],[161],[33,11],[5],[12,4],[26],[11],[11],[5],[12,2],[26],[11],[11],[12,1],[11],[11],[32,15],[252,3],[4,64],[32,11],[154],[65,1],[15],[26],[11],[32,11],[65,1],[15]],
|
1984
|
+
wasm:(_,{t,builtin,internalThrow})=>[[32,0],[32,1],[16,builtin('__ecma262_ToString')],[33,4],[33,5],[32,4],[33,6],[32,4],[33,7],[2,124],...t([39],()=>[[32,7],[65,39],[70],[4,64],[32,5],[252,2],[32,6],[16,builtin('__String_prototype_trim')],[33,4],[183],[12,1],[11]]),...t([67],()=>[[32,7],[65,195,0],[70],[4,64],[32,5],[252,2],[32,6],[16,builtin('__String_prototype_trim')],[33,4],[183],[12,1],[11]]),...t([195],()=>[[32,7],[65,195,1],[70],[4,64],[32,5],[252,2],[32,6],[16,builtin('__ByteString_prototype_trim')],[33,4],[183],[12,1],[11]]),...internalThrow(_,'TypeError',`'trim' proto func tried to be called on a type without an impl`),[68,0],[11],[33,0],[32,4],[33,1],[68,0],[33,8],[32,2],[32,3],[16,builtin('__ecma262_ToIntegerOrInfinity')],[34,4],[33,3],[34,2],[16,builtin('__Number_isFinite')],[68,0],[97],[4,64],[68,0],[33,2],[65,1],[33,3],[11],[32,2],[68,0],[97],[4,64],[68,1],[33,8],[68,10],[33,2],[65,1],[33,3],[11],[32,2],[68,2],[99],[34,9],[69],[4,127],[32,2],[68,36],[100],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[68,"NaN"],[65,1],[15],[26],[11],[68,58],[33,10],[32,2],[68,10],[99],[4,64],[68,48],[32,2],[160],[33,10],[11],[68,"NaN"],[33,11],[32,0],[34,12],[252,2],[40,0,0],[183],[33,13],[32,12],[33,14],[68,0],[33,15],[32,1],[184],[68,195],[97],[4,64],[32,14],[32,13],[160],[33,16],[32,14],[252,2],[45,0,4],[183],[34,17],[68,43],[97],[4,64],[32,14],[68,1],[160],[33,14],[11],[32,17],[68,45],[97],[4,64],[68,1],[33,15],[32,14],[68,1],[160],[33,14],[11],[32,8],[34,18],[68,0],[97],[4,124],[32,2],[68,16],[97],[184],[65,2],[33,4],[5],[32,18],[65,2],[33,4],[11],[34,18],[33,19],[32,4],[33,7],[2,127],...t([67,195],()=>[[32,7],[65,195,0],[70],[32,7],[65,195,1],[70],[114],[4,64],[32,19],[252,3],[40,1,0],[12,1],[11]]),[32,19],[252,3],[11],[4,124],[32,17],[68,48],[97],[184],[65,2],[33,4],[5],[32,18],[32,4],[33,4],[11],[33,19],[32,4],[33,7],[2,127],...t([67,195],()=>[[32,7],[65,195,0],[70],[32,7],[65,195,1],[70],[114],[4,64],[32,19],[252,3],[40,1,0],[12,1],[11]]),[32,19],[252,3],[11],[4,64],[32,14],[68,1],[160],[252,2],[45,0,4],[183],[34,20],[68,120],[97],[34,9],[69],[4,127],[32,20],[68,88],[97],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,14],[68,2],[160],[33,14],[68,16],[33,2],[65,1],[33,3],[11],[11],[3,64],[32,14],[32,16],[99],[4,64],[32,14],[32,14],[68,1],[160],[33,14],[252,2],[45,0,4],[183],[34,21],[68,48],[102],[34,9],[4,127],[32,21],[32,10],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,48],[161],[33,11],[5],[32,2],[68,10],[100],[4,64],[32,21],[68,97],[102],[34,9],[4,127],[32,21],[68,87],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,87],[161],[33,11],[5],[32,21],[68,65],[102],[34,9],[4,127],[32,21],[68,55],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,55],[161],[33,11],[5],[12,4],[26],[11],[11],[5],[12,2],[26],[11],[11],[12,1],[11],[11],[32,15],[252,3],[4,64],[32,11],[154],[65,1],[15],[26],[11],[32,11],[65,1],[15],[26],[11],[32,14],[32,13],[68,2],[162],[160],[33,16],[32,14],[252,2],[47,0,4],[183],[34,17],[68,43],[97],[4,64],[32,14],[68,2],[160],[33,14],[11],[32,17],[68,45],[97],[4,64],[68,1],[33,15],[32,14],[68,2],[160],[33,14],[11],[32,8],[34,18],[68,0],[97],[4,124],[32,2],[68,16],[97],[184],[65,2],[33,4],[5],[32,18],[65,2],[33,4],[11],[34,18],[33,19],[32,4],[33,7],[2,127],...t([67,195],()=>[[32,7],[65,195,0],[70],[32,7],[65,195,1],[70],[114],[4,64],[32,19],[252,3],[40,1,0],[12,1],[11]]),[32,19],[252,3],[11],[4,124],[32,17],[68,48],[97],[184],[65,2],[33,4],[5],[32,18],[32,4],[33,4],[11],[33,19],[32,4],[33,7],[2,127],...t([67,195],()=>[[32,7],[65,195,0],[70],[32,7],[65,195,1],[70],[114],[4,64],[32,19],[252,3],[40,1,0],[12,1],[11]]),[32,19],[252,3],[11],[4,64],[32,14],[68,2],[160],[252,2],[47,0,4],[183],[34,20],[68,120],[97],[34,9],[69],[4,127],[32,20],[68,88],[97],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,14],[68,4],[160],[33,14],[68,16],[33,2],[65,1],[33,3],[11],[11],[3,64],[32,14],[32,16],[99],[4,64],[32,14],[252,2],[47,0,4],[183],[33,21],[32,14],[68,2],[160],[33,14],[32,21],[68,48],[102],[34,9],[4,127],[32,21],[32,10],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,48],[161],[33,11],[5],[32,2],[68,10],[100],[4,64],[32,21],[68,97],[102],[34,9],[4,127],[32,21],[68,87],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,87],[161],[33,11],[5],[32,21],[68,65],[102],[34,9],[4,127],[32,21],[68,55],[32,2],[160],[99],[65,2],[33,4],[5],[32,9],[65,2],[33,4],[11],[4,64],[32,11],[16,builtin('__Number_isNaN')],[252,3],[4,64],[68,0],[33,11],[11],[32,11],[32,2],[162],[32,21],[160],[68,55],[161],[33,11],[5],[12,4],[26],[11],[11],[5],[12,2],[26],[11],[11],[12,1],[11],[11],[32,15],[252,3],[4,64],[32,11],[154],[65,1],[15],[26],[11],[32,11],[65,1],[15]],
|
1985
1985
|
params:[124,127,124,127],typedParams:1,returns:[124,127],typedReturns:1,
|
1986
1986
|
locals:[127,124,127,127,124,127,124,124,124,124,124,124,124,124,124,124,124,124],localNames:["input","input#type","radix","radix#type","#last_type","#proto_target","#proto_target#type","#typeswitch_tmp1","defaultRadix","logictmpi","nMax","n","inputPtr","len","i","negative","endPtr","startChr","logictmp","#logicinner_tmp","second","chr"],
|
1987
1987
|
usesTag:1,
|
package/compiler/codegen.js
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
import { Blocktype, Opcodes, Valtype, ValtypeSize } from './wasmSpec.js';
|
2
|
-
import { ieee754_binary64, signedLEB128, unsignedLEB128, encodeVector, read_signedLEB128 } from './encoding.js';
|
2
|
+
import { number, ieee754_binary64, signedLEB128, unsignedLEB128, encodeVector, read_signedLEB128 } from './encoding.js';
|
3
3
|
import { operatorOpcode } from './expression.js';
|
4
4
|
import { BuiltinFuncs, BuiltinVars, importedFuncs, NULL, UNDEFINED } from './builtins.js';
|
5
5
|
import { PrototypeFuncs } from './prototype.js';
|
6
|
-
import { number } from './embedding.js';
|
7
6
|
import { TYPES, TYPE_FLAGS, TYPE_NAMES, typeHasFlag } from './types.js';
|
8
7
|
import * as Rhemyn from '../rhemyn/compile.js';
|
9
8
|
import parse from './parse.js';
|
10
9
|
import { log } from './log.js';
|
11
|
-
import './prefs.js';
|
12
10
|
import { allocPage, allocStr } from './allocator.js';
|
11
|
+
import './prefs.js';
|
13
12
|
|
14
13
|
let globals = {};
|
15
14
|
let tags = [];
|
package/compiler/cyclone.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
// cyclone: wasm partial constant evaluator (it is fast and dangerous hence "cyclone")
|
2
|
-
import { signedLEB128, ieee754_binary64, read_ieee754_binary64, read_signedLEB128 } from './encoding.js';
|
2
|
+
import { number, signedLEB128, ieee754_binary64, read_ieee754_binary64, read_signedLEB128 } from './encoding.js';
|
3
3
|
import { Opcodes, Valtype } from './wasmSpec.js';
|
4
|
-
import { number } from './embedding.js';
|
5
4
|
|
6
5
|
const f64ToI32Op = {
|
7
6
|
[Opcodes.f64_eq]: Opcodes.i32_eq,
|
package/compiler/encoding.js
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
import { Opcodes, Valtype } from './wasmSpec.js';
|
2
|
+
export const number = (n, valtype = valtypeBinary) => {
|
3
|
+
if (valtype === Valtype.f64) return [ Opcodes.f64_const, n ];
|
4
|
+
|
5
|
+
const out = [ valtype === Valtype.i32 ? Opcodes.i32_const : Opcodes.i64_const ];
|
6
|
+
signedLEB128_into(n, out);
|
7
|
+
|
8
|
+
return out;
|
9
|
+
};
|
10
|
+
|
1
11
|
export const codifyString = str => {
|
2
12
|
let out = [];
|
3
13
|
for (let i = 0; i < str.length; i++) {
|
package/compiler/opt.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { Opcodes, Valtype } from './wasmSpec.js';
|
2
|
-
import { number } from './
|
3
|
-
import { read_signedLEB128, read_ieee754_binary64 } from './encoding.js';
|
2
|
+
import { number, read_signedLEB128, read_ieee754_binary64 } from './encoding.js';
|
4
3
|
import { log } from './log.js';
|
5
4
|
import './prefs.js';
|
6
5
|
|
package/compiler/pgo.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import { Opcodes, Valtype } from './wasmSpec.js';
|
2
|
-
import { number } from './
|
2
|
+
import { number } from './encoding.js';
|
3
3
|
import { importedFuncs } from './builtins.js';
|
4
|
-
import './prefs.js';
|
5
4
|
import assemble from './assemble.js';
|
6
5
|
import wrap, { writeByteStr } from './wrap.js';
|
7
6
|
import * as Havoc from './havoc.js';
|
7
|
+
import './prefs.js';
|
8
8
|
|
9
9
|
export const setup = () => {
|
10
10
|
importedFuncs[importedFuncs.profile2].params = [ Valtype.i32, valtypeBinary ];
|
package/compiler/precompile.js
CHANGED
@@ -216,7 +216,7 @@ const precompile = async () => {
|
|
216
216
|
};
|
217
217
|
|
218
218
|
return `// autogenerated by compiler/precompile.js
|
219
|
-
import { number } from './
|
219
|
+
import { number } from './encoding.js';
|
220
220
|
|
221
221
|
export const BuiltinFuncs = function() {
|
222
222
|
${funcs.map(x => {
|
package/compiler/prototype.js
CHANGED
package/compiler/types.js
CHANGED
@@ -58,15 +58,9 @@ registerInternalType('Map');
|
|
58
58
|
registerInternalType('ArrayBuffer');
|
59
59
|
registerInternalType('SharedArrayBuffer');
|
60
60
|
registerInternalType('DataView');
|
61
|
-
|
62
|
-
|
63
|
-
registerInternalType(
|
64
|
-
registerInternalType('Uint16Array', ['iterable', 'length']);
|
65
|
-
registerInternalType('Int16Array', ['iterable', 'length']);
|
66
|
-
registerInternalType('Uint32Array', ['iterable', 'length']);
|
67
|
-
registerInternalType('Int32Array', ['iterable', 'length']);
|
68
|
-
registerInternalType('Float32Array', ['iterable', 'length']);
|
69
|
-
registerInternalType('Float64Array', ['iterable', 'length']);
|
61
|
+
|
62
|
+
for (const x of [ 'Uint8', 'Int8', 'Uint8Clamped', 'Uint16', 'Int16', 'Uint32', 'Int32', 'Float32', 'Float64' ])
|
63
|
+
registerInternalType(`${x}Array`, ['iterable', 'length']);
|
70
64
|
|
71
65
|
registerInternalType('WeakRef');
|
72
66
|
registerInternalType('WeakSet');
|
@@ -78,16 +72,8 @@ registerInternalType('BooleanObject');
|
|
78
72
|
registerInternalType('NumberObject');
|
79
73
|
registerInternalType('StringObject');
|
80
74
|
|
81
|
-
|
82
|
-
registerInternalType(
|
83
|
-
registerInternalType('TypeError');
|
84
|
-
registerInternalType('ReferenceError');
|
85
|
-
registerInternalType('SyntaxError');
|
86
|
-
registerInternalType('RangeError');
|
87
|
-
registerInternalType('EvalError');
|
88
|
-
registerInternalType('URIError');
|
89
|
-
registerInternalType('Test262Error');
|
90
|
-
registerInternalType('TodoError');
|
75
|
+
for (const x of [ '', 'Aggregate', 'Type', 'Reference', 'Syntax', 'Range', 'Eval', 'URI', 'Test262', 'Todo' ])
|
76
|
+
registerInternalType(`${x}Error`);
|
91
77
|
|
92
78
|
registerInternalType('__Porffor_Generator');
|
93
79
|
registerInternalType('__Porffor_AsyncGenerator');
|
package/package.json
CHANGED
package/r.cjs
CHANGED
@@ -1,13 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
'use strict';
|
4
|
-
console.log(this);
|
5
|
-
eval('console.log(this)');
|
6
|
-
(0, eval)('console.log(this)');
|
7
|
-
eval?.('console.log(this)');
|
8
|
-
}
|
1
|
+
const x = new Date();
|
2
|
+
console.log(x.constructor === Date);
|
9
3
|
|
10
|
-
foo();
|
11
4
|
|
12
5
|
// let o = { set foo(x) { console.log('set foo', x); }, __proto__: { set bar(x) { console.log('set bar', x); } } };
|
13
6
|
|
package/rhemyn/compile.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Blocktype, Opcodes, Valtype, ValtypeSize } from '../compiler/wasmSpec.js';
|
2
|
-
import { number } from '../compiler/
|
2
|
+
import { number } from '../compiler/encoding.js';
|
3
3
|
import parse from './parse.js';
|
4
|
-
import '../compiler/prefs.js';
|
5
4
|
import { TYPES } from '../compiler/types.js';
|
5
|
+
import '../compiler/prefs.js';
|
6
6
|
|
7
7
|
// local indexes
|
8
8
|
const BasePointer = 0; // base string pointer
|
package/runner/flamegraph.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import { Opcodes, Valtype } from '../compiler/wasmSpec.js';
|
3
|
-
import { number } from '../compiler/
|
3
|
+
import { number } from '../compiler/encoding.js';
|
4
4
|
import { importedFuncs } from '../compiler/builtins.js';
|
5
5
|
import compile from '../compiler/wrap.js';
|
6
6
|
import fs from 'node:fs';
|
package/runner/index.js
CHANGED
package/.fails.cjs
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
const all = require('./all.json').map(x => x.slice(21));
|
2
|
-
const { passes } = require('./test262/results.json');
|
3
|
-
const fails = all.filter(x => !passes.includes(x));
|
4
|
-
{
|
5
|
-
const dirs = Object.groupBy(fails, x => x.split('/').slice(0, 2).join('/'));
|
6
|
-
const top = Object.keys(dirs).sort((a, b) => dirs[b].length - dirs[a].length);
|
7
|
-
console.log(top.slice(0, 20).map(x => `${x}: ${dirs[x].length} (${((dirs[x].length / all.length) * 100).toFixed(2)}%)`).join('\n'));
|
8
|
-
}
|
9
|
-
console.log()
|
10
|
-
{
|
11
|
-
const dirs = Object.groupBy(fails, x => x.split('/').slice(0, 3).join('/'));
|
12
|
-
const top = Object.keys(dirs).sort((a, b) => dirs[b].length - dirs[a].length);
|
13
|
-
console.log(top.slice(0, 20).map(x => `${x}: ${dirs[x].length} (${((dirs[x].length / all.length) * 100).toFixed(2)}%)`).join('\n'));
|
14
|
-
}
|
15
|
-
console.log()
|
16
|
-
{
|
17
|
-
const dirs = Object.groupBy(fails, x => x.split('/').slice(0, 4).join('/'));
|
18
|
-
const top = Object.keys(dirs).sort((a, b) => dirs[b].length - dirs[a].length);
|
19
|
-
console.log(top.slice(0, 20).map(x => `${x}: ${dirs[x].length} (${((dirs[x].length / all.length) * 100).toFixed(2)}%)`).join('\n'));
|
20
|
-
}
|