v8/test/message/wasm-trace-liftoff.js
Arnaud Robin 58dea48459 [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/+/2245595
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Commit-Queue: Arnaud Robin <arobin@google.com>
Cr-Commit-Position: refs/heads/master@{#68340}
2020-06-15 11:13:18 +00:00

56 lines
2.4 KiB
JavaScript

// 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-wasm-tier-up --liftoff --no-stress-opt
load('test/mjsunit/wasm/wasm-module-builder.js');
let builder = new WasmModuleBuilder();
let kRet23Function = builder.addFunction('ret_23', kSig_i_v)
.addBody([kExprI32Const, 23])
.exportFunc()
.index;
let kCall23Function = builder.addFunction('call_23', kSig_i_v)
.addBody([kExprCallFunction, kRet23Function])
.exportFunc()
.index;
let kRet57Function = builder.addFunction('ret_57', kSig_l_v)
.addBody([kExprI64Const, 57])
.exportFunc()
.index;
let kUnnamedFunction = builder.addFunction(undefined, kSig_l_v)
.addBody([kExprCallFunction, kRet57Function])
.index;
let kRet0Function = builder.addFunction('ret_0', kSig_f_v)
.addBody(wasmF32Const(0))
.exportFunc()
.index;
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, kCallIdentityFunction, kExprDrop // -
])
.exportAs('main');
let instance = builder.instantiate();
instance.exports.main();