porffor 0.25.9 → 0.27.0
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 +4 -1
- package/compiler/builtins/arraybuffer.ts +6 -2
- package/compiler/builtins.js +1 -1
- package/compiler/builtins_objects.js +2 -2
- package/compiler/builtins_precompiled.js +650 -644
- package/compiler/codegen.js +26 -26
- package/compiler/decompile.js +1 -1
- package/compiler/precompile.js +3 -3
- package/package.json +1 -1
- package/runner/index.js +1 -1
- package/tmp.txt +0 -423
package/compiler/assemble.js
CHANGED
@@ -97,13 +97,16 @@ export default (funcs, globals, tags, pages, data, flags, noTreeshake = false) =
|
|
97
97
|
|
98
98
|
// fix call indexes for non-imports
|
99
99
|
// also fix call_indirect types
|
100
|
+
// also encode call indexes
|
100
101
|
for (const f of funcs) {
|
101
102
|
f.originalIndex = f.index;
|
102
103
|
f.index -= importDelta;
|
103
104
|
|
104
105
|
for (const inst of f.wasm) {
|
105
106
|
if ((inst[0] === Opcodes.call || inst[0] === Opcodes.return_call) && inst[1] >= importedFuncs.length) {
|
106
|
-
inst[1]
|
107
|
+
const idx = inst[1] - importDelta;
|
108
|
+
inst.pop(); // remove idx
|
109
|
+
unsignedLEB128_into(idx, inst); // add unsigned leb128 encoded index to inst
|
107
110
|
}
|
108
111
|
|
109
112
|
if (inst[0] === Opcodes.call_indirect) {
|
@@ -5,6 +5,11 @@ export const __ArrayBuffer_isView = (value: any): boolean => {
|
|
5
5
|
return false;
|
6
6
|
};
|
7
7
|
|
8
|
+
export const __Porffor_arraybuffer_detach = (buffer: any): void => {
|
9
|
+
// mark as detached by setting length = "-1"
|
10
|
+
Porffor.wasm.i32.store(buffer, 4294967295, 0, 0);
|
11
|
+
};
|
12
|
+
|
8
13
|
export const ArrayBuffer = function (length: any): ArrayBuffer {
|
9
14
|
// 1. If NewTarget is undefined, throw a TypeError exception.
|
10
15
|
if (!new.target) throw new TypeError("Constructor ArrayBuffer requires 'new'");
|
@@ -155,8 +160,7 @@ i32.to_u
|
|
155
160
|
|
156
161
|
memory.copy 0 0`;
|
157
162
|
|
158
|
-
|
159
|
-
Porffor.wasm.i32.store(_this, 4294967295, 0, 0);
|
163
|
+
__Porffor_arraybuffer_detach(_this);
|
160
164
|
|
161
165
|
return out;
|
162
166
|
};
|
package/compiler/builtins.js
CHANGED
@@ -190,7 +190,7 @@ export const BuiltinFuncs = function() {
|
|
190
190
|
...number(TYPES.number, Valtype.i32),
|
191
191
|
[ Opcodes.local_get, 1 ],
|
192
192
|
...number(TYPES.number, Valtype.i32),
|
193
|
-
[ Opcodes.call,
|
193
|
+
[ Opcodes.call, builtin('__Math_pow') ],
|
194
194
|
[ Opcodes.drop ],
|
195
195
|
]
|
196
196
|
};
|
@@ -66,7 +66,7 @@ export default function({ builtinFuncs }, Prefs) {
|
|
66
66
|
...number(flags, Valtype.i32),
|
67
67
|
...number(TYPES.number, Valtype.i32),
|
68
68
|
|
69
|
-
[ Opcodes.call,
|
69
|
+
[ Opcodes.call, builtin('__Porffor_object_define') ],
|
70
70
|
[ Opcodes.drop ],
|
71
71
|
[ Opcodes.drop ]
|
72
72
|
);
|
@@ -82,7 +82,7 @@ export default function({ builtinFuncs }, Prefs) {
|
|
82
82
|
|
83
83
|
|
84
84
|
this[name] = (scope, { builtin }) => [
|
85
|
-
[ Opcodes.call,
|
85
|
+
[ Opcodes.call, builtin('#get_' + name) ],
|
86
86
|
Opcodes.i32_from_u
|
87
87
|
];
|
88
88
|
this[name].type = TYPES.object;
|