Commit 58dea484 authored by Arnaud Robin's avatar Arnaud Robin Committed by Commit Bot

[wasm] Fix register uses in wasm tracing

The registers were not spilled correctly in liftoff when tracing
function calls, which caused runtime errors.

R=clemensb@chromium.org
CC=thibaudm@chromium.org

Bug: v8:10559
Change-Id: Ic0a9ae8a286bdee8f8440e006d0b47e52241ea5a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2245595Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Arnaud Robin <arobin@google.com>
Cr-Commit-Position: refs/heads/master@{#68340}
parent f30b53bd
......@@ -526,6 +526,7 @@ class LiftoffCompiler {
void TraceFunctionEntry(FullDecoder* decoder) {
DEBUG_CODE_COMMENT("trace function entry");
__ SpillAllRegisters();
source_position_table_builder_.AddPosition(
__ pc_offset(), SourcePosition(decoder->position()), false);
__ CallRuntimeStub(WasmCode::kWasmTraceEnter);
......@@ -1548,7 +1549,6 @@ class LiftoffCompiler {
DEBUG_CODE_COMMENT("trace function exit");
// Before making the runtime call, spill all cache registers.
__ SpillAllRegisters();
LiftoffRegList pinned;
// Get a register to hold the stack slot for the return value.
LiftoffRegister info = pinned.set(__ GetUnusedRegister(kGpReg, pinned));
......
......@@ -30,12 +30,24 @@ let kRet1Function = builder.addFunction('ret_1', kSig_d_v)
.addBody(wasmF64Const(1))
.exportFunc()
.index;
let kIdentityFunction = builder.addFunction('identity', kSig_i_i)
.addBody([kExprLocalGet, 0])
.exportFunc()
.index;
let kCallIdentityFunction = builder.addFunction('call_identity', kSig_i_v)
.addBody([
kExprI32Const, 42, // -
kExprCallFunction, kIdentityFunction // -
])
.exportFunc()
.index;
builder.addFunction('main', kSig_v_v)
.addBody([
kExprCallFunction, kCall23Function, kExprDrop, // -
kExprCallFunction, kUnnamedFunction, kExprDrop, // -
kExprCallFunction, kRet0Function, kExprDrop, // -
kExprCallFunction, kRet1Function, kExprDrop // -
kExprCallFunction, kCall23Function, kExprDrop, // -
kExprCallFunction, kUnnamedFunction, kExprDrop, // -
kExprCallFunction, kRet0Function, kExprDrop, // -
kExprCallFunction, kRet1Function, kExprDrop, // -
kExprCallFunction, kCallIdentityFunction, kExprDrop // -
])
.exportAs('main');
......
1: ~wasm-function[6] "main" {
1: ~wasm-function[8] "main" {
2: ~wasm-function[1] "call_23" {
3: ~wasm-function[0] "ret_23" {
3: } -> 23
......@@ -11,4 +11,8 @@
2: } -> 0.000000
2: ~wasm-function[5] "ret_1" {
2: } -> 1.000000
2: ~wasm-function[7] "call_identity" {
3: ~wasm-function[6] "identity" {
3: } -> 42
2: } -> 42
1: }
1: *wasm-function[6] "main" {
1: *wasm-function[8] "main" {
2: *wasm-function[1] "call_23" {
3: *wasm-function[0] "ret_23" {
3: } -> 23
......@@ -11,4 +11,8 @@
2: } -> 0.000000
2: *wasm-function[5] "ret_1" {
2: } -> 1.000000
2: *wasm-function[7] "call_identity" {
3: *wasm-function[6] "identity" {
3: } -> 42
2: } -> 42
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