Commit ee96d8bf authored by Arnaud Robin's avatar Arnaud Robin Committed by Commit Bot

[wasm] Add tracing support in turbofan

Added wasm tracing support for turbofan with the flag --trace-wasm.
The test suite was updated accordingly.

R=clemensb@chromium.org

Bug: v8:10559
Change-Id: Ie6ee2a05142081416d8572d4d72dcd315e0bf285
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2235536Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Arnaud Robin <arobin@google.com>
Cr-Commit-Position: refs/heads/master@{#68253}
parent f6f80d65
......@@ -3617,6 +3617,31 @@ const Operator* WasmGraphBuilder::GetSafeStoreOperator(int offset,
return mcgraph()->machine()->UnalignedStore(store_rep);
}
Node* WasmGraphBuilder::TraceFunctionEntry(wasm::WasmCodePosition position) {
Node* call = BuildCallToRuntime(Runtime::kWasmTraceEnter, nullptr, 0);
SetSourcePosition(call, position);
return call;
}
Node* WasmGraphBuilder::TraceFunctionExit(Vector<Node*> vals,
wasm::WasmCodePosition position) {
Node* info = gasm_->IntPtrConstant(0);
size_t num_returns = vals.size();
if (num_returns == 1) {
wasm::ValueType return_type = sig_->GetReturn(0);
MachineRepresentation rep = return_type.machine_representation();
int size = ElementSizeInBytes(rep);
info = gasm_->StackSlot(size, size);
gasm_->Store(StoreRepresentation(rep, kNoWriteBarrier), info,
gasm_->Int32Constant(0), vals[0]);
}
Node* call = BuildCallToRuntime(Runtime::kWasmTraceExit, &info, 1);
SetSourcePosition(call, position);
return call;
}
Node* WasmGraphBuilder::TraceMemoryOperation(bool is_store,
MachineRepresentation rep,
Node* index, uint32_t offset,
......
......@@ -250,6 +250,10 @@ class WasmGraphBuilder {
Node* arr[] = {fst, more...};
return Return(ArrayVector(arr));
}
Node* TraceFunctionEntry(wasm::WasmCodePosition position);
Node* TraceFunctionExit(Vector<Node*> vals, wasm::WasmCodePosition position);
Node* Trap(wasm::TrapReason reason, wasm::WasmCodePosition position);
Node* CallDirect(uint32_t index, Vector<Node*> args, Vector<Node*> rets,
......
......@@ -142,6 +142,8 @@ class WasmGraphBuildingInterface {
}
SetEnv(ssa_env);
LoadContextIntoSsa(ssa_env);
if (FLAG_trace_wasm) BUILD(TraceFunctionEntry, decoder->position());
}
// Reload the instance cache entries into the Ssa Environment.
......@@ -277,6 +279,9 @@ class WasmGraphBuildingInterface {
void DoReturn(FullDecoder* decoder, Vector<Value> values) {
base::SmallVector<TFNode*, 8> nodes(values.size());
GetNodes(nodes.begin(), values);
if (FLAG_trace_wasm) {
BUILD(TraceFunctionExit, VectorOf(nodes), decoder->position());
}
BUILD(Return, VectorOf(nodes));
}
......
......@@ -41,7 +41,7 @@
# TODO(clemensb): Implement on all other platforms (crbug.com/v8/6600).
['arch != x64 and arch != ia32 and arch != arm64 and arch != arm', {
'wasm-trace-memory-liftoff': [SKIP],
'wasm-trace': [SKIP],
'wasm-trace-liftoff': [SKIP],
}], # arch != x64 and arch != ia32 and arch != arm64 and arch != arm
['variant == code_serializer', {
......
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --trace-wasm --no-liftoff --no-stress-opt
load('test/message/wasm-trace-liftoff.js')
1: *wasm-function[6] "main" {
2: *wasm-function[1] "call_23" {
3: *wasm-function[0] "ret_23" {
3: } -> 23
2: } -> 23
2: *wasm-function[3] {
3: *wasm-function[2] "ret_57" {
3: } -> 57
2: } -> 57
2: *wasm-function[4] "ret_0" {
2: } -> 0.000000
2: *wasm-function[5] "ret_1" {
2: } -> 1.000000
1: }
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