Skip to content
Closed
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
13 changes: 12 additions & 1 deletion src/passes/ministack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ export class MiniStack extends Pass {
this.managedReturns.add(exportName);
}

/** Reads a cached string, throwing a descriptive error if null. */
private readStringOrThrow(ref: number, context: string): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this method even used?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this was accidental, please ignore!

const result = this.module.readStringCached(ref);
if (result == null) {
throw new Error(`Failed to read string for ${context}`);
}
return result;
}

/** Instruments a function export to also maintain stack depth. */
instrumentFunctionExport(ref: ExportRef): void {
assert(_BinaryenExportGetKind(ref) == ExternalKind.Function);
Expand Down Expand Up @@ -154,8 +163,10 @@ export class MiniStack extends Pass {
_BinaryenAddFunctionExport(module.ref, module.allocStringCached(wrapperName), externalNameRef);
}

/** Runs the pass. Returns `true` if the mini stack has been added. */
/** Runs the pass. Return `true` if mini stack is added. */
run(): bool {
if (!this.validateModule()) return false;

let module = this.module;
let moduleRef = module.ref;
let numExports = _BinaryenGetNumExports(moduleRef);
Expand Down