Commit 3556facb authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm][liftoff] Implement memory.fill

R=clemensb@chromium.org

Bug: v8:10281
Change-Id: I33ca74a1536f4a99478aa1ee42dd7c7a46980f6d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2100999
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66708}
parent 4613f3a2
...@@ -2733,6 +2733,7 @@ class LiftoffCompiler { ...@@ -2733,6 +2733,7 @@ class LiftoffCompiler {
#undef ATOMIC_COMPARE_EXCHANGE_LIST #undef ATOMIC_COMPARE_EXCHANGE_LIST
void AtomicFence(FullDecoder* decoder) { __ AtomicFence(); } void AtomicFence(FullDecoder* decoder) { __ AtomicFence(); }
void MemoryInit(FullDecoder* decoder, void MemoryInit(FullDecoder* decoder,
const MemoryInitImmediate<validate>& imm, const Value&, const MemoryInitImmediate<validate>& imm, const Value&,
const Value&, const Value&) { const Value&, const Value&) {
...@@ -2762,9 +2763,11 @@ class LiftoffCompiler { ...@@ -2762,9 +2763,11 @@ class LiftoffCompiler {
decoder->position(), WasmCode::kThrowWasmTrapMemOutOfBounds); decoder->position(), WasmCode::kThrowWasmTrapMemOutOfBounds);
__ emit_cond_jump(kEqual, trap_label, kWasmI32, result.gp()); __ emit_cond_jump(kEqual, trap_label, kWasmI32, result.gp());
} }
void DataDrop(FullDecoder* decoder, const DataDropImmediate<validate>& imm) { void DataDrop(FullDecoder* decoder, const DataDropImmediate<validate>& imm) {
unsupported(decoder, kBulkMemory, "data.drop"); unsupported(decoder, kBulkMemory, "data.drop");
} }
void MemoryCopy(FullDecoder* decoder, void MemoryCopy(FullDecoder* decoder,
const MemoryCopyImmediate<validate>& imm, const Value&, const MemoryCopyImmediate<validate>& imm, const Value&,
const Value&, const Value&) { const Value&, const Value&) {
...@@ -2787,30 +2790,54 @@ class LiftoffCompiler { ...@@ -2787,30 +2790,54 @@ class LiftoffCompiler {
decoder->position(), WasmCode::kThrowWasmTrapMemOutOfBounds); decoder->position(), WasmCode::kThrowWasmTrapMemOutOfBounds);
__ emit_cond_jump(kEqual, trap_label, kWasmI32, result.gp()); __ emit_cond_jump(kEqual, trap_label, kWasmI32, result.gp());
} }
void MemoryFill(FullDecoder* decoder, void MemoryFill(FullDecoder* decoder,
const MemoryIndexImmediate<validate>& imm, const Value& dst, const MemoryIndexImmediate<validate>& imm, const Value&,
const Value& value, const Value& size) { const Value&, const Value&) {
unsupported(decoder, kBulkMemory, "memory.fill"); LiftoffRegList pinned;
LiftoffRegister size = pinned.set(__ PopToRegister());
LiftoffRegister value = pinned.set(__ PopToRegister(pinned));
LiftoffRegister dst = pinned.set(__ PopToRegister(pinned));
Register instance = pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
__ FillInstanceInto(instance);
ExternalReference ext_ref = ExternalReference::wasm_memory_fill();
ValueType sig_reps[] = {kWasmI32, kPointerValueType, kWasmI32, kWasmI32,
kWasmI32};
FunctionSig sig(1, 4, sig_reps);
LiftoffRegister args[] = {LiftoffRegister(instance), dst, value, size};
// We don't need the instance anymore after the call. We can use the
// register for the result.
LiftoffRegister result(instance);
GenerateCCall(&result, &sig, kWasmStmt, args, ext_ref);
Label* trap_label = AddOutOfLineTrap(
decoder->position(), WasmCode::kThrowWasmTrapMemOutOfBounds);
__ emit_cond_jump(kEqual, trap_label, kWasmI32, result.gp());
} }
void TableInit(FullDecoder* decoder, const TableInitImmediate<validate>& imm, void TableInit(FullDecoder* decoder, const TableInitImmediate<validate>& imm,
Vector<Value> args) { Vector<Value> args) {
unsupported(decoder, kBulkMemory, "table.init"); unsupported(decoder, kBulkMemory, "table.init");
} }
void ElemDrop(FullDecoder* decoder, const ElemDropImmediate<validate>& imm) { void ElemDrop(FullDecoder* decoder, const ElemDropImmediate<validate>& imm) {
unsupported(decoder, kBulkMemory, "elem.drop"); unsupported(decoder, kBulkMemory, "elem.drop");
} }
void TableCopy(FullDecoder* decoder, const TableCopyImmediate<validate>& imm, void TableCopy(FullDecoder* decoder, const TableCopyImmediate<validate>& imm,
Vector<Value> args) { Vector<Value> args) {
unsupported(decoder, kBulkMemory, "table.copy"); unsupported(decoder, kBulkMemory, "table.copy");
} }
void TableGrow(FullDecoder* decoder, const TableIndexImmediate<validate>& imm, void TableGrow(FullDecoder* decoder, const TableIndexImmediate<validate>& imm,
const Value& value, const Value& delta, Value* result) { const Value& value, const Value& delta, Value* result) {
unsupported(decoder, kAnyRef, "table.grow"); unsupported(decoder, kAnyRef, "table.grow");
} }
void TableSize(FullDecoder* decoder, const TableIndexImmediate<validate>& imm, void TableSize(FullDecoder* decoder, const TableIndexImmediate<validate>& imm,
Value* result) { Value* result) {
unsupported(decoder, kAnyRef, "table.size"); unsupported(decoder, kAnyRef, "table.size");
} }
void TableFill(FullDecoder* decoder, const TableIndexImmediate<validate>& imm, void TableFill(FullDecoder* decoder, const TableIndexImmediate<validate>& imm,
const Value& start, const Value& value, const Value& count) { const Value& start, const Value& value, const Value& count) {
unsupported(decoder, kAnyRef, "table.fill"); unsupported(decoder, kAnyRef, "table.fill");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment