diff options
Diffstat (limited to 'src/ir/module-splitting.cpp')
-rw-r--r-- | src/ir/module-splitting.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp index f299d7a35..a7ee96fa2 100644 --- a/src/ir/module-splitting.cpp +++ b/src/ir/module-splitting.cpp @@ -146,12 +146,24 @@ void TableSlotManager::addSlot(Name func, Slot slot) { } TableSlotManager::TableSlotManager(Module& module) : module(module) { - if (module.features.hasReferenceTypes()) { - // Just create a new table to manage all primary-to-secondary calls lazily. - // Do not re-use slots for functions that will already be in existing - // tables, since that is not correct in the face of table mutations. - // TODO: Reduce overhead by creating a separate table for each function type - // if WasmGC is enabled. + // If possible, just create a new table to manage all primary-to-secondary + // calls lazily. Do not re-use slots for functions that will already be in + // existing tables, since that is not correct in the face of table mutations. + // However, do not do this for emscripten; its loader code (and dynamic + // loading in particular) do not support this yet. + // TODO: Reduce overhead by creating a separate table for each function type + // if WasmGC is enabled. + Export* emscriptenTableExport = + module.getExportOrNull("__indirect_function_table"); + Table* singletonTable = + module.tables.size() == 1 ? module.tables[0].get() : nullptr; + bool emscriptenTableImport = + singletonTable && singletonTable->imported() && + singletonTable->module == "env" && + singletonTable->base == "__indirect_function_table"; + + if (module.features.hasReferenceTypes() && !emscriptenTableExport && + !emscriptenTableImport) { return; } |