PPC/s390: [turbofan] Introduce new JSCallWithArrayLike operator.

Port 767ce78871

Original Commit Message:

    Add a new JSCallWithArrayLike operator that is backed by the
    CallWithArrayLike builtin, and use that operator for both
    Function.prototype.apply and Reflect.apply inlining. Also unify
    the handling of JSCallWithArrayLike and JSCallWithSpread in
    the JSCallReducer to reduce the copy&paste overhead.

    Function.prototype.apply in optimized code, especially for some
    corner cases, which was missing so far.

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

Change-Id: I930845df7e87b8962588cc79f6069477865fa086
Reviewed-on: https://chromium-review.googlesource.com/546735
Reviewed-by: Joran Siu <joransiu@ca.ibm.com>
Commit-Queue: Jaideep Bajwa <bjaideep@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#46188}
This commit is contained in:
Jaideep Bajwa 2017-06-23 14:25:12 -04:00 committed by Commit Bot
parent 789f9592de
commit b09ff25cfd
2 changed files with 14 additions and 58 deletions

View File

@ -1999,13 +1999,9 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
// -- sp[0] : thisArg
// -----------------------------------
// 2. Make sure the receiver is actually callable.
Label receiver_not_callable;
__ JumpIfSmi(r4, &receiver_not_callable);
__ LoadP(r7, FieldMemOperand(r4, HeapObject::kMapOffset));
__ lbz(r7, FieldMemOperand(r7, Map::kBitFieldOffset));
__ TestBit(r7, Map::kIsCallable, r0);
__ beq(&receiver_not_callable, cr0);
// 2. We don't need to check explicitly for callable receiver here,
// since that's the first thing the Call/CallWithArrayLike builtins
// will do.
// 3. Tail call with no arguments if argArray is null or undefined.
Label no_arguments;
@ -2023,13 +2019,6 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
__ li(r3, Operand::Zero());
__ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
}
// 4c. The receiver is not callable, throw an appropriate TypeError.
__ bind(&receiver_not_callable);
{
__ StoreP(r4, MemOperand(sp, 0));
__ TailCallRuntime(Runtime::kThrowApplyNonFunction);
}
}
// static
@ -2117,24 +2106,13 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
// -- sp[0] : thisArgument
// -----------------------------------
// 2. Make sure the target is actually callable.
Label target_not_callable;
__ JumpIfSmi(r4, &target_not_callable);
__ LoadP(r7, FieldMemOperand(r4, HeapObject::kMapOffset));
__ lbz(r7, FieldMemOperand(r7, Map::kBitFieldOffset));
__ TestBit(r7, Map::kIsCallable, r0);
__ beq(&target_not_callable, cr0);
// 2. We don't need to check explicitly for callable target here,
// since that's the first thing the Call/CallWithArrayLike builtins
// will do.
// 3a. Apply the target to the given argumentsList.
// 3. Apply the target to the given argumentsList.
__ Jump(masm->isolate()->builtins()->CallWithArrayLike(),
RelocInfo::CODE_TARGET);
// 3b. The target is not callable, throw an appropriate TypeError.
__ bind(&target_not_callable);
{
__ StoreP(r4, MemOperand(sp, 0));
__ TailCallRuntime(Runtime::kThrowApplyNonFunction);
}
}
void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {

View File

@ -1988,13 +1988,9 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
// -- sp[0] : thisArg
// -----------------------------------
// 2. Make sure the receiver is actually callable.
Label receiver_not_callable;
__ JumpIfSmi(r3, &receiver_not_callable);
__ LoadP(r6, FieldMemOperand(r3, HeapObject::kMapOffset));
__ LoadlB(r6, FieldMemOperand(r6, Map::kBitFieldOffset));
__ TestBit(r6, Map::kIsCallable);
__ beq(&receiver_not_callable);
// 2. We don't need to check explicitly for callable receiver here,
// since that's the first thing the Call/CallWithArrayLike builtins
// will do.
// 3. Tail call with no arguments if argArray is null or undefined.
Label no_arguments;
@ -2012,13 +2008,6 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
__ LoadImmP(r2, Operand::Zero());
__ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
}
// 4c. The receiver is not callable, throw an appropriate TypeError.
__ bind(&receiver_not_callable);
{
__ StoreP(r3, MemOperand(sp, 0));
__ TailCallRuntime(Runtime::kThrowApplyNonFunction);
}
}
// static
@ -2106,24 +2095,13 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
// -- sp[0] : thisArgument
// -----------------------------------
// 2. Make sure the target is actually callable.
Label target_not_callable;
__ JumpIfSmi(r3, &target_not_callable);
__ LoadP(r6, FieldMemOperand(r3, HeapObject::kMapOffset));
__ LoadlB(r6, FieldMemOperand(r6, Map::kBitFieldOffset));
__ TestBit(r6, Map::kIsCallable);
__ beq(&target_not_callable);
// 2. We don't need to check explicitly for callable target here,
// since that's the first thing the Call/CallWithArrayLike builtins
// will do.
// 3a. Apply the target to the given argumentsList.
// 3 Apply the target to the given argumentsList.
__ Jump(masm->isolate()->builtins()->CallWithArrayLike(),
RelocInfo::CODE_TARGET);
// 3b. The target is not callable, throw an appropriate TypeError.
__ bind(&target_not_callable);
{
__ StoreP(r3, MemOperand(sp, 0));
__ TailCallRuntime(Runtime::kThrowApplyNonFunction);
}
}
void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {