Commit 9f4ff3b1 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [runtime] Implement %_ToLength via ToLengthStub.

    port e678a0f9 (r31358)

    original commit message:
    Use %_ToLength for TO_LENGTH, implemented via a ToLengthStub
    that supports a fast path for small integers. Everything else is still
    handled in the runtime.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#31542}
parent 1e52cd52
......@@ -2902,6 +2902,25 @@ void ToNumberStub::Generate(MacroAssembler* masm) {
}
void ToLengthStub::Generate(MacroAssembler* masm) {
// The ToLength stub takes on argument in eax.
Label not_smi, positive_smi;
__ JumpIfNotSmi(eax, &not_smi, Label::kNear);
STATIC_ASSERT(kSmiTag == 0);
__ test(eax, eax);
__ j(greater_equal, &positive_smi, Label::kNear);
__ xor_(eax, eax);
__ bind(&positive_smi);
__ Ret();
__ bind(&not_smi);
__ pop(ecx); // Pop return address.
__ push(eax); // Push argument.
__ push(ecx); // Push return address.
__ TailCallRuntime(Runtime::kToLength, 1, 1);
}
void ToStringStub::Generate(MacroAssembler* masm) {
// The ToString stub takes one argument in eax.
Label is_number;
......
......@@ -105,6 +105,10 @@ void ToNumberDescriptor::InitializePlatformSpecific(
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return eax; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return eax; }
......
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