[wasm] Implement pushing of externref parameters on the stack

On x64, reference types where not handled yet in LiftoffAssembler::push.
Note that the values pushed on the stack there do not have to be
handled by a safepoint. The reason is that stack parameters in general
are handled separately from safepoints.

R=thibaudm@chromium.org

Bug: chromium:1168116
Change-Id: Ie62479c13839f0ba240d0e41fa76d07a2cc48881
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2642263
Reviewed-by: Thibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72252}
This commit is contained in:
Andreas Haas 2021-01-21 19:33:12 +01:00 committed by Commit Bot
parent 7d3f3d7fbb
commit 3a8a7e6184
2 changed files with 50 additions and 0 deletions

View File

@ -135,6 +135,8 @@ inline void push(LiftoffAssembler* assm, LiftoffRegister reg, ValueType type) {
switch (type.kind()) {
case ValueType::kI32:
case ValueType::kI64:
case ValueType::kRef:
case ValueType::kOptRef:
assm->pushq(reg.gp());
break;
case ValueType::kF32:

View File

@ -0,0 +1,48 @@
// Copyright 2021 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: --wasm-staging
load('test/mjsunit/wasm/wasm-module-builder.js');
const builder = new WasmModuleBuilder();
builder.addType(makeSig([kWasmF32, kWasmF32, kWasmI32, kWasmI32, kWasmI32, kWasmExternRef, kWasmI32, kWasmI32, kWasmI32, kWasmI32], [kWasmI64]));
// Generate function 1 (out of 2).
builder.addFunction(undefined, 0 /* sig */)
.addBodyWithEnd([
// signature: l_ffiiiniiii
// body:
]);
// Generate function 2 (out of 2).
builder.addFunction(undefined, 0 /* sig */)
.addBodyWithEnd([
// signature: l_ffiiiniiii
// body:
kExprLocalGet, 0x00, // local.get
kExprLocalGet, 0x01, // local.get
kExprLocalGet, 0x02, // local.get
kExprLocalGet, 0x03, // local.get
kExprI32Const, 0x05, // i32.const
kExprLocalGet, 0x05, // local.get
kExprLocalGet, 0x06, // local.get
kExprLocalGet, 0x07, // local.get
kExprI32Const, 0x5b, // i32.const
kExprI32Const, 0x30, // i32.const
kExprCallFunction, 0x01, // call function #1: l_ffiiiniiii
kExprLocalGet, 0x00, // local.get
kExprLocalGet, 0x01, // local.get
kExprLocalGet, 0x02, // local.get
kExprLocalGet, 0x03, // local.get
kExprLocalGet, 0x07, // local.get
kExprLocalGet, 0x05, // local.get
kExprLocalGet, 0x06, // local.get
kExprLocalGet, 0x07, // local.get
kExprI32Const, 0x7f, // i32.const
kExprI64DivS, // i64.div_s
kExprF64Eq, // f64.eq
kExprI32DivU, // i32.div_u
kExprTableGet, 0x7f, // table.get
kExprI64ShrS, // i64.shr_s
]);
assertThrows(function() { builder.instantiate(); }, WebAssembly.CompileError);