mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 12:23:15 +00:00
LibWasm: Make the main module's functions addressable by globals
This commit is contained in:
parent
9204a60397
commit
aafef1e92d
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue