Commit 16de74bb authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

PPC/s390: [turbofan] replace linear lookup switches with binary search

Port 825c7481

R=tebbi@chromium.org, joransiu@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: If067828166e44b99f48add7e929d6be8b585f34b
Reviewed-on: https://chromium-review.googlesource.com/1106877Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#53856}
parent 81835bf0
......@@ -2236,6 +2236,17 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr,
__ bind(&done);
}
void CodeGenerator::AssembleArchBinarySearchSwitch(Instruction* instr) {
PPCOperandConverter i(this, instr);
Register input = i.InputRegister(0);
std::vector<std::pair<int32_t, Label*>> cases;
for (size_t index = 2; index < instr->InputCount(); index += 2) {
cases.push_back({i.InputInt32(index + 0), GetLabel(i.InputRpo(index + 1))});
}
AssembleArchBinarySearchSwitchRange(input, i.InputRpo(1), cases.data(),
cases.data() + cases.size());
}
void CodeGenerator::AssembleArchLookupSwitch(Instruction* instr) {
PPCOperandConverter i(this, instr);
Register input = i.InputRegister(0);
......
......@@ -2890,6 +2890,17 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr,
__ bind(&done);
}
void CodeGenerator::AssembleArchBinarySearchSwitch(Instruction* instr) {
S390OperandConverter i(this, instr);
Register input = i.InputRegister(0);
std::vector<std::pair<int32_t, Label*>> cases;
for (size_t index = 2; index < instr->InputCount(); index += 2) {
cases.push_back({i.InputInt32(index + 0), GetLabel(i.InputRpo(index + 1))});
}
AssembleArchBinarySearchSwitchRange(input, i.InputRpo(1), cases.data(),
cases.data() + cases.size());
}
void CodeGenerator::AssembleArchLookupSwitch(Instruction* instr) {
S390OperandConverter i(this, instr);
Register input = i.InputRegister(0);
......
......@@ -2377,7 +2377,7 @@ void TurboAssembler::Add(Register dst, Register src, intptr_t value,
}
void MacroAssembler::Cmpi(Register src1, const Operand& src2, Register scratch,
void TurboAssembler::Cmpi(Register src1, const Operand& src2, Register scratch,
CRegister cr) {
intptr_t value = src2.immediate();
if (is_int16(value)) {
......@@ -3089,6 +3089,16 @@ void TurboAssembler::ResetSpeculationPoisonRegister() {
mov(kSpeculationPoisonRegister, Operand(-1));
}
void TurboAssembler::JumpIfEqual(Register x, int32_t y, Label* dest) {
Cmpi(x, Operand(y), r0);
beq(dest);
}
void TurboAssembler::JumpIfLessThan(Register x, int32_t y, Label* dest) {
Cmpi(x, Operand(y), r0);
blt(dest);
}
} // namespace internal
} // namespace v8
......
......@@ -229,6 +229,8 @@ class TurboAssembler : public TurboAssemblerBase {
void StoreSingleU(DoubleRegister src, const MemOperand& mem,
Register scratch = no_reg);
void Cmpi(Register src1, const Operand& src2, Register scratch,
CRegister cr = cr7);
void Cmpli(Register src1, const Operand& src2, Register scratch,
CRegister cr = cr7);
void Cmpwi(Register src1, const Operand& src2, Register scratch,
......@@ -620,6 +622,9 @@ class TurboAssembler : public TurboAssemblerBase {
TestIfSmi(value, r0);
beq(smi_label, cr0); // branch if SMI
}
void JumpIfEqual(Register x, int32_t y, Label* dest);
void JumpIfLessThan(Register x, int32_t y, Label* dest);
#if V8_TARGET_ARCH_PPC64
inline void TestIfInt32(Register value, Register scratch,
CRegister cr = cr7) {
......@@ -808,8 +813,6 @@ class MacroAssembler : public TurboAssembler {
void LoadDoubleU(DoubleRegister dst, const MemOperand& mem,
Register scratch = no_reg);
void Cmpi(Register src1, const Operand& src2, Register scratch,
CRegister cr = cr7);
void Cmplwi(Register src1, const Operand& src2, Register scratch,
CRegister cr = cr7);
void And(Register ra, Register rs, const Operand& rb, RCBit rc = LeaveRC);
......
......@@ -4484,6 +4484,16 @@ void TurboAssembler::ComputeCodeStartAddress(Register dst) {
larl(dst, Operand(-pc_offset() / 2));
}
void TurboAssembler::JumpIfEqual(Register x, int32_t y, Label* dest) {
Cmp32(x, Operand(y));
beq(dest);
}
void TurboAssembler::JumpIfLessThan(Register x, int32_t y, Label* dest) {
Cmp32(x, Operand(y));
blt(dest);
}
} // namespace internal
} // namespace v8
......
......@@ -202,6 +202,9 @@ class TurboAssembler : public TurboAssemblerBase {
TestIfSmi(value);
beq(smi_label /*, cr0*/); // branch if SMI
}
void JumpIfEqual(Register x, int32_t y, Label* dest);
void JumpIfLessThan(Register x, int32_t y, Label* dest);
void Call(Register target);
void Call(Address target, RelocInfo::Mode rmode, Condition cond = al);
int CallSize(Handle<Code> code,
......
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