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.
@@ -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(funcs.length) ] ])
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(funcs.map(x => unsignedLEB128((x.wrapperFunc ?? x).asmIndex)))
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 < funcs.length; i++) {
149
- const func = funcs[i];
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