mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 11:37:35 +00:00
LibWasm: Make the main module's functions addressable by globals
This commit is contained in:
parent
9204a60397
commit
aafef1e92d
1 changed files with 7 additions and 6 deletions
|
@ -162,6 +162,13 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
||||||
auxiliary_instance.globals().append(*ptr);
|
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);
|
BytecodeInterpreter interpreter(m_stack_info);
|
||||||
|
|
||||||
module.for_each_section_of_type<GlobalSection>([&](auto& global_section) {
|
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?
|
// 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) {
|
module.for_each_section_of_type<TableSection>([&](TableSection const& section) {
|
||||||
for (auto& table : section.tables()) {
|
for (auto& table : section.tables()) {
|
||||||
auto table_address = m_store.allocate(table.type());
|
auto table_address = m_store.allocate(table.type());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue