[wasm][bulk-memory] Adjust memory.fill to recent spec changes
R=binji@chromium.org Change-Id: I01721c708b1e40cdef4bd48a1f9ca68b31c8f49d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1708470 Reviewed-by: Ben Smith <binji@chromium.org> Commit-Queue: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#62814}
This commit is contained in:
parent
269c279e09
commit
f8047441cf
@ -4842,6 +4842,18 @@ Node* WasmGraphBuilder::MemoryCopy(Node* dst, Node* src, Node* size,
|
||||
|
||||
Node* WasmGraphBuilder::MemoryFill(Node* dst, Node* value, Node* size,
|
||||
wasm::WasmCodePosition position) {
|
||||
auto machine = mcgraph()->machine();
|
||||
auto common = mcgraph()->common();
|
||||
// If size == 0, then memory.copy is a no-op.
|
||||
Node* size_null_check = graph()->NewNode(machine->Word32Equal(), size,
|
||||
mcgraph()->Int32Constant(0));
|
||||
Node* size_null_branch = graph()->NewNode(common->Branch(BranchHint::kFalse),
|
||||
size_null_check, Control());
|
||||
|
||||
Node* size_null_etrue = Effect();
|
||||
Node* size_null_if_false =
|
||||
graph()->NewNode(common->IfFalse(), size_null_branch);
|
||||
SetControl(size_null_if_false);
|
||||
Node* fail = BoundsCheckMemRange(&dst, &size, position);
|
||||
Node* function = graph()->NewNode(mcgraph()->common()->ExternalConstant(
|
||||
ExternalReference::wasm_memory_fill()));
|
||||
@ -4849,7 +4861,15 @@ Node* WasmGraphBuilder::MemoryFill(Node* dst, Node* value, Node* size,
|
||||
MachineType::Uint32()};
|
||||
MachineSignature sig(0, 3, sig_types);
|
||||
BuildCCall(&sig, function, dst, value, size);
|
||||
return TrapIfTrue(wasm::kTrapMemOutOfBounds, fail, position);
|
||||
TrapIfTrue(wasm::kTrapMemOutOfBounds, fail, position);
|
||||
Node* size_null_if_true =
|
||||
graph()->NewNode(common->IfTrue(), size_null_branch);
|
||||
|
||||
Node* merge = SetControl(
|
||||
graph()->NewNode(common->Merge(2), size_null_if_true, Control()));
|
||||
SetEffect(
|
||||
graph()->NewNode(common->EffectPhi(2), size_null_etrue, Effect(), merge));
|
||||
return merge;
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::CheckElemSegmentIsPassiveAndNotDropped(
|
||||
|
@ -1841,14 +1841,17 @@ class ThreadImpl {
|
||||
case kExprMemoryFill: {
|
||||
MemoryIndexImmediate<Decoder::kNoValidate> imm(decoder,
|
||||
code->at(pc + 1));
|
||||
*len += imm.length;
|
||||
auto size = Pop().to<uint32_t>();
|
||||
auto value = Pop().to<uint32_t>();
|
||||
auto dst = Pop().to<uint32_t>();
|
||||
if (size == 0) {
|
||||
return true;
|
||||
}
|
||||
Address dst_addr;
|
||||
bool ok = BoundsCheckMemRange(dst, &size, &dst_addr);
|
||||
memory_fill_wrapper(dst_addr, value, size);
|
||||
if (!ok) DoTrap(kTrapMemOutOfBounds, pc);
|
||||
*len += imm.length;
|
||||
return ok;
|
||||
}
|
||||
case kExprTableInit: {
|
||||
|
@ -323,8 +323,8 @@ WASM_EXEC_TEST(MemoryFillOutOfBounds) {
|
||||
CHECK_EQ(0xDEADBEEF, r.Call(1000, v, kWasmPageSize));
|
||||
CHECK_EQ(0xDEADBEEF, r.Call(kWasmPageSize, v, 1));
|
||||
|
||||
// Fill 0 out-of-bounds fails.
|
||||
CHECK_EQ(0xDEADBEEF, r.Call(kWasmPageSize + 1, v, 0));
|
||||
// Fill 0 out-of-bounds succeeds.
|
||||
CHECK_EQ(0, r.Call(kWasmPageSize + 1, v, 0));
|
||||
|
||||
// Make sure bounds aren't checked with 32-bit wrapping.
|
||||
CHECK_EQ(0xDEADBEEF, r.Call(1, v, 0xFFFFFFFF));
|
||||
|
@ -17,8 +17,6 @@
|
||||
# TODO(ahaas): Incorporate recent changes to the bulk-memory-operations
|
||||
# proposal.
|
||||
'tests/proposals/bulk-memory-operations/elem': [FAIL],
|
||||
'tests/proposals/bulk-memory-operations/memory_fill': [FAIL],
|
||||
'tests/proposals/bulk-memory-operations/bulk': [FAIL],
|
||||
'tests/proposals/bulk-memory-operations/data': [FAIL],
|
||||
}], # ALWAYS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user