mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibWasm: Implement memory.fill instruction
This commit is contained in:
parent
e96c64cdb4
commit
42adba5ad4
Notes:
sideshowbarker
2024-07-17 02:21:14 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/42adba5ad4 Pull-request: https://github.com/SerenityOS/serenity/pull/17218 Reviewed-by: https://github.com/alimpfard ✅
1 changed files with 24 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -615,6 +616,29 @@ void BytecodeInterpreter::interpret(Configuration& configuration, InstructionPoi
|
|||
configuration.stack().peek() = Value((i32)-1);
|
||||
return;
|
||||
}
|
||||
// https://webassembly.github.io/spec/core/bikeshed/#exec-memory-fill
|
||||
case Instructions::memory_fill.value(): {
|
||||
auto address = configuration.frame().module().memories()[0];
|
||||
auto instance = configuration.store().get(address);
|
||||
auto count = configuration.stack().pop().get<Value>().to<i32>().value();
|
||||
auto value = configuration.stack().pop().get<Value>().to<i32>().value();
|
||||
auto destination_offset = configuration.stack().pop().get<Value>().to<i32>().value();
|
||||
|
||||
TRAP_IF_NOT(static_cast<size_t>(destination_offset + count) <= instance->data().size());
|
||||
|
||||
if (count == 0)
|
||||
return;
|
||||
|
||||
Instruction synthetic_store_instruction {
|
||||
Instructions::i32_store8,
|
||||
Instruction::MemoryArgument { 0, 0 }
|
||||
};
|
||||
|
||||
for (auto i = 0; i < count; ++i) {
|
||||
store_to_memory(configuration, synthetic_store_instruction, { &value, sizeof(value) }, destination_offset);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case Instructions::table_get.value():
|
||||
case Instructions::table_set.value():
|
||||
goto unimplemented;
|
||||
|
@ -950,7 +974,6 @@ void BytecodeInterpreter::interpret(Configuration& configuration, InstructionPoi
|
|||
}
|
||||
case Instructions::data_drop.value():
|
||||
case Instructions::memory_copy.value():
|
||||
case Instructions::memory_fill.value():
|
||||
case Instructions::table_init.value():
|
||||
case Instructions::elem_drop.value():
|
||||
case Instructions::table_copy.value():
|
||||
|
|
Loading…
Reference in a new issue