Commit 1c507667 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[liftoff] Skip write barrier for storing Smis

There is no need for write barriers if the stored value is known to be a
Smi.

R=thibaudm@chromium.org

Bug: v8:11453
Change-Id: Id1cf306b246686c245d1be5f72c46b54ba9829ca
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2707172Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72903}
parent 77d09fe6
......@@ -720,7 +720,8 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
Register offset_reg,
int32_t offset_imm,
LiftoffRegister src,
LiftoffRegList pinned) {
LiftoffRegList pinned,
SkipWriteBarrier skip_write_barrier) {
STATIC_ASSERT(kTaggedSize == kInt32Size);
Register actual_offset_reg = offset_reg;
if (offset_reg != no_reg && offset_imm != 0) {
......@@ -733,6 +734,9 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
? MemOperand(dst_addr, offset_imm)
: MemOperand(dst_addr, actual_offset_reg);
str(src.gp(), dst_op);
if (skip_write_barrier) return;
// The write barrier.
Label write_barrier;
Label exit;
......
......@@ -444,12 +444,16 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
Register offset_reg,
int32_t offset_imm,
LiftoffRegister src,
LiftoffRegList pinned) {
LiftoffRegList pinned,
SkipWriteBarrier skip_write_barrier) {
// Store the value.
UseScratchRegisterScope temps(this);
MemOperand dst_op =
liftoff::GetMemOp(this, &temps, dst_addr, offset_reg, offset_imm);
StoreTaggedField(src.gp(), dst_op);
if (skip_write_barrier) return;
// The write barrier.
Label write_barrier;
Label exit;
......
......@@ -344,16 +344,19 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
Register offset_reg,
int32_t offset_imm,
LiftoffRegister src,
LiftoffRegList pinned) {
LiftoffRegList pinned,
SkipWriteBarrier skip_write_barrier) {
DCHECK_GE(offset_imm, 0);
DCHECK_LE(offset_imm, std::numeric_limits<int32_t>::max());
STATIC_ASSERT(kTaggedSize == kInt32Size);
Register scratch = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Operand dst_op = offset_reg == no_reg
? Operand(dst_addr, offset_imm)
: Operand(dst_addr, offset_reg, times_1, offset_imm);
mov(dst_op, src.gp());
if (skip_write_barrier) return;
Register scratch = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Label write_barrier;
Label exit;
CheckPageFlag(dst_addr, scratch,
......
......@@ -609,9 +609,14 @@ class LiftoffAssembler : public TurboAssembler {
inline void LoadTaggedPointer(Register dst, Register src_addr,
Register offset_reg, int32_t offset_imm,
LiftoffRegList pinned);
enum SkipWriteBarrier : bool {
kSkipWriteBarrier = true,
kNoSkipWriteBarrier = false
};
inline void StoreTaggedPointer(Register dst_addr, Register offset_reg,
int32_t offset_imm, LiftoffRegister src,
LiftoffRegList pinned);
LiftoffRegList pinned,
SkipWriteBarrier = kNoSkipWriteBarrier);
inline void LoadFixedArrayLengthAsInt32(LiftoffRegister dst, Register array,
LiftoffRegList pinned) {
int offset = FixedArray::kLengthOffset - kHeapObjectTag;
......
......@@ -3570,7 +3570,7 @@ class LiftoffCompiler {
__ StoreTaggedPointer(
values_array, no_reg,
wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(*index_in_array),
tmp_reg, pinned);
tmp_reg, pinned, LiftoffAssembler::kSkipWriteBarrier);
// Get the upper half word into tmp_reg and extend to a Smi.
--*index_in_array;
......@@ -3579,7 +3579,7 @@ class LiftoffCompiler {
__ StoreTaggedPointer(
values_array, no_reg,
wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(*index_in_array),
tmp_reg, pinned);
tmp_reg, pinned, LiftoffAssembler::kSkipWriteBarrier);
}
void StoreExceptionValue(ValueType type, Register values_array,
......@@ -3641,11 +3641,6 @@ class LiftoffCompiler {
}
DCHECK_EQ(0, index);
// Since we need to call another builtin before the final use of the values
// array, put the reference on the stack, such that it survives the builtin
// call.
__ PushRegister(kPointerValueType, values_array);
// Load the exception tag.
DEBUG_CODE_COMMENT("load exception tag");
Register exception_tag =
......@@ -3655,9 +3650,6 @@ class LiftoffCompiler {
exception_tag, exception_tag, no_reg,
wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(imm.index), {});
// Pop the values array reference back into a register.
values_array = __ PopToRegister(pinned);
// Finally, call WasmThrow.
DEBUG_CODE_COMMENT("call WasmThrow builtin");
compiler::CallDescriptor* throw_descriptor =
......
......@@ -335,13 +335,16 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
Register offset_reg,
int32_t offset_imm,
LiftoffRegister src,
LiftoffRegList pinned) {
LiftoffRegList pinned,
SkipWriteBarrier skip_write_barrier) {
DCHECK_GE(offset_imm, 0);
Register scratch = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Operand dst_op = liftoff::GetMemOp(this, dst_addr, offset_reg,
static_cast<uint32_t>(offset_imm));
StoreTaggedField(dst_op, src.gp());
if (skip_write_barrier) return;
Register scratch = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Label write_barrier;
Label exit;
CheckPageFlag(dst_addr, scratch,
......
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