porffor 0.57.4 → 0.57.5
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.js +28 -0
- package/compiler/codegen.js +1 -1
- package/compiler/wrap.js +2 -8
- package/package.json +1 -1
- package/runtime/index.js +1 -1
package/compiler/builtins.js
CHANGED
@@ -95,6 +95,34 @@ export const BuiltinVars = function(ctx) {
|
|
95
95
|
this.__BigInt64Array_BYTES_PER_ELEMENT = [ number(8) ];
|
96
96
|
this.__BigUint64Array_BYTES_PER_ELEMENT = [ number(8) ];
|
97
97
|
|
98
|
+
// well-known symbols
|
99
|
+
for (const x of [
|
100
|
+
'asyncIterator', 'hasInstance',
|
101
|
+
'isConcatSpreadable', 'iterator',
|
102
|
+
'match', 'matchAll', 'replace',
|
103
|
+
'search', 'species', 'split',
|
104
|
+
'toPrimitive', 'toStringTag', 'unscopables',
|
105
|
+
'dispose', 'asyncDispose'
|
106
|
+
]) {
|
107
|
+
this[`__Symbol_${x}`] = (scope, { glbl, builtin, makeString }) => [
|
108
|
+
[ Opcodes.block, Valtype.f64 ],
|
109
|
+
...glbl(Opcodes.global_get, `#wellknown_${x}`, Valtype.f64),
|
110
|
+
Opcodes.i32_to_u,
|
111
|
+
[ Opcodes.if, Blocktype.void ],
|
112
|
+
...glbl(Opcodes.global_get, `#wellknown_${x}`, Valtype.f64),
|
113
|
+
[ Opcodes.br, 1 ],
|
114
|
+
[ Opcodes.end ],
|
115
|
+
|
116
|
+
...makeString(scope, `Symbol.${x}`),
|
117
|
+
number(TYPES.bytestring, Valtype.i32),
|
118
|
+
[ Opcodes.call, builtin('Symbol') ],
|
119
|
+
...glbl(Opcodes.global_set, `#wellknown_${x}`, Valtype.f64),
|
120
|
+
...glbl(Opcodes.global_get, `#wellknown_${x}`, Valtype.f64),
|
121
|
+
[ Opcodes.end ]
|
122
|
+
];
|
123
|
+
this[`__Symbol_${x}`].type = TYPES.symbol;
|
124
|
+
}
|
125
|
+
|
98
126
|
ObjectBuiltins.call(this, ctx, Prefs);
|
99
127
|
};
|
100
128
|
|
package/compiler/codegen.js
CHANGED
@@ -1280,7 +1280,7 @@ const asmFuncToAsm = (scope, func, extra) => func(scope, {
|
|
1280
1280
|
scope.initedGlobals ??= new Set();
|
1281
1281
|
if (!scope.initedGlobals.has(name)) {
|
1282
1282
|
scope.initedGlobals.add(name);
|
1283
|
-
if (scope.globalInits[name]) out.unshift(
|
1283
|
+
if (scope.globalInits?.[name]) out.unshift(
|
1284
1284
|
[ Opcodes.global_get, globals[globalName + '#glbl_inited'].idx ],
|
1285
1285
|
[ Opcodes.i32_eqz ],
|
1286
1286
|
[ Opcodes.if, Blocktype.void ],
|
package/compiler/wrap.js
CHANGED
@@ -179,14 +179,8 @@ ${flags & 0b0001 ? ` get func idx: ${get}
|
|
179
179
|
}
|
180
180
|
|
181
181
|
case TYPES.symbol: {
|
182
|
-
const
|
183
|
-
|
184
|
-
|
185
|
-
const descStore = page * pageSize;
|
186
|
-
const offset = descStore + 4 + ((value - 1) * 9);
|
187
|
-
|
188
|
-
const v = read(Float64Array, memory, offset, 1)[0];
|
189
|
-
const t = read(Uint8Array, memory, offset + 8, 1)[0];
|
182
|
+
const v = read(Float64Array, memory, value, 1)[0];
|
183
|
+
const t = read(Uint8Array, memory, value + 8, 1)[0];
|
190
184
|
|
191
185
|
const desc = porfToJSValue({ memory, funcs, pages }, v, t);
|
192
186
|
return Symbol(desc);
|
package/package.json
CHANGED