LibWasm: Make the main module's functions addressable by globals

This commit is contained in:
Ali Mohammad Pur 2023-07-08 13:50:40 +03:30 committed by Andreas Kling
parent 9204a60397
commit aafef1e92d
Notes: sideshowbarker 2024-07-17 02:37:08 +09:00

View file

@ -162,6 +162,13 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
auxiliary_instance.globals().append(*ptr);
}
for (auto& func : module.functions()) {
auto address = m_store.allocate(main_module_instance, func);
VERIFY(address.has_value());
auxiliary_instance.functions().append(*address);
main_module_instance.functions().append(*address);
}
BytecodeInterpreter interpreter(m_stack_info);
module.for_each_section_of_type<GlobalSection>([&](auto& global_section) {
@ -399,12 +406,6 @@ Optional<InstantiationError> AbstractMachine::allocate_all_initial_phase(Module
// FIXME: What if this fails?
for (auto& func : module.functions()) {
auto address = m_store.allocate(module_instance, func);
VERIFY(address.has_value());
module_instance.functions().append(*address);
}
module.for_each_section_of_type<TableSection>([&](TableSection const& section) {
for (auto& table : section.tables()) {
auto table_address = m_store.allocate(table.type());