porffor 0.41.7 → 0.42.1
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 +6 -5
- package/compiler/builtins_precompiled.js +563 -364
- package/compiler/codegen.js +197 -122
- package/compiler/precompile.js +6 -1
- package/compiler/wrap.js +3 -5
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/assemble.js
CHANGED
@@ -121,18 +121,20 @@ export default (funcs, globals, tags, pages, data, noTreeshake = false) => {
|
|
121
121
|
|
122
122
|
const nameSection = Prefs.d ? customSection('name', encodeNames(funcs)) : [];
|
123
123
|
|
124
|
+
const directFuncs = funcs.filter(x => !x.indirect);
|
124
125
|
const tableSection = !funcs.table ? [] : createSection(
|
125
126
|
Section.table,
|
126
|
-
encodeVector([ [ Reftype.funcref, 0x00, ...unsignedLEB128(
|
127
|
+
encodeVector([ [ Reftype.funcref, 0x00, ...unsignedLEB128(directFuncs.length) ] ])
|
127
128
|
);
|
128
129
|
time('table section');
|
129
130
|
|
131
|
+
const emptyWrapperFunc = funcs.find(x => x.name === '#indirect#empty');
|
130
132
|
const elementSection = !funcs.table ? [] : createSection(
|
131
133
|
Section.element,
|
132
134
|
encodeVector([ [
|
133
135
|
0x00,
|
134
136
|
Opcodes.i32_const, 0, Opcodes.end,
|
135
|
-
...encodeVector(
|
137
|
+
...encodeVector(directFuncs.map(x => unsignedLEB128((x.wrapperFunc ?? emptyWrapperFunc ?? x).asmIndex)))
|
136
138
|
] ])
|
137
139
|
);
|
138
140
|
time('element section');
|
@@ -145,8 +147,8 @@ export default (funcs, globals, tags, pages, data, noTreeshake = false) => {
|
|
145
147
|
|
146
148
|
// generate func lut data
|
147
149
|
const bytes = [];
|
148
|
-
for (let i = 0; i <
|
149
|
-
const func =
|
150
|
+
for (let i = 0; i < directFuncs.length; i++) {
|
151
|
+
const func = directFuncs[i];
|
150
152
|
let name = func.name;
|
151
153
|
|
152
154
|
// userland exposed .length
|
@@ -167,7 +169,6 @@ export default (funcs, globals, tags, pages, data, noTreeshake = false) => {
|
|
167
169
|
if (func.constr) flags |= 0b10;
|
168
170
|
bytes.push(flags);
|
169
171
|
|
170
|
-
if (name.startsWith('#indirect_')) name = name.slice(10);
|
171
172
|
if (name.startsWith('#')) name = '';
|
172
173
|
|
173
174
|
// eg: __String_prototype_toLowerCase -> toLowerCase
|