mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-05 23:59:53 +00:00
LibWasm: Improve table support
Implements `table.get`, `table.set`, `elem.drop`, `table.size`, and `table.grow`. Also fixes a few issues when generating ref-related spectests. Also changes the `TableInstance` type to use `Vector<Reference>` instead of `Vector<Optional<Reference>>`, because the ability to be null is already encoded in the `Reference` type.
This commit is contained in:
parent
3ca6dfba48
commit
d906255cbb
Notes:
sideshowbarker
2024-07-18 03:35:30 +09:00
Author: https://github.com/dzfrias
Commit: d906255cbb
Pull-request: https://github.com/SerenityOS/serenity/pull/24492
Reviewed-by: https://github.com/alimpfard
6 changed files with 82 additions and 29 deletions
|
@ -34,7 +34,7 @@ Optional<FunctionAddress> Store::allocate(HostFunction&& function)
|
|||
Optional<TableAddress> Store::allocate(TableType const& type)
|
||||
{
|
||||
TableAddress address { m_tables.size() };
|
||||
Vector<Optional<Reference>> elements;
|
||||
Vector<Reference> elements;
|
||||
elements.resize(type.limits().min());
|
||||
m_tables.empend(TableInstance { type, move(elements) });
|
||||
return address;
|
||||
|
@ -252,10 +252,6 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
auto active_ptr = segment.mode.get_pointer<ElementSection::Active>();
|
||||
if (!active_ptr)
|
||||
continue;
|
||||
if (active_ptr->index.value() != 0) {
|
||||
instantiation_result = InstantiationError { "Non-zero table referenced by active element segment" };
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
Configuration config { m_store };
|
||||
if (m_should_limit_instruction_count)
|
||||
config.enable_instruction_count_limit();
|
||||
|
@ -275,11 +271,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
instantiation_result = InstantiationError { "Element section initialisation returned invalid table initial offset" };
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
if (main_module_instance.tables().size() < 1) {
|
||||
instantiation_result = InstantiationError { "Element section initialisation references nonexistent table" };
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
auto table_instance = m_store.get(main_module_instance.tables()[0]);
|
||||
auto table_instance = m_store.get(main_module_instance.tables()[active_ptr->index.value()]);
|
||||
if (current_index >= main_module_instance.elements().size()) {
|
||||
instantiation_result = InstantiationError { "Invalid element referenced by active element segment" };
|
||||
return IterationDecision::Break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue