LibWasm: Remove Module::functions

`Module::functions` created clones of all of the functions in the
module. It provided a _slightly_ better API, but ended up costing around
40ms when instantiating spidermonkey.
This commit is contained in:
Diego Frias
2024-07-27 16:44:36 -07:00
committed by Ali Mohammad Pur
parent 2d95cc01dc
commit dc52998341
8 changed files with 36 additions and 111 deletions

View File

@@ -74,9 +74,13 @@ ErrorOr<void, ValidationError> Validator::validate(Module& module)
return result;
}
module.for_each_section_of_type<FunctionSection>([this, &result](FunctionSection const& section) {
if (result.is_error())
CodeSection const* code_section { nullptr };
module.for_each_section_of_type<CodeSection>([&](auto& section) { code_section = &section; });
module.for_each_section_of_type<FunctionSection>([&](FunctionSection const& section) {
if ((!code_section && !section.types().is_empty()) || (code_section && code_section->functions().size() != section.types().size())) {
result = Errors::invalid("FunctionSection"sv);
return;
}
m_context.functions.ensure_capacity(section.types().size() + m_context.functions.size());
for (auto& index : section.types()) {
if (m_context.types.size() > index.value()) {