Skip to content

Add tableName for indirect calls #2125

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

Merged
merged 1 commit into from
Dec 2, 2021
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/builtins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3288,7 +3288,7 @@ function builtin_call_indirect(ctx: BuiltinContext): ExpressionRef {
paramTypeRefs[i] = compiler.currentType.toRef();
}
compiler.currentType = returnType;
return module.call_indirect(indexArg, operandExprs, createType(paramTypeRefs), returnType.toRef());
return module.call_indirect(null /* TODO */, indexArg, operandExprs, createType(paramTypeRefs), returnType.toRef());
}
builtins.set(BuiltinNames.call_indirect, builtin_call_indirect);

Expand Down
1 change: 1 addition & 0 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7366,6 +7366,7 @@ export class Compiler extends DiagnosticEmitter {
}
if (operands) this.operandsTostack(signature, operands);
var expr = module.call_indirect(
null, // TODO: handle multiple tables
module.load(4, false, functionArg, TypeRef.I32), // ._index
operands,
signature.paramRefs,
Expand Down
7 changes: 4 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1560,13 +1560,14 @@ export class Module {
}

call_indirect(
tableName: string | null,
index: ExpressionRef,
operands: ExpressionRef[] | null,
params: TypeRef,
results: TypeRef,
isReturn: bool = false
): ExpressionRef {
var cStr = this.allocStringCached("0"); // TODO: multiple tables
var cStr = this.allocStringCached(tableName !== null ? tableName : "0");
var cArr = allocPtrArray(operands);
var ret = isReturn
? binaryen._BinaryenReturnCallIndirect(
Expand All @@ -1580,13 +1581,13 @@ export class Module {
}

return_call_indirect(
tableName: string,
tableName: string | null,
index: ExpressionRef,
operands: ExpressionRef[] | null,
params: TypeRef,
results: TypeRef
): ExpressionRef {
return this.call_indirect(index, operands, params, results, true);
return this.call_indirect(tableName, index, operands, params, results, true);
}

unreachable(): ExpressionRef {
Expand Down