PPC: [runtime] Implement %_ToLength via ToLengthStub.

Port e678a0f9a9

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}
This commit is contained in:
mbrandy 2015-10-19 10:00:33 -07:00 committed by Commit bot
parent af4888de13
commit 8fafb2916c
2 changed files with 26 additions and 0 deletions

View File

@ -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;

View File

@ -99,6 +99,10 @@ void ToNumberDescriptor::InitializePlatformSpecific(
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return r3; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return r3; }