Commit 66faa842 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Use GraphAssembler in TraceMemoryOperation

This is a little cleanup to use the {GraphAssembler} for implementing
{TraceMemoryOperation}. The {GraphAssembler} needs to be extended by a
straight-forward {StackSlot} method.

R=tebbi@chromium.org
CC=arobin@google.com

Bug: v8:10123
Change-Id: Ic872870bfd8609bb09383a0458b5c08fd7586993
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2232556
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68238}
parent 826cf695
......@@ -629,6 +629,11 @@ Node* GraphAssembler::Unreachable() {
graph()->NewNode(common()->Unreachable(), effect(), control()));
}
TNode<RawPtrT> GraphAssembler::StackSlot(int size, int alignment) {
return AddNode<RawPtrT>(
graph()->NewNode(machine()->StackSlot(size, alignment)));
}
Node* GraphAssembler::Store(StoreRepresentation rep, Node* object, Node* offset,
Node* value) {
return AddNode(graph()->NewNode(machine()->Store(rep), object, offset, value,
......
......@@ -313,6 +313,8 @@ class V8_EXPORT_PRIVATE GraphAssembler {
Node* TypeGuard(Type type, Node* value);
Node* Checkpoint(FrameState frame_state);
TNode<RawPtrT> StackSlot(int size, int alignment);
Node* Store(StoreRepresentation rep, Node* object, Node* offset, Node* value);
Node* Store(StoreRepresentation rep, Node* object, int offset, Node* value);
Node* Load(MachineType type, Node* object, Node* offset);
......
......@@ -3622,15 +3622,13 @@ Node* WasmGraphBuilder::TraceMemoryOperation(bool is_store,
Node* index, uint32_t offset,
wasm::WasmCodePosition position) {
int kAlign = 4; // Ensure that the LSB is 0, such that this looks like a Smi.
Node* info = graph()->NewNode(
mcgraph()->machine()->StackSlot(sizeof(wasm::MemoryTracingInfo), kAlign));
TNode<RawPtrT> info =
gasm_->StackSlot(sizeof(wasm::MemoryTracingInfo), kAlign);
Node* address = graph()->NewNode(mcgraph()->machine()->Int32Add(),
Int32Constant(offset), index);
Node* address = gasm_->Int32Add(Int32Constant(offset), index);
auto store = [&](int offset, MachineRepresentation rep, Node* data) {
SetEffect(graph()->NewNode(
mcgraph()->machine()->Store(StoreRepresentation(rep, kNoWriteBarrier)),
info, mcgraph()->Int32Constant(offset), data, effect(), control()));
gasm_->Store(StoreRepresentation(rep, kNoWriteBarrier), info,
gasm_->Int32Constant(offset), data);
};
// Store address, is_store, and mem_rep.
store(offsetof(wasm::MemoryTracingInfo, address),
......@@ -3642,7 +3640,9 @@ Node* WasmGraphBuilder::TraceMemoryOperation(bool is_store,
MachineRepresentation::kWord8,
mcgraph()->Int32Constant(static_cast<int>(rep)));
Node* call = BuildCallToRuntime(Runtime::kWasmTraceMemory, &info, 1);
Node* args[] = {info};
Node* call =
BuildCallToRuntime(Runtime::kWasmTraceMemory, args, arraysize(args));
SetSourcePosition(call, position);
return call;
}
......
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