Commit be04dd5c authored by chunyang.dai's avatar chunyang.dai Committed by Commit bot

X87: [stubs] Refactor StringCompareStub and use it for HStringCompareAndBranch.

port 8016547c (r30818).

original commit message:

    The StringCompareStub used to take its parameters on the (JavaScript)
    stack, which made it impossible to use in TurboFan. Actually
    StringCompareStub was currently completely unused. This changes the
    calling convention to something TurboFan compatible and introduces a
    CallInterfaceDescriptor for StringCompareStub. It also changes
    HStringCompareAndBranch to use the StringCompareStub instead of using
    the full blown CompareICStub for a stupid string comparison.

BUG=

Review URL: https://codereview.chromium.org/1355983003

Cr-Commit-Position: refs/heads/master@{#30845}
parent 9155967e
...@@ -3072,41 +3072,39 @@ void StringHelper::GenerateOneByteCharsCompareLoop( ...@@ -3072,41 +3072,39 @@ void StringHelper::GenerateOneByteCharsCompareLoop(
void StringCompareStub::Generate(MacroAssembler* masm) { void StringCompareStub::Generate(MacroAssembler* masm) {
Label runtime; // ----------- S t a t e -------------
// -- edx : left string
// Stack frame on entry. // -- eax : right string
// esp[0]: return address // -- esp[0] : return address
// esp[4]: right string // -----------------------------------
// esp[8]: left string __ AssertString(edx);
__ AssertString(eax);
__ mov(edx, Operand(esp, 2 * kPointerSize)); // left
__ mov(eax, Operand(esp, 1 * kPointerSize)); // right
Label not_same; Label not_same;
__ cmp(edx, eax); __ cmp(edx, eax);
__ j(not_equal, &not_same, Label::kNear); __ j(not_equal, &not_same, Label::kNear);
STATIC_ASSERT(EQUAL == 0);
STATIC_ASSERT(kSmiTag == 0);
__ Move(eax, Immediate(Smi::FromInt(EQUAL))); __ Move(eax, Immediate(Smi::FromInt(EQUAL)));
__ IncrementCounter(isolate()->counters()->string_compare_native(), 1); __ IncrementCounter(isolate()->counters()->string_compare_native(), 1);
__ ret(2 * kPointerSize); __ Ret();
__ bind(&not_same); __ bind(&not_same);
// Check that both objects are sequential one-byte strings. // Check that both objects are sequential one-byte strings.
Label runtime;
__ JumpIfNotBothSequentialOneByteStrings(edx, eax, ecx, ebx, &runtime); __ JumpIfNotBothSequentialOneByteStrings(edx, eax, ecx, ebx, &runtime);
// Compare flat one-byte strings. // Compare flat one-byte strings.
// Drop arguments from the stack. __ IncrementCounter(isolate()->counters()->string_compare_native(), 1);
__ pop(ecx);
__ add(esp, Immediate(2 * kPointerSize));
__ push(ecx);
StringHelper::GenerateCompareFlatOneByteStrings(masm, edx, eax, ecx, ebx, StringHelper::GenerateCompareFlatOneByteStrings(masm, edx, eax, ecx, ebx,
edi); edi);
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
// tagged as a small integer. // tagged as a small integer.
__ bind(&runtime); __ bind(&runtime);
__ PopReturnAddressTo(ecx);
__ Push(edx);
__ Push(eax);
__ PushReturnAddressFrom(ecx);
__ TailCallRuntime(Runtime::kStringCompare, 2, 1); __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
} }
......
...@@ -57,6 +57,10 @@ const Register InstanceOfDescriptor::LeftRegister() { return edx; } ...@@ -57,6 +57,10 @@ const Register InstanceOfDescriptor::LeftRegister() { return edx; }
const Register InstanceOfDescriptor::RightRegister() { return eax; } const Register InstanceOfDescriptor::RightRegister() { return eax; }
const Register StringCompareDescriptor::LeftRegister() { return edx; }
const Register StringCompareDescriptor::RightRegister() { return eax; }
const Register ArgumentsAccessReadDescriptor::index() { return edx; } const Register ArgumentsAccessReadDescriptor::index() { return edx; }
const Register ArgumentsAccessReadDescriptor::parameter_count() { return eax; } const Register ArgumentsAccessReadDescriptor::parameter_count() { return eax; }
......
...@@ -1372,11 +1372,6 @@ void LCodeGen::DoCallStub(LCallStub* instr) { ...@@ -1372,11 +1372,6 @@ void LCodeGen::DoCallStub(LCallStub* instr) {
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
break; break;
} }
case CodeStub::StringCompare: {
StringCompareStub stub(isolate());
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
} }
...@@ -2724,16 +2719,15 @@ static Condition ComputeCompareCondition(Token::Value op) { ...@@ -2724,16 +2719,15 @@ static Condition ComputeCompareCondition(Token::Value op) {
void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) { void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) {
Token::Value op = instr->op(); DCHECK(ToRegister(instr->context()).is(esi));
DCHECK(ToRegister(instr->left()).is(edx));
Handle<Code> ic = DCHECK(ToRegister(instr->right()).is(eax));
CodeFactory::CompareIC(isolate(), op, Strength::WEAK).code();
CallCode(ic, RelocInfo::CODE_TARGET, instr);
Condition condition = ComputeCompareCondition(op); Handle<Code> code = CodeFactory::StringCompare(isolate()).code();
__ test(eax, Operand(eax)); CallCode(code, RelocInfo::CODE_TARGET, instr);
__ test(eax, eax);
EmitBranch(instr, condition); EmitBranch(instr, ComputeCompareCondition(instr->op()));
} }
......
...@@ -1067,7 +1067,7 @@ class LStringCompareAndBranch final : public LControlInstruction<3, 0> { ...@@ -1067,7 +1067,7 @@ class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
inputs_[2] = right; inputs_[2] = right;
} }
LOperand* context() { return inputs_[1]; } LOperand* context() { return inputs_[0]; }
LOperand* left() { return inputs_[1]; } LOperand* left() { return inputs_[1]; }
LOperand* right() { return inputs_[2]; } LOperand* right() { return inputs_[2]; }
......
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