Skip to content

Commit 0575a7b

Browse files
committed
refactor
1 parent 1cdee67 commit 0575a7b

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

src/compiler.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -877,15 +877,6 @@ export class Compiler extends DiagnosticEmitter {
877877
}
878878
}
879879

880-
/** Declares the default function table early so an indirect call's effects can be analyzed before it is populated. */
881-
private ensureFunctionTable(): void {
882-
// imported tables are declared by initDefaultTable. only the local default table
883-
// needs to exist early, since effect analysis of an indirect call looks it up
884-
if (!this.options.importTable) {
885-
this.module.ensureFunctionTable(CommonNames.DefaultTable);
886-
}
887-
}
888-
889880
private initDefaultTable(): void {
890881
let options = this.options;
891882
let module = this.module;
@@ -2163,7 +2154,10 @@ export class Compiler extends DiagnosticEmitter {
21632154
if (!memorySegment) {
21642155

21652156
// Add to the function table, declaring it on first use so effect analysis works
2166-
this.ensureFunctionTable();
2157+
if (!this.options.importTable) {
2158+
this.module.ensureFunctionTable(CommonNames.DefaultTable);
2159+
}
2160+
21672161
let functionTable = this.functionTable;
21682162
let tableBase = this.options.tableBase;
21692163
if (!tableBase) tableBase = 1; // leave first elem blank
@@ -7139,13 +7133,11 @@ export class Compiler extends DiagnosticEmitter {
71397133
// provided, so we must set `argumentsLength` in any case. Inject setting it
71407134
// into the index argument, which becomes executed last after any operands.
71417135
let argumentsLength = this.ensureArgumentsLength();
7142-
7143-
71447136
let functionArgWithVararg = module.block(null, [
71457137
module.global_set(argumentsLength, module.i32(numArguments)),
71467138
functionArg
71477139
], sizeTypeRef);
7148-
7140+
71497141
if (operands) this.operandsTostack(signature, operands);
71507142
let expr = module.call_indirect(
71517143
null, // TODO: handle multiple tables

0 commit comments

Comments
 (0)