Skip to content

Use fixed size tables when possible #2189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 9 additions & 1 deletion src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,15 @@ export class Compiler extends DiagnosticEmitter {
for (let i = 0, k = functionTable.length; i < k; ++i) {
functionTableNames[i] = functionTable[i].internalName;
}
module.addFunctionTable("0", tableBase + functionTable.length, Module.UNLIMITED_TABLE, functionTableNames, module.i32(tableBase));
var tableSize = tableBase + functionTable.length;
module.addFunctionTable(
"0",
tableSize,
// use fixed size for non-imported tables
options.importTable ? Module.UNLIMITED_TABLE : tableSize,
functionTableNames,
module.i32(tableBase)
);

// expose the arguments length helper if there are varargs exports
if (this.runtimeFeatures & RuntimeFeatures.setArgumentsLength) {
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/NonNullable.debug.wat
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
(data (i32.const 124) "L\00\00\00\00\00\00\00\00\00\00\00\01\00\00\002\00\00\00A\00r\00r\00a\00y\00<\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00/\00S\00t\00r\00i\00n\00g\00>\00\00\00\00\00\00\00\00\00\00\00")
(data (i32.const 204) "\1c\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00z\00\00\00\00\00\00\00\00\00\00\00")
(data (i32.const 236) "<\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\1e\00\00\00u\00n\00e\00x\00p\00e\00c\00t\00e\00d\00 \00n\00u\00l\00l\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
(table $0 1 funcref)
(table $0 1 1 funcref)
(elem $0 (i32.const 1))
(export "memory" (memory $0))
(start $~start)
Expand Down
Loading