Commit c7c9f1c3 authored by Liu Yu's avatar Liu Yu Committed by V8 LUCI CQ

[loong64][mips64][codegen] Optimize out calls to TurboAssembler::Assert*

Port commit c3ca8158

Change-Id: I76fd54522ec901534a13af6eadb917f6e8608d14
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3835264
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Auto-Submit: Liu Yu <liuyu@loongson.cn>
Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Cr-Commit-Position: refs/heads/main@{#82509}
parent da24d86a
......@@ -3379,11 +3379,6 @@ void MacroAssembler::EmitDecrementCounter(StatsCounter* counter, int value,
void TurboAssembler::Trap() { stop(); }
void TurboAssembler::DebugBreak() { stop(); }
void TurboAssembler::Assert(Condition cc, AbortReason reason, Register rs,
Operand rk) {
if (FLAG_debug_code) Check(cc, reason, rs, rk);
}
void TurboAssembler::Check(Condition cc, AbortReason reason, Register rj,
Operand rk) {
Label L;
......@@ -3641,28 +3636,6 @@ int TurboAssembler::ActivationFrameAlignment() {
#endif // V8_HOST_ARCH_LOONG64
}
void MacroAssembler::AssertStackIsAligned() {
if (FLAG_debug_code) {
ASM_CODE_COMMENT(this);
const int frame_alignment = ActivationFrameAlignment();
const int frame_alignment_mask = frame_alignment - 1;
if (frame_alignment > kPointerSize) {
Label alignment_as_expected;
DCHECK(base::bits::IsPowerOfTwo(frame_alignment));
{
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
andi(scratch, sp, frame_alignment_mask);
Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg));
}
// Don't use Check here, as it will call Runtime_Abort re-entering here.
stop();
bind(&alignment_as_expected);
}
}
}
void TurboAssembler::SmiUntag(Register dst, const MemOperand& src) {
if (SmiValuesAre32Bits()) {
Ld_w(dst, MemOperand(src.base(), SmiWordOffset(src.offset())));
......@@ -3689,6 +3662,13 @@ void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label) {
Branch(not_smi_label, ne, scratch, Operand(zero_reg));
}
#ifdef V8_ENABLE_DEBUG_CODE
void TurboAssembler::Assert(Condition cc, AbortReason reason, Register rs,
Operand rk) {
if (FLAG_debug_code) Check(cc, reason, rs, rk);
}
void TurboAssembler::AssertNotSmi(Register object) {
if (FLAG_debug_code) {
ASM_CODE_COMMENT(this);
......@@ -3711,6 +3691,28 @@ void TurboAssembler::AssertSmi(Register object) {
}
}
void MacroAssembler::AssertStackIsAligned() {
if (FLAG_debug_code) {
ASM_CODE_COMMENT(this);
const int frame_alignment = ActivationFrameAlignment();
const int frame_alignment_mask = frame_alignment - 1;
if (frame_alignment > kPointerSize) {
Label alignment_as_expected;
DCHECK(base::bits::IsPowerOfTwo(frame_alignment));
{
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
andi(scratch, sp, frame_alignment_mask);
Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg));
}
// Don't use Check here, as it will call Runtime_Abort re-entering here.
stop();
bind(&alignment_as_expected);
}
}
}
void MacroAssembler::AssertConstructor(Register object) {
if (FLAG_debug_code) {
ASM_CODE_COMMENT(this);
......@@ -3806,6 +3808,8 @@ void MacroAssembler::AssertUndefinedOrAllocationSite(Register object,
}
}
#endif // V8_ENABLE_DEBUG_CODE
void TurboAssembler::Float32Max(FPURegister dst, FPURegister src1,
FPURegister src2, Label* out_of_line) {
ASM_CODE_COMMENT(this);
......
......@@ -100,7 +100,8 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// Calls Abort(msg) if the condition cc is not satisfied.
// Use --debug_code to enable.
void Assert(Condition cc, AbortReason reason, Register rj, Operand rk);
void Assert(Condition cc, AbortReason reason, Register rj,
Operand rk) NOOP_UNLESS_DEBUG_CODE;
// Like Assert(), but always enabled.
void Check(Condition cc, AbortReason reason, Register rj, Operand rk);
......@@ -460,8 +461,8 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
}
// Abort execution if argument is a smi, enabled via --debug-code.
void AssertNotSmi(Register object);
void AssertSmi(Register object);
void AssertNotSmi(Register object) NOOP_UNLESS_DEBUG_CODE;
void AssertSmi(Register object) NOOP_UNLESS_DEBUG_CODE;
int CalculateStackPassedWords(int num_reg_arguments,
int num_double_arguments);
......@@ -897,7 +898,7 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
bool argument_count_is_length = false);
// Make sure the stack is aligned. Only emits code in debug mode.
void AssertStackIsAligned();
void AssertStackIsAligned() NOOP_UNLESS_DEBUG_CODE;
// Load the global proxy from the current context.
void LoadGlobalProxy(Register dst) {
......@@ -1021,26 +1022,27 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
void JumpIfNotSmi(Register value, Label* not_smi_label);
// Abort execution if argument is not a Constructor, enabled via --debug-code.
void AssertConstructor(Register object);
void AssertConstructor(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSFunction, enabled via --debug-code.
void AssertFunction(Register object);
void AssertFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a callable JSFunction, enabled via
// --debug-code.
void AssertCallableFunction(Register object);
void AssertCallableFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSBoundFunction,
// enabled via --debug-code.
void AssertBoundFunction(Register object);
void AssertBoundFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSGeneratorObject (or subclass),
// enabled via --debug-code.
void AssertGeneratorObject(Register object);
void AssertGeneratorObject(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not undefined or an AllocationSite, enabled
// via --debug-code.
void AssertUndefinedOrAllocationSite(Register object, Register scratch);
void AssertUndefinedOrAllocationSite(Register object,
Register scratch) NOOP_UNLESS_DEBUG_CODE;
// ---------------------------------------------------------------------------
// Tiering support.
......
......@@ -5281,11 +5281,6 @@ void MacroAssembler::EmitDecrementCounter(StatsCounter* counter, int value,
void TurboAssembler::Trap() { stop(); }
void TurboAssembler::DebugBreak() { stop(); }
void TurboAssembler::Assert(Condition cc, AbortReason reason, Register rs,
Operand rt) {
if (FLAG_debug_code) Check(cc, reason, rs, rt);
}
void TurboAssembler::Check(Condition cc, AbortReason reason, Register rs,
Operand rt) {
Label L;
......@@ -5543,28 +5538,6 @@ int TurboAssembler::ActivationFrameAlignment() {
#endif // V8_HOST_ARCH_MIPS
}
void MacroAssembler::AssertStackIsAligned() {
if (FLAG_debug_code) {
ASM_CODE_COMMENT(this);
const int frame_alignment = ActivationFrameAlignment();
const int frame_alignment_mask = frame_alignment - 1;
if (frame_alignment > kPointerSize) {
Label alignment_as_expected;
DCHECK(base::bits::IsPowerOfTwo(frame_alignment));
{
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
andi(scratch, sp, frame_alignment_mask);
Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg));
}
// Don't use Check here, as it will call Runtime_Abort re-entering here.
stop();
bind(&alignment_as_expected);
}
}
}
void TurboAssembler::SmiUntag(Register dst, const MemOperand& src) {
if (SmiValuesAre32Bits()) {
Lw(dst, MemOperand(src.rm(), SmiWordOffset(src.offset())));
......@@ -5593,6 +5566,13 @@ void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label,
Branch(bd, not_smi_label, ne, scratch, Operand(zero_reg));
}
#ifdef V8_ENABLE_DEBUG_CODE
void TurboAssembler::Assert(Condition cc, AbortReason reason, Register rs,
Operand rt) {
if (FLAG_debug_code) Check(cc, reason, rs, rt);
}
void TurboAssembler::AssertNotSmi(Register object) {
if (FLAG_debug_code) {
ASM_CODE_COMMENT(this);
......@@ -5615,6 +5595,28 @@ void TurboAssembler::AssertSmi(Register object) {
}
}
void MacroAssembler::AssertStackIsAligned() {
if (FLAG_debug_code) {
ASM_CODE_COMMENT(this);
const int frame_alignment = ActivationFrameAlignment();
const int frame_alignment_mask = frame_alignment - 1;
if (frame_alignment > kPointerSize) {
Label alignment_as_expected;
DCHECK(base::bits::IsPowerOfTwo(frame_alignment));
{
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
andi(scratch, sp, frame_alignment_mask);
Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg));
}
// Don't use Check here, as it will call Runtime_Abort re-entering here.
stop();
bind(&alignment_as_expected);
}
}
}
void MacroAssembler::AssertConstructor(Register object) {
if (FLAG_debug_code) {
ASM_CODE_COMMENT(this);
......@@ -5710,6 +5712,8 @@ void MacroAssembler::AssertUndefinedOrAllocationSite(Register object,
}
}
#endif // V8_ENABLE_DEBUG_CODE
void TurboAssembler::Float32Max(FPURegister dst, FPURegister src1,
FPURegister src2, Label* out_of_line) {
ASM_CODE_COMMENT(this);
......
......@@ -134,7 +134,8 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// Calls Abort(msg) if the condition cc is not satisfied.
// Use --debug_code to enable.
void Assert(Condition cc, AbortReason reason, Register rs, Operand rt);
void Assert(Condition cc, AbortReason reason, Register rs,
Operand rt) NOOP_UNLESS_DEBUG_CODE;
// Like Assert(), but always enabled.
void Check(Condition cc, AbortReason reason, Register rs, Operand rt);
......@@ -525,8 +526,8 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
}
// Abort execution if argument is a smi, enabled via --debug-code.
void AssertNotSmi(Register object);
void AssertSmi(Register object);
void AssertNotSmi(Register object) NOOP_UNLESS_DEBUG_CODE;
void AssertSmi(Register object) NOOP_UNLESS_DEBUG_CODE;
int CalculateStackPassedWords(int num_reg_arguments,
int num_double_arguments);
......@@ -1083,7 +1084,7 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
bool argument_count_is_length = false);
// Make sure the stack is aligned. Only emits code in debug mode.
void AssertStackIsAligned();
void AssertStackIsAligned() NOOP_UNLESS_DEBUG_CODE;
// Load the global proxy from the current context.
void LoadGlobalProxy(Register dst) {
......@@ -1209,26 +1210,27 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
BranchDelaySlot bd = PROTECT);
// Abort execution if argument is not a Constructor, enabled via --debug-code.
void AssertConstructor(Register object);
void AssertConstructor(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSFunction, enabled via --debug-code.
void AssertFunction(Register object);
void AssertFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a callable JSFunction, enabled via
// --debug-code.
void AssertCallableFunction(Register object);
void AssertCallableFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSBoundFunction,
// enabled via --debug-code.
void AssertBoundFunction(Register object);
void AssertBoundFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSGeneratorObject (or subclass),
// enabled via --debug-code.
void AssertGeneratorObject(Register object);
void AssertGeneratorObject(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not undefined or an AllocationSite, enabled
// via --debug-code.
void AssertUndefinedOrAllocationSite(Register object, Register scratch);
void AssertUndefinedOrAllocationSite(Register object,
Register scratch) NOOP_UNLESS_DEBUG_CODE;
// ---------------------------------------------------------------------------
// Tiering support.
......
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