mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWasm: Parse struct types and support multiple types in type section
This patch adds support for parsing structs in the type section. It also removes the assumption that all types in the type section are function types, adding appropriate validation. Spec tests struct.3 and struct.4 have been disable as this would require expanding `ValueType` to include more heap-types.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
b5b3e37fac
commit
bfa51c2555
Notes:
github-actions[bot]
2026-02-06 10:35:53 +00:00
Author: https://github.com/mkanilsson Commit: https://github.com/LadybirdBrowser/ladybird/commit/bfa51c2555a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7731 Reviewed-by: https://github.com/alimpfard
@@ -20,7 +20,7 @@ Optional<FunctionAddress> Store::allocate(ModuleInstance& instance, Module const
|
||||
if (type_index.value() >= instance.types().size())
|
||||
return {};
|
||||
|
||||
auto& type = instance.types()[type_index.value()];
|
||||
auto& type = instance.types()[type_index.value()].function();
|
||||
m_functions.empend(WasmFunction { type, instance, module, code });
|
||||
return address;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
||||
|
||||
auto& this_type = module.type_section().types()[type.type().value()];
|
||||
|
||||
if (other_tag_instance->type().parameters() != this_type.parameters())
|
||||
if (other_tag_instance->type().parameters() != this_type.function().parameters())
|
||||
return "Tag import and extern do not match"sv;
|
||||
return {};
|
||||
},
|
||||
@@ -256,7 +256,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
||||
if (!extern_.has<FunctionAddress>())
|
||||
return "Expected function import"sv;
|
||||
auto other_type = m_store.get(extern_.get<FunctionAddress>())->visit([&](WasmFunction const& wasm_func) { return wasm_func.type(); }, [&](HostFunction const& host_func) { return host_func.type(); });
|
||||
auto& type = module.type_section().types()[type_index.value()];
|
||||
auto& type = module.type_section().types()[type_index.value()].function();
|
||||
if (type.results() != other_type.results())
|
||||
return ByteString::formatted("Function import and extern do not match, results: {} vs {}", type.results(), other_type.results());
|
||||
if (type.parameters() != other_type.parameters())
|
||||
@@ -482,7 +482,7 @@ Optional<InstantiationError> AbstractMachine::allocate_all_initial_phase(Module
|
||||
|
||||
for (auto& entry : module.tag_section().tags()) {
|
||||
auto& type = module.type_section().types()[entry.type().value()];
|
||||
auto address = m_store.allocate(type, entry.flags());
|
||||
auto address = m_store.allocate(type.function(), entry.flags());
|
||||
VERIFY(address.has_value());
|
||||
module_instance.tags().append(*address);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user