Commit 8fafb291 authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: [runtime] Implement %_ToLength via ToLengthStub.

Port e678a0f9

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.

R=bmeurer@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, dstence@us.ibm.com
BUG=v8:4494
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#31384}
parent af4888de
......@@ -3334,6 +3334,28 @@ void ToNumberStub::Generate(MacroAssembler* masm) {
}
void ToLengthStub::Generate(MacroAssembler* masm) {
// The ToLength stub takes one argument in r3.
Label not_smi;
__ JumpIfNotSmi(r3, &not_smi);
STATIC_ASSERT(kSmiTag == 0);
__ cmpi(r3, Operand::Zero());
if (CpuFeatures::IsSupported(ISELECT)) {
__ isel(lt, r3, r0, r3);
} else {
Label positive;
__ bgt(&positive);
__ li(r3, Operand::Zero());
__ bind(&positive);
}
__ Ret();
__ bind(&not_smi);
__ push(r3); // Push argument.
__ TailCallRuntime(Runtime::kToLength, 1, 1);
}
void ToStringStub::Generate(MacroAssembler* masm) {
// The ToString stub takes one argument in r3.
Label is_number;
......
......@@ -99,6 +99,10 @@ void ToNumberDescriptor::InitializePlatformSpecific(
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return r3; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return r3; }
......
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