PPC/s390: [liftoff] Cache the instance in a register

Port adf035fb41

Original Commit Message:

    This CL avoids redundant loads of the instance from the frame by caching
    it in a register if possible. This register will be the first one to be
    cleared once we run out of registers (hence it's called a "volatile
    register"). On local tests, this seems to reduce most redundant loads
    within a function, and it also reduces the load for the stack check in
    the function prologue.
    After the stack check, we need to discard the cached instance though,
    since the potential runtime call for the stack check might clobber it.
    This will be addressed in a follow-up CL by re-loading the cached
    instance after the stack check. This is expected to remove another good
    chunk of instance loads, because the instance would initially be
    available in a register when starting the function code.

R=clemensb@chromium.org, midawson@redhat.com, mfarazma@redhat.com
BUG=
LOG=N

Change-Id: I3756ce98d4dfefb44c946a4948f1a6dbe0ce44dd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2698291
Reviewed-by: Milad Fa <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/master@{#72791}
This commit is contained in:
Junliang Yan 2021-02-16 14:25:58 -05:00 committed by Commit Bot
parent 22a683f5f2
commit a9f2bb0bce
2 changed files with 22 additions and 11 deletions

View File

@ -90,11 +90,18 @@ void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
bailout(kUnsupportedArchitecture, "LoadConstant");
}
void LiftoffAssembler::LoadFromInstance(Register dst, int offset, int size) {
void LiftoffAssembler::LoadInstanceFromFrame(Register dst) {
bailout(kUnsupportedArchitecture, "LoadInstanceFromFrame");
}
void LiftoffAssembler::LoadFromInstance(Register dst, Register instance,
int offset, int size) {
bailout(kUnsupportedArchitecture, "LoadFromInstance");
}
void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, int offset) {
void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst,
Register instance,
int offset) {
bailout(kUnsupportedArchitecture, "LoadTaggedPointerFromInstance");
}

View File

@ -92,7 +92,6 @@ inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); }
} // namespace liftoff
int LiftoffAssembler::PrepareStackFrame() {
bailout(kUnsupportedArchitecture, "PrepareStackFrame");
int offset = pc_offset();
lay(sp, MemOperand(sp));
return offset;
@ -174,28 +173,33 @@ void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
}
}
void LiftoffAssembler::LoadFromInstance(Register dst, int offset, int size) {
DCHECK_LE(0, offset);
void LiftoffAssembler::LoadInstanceFromFrame(Register dst) {
LoadU64(dst, liftoff::GetInstanceOperand());
}
void LiftoffAssembler::LoadFromInstance(Register dst, Register instance,
int offset, int size) {
DCHECK_LE(0, offset);
switch (size) {
case 1:
LoadU8(dst, MemOperand(dst, offset));
LoadU8(dst, MemOperand(instance, offset));
break;
case 4:
LoadU32(dst, MemOperand(dst, offset));
LoadU32(dst, MemOperand(instance, offset));
break;
case 8:
LoadU64(dst, MemOperand(dst, offset));
LoadU64(dst, MemOperand(instance, offset));
break;
default:
UNIMPLEMENTED();
}
}
void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, int offset) {
void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst,
Register instance,
int offset) {
DCHECK_LE(0, offset);
LoadU64(dst, liftoff::GetInstanceOperand());
LoadTaggedPointerField(dst, MemOperand(dst, offset));
LoadTaggedPointerField(dst, MemOperand(instance, offset));
}
void LiftoffAssembler::SpillInstance(Register instance) {