From f27d254a7006323aaa19c90d5124dad599648343 Mon Sep 17 00:00:00 2001 From: Liu Yu Date: Wed, 1 Sep 2021 10:52:05 +0800 Subject: [PATCH] [mips][loong64] Modify the method of get a scratch register Acquire a scratch register instead of passing scratch register in JumpIfSmi and JumpIfNotSmi. Change-Id: I21776e1cd9d19f0d55c25a5bb3f7efcc247c80e5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3135155 Reviewed-by: Zhao Jiazhong Commit-Queue: Zhao Jiazhong Auto-Submit: Liu yu Cr-Commit-Position: refs/heads/main@{#76632} --- src/baseline/loong64/baseline-assembler-loong64-inl.h | 8 ++------ src/codegen/loong64/macro-assembler-loong64.cc | 10 ++++++---- src/codegen/loong64/macro-assembler-loong64.h | 4 ++-- src/codegen/mips/macro-assembler-mips.cc | 8 ++++++-- src/codegen/mips/macro-assembler-mips.h | 4 ++-- src/codegen/mips64/macro-assembler-mips64.cc | 8 ++++++-- src/codegen/mips64/macro-assembler-mips64.h | 4 ++-- 7 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/baseline/loong64/baseline-assembler-loong64-inl.h b/src/baseline/loong64/baseline-assembler-loong64-inl.h index 4a42cfead5..059d932ef9 100644 --- a/src/baseline/loong64/baseline-assembler-loong64-inl.h +++ b/src/baseline/loong64/baseline-assembler-loong64-inl.h @@ -102,15 +102,11 @@ void BaselineAssembler::JumpIfNotRoot(Register value, RootIndex index, } void BaselineAssembler::JumpIfSmi(Register value, Label* target, Label::Distance) { - ScratchRegisterScope temps(this); - Register temp = temps.AcquireScratch(); - __ JumpIfSmi(value, target, temp); + __ JumpIfSmi(value, target); } void BaselineAssembler::JumpIfNotSmi(Register value, Label* target, Label::Distance) { - ScratchRegisterScope temps(this); - Register temp = temps.AcquireScratch(); - __ JumpIfNotSmi(value, target, temp); + __ JumpIfNotSmi(value, target); } void BaselineAssembler::CallBuiltin(Builtin builtin) { diff --git a/src/codegen/loong64/macro-assembler-loong64.cc b/src/codegen/loong64/macro-assembler-loong64.cc index a94b5745ba..b999c1166b 100644 --- a/src/codegen/loong64/macro-assembler-loong64.cc +++ b/src/codegen/loong64/macro-assembler-loong64.cc @@ -3643,16 +3643,18 @@ void TurboAssembler::SmiUntag(Register dst, const MemOperand& src) { } } -void TurboAssembler::JumpIfSmi(Register value, Label* smi_label, - Register scratch) { +void TurboAssembler::JumpIfSmi(Register value, Label* smi_label) { DCHECK_EQ(0, kSmiTag); + UseScratchRegisterScope temps(this); + Register scratch = temps.Acquire(); andi(scratch, value, kSmiTagMask); Branch(smi_label, eq, scratch, Operand(zero_reg)); } -void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label, - Register scratch) { +void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label) { DCHECK_EQ(0, kSmiTag); + UseScratchRegisterScope temps(this); + Register scratch = temps.Acquire(); andi(scratch, value, kSmiTagMask); Branch(not_smi_label, ne, scratch, Operand(zero_reg)); } diff --git a/src/codegen/loong64/macro-assembler-loong64.h b/src/codegen/loong64/macro-assembler-loong64.h index 0740830637..adb6cfc5ef 100644 --- a/src/codegen/loong64/macro-assembler-loong64.h +++ b/src/codegen/loong64/macro-assembler-loong64.h @@ -664,7 +664,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { void Ceil_s(FPURegister fd, FPURegister fj); // Jump the register contains a smi. - void JumpIfSmi(Register value, Label* smi_label, Register scratch = t7); + void JumpIfSmi(Register value, Label* smi_label); void JumpIfEqual(Register a, int32_t b, Label* dest) { UseScratchRegisterScope temps(this); @@ -994,7 +994,7 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler { } // Jump if the register contains a non-smi. - void JumpIfNotSmi(Register value, Label* not_smi_label, Register scratch); + void JumpIfNotSmi(Register value, Label* not_smi_label); // Abort execution if argument is a smi, enabled via --debug-code. void AssertNotSmi(Register object); diff --git a/src/codegen/mips/macro-assembler-mips.cc b/src/codegen/mips/macro-assembler-mips.cc index 5c2e13bdb0..32f85c6ec2 100644 --- a/src/codegen/mips/macro-assembler-mips.cc +++ b/src/codegen/mips/macro-assembler-mips.cc @@ -4984,15 +4984,19 @@ void MacroAssembler::AssertStackIsAligned() { } void TurboAssembler::JumpIfSmi(Register value, Label* smi_label, - Register scratch, BranchDelaySlot bd) { + BranchDelaySlot bd) { DCHECK_EQ(0, kSmiTag); + UseScratchRegisterScope temps(this); + Register scratch = temps.Acquire(); andi(scratch, value, kSmiTagMask); Branch(bd, smi_label, eq, scratch, Operand(zero_reg)); } void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label, - Register scratch, BranchDelaySlot bd) { + BranchDelaySlot bd) { DCHECK_EQ(0, kSmiTag); + UseScratchRegisterScope temps(this); + Register scratch = temps.Acquire(); andi(scratch, value, kSmiTagMask); Branch(bd, not_smi_label, ne, scratch, Operand(zero_reg)); } diff --git a/src/codegen/mips/macro-assembler-mips.h b/src/codegen/mips/macro-assembler-mips.h index 365640a617..f467f83bd0 100644 --- a/src/codegen/mips/macro-assembler-mips.h +++ b/src/codegen/mips/macro-assembler-mips.h @@ -795,7 +795,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { // Jump the register contains a smi. void JumpIfSmi(Register value, Label* smi_label, - Register scratch = kScratchReg, BranchDelaySlot bd = PROTECT); + BranchDelaySlot bd = PROTECT); void JumpIfEqual(Register a, int32_t b, Label* dest) { li(kScratchReg, Operand(b)); @@ -1106,7 +1106,7 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler { } // Jump if the register contains a non-smi. - void JumpIfNotSmi(Register value, Label* not_smi_label, Register scratch = at, + void JumpIfNotSmi(Register value, Label* not_smi_label, BranchDelaySlot bd = PROTECT); // Abort execution if argument is a smi, enabled via --debug-code. diff --git a/src/codegen/mips64/macro-assembler-mips64.cc b/src/codegen/mips64/macro-assembler-mips64.cc index 95eb507cbf..5ceb69e861 100644 --- a/src/codegen/mips64/macro-assembler-mips64.cc +++ b/src/codegen/mips64/macro-assembler-mips64.cc @@ -5529,15 +5529,19 @@ void TurboAssembler::SmiUntag(Register dst, const MemOperand& src) { } void TurboAssembler::JumpIfSmi(Register value, Label* smi_label, - Register scratch, BranchDelaySlot bd) { + BranchDelaySlot bd) { DCHECK_EQ(0, kSmiTag); + UseScratchRegisterScope temps(this); + Register scratch = temps.Acquire(); andi(scratch, value, kSmiTagMask); Branch(bd, smi_label, eq, scratch, Operand(zero_reg)); } void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label, - Register scratch, BranchDelaySlot bd) { + BranchDelaySlot bd) { DCHECK_EQ(0, kSmiTag); + UseScratchRegisterScope temps(this); + Register scratch = temps.Acquire(); andi(scratch, value, kSmiTagMask); Branch(bd, not_smi_label, ne, scratch, Operand(zero_reg)); } diff --git a/src/codegen/mips64/macro-assembler-mips64.h b/src/codegen/mips64/macro-assembler-mips64.h index 1ad5f4fdae..a0ebe35a93 100644 --- a/src/codegen/mips64/macro-assembler-mips64.h +++ b/src/codegen/mips64/macro-assembler-mips64.h @@ -805,7 +805,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { void MSARoundD(MSARegister dst, MSARegister src, FPURoundingMode mode); // Jump the register contains a smi. - void JumpIfSmi(Register value, Label* smi_label, Register scratch = at, + void JumpIfSmi(Register value, Label* smi_label, BranchDelaySlot bd = PROTECT); void JumpIfEqual(Register a, int32_t b, Label* dest) { @@ -1180,7 +1180,7 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler { } // Jump if the register contains a non-smi. - void JumpIfNotSmi(Register value, Label* not_smi_label, Register scratch = at, + void JumpIfNotSmi(Register value, Label* not_smi_label, BranchDelaySlot bd = PROTECT); // Abort execution if argument is a smi, enabled via --debug-code.