Commit 00a8ab2e authored by Jaideep Bajwa's avatar Jaideep Bajwa Committed by Commit Bot

PPC/s390: [turbofan] Widen the fast-path for JSCreateArray.

Port 1edb46cc

Original Commit Message:

    This improves the general Array constructor call performance (w/o
    usable AllocationSite feedback) in TurboFan by ~2x, i.e. for example
    invoking the Array constructor like this

      var a = Array.call(undefined, n);

    instead of

      var a = Array(n);

    such that the CallIC doesn't know that it's eventually calling the
    Array constructor.

    It also thus changes the single argument Array constructor to always
    return holey arrays. Previously the single argument case for the Array
    constructor was somehow trying to dynamically detect 0 and in that case
    returned a packed array instead of a holey one. That adds quite a lot
    of churn, and doesn't seem to be very useful, especially since this
    might lead to unnecessary feedback pollution later.

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

Change-Id: I6a50ae016556ed38a7d7ca5546b575ca25e91b4a
Reviewed-on: https://chromium-review.googlesource.com/586641Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Commit-Queue: Jaideep Bajwa <bjaideep@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#46909}
parent c178cf38
......@@ -2452,24 +2452,12 @@ static void CreateArrayDispatchOneArgument(MacroAssembler* masm,
// r3 - number of arguments
// r4 - constructor?
// sp[0] - last argument
Label normal_sequence;
if (mode == DONT_OVERRIDE) {
STATIC_ASSERT(PACKED_SMI_ELEMENTS == 0);
STATIC_ASSERT(HOLEY_SMI_ELEMENTS == 1);
STATIC_ASSERT(PACKED_ELEMENTS == 2);
STATIC_ASSERT(HOLEY_ELEMENTS == 3);
STATIC_ASSERT(PACKED_DOUBLE_ELEMENTS == 4);
STATIC_ASSERT(HOLEY_DOUBLE_ELEMENTS == 5);
// is the low bit set? If so, we are holey and that is good.
__ andi(r0, r6, Operand(1));
__ bne(&normal_sequence, cr0);
}
// look at the first argument
__ LoadP(r8, MemOperand(sp, 0));
__ cmpi(r8, Operand::Zero());
__ beq(&normal_sequence);
STATIC_ASSERT(PACKED_SMI_ELEMENTS == 0);
STATIC_ASSERT(HOLEY_SMI_ELEMENTS == 1);
STATIC_ASSERT(PACKED_ELEMENTS == 2);
STATIC_ASSERT(HOLEY_ELEMENTS == 3);
STATIC_ASSERT(PACKED_DOUBLE_ELEMENTS == 4);
STATIC_ASSERT(HOLEY_DOUBLE_ELEMENTS == 5);
if (mode == DISABLE_ALLOCATION_SITES) {
ElementsKind initial = GetInitialFastElementsKind();
......@@ -2478,12 +2466,12 @@ static void CreateArrayDispatchOneArgument(MacroAssembler* masm,
ArraySingleArgumentConstructorStub stub_holey(
masm->isolate(), holey_initial, DISABLE_ALLOCATION_SITES);
__ TailCallStub(&stub_holey);
__ bind(&normal_sequence);
ArraySingleArgumentConstructorStub stub(masm->isolate(), initial,
DISABLE_ALLOCATION_SITES);
__ TailCallStub(&stub);
} else if (mode == DONT_OVERRIDE) {
// is the low bit set? If so, we are holey and that is good.
Label normal_sequence;
__ andi(r0, r6, Operand(1));
__ bne(&normal_sequence, cr0);
// We are going to create a holey array, but our kind is non-holey.
// Fix kind and retry (only if we have an allocation site in the slot).
__ addi(r6, r6, Operand(1));
......
......@@ -2979,7 +2979,7 @@ void TurboAssembler::LoadSmiLiteral(Register dst, Smi* smi) {
mov(dst, Operand(smi));
}
void TurboAssembler::LoadDoubleLiteral(DoubleRegister result, double value,
void TurboAssembler::LoadDoubleLiteral(DoubleRegister result, Double value,
Register scratch) {
if (FLAG_enable_embedded_constant_pool && is_constant_pool_available() &&
!(scratch.is(r0) && ConstantPoolAccessIsInOverflow())) {
......
......@@ -205,7 +205,7 @@ class TurboAssembler : public Assembler {
void LoadDouble(DoubleRegister dst, const MemOperand& mem,
Register scratch = no_reg);
void LoadDoubleLiteral(DoubleRegister result, double value, Register scratch);
void LoadDoubleLiteral(DoubleRegister result, Double value, Register scratch);
// load a literal signed int value <value> to GPR <dst>
void LoadIntLiteral(Register dst, int value);
......
......@@ -2402,24 +2402,12 @@ static void CreateArrayDispatchOneArgument(MacroAssembler* masm,
// r2 - number of arguments
// r3 - constructor?
// sp[0] - last argument
Label normal_sequence;
if (mode == DONT_OVERRIDE) {
STATIC_ASSERT(PACKED_SMI_ELEMENTS == 0);
STATIC_ASSERT(HOLEY_SMI_ELEMENTS == 1);
STATIC_ASSERT(PACKED_ELEMENTS == 2);
STATIC_ASSERT(HOLEY_ELEMENTS == 3);
STATIC_ASSERT(PACKED_DOUBLE_ELEMENTS == 4);
STATIC_ASSERT(HOLEY_DOUBLE_ELEMENTS == 5);
// is the low bit set? If so, we are holey and that is good.
__ AndP(r0, r5, Operand(1));
__ bne(&normal_sequence);
}
// look at the first argument
__ LoadP(r7, MemOperand(sp, 0));
__ CmpP(r7, Operand::Zero());
__ beq(&normal_sequence);
STATIC_ASSERT(PACKED_SMI_ELEMENTS == 0);
STATIC_ASSERT(HOLEY_SMI_ELEMENTS == 1);
STATIC_ASSERT(PACKED_ELEMENTS == 2);
STATIC_ASSERT(HOLEY_ELEMENTS == 3);
STATIC_ASSERT(PACKED_DOUBLE_ELEMENTS == 4);
STATIC_ASSERT(HOLEY_DOUBLE_ELEMENTS == 5);
if (mode == DISABLE_ALLOCATION_SITES) {
ElementsKind initial = GetInitialFastElementsKind();
......@@ -2428,12 +2416,12 @@ static void CreateArrayDispatchOneArgument(MacroAssembler* masm,
ArraySingleArgumentConstructorStub stub_holey(
masm->isolate(), holey_initial, DISABLE_ALLOCATION_SITES);
__ TailCallStub(&stub_holey);
__ bind(&normal_sequence);
ArraySingleArgumentConstructorStub stub(masm->isolate(), initial,
DISABLE_ALLOCATION_SITES);
__ TailCallStub(&stub);
} else if (mode == DONT_OVERRIDE) {
Label normal_sequence;
// is the low bit set? If so, we are holey and that is good.
__ AndP(r0, r5, Operand(1));
__ bne(&normal_sequence);
// We are going to create a holey array, but our kind is non-holey.
// Fix kind and retry (only if we have an allocation site in the slot).
__ AddP(r5, r5, Operand(1));
......
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