Commit b09ff25c authored by Jaideep Bajwa's avatar Jaideep Bajwa Committed by Commit Bot

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

Port 767ce788

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/546735Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Commit-Queue: Jaideep Bajwa <bjaideep@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#46188}
parent 789f9592
...@@ -1999,13 +1999,9 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { ...@@ -1999,13 +1999,9 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
// -- sp[0] : thisArg // -- sp[0] : thisArg
// ----------------------------------- // -----------------------------------
// 2. Make sure the receiver is actually callable. // 2. We don't need to check explicitly for callable receiver here,
Label receiver_not_callable; // since that's the first thing the Call/CallWithArrayLike builtins
__ JumpIfSmi(r4, &receiver_not_callable); // will do.
__ LoadP(r7, FieldMemOperand(r4, HeapObject::kMapOffset));
__ lbz(r7, FieldMemOperand(r7, Map::kBitFieldOffset));
__ TestBit(r7, Map::kIsCallable, r0);
__ beq(&receiver_not_callable, cr0);
// 3. Tail call with no arguments if argArray is null or undefined. // 3. Tail call with no arguments if argArray is null or undefined.
Label no_arguments; Label no_arguments;
...@@ -2023,13 +2019,6 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { ...@@ -2023,13 +2019,6 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
__ li(r3, Operand::Zero()); __ li(r3, Operand::Zero());
__ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); __ 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 // static
...@@ -2117,24 +2106,13 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) { ...@@ -2117,24 +2106,13 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
// -- sp[0] : thisArgument // -- sp[0] : thisArgument
// ----------------------------------- // -----------------------------------
// 2. Make sure the target is actually callable. // 2. We don't need to check explicitly for callable target here,
Label target_not_callable; // since that's the first thing the Call/CallWithArrayLike builtins
__ JumpIfSmi(r4, &target_not_callable); // will do.
__ LoadP(r7, FieldMemOperand(r4, HeapObject::kMapOffset));
__ lbz(r7, FieldMemOperand(r7, Map::kBitFieldOffset));
__ TestBit(r7, Map::kIsCallable, r0);
__ beq(&target_not_callable, cr0);
// 3a. Apply the target to the given argumentsList. // 3. Apply the target to the given argumentsList.
__ Jump(masm->isolate()->builtins()->CallWithArrayLike(), __ Jump(masm->isolate()->builtins()->CallWithArrayLike(),
RelocInfo::CODE_TARGET); 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) { void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
......
...@@ -1988,13 +1988,9 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { ...@@ -1988,13 +1988,9 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
// -- sp[0] : thisArg // -- sp[0] : thisArg
// ----------------------------------- // -----------------------------------
// 2. Make sure the receiver is actually callable. // 2. We don't need to check explicitly for callable receiver here,
Label receiver_not_callable; // since that's the first thing the Call/CallWithArrayLike builtins
__ JumpIfSmi(r3, &receiver_not_callable); // will do.
__ LoadP(r6, FieldMemOperand(r3, HeapObject::kMapOffset));
__ LoadlB(r6, FieldMemOperand(r6, Map::kBitFieldOffset));
__ TestBit(r6, Map::kIsCallable);
__ beq(&receiver_not_callable);
// 3. Tail call with no arguments if argArray is null or undefined. // 3. Tail call with no arguments if argArray is null or undefined.
Label no_arguments; Label no_arguments;
...@@ -2012,13 +2008,6 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { ...@@ -2012,13 +2008,6 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
__ LoadImmP(r2, Operand::Zero()); __ LoadImmP(r2, Operand::Zero());
__ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); __ 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 // static
...@@ -2106,24 +2095,13 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) { ...@@ -2106,24 +2095,13 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
// -- sp[0] : thisArgument // -- sp[0] : thisArgument
// ----------------------------------- // -----------------------------------
// 2. Make sure the target is actually callable. // 2. We don't need to check explicitly for callable target here,
Label target_not_callable; // since that's the first thing the Call/CallWithArrayLike builtins
__ JumpIfSmi(r3, &target_not_callable); // will do.
__ LoadP(r6, FieldMemOperand(r3, HeapObject::kMapOffset));
__ LoadlB(r6, FieldMemOperand(r6, Map::kBitFieldOffset));
__ TestBit(r6, Map::kIsCallable);
__ beq(&target_not_callable);
// 3a. Apply the target to the given argumentsList. // 3 Apply the target to the given argumentsList.
__ Jump(masm->isolate()->builtins()->CallWithArrayLike(), __ Jump(masm->isolate()->builtins()->CallWithArrayLike(),
RelocInfo::CODE_TARGET); 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) { void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
......
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