Skip to content
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

allow specifying the external memory #7125

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
16 changes: 14 additions & 2 deletions src/passes/Asyncify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1648,14 +1648,26 @@ struct Asyncify : public Pass {
auto propagateAddList = hasArgument("asyncify-propagate-addlist");

// Ensure there is a memory, as we need it.

if (secondaryMemory) {
auto secondaryMemorySizeString =
getArgumentOrDefault("asyncify-secondary-memory-size", "1");
Address secondaryMemorySize = std::stoi(secondaryMemorySizeString);
asyncifyMemory = createSecondaryMemory(module, secondaryMemorySize);
} else {
MemoryUtils::ensureExists(module);
asyncifyMemory = module->memories[0]->name;
if (module->memories.size() == 1) {
MemoryUtils::ensureExists(module);
asyncifyMemory = module->memories[0]->name;
} else {
auto asyncifyMemoryValue =
getArgumentOrDefault("asyncify-memory", "memory");
for (auto& export : module->exports) {
if (export->kind == ExternalKind::Memory &&
export->name == asyncifyMemoryValue) {
asyncifyMemory = export->value;
gkgoat1 marked this conversation as resolved.
Show resolved Hide resolved
}
}
gkgoat1 marked this conversation as resolved.
Show resolved Hide resolved
}
}
pointerType =
module->getMemory(asyncifyMemory)->is64() ? Type::i64 : Type::i32;
Expand Down