[wasm][liftoff] Support for most externref globals
With this CL we add support for all externref globals except for imported mutable globals. R=thibaudm@chromium.org Bug: v8:7581 Change-Id: I63cb26f8ad6f4b8fc1c276e223c5d45745122ebf Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2396086 Commit-Queue: Andreas Haas <ahaas@chromium.org> Reviewed-by: Thibaud Michaud <thibaudm@chromium.org> Cr-Commit-Position: refs/heads/master@{#69741}
This commit is contained in:
parent
6565eb09c8
commit
e43ec59b4e
@ -659,6 +659,15 @@ void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
|
||||
offset_imm, LoadType::kI32Load, pinned);
|
||||
}
|
||||
|
||||
void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
|
||||
Register offset_reg,
|
||||
int32_t offset_imm,
|
||||
LiftoffRegister src,
|
||||
LiftoffRegList pinned) {
|
||||
STATIC_ASSERT(kTaggedSize == kInt32Size);
|
||||
Store(dst_addr, offset_reg, offset_imm, src, StoreType::kI32Store, pinned);
|
||||
}
|
||||
|
||||
void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
|
||||
Register offset_reg, uint32_t offset_imm,
|
||||
LoadType type, LiftoffRegList pinned,
|
||||
|
@ -338,6 +338,17 @@ void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
|
||||
LoadTaggedPointerField(dst, src_op);
|
||||
}
|
||||
|
||||
void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
|
||||
Register offset_reg,
|
||||
int32_t offset_imm,
|
||||
LiftoffRegister src,
|
||||
LiftoffRegList pinned) {
|
||||
UseScratchRegisterScope temps(this);
|
||||
MemOperand dst_op =
|
||||
liftoff::GetMemOp(this, &temps, dst_addr, offset_reg, offset_imm);
|
||||
StoreTaggedField(src.gp(), dst_op);
|
||||
}
|
||||
|
||||
void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
|
||||
Register offset_reg, uint32_t offset_imm,
|
||||
LoadType type, LiftoffRegList pinned,
|
||||
|
@ -291,6 +291,16 @@ void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
|
||||
static_cast<uint32_t>(offset_imm), LoadType::kI32Load, pinned);
|
||||
}
|
||||
|
||||
void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
|
||||
Register offset_reg,
|
||||
int32_t offset_imm,
|
||||
LiftoffRegister src,
|
||||
LiftoffRegList pinned) {
|
||||
DCHECK_GE(offset_imm, 0);
|
||||
STATIC_ASSERT(kTaggedSize == kInt32Size);
|
||||
Store(dst_addr, offset_reg, offset_imm, src, StoreType::kI32Store, pinned);
|
||||
}
|
||||
|
||||
void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
|
||||
Register offset_reg, uint32_t offset_imm,
|
||||
LoadType type, LiftoffRegList pinned,
|
||||
|
@ -485,6 +485,9 @@ class LiftoffAssembler : public TurboAssembler {
|
||||
inline void LoadTaggedPointer(Register dst, Register src_addr,
|
||||
Register offset_reg, int32_t offset_imm,
|
||||
LiftoffRegList pinned);
|
||||
inline void StoreTaggedPointer(Register dst_addr, Register offset_reg,
|
||||
int32_t offset_imm, LiftoffRegister src,
|
||||
LiftoffRegList pinned);
|
||||
inline void Load(LiftoffRegister dst, Register src_addr, Register offset_reg,
|
||||
uint32_t offset_imm, LoadType type, LiftoffRegList pinned,
|
||||
uint32_t* protected_load_pc = nullptr,
|
||||
|
@ -1813,8 +1813,30 @@ class LiftoffCompiler {
|
||||
void GlobalGet(FullDecoder* decoder, Value* result,
|
||||
const GlobalIndexImmediate<validate>& imm) {
|
||||
const auto* global = &env_->module->globals[imm.index];
|
||||
if (!CheckSupportedType(decoder, kSupportedTypesWithoutRefs, global->type,
|
||||
"global")) {
|
||||
if (!CheckSupportedType(decoder,
|
||||
FLAG_liftoff_extern_ref
|
||||
? kSupportedTypes
|
||||
: kSupportedTypesWithoutRefs,
|
||||
global->type, "global")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (global->type.is_reference_type()) {
|
||||
if (global->mutability && global->imported) {
|
||||
unsupported(decoder, kRefTypes, "imported mutable globals");
|
||||
return;
|
||||
}
|
||||
|
||||
LiftoffRegList pinned;
|
||||
Register globals_buffer =
|
||||
pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
LOAD_TAGGED_PTR_INSTANCE_FIELD(globals_buffer, TaggedGlobalsBuffer);
|
||||
Register value = pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
__ LoadTaggedPointer(value, globals_buffer, no_reg,
|
||||
wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(
|
||||
imm.global->offset),
|
||||
pinned);
|
||||
__ PushRegister(global->type, LiftoffRegister(value));
|
||||
return;
|
||||
}
|
||||
LiftoffRegList pinned;
|
||||
@ -1830,9 +1852,31 @@ class LiftoffCompiler {
|
||||
void GlobalSet(FullDecoder* decoder, const Value& value,
|
||||
const GlobalIndexImmediate<validate>& imm) {
|
||||
auto* global = &env_->module->globals[imm.index];
|
||||
if (!CheckSupportedType(decoder, kSupportedTypesWithoutRefs, global->type,
|
||||
"global"))
|
||||
if (!CheckSupportedType(decoder,
|
||||
FLAG_liftoff_extern_ref
|
||||
? kSupportedTypes
|
||||
: kSupportedTypesWithoutRefs,
|
||||
global->type, "global")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (global->type.is_reference_type()) {
|
||||
if (global->mutability && global->imported) {
|
||||
unsupported(decoder, kRefTypes, "imported mutable globals");
|
||||
return;
|
||||
}
|
||||
|
||||
LiftoffRegList pinned;
|
||||
Register globals_buffer =
|
||||
pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
LOAD_TAGGED_PTR_INSTANCE_FIELD(globals_buffer, TaggedGlobalsBuffer);
|
||||
LiftoffRegister value = pinned.set(__ PopToRegister(pinned));
|
||||
__ StoreTaggedPointer(globals_buffer, no_reg,
|
||||
wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(
|
||||
imm.global->offset),
|
||||
value, pinned);
|
||||
return;
|
||||
}
|
||||
LiftoffRegList pinned;
|
||||
uint32_t offset = 0;
|
||||
Register addr = GetGlobalBaseAndOffset(global, &pinned, &offset);
|
||||
|
@ -391,6 +391,14 @@ void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
|
||||
static_cast<uint32_t>(offset_imm), LoadType::kI32Load, pinned);
|
||||
}
|
||||
|
||||
void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
|
||||
Register offset_reg,
|
||||
int32_t offset_imm,
|
||||
LiftoffRegister src,
|
||||
LiftoffRegList pinned) {
|
||||
bailout(kRefTypes, "GlobalSet");
|
||||
}
|
||||
|
||||
void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
|
||||
Register offset_reg, uint32_t offset_imm,
|
||||
LoadType type, LiftoffRegList pinned,
|
||||
|
@ -355,6 +355,14 @@ void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
|
||||
static_cast<uint32_t>(offset_imm), LoadType::kI64Load, pinned);
|
||||
}
|
||||
|
||||
void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
|
||||
Register offset_reg,
|
||||
int32_t offset_imm,
|
||||
LiftoffRegister src,
|
||||
LiftoffRegList pinned) {
|
||||
bailout(kRefTypes, "GlobalSet");
|
||||
}
|
||||
|
||||
void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
|
||||
Register offset_reg, uint32_t offset_imm,
|
||||
LoadType type, LiftoffRegList pinned,
|
||||
|
@ -119,6 +119,14 @@ void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
|
||||
bailout(kUnsupportedArchitecture, "LoadTaggedPointer");
|
||||
}
|
||||
|
||||
void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
|
||||
Register offset_reg,
|
||||
int32_t offset_imm,
|
||||
LiftoffRegister src,
|
||||
LiftoffRegList pinned) {
|
||||
bailout(kRefTypes, "GlobalSet");
|
||||
}
|
||||
|
||||
void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
|
||||
Register offset_reg, uint32_t offset_imm,
|
||||
LoadType type, LiftoffRegList pinned,
|
||||
|
@ -118,6 +118,14 @@ void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
|
||||
bailout(kUnsupportedArchitecture, "LoadTaggedPointer");
|
||||
}
|
||||
|
||||
void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
|
||||
Register offset_reg,
|
||||
int32_t offset_imm,
|
||||
LiftoffRegister src,
|
||||
LiftoffRegList pinned) {
|
||||
bailout(kRefTypes, "GlobalSet");
|
||||
}
|
||||
|
||||
void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
|
||||
Register offset_reg, uint32_t offset_imm,
|
||||
LoadType type, LiftoffRegList pinned,
|
||||
|
@ -275,6 +275,20 @@ void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
|
||||
LoadTaggedPointerField(dst, src_op);
|
||||
}
|
||||
|
||||
void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
|
||||
Register offset_reg,
|
||||
int32_t offset_imm,
|
||||
LiftoffRegister src,
|
||||
LiftoffRegList pinned) {
|
||||
DCHECK_GE(offset_imm, 0);
|
||||
if (emit_debug_code() && offset_reg != no_reg) {
|
||||
AssertZeroExtended(offset_reg);
|
||||
}
|
||||
Operand dst_op = liftoff::GetMemOp(this, dst_addr, offset_reg,
|
||||
static_cast<uint32_t>(offset_imm));
|
||||
StoreTaggedField(dst_op, src.gp());
|
||||
}
|
||||
|
||||
void LiftoffAssembler::AtomicLoad(LiftoffRegister dst, Register src_addr,
|
||||
Register offset_reg, uint32_t offset_imm,
|
||||
LoadType type, LiftoffRegList pinned) {
|
||||
|
8
test/mjsunit/wasm/externref-globals-liftoff.js
Normal file
8
test/mjsunit/wasm/externref-globals-liftoff.js
Normal file
@ -0,0 +1,8 @@
|
||||
// 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: --experimental-wasm-reftypes --expose-gc --liftoff
|
||||
// Flags: --no-wasm-tier-up --liftoff-extern-ref
|
||||
|
||||
load("test/mjsunit/wasm/externref-globals.js");
|
Loading…
Reference in New Issue
Block a user