[loong64][mips][osr] Extract extended OSR checks to BaselineOnStackReplacement builtin
Port f8fddd6b13
v8: 12161
Change-Id: Ied27490a457ff1e4fcc9e80057c5d39c4c5c08cc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3601876
Reviewed-by: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Commit-Queue: Yu Liu <liuyu@loongson.cn>
Auto-Submit: Yu Liu <liuyu@loongson.cn>
Cr-Commit-Position: refs/heads/main@{#80100}
This commit is contained in:
parent
098f722d90
commit
130a3099f2
@ -1797,7 +1797,43 @@ void Generate_OSREntry(MacroAssembler* masm, Register entry_address,
|
||||
__ Ret();
|
||||
}
|
||||
|
||||
void OnStackReplacement(MacroAssembler* masm, bool is_interpreter) {
|
||||
enum class OsrSourceTier {
|
||||
kInterpreter,
|
||||
kBaseline,
|
||||
};
|
||||
|
||||
void OnStackReplacement(MacroAssembler* masm, OsrSourceTier source,
|
||||
Register current_loop_depth,
|
||||
Register encoded_current_bytecode_offset,
|
||||
Register osr_urgency_and_install_target) {
|
||||
static constexpr Register scratch = a3;
|
||||
DCHECK(!AreAliased(scratch, current_loop_depth,
|
||||
encoded_current_bytecode_offset,
|
||||
osr_urgency_and_install_target));
|
||||
// OSR based on urgency, i.e. is the OSR urgency greater than the current
|
||||
// loop depth?
|
||||
Label try_osr;
|
||||
STATIC_ASSERT(BytecodeArray::OsrUrgencyBits::kShift == 0);
|
||||
Register urgency = scratch;
|
||||
__ And(urgency, osr_urgency_and_install_target,
|
||||
BytecodeArray::OsrUrgencyBits::kMask);
|
||||
__ Branch(&try_osr, hi, urgency, Operand(current_loop_depth));
|
||||
|
||||
// OSR based on the install target offset, i.e. does the current bytecode
|
||||
// offset match the install target offset?
|
||||
static constexpr int kMask = BytecodeArray::OsrInstallTargetBits::kMask;
|
||||
Register install_target = osr_urgency_and_install_target;
|
||||
__ And(install_target, osr_urgency_and_install_target, Operand(kMask));
|
||||
__ Branch(&try_osr, eq, install_target,
|
||||
Operand(encoded_current_bytecode_offset));
|
||||
|
||||
// Neither urgency nor the install target triggered, return to the caller.
|
||||
// Note: the return value must be nullptr or a valid Code object.
|
||||
__ Move(a0, zero_reg);
|
||||
__ Ret();
|
||||
|
||||
__ bind(&try_osr);
|
||||
|
||||
{
|
||||
FrameScope scope(masm, StackFrame::INTERNAL);
|
||||
__ CallRuntime(Runtime::kCompileOptimizedOSR);
|
||||
@ -1806,7 +1842,7 @@ void OnStackReplacement(MacroAssembler* masm, bool is_interpreter) {
|
||||
// If the code object is null, just return to the caller.
|
||||
__ Ret(eq, a0, Operand(Smi::zero()));
|
||||
|
||||
if (is_interpreter) {
|
||||
if (source == OsrSourceTier::kInterpreter) {
|
||||
// Drop the handler frame that is be sitting on top of the actual
|
||||
// JavaScript frame. This is the case then OSR is triggered from bytecode.
|
||||
__ LeaveFrame(StackFrame::STUB);
|
||||
@ -1831,13 +1867,24 @@ void OnStackReplacement(MacroAssembler* masm, bool is_interpreter) {
|
||||
} // namespace
|
||||
|
||||
void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
|
||||
return OnStackReplacement(masm, true);
|
||||
using D = InterpreterOnStackReplacementDescriptor;
|
||||
STATIC_ASSERT(D::kParameterCount == 3);
|
||||
OnStackReplacement(masm, OsrSourceTier::kInterpreter,
|
||||
D::CurrentLoopDepthRegister(),
|
||||
D::EncodedCurrentBytecodeOffsetRegister(),
|
||||
D::OsrUrgencyAndInstallTargetRegister());
|
||||
}
|
||||
|
||||
void Builtins::Generate_BaselineOnStackReplacement(MacroAssembler* masm) {
|
||||
using D = BaselineOnStackReplacementDescriptor;
|
||||
STATIC_ASSERT(D::kParameterCount == 3);
|
||||
|
||||
__ Ld_d(kContextRegister,
|
||||
MemOperand(fp, StandardFrameConstants::kContextOffset));
|
||||
return OnStackReplacement(masm, false);
|
||||
OnStackReplacement(masm, OsrSourceTier::kBaseline,
|
||||
D::CurrentLoopDepthRegister(),
|
||||
D::EncodedCurrentBytecodeOffsetRegister(),
|
||||
D::OsrUrgencyAndInstallTargetRegister());
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1789,7 +1789,43 @@ void Generate_OSREntry(MacroAssembler* masm, Register entry_address,
|
||||
__ Ret();
|
||||
}
|
||||
|
||||
void OnStackReplacement(MacroAssembler* masm, bool is_interpreter) {
|
||||
enum class OsrSourceTier {
|
||||
kInterpreter,
|
||||
kBaseline,
|
||||
};
|
||||
|
||||
void OnStackReplacement(MacroAssembler* masm, OsrSourceTier source,
|
||||
Register current_loop_depth,
|
||||
Register encoded_current_bytecode_offset,
|
||||
Register osr_urgency_and_install_target) {
|
||||
static constexpr Register scratch = a3;
|
||||
DCHECK(!AreAliased(scratch, current_loop_depth,
|
||||
encoded_current_bytecode_offset,
|
||||
osr_urgency_and_install_target));
|
||||
// OSR based on urgency, i.e. is the OSR urgency greater than the current
|
||||
// loop depth?
|
||||
Label try_osr;
|
||||
STATIC_ASSERT(BytecodeArray::OsrUrgencyBits::kShift == 0);
|
||||
Register urgency = scratch;
|
||||
__ And(urgency, osr_urgency_and_install_target,
|
||||
BytecodeArray::OsrUrgencyBits::kMask);
|
||||
__ Branch(&try_osr, hi, urgency, Operand(current_loop_depth));
|
||||
|
||||
// OSR based on the install target offset, i.e. does the current bytecode
|
||||
// offset match the install target offset?
|
||||
static constexpr int kMask = BytecodeArray::OsrInstallTargetBits::kMask;
|
||||
Register install_target = osr_urgency_and_install_target;
|
||||
__ And(install_target, osr_urgency_and_install_target, Operand(kMask));
|
||||
__ Branch(&try_osr, eq, install_target,
|
||||
Operand(encoded_current_bytecode_offset));
|
||||
|
||||
// Neither urgency nor the install target triggered, return to the caller.
|
||||
// Note: the return value must be nullptr or a valid Code object.
|
||||
__ Move(v0, zero_reg);
|
||||
__ Ret();
|
||||
|
||||
__ bind(&try_osr);
|
||||
|
||||
{
|
||||
FrameScope scope(masm, StackFrame::INTERNAL);
|
||||
__ CallRuntime(Runtime::kCompileOptimizedOSR);
|
||||
@ -1798,7 +1834,7 @@ void OnStackReplacement(MacroAssembler* masm, bool is_interpreter) {
|
||||
// If the code object is null, just return to the caller.
|
||||
__ Ret(eq, v0, Operand(Smi::zero()));
|
||||
|
||||
if (is_interpreter) {
|
||||
if (source == OsrSourceTier::kInterpreter) {
|
||||
// Drop the handler frame that is be sitting on top of the actual
|
||||
// JavaScript frame. This is the case then OSR is triggered from bytecode.
|
||||
__ LeaveFrame(StackFrame::STUB);
|
||||
@ -1823,13 +1859,24 @@ void OnStackReplacement(MacroAssembler* masm, bool is_interpreter) {
|
||||
} // namespace
|
||||
|
||||
void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
|
||||
return OnStackReplacement(masm, true);
|
||||
using D = InterpreterOnStackReplacementDescriptor;
|
||||
STATIC_ASSERT(D::kParameterCount == 3);
|
||||
OnStackReplacement(masm, OsrSourceTier::kInterpreter,
|
||||
D::CurrentLoopDepthRegister(),
|
||||
D::EncodedCurrentBytecodeOffsetRegister(),
|
||||
D::OsrUrgencyAndInstallTargetRegister());
|
||||
}
|
||||
|
||||
void Builtins::Generate_BaselineOnStackReplacement(MacroAssembler* masm) {
|
||||
using D = BaselineOnStackReplacementDescriptor;
|
||||
STATIC_ASSERT(D::kParameterCount == 3);
|
||||
|
||||
__ Lw(kContextRegister,
|
||||
MemOperand(fp, StandardFrameConstants::kContextOffset));
|
||||
return OnStackReplacement(masm, false);
|
||||
OnStackReplacement(masm, OsrSourceTier::kBaseline,
|
||||
D::CurrentLoopDepthRegister(),
|
||||
D::EncodedCurrentBytecodeOffsetRegister(),
|
||||
D::OsrUrgencyAndInstallTargetRegister());
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1794,7 +1794,43 @@ void Generate_OSREntry(MacroAssembler* masm, Register entry_address,
|
||||
__ Ret();
|
||||
}
|
||||
|
||||
void OnStackReplacement(MacroAssembler* masm, bool is_interpreter) {
|
||||
enum class OsrSourceTier {
|
||||
kInterpreter,
|
||||
kBaseline,
|
||||
};
|
||||
|
||||
void OnStackReplacement(MacroAssembler* masm, OsrSourceTier source,
|
||||
Register current_loop_depth,
|
||||
Register encoded_current_bytecode_offset,
|
||||
Register osr_urgency_and_install_target) {
|
||||
static constexpr Register scratch = a3;
|
||||
DCHECK(!AreAliased(scratch, current_loop_depth,
|
||||
encoded_current_bytecode_offset,
|
||||
osr_urgency_and_install_target));
|
||||
// OSR based on urgency, i.e. is the OSR urgency greater than the current
|
||||
// loop depth?
|
||||
Label try_osr;
|
||||
STATIC_ASSERT(BytecodeArray::OsrUrgencyBits::kShift == 0);
|
||||
Register urgency = scratch;
|
||||
__ And(urgency, osr_urgency_and_install_target,
|
||||
BytecodeArray::OsrUrgencyBits::kMask);
|
||||
__ Branch(&try_osr, hi, urgency, Operand(current_loop_depth));
|
||||
|
||||
// OSR based on the install target offset, i.e. does the current bytecode
|
||||
// offset match the install target offset?
|
||||
static constexpr int kMask = BytecodeArray::OsrInstallTargetBits::kMask;
|
||||
Register install_target = osr_urgency_and_install_target;
|
||||
__ And(install_target, osr_urgency_and_install_target, Operand(kMask));
|
||||
__ Branch(&try_osr, eq, install_target,
|
||||
Operand(encoded_current_bytecode_offset));
|
||||
|
||||
// Neither urgency nor the install target triggered, return to the caller.
|
||||
// Note: the return value must be nullptr or a valid Code object.
|
||||
__ Move(v0, zero_reg);
|
||||
__ Ret();
|
||||
|
||||
__ bind(&try_osr);
|
||||
|
||||
{
|
||||
FrameScope scope(masm, StackFrame::INTERNAL);
|
||||
__ CallRuntime(Runtime::kCompileOptimizedOSR);
|
||||
@ -1802,7 +1838,7 @@ void OnStackReplacement(MacroAssembler* masm, bool is_interpreter) {
|
||||
|
||||
// If the code object is null, just return to the caller.
|
||||
__ Ret(eq, v0, Operand(Smi::zero()));
|
||||
if (is_interpreter) {
|
||||
if (source == OsrSourceTier::kInterpreter) {
|
||||
// Drop the handler frame that is be sitting on top of the actual
|
||||
// JavaScript frame. This is the case then OSR is triggered from bytecode.
|
||||
__ LeaveFrame(StackFrame::STUB);
|
||||
@ -1826,13 +1862,24 @@ void OnStackReplacement(MacroAssembler* masm, bool is_interpreter) {
|
||||
} // namespace
|
||||
|
||||
void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
|
||||
return OnStackReplacement(masm, true);
|
||||
using D = InterpreterOnStackReplacementDescriptor;
|
||||
STATIC_ASSERT(D::kParameterCount == 3);
|
||||
OnStackReplacement(masm, OsrSourceTier::kInterpreter,
|
||||
D::CurrentLoopDepthRegister(),
|
||||
D::EncodedCurrentBytecodeOffsetRegister(),
|
||||
D::OsrUrgencyAndInstallTargetRegister());
|
||||
}
|
||||
|
||||
void Builtins::Generate_BaselineOnStackReplacement(MacroAssembler* masm) {
|
||||
using D = BaselineOnStackReplacementDescriptor;
|
||||
STATIC_ASSERT(D::kParameterCount == 3);
|
||||
|
||||
__ Ld(kContextRegister,
|
||||
MemOperand(fp, StandardFrameConstants::kContextOffset));
|
||||
return OnStackReplacement(masm, false);
|
||||
OnStackReplacement(masm, OsrSourceTier::kBaseline,
|
||||
D::CurrentLoopDepthRegister(),
|
||||
D::EncodedCurrentBytecodeOffsetRegister(),
|
||||
D::OsrUrgencyAndInstallTargetRegister());
|
||||
}
|
||||
|
||||
// static
|
||||
|
Loading…
Reference in New Issue
Block a user