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

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

Port 21701297

Original Commit Message:

    Add a new JSConstructWithArrayLike operator that is backed by the
    ConstructWithArrayLike builtin (similar to what was done before
    for the JSCallWithArrayLike operator), and use that operator to
    optimize Reflect.construct inlining in TurboFan. This is handled
    uniformly with JSConstructWithSpread in the JSCallReducer.

    Also add missing test coverage for Reflect.construct in optimized
    code, especially for some interesting corner cases.

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: Idaf247317036ddec74b9aa3addd2e7d75b65bfaf
Reviewed-on: https://chromium-review.googlesource.com/546716
Commit-Queue: Jaideep Bajwa <bjaideep@ca.ibm.com>
Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#46189}
parent b09ff25c
......@@ -2158,39 +2158,17 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
// -- sp[0] : receiver (undefined)
// -----------------------------------
// 2. Make sure the target is actually a constructor.
Label target_not_constructor;
__ JumpIfSmi(r4, &target_not_constructor);
__ LoadP(r7, FieldMemOperand(r4, HeapObject::kMapOffset));
__ lbz(r7, FieldMemOperand(r7, Map::kBitFieldOffset));
__ TestBit(r7, Map::kIsConstructor, r0);
__ beq(&target_not_constructor, cr0);
// 2. We don't need to check explicitly for constructor target here,
// since that's the first thing the Construct/ConstructWithArrayLike
// builtins will do.
// 3. Make sure the target is actually a constructor.
Label new_target_not_constructor;
__ JumpIfSmi(r6, &new_target_not_constructor);
__ LoadP(r7, FieldMemOperand(r6, HeapObject::kMapOffset));
__ lbz(r7, FieldMemOperand(r7, Map::kBitFieldOffset));
__ TestBit(r7, Map::kIsConstructor, r0);
__ beq(&new_target_not_constructor, cr0);
// 3. We don't need to check explicitly for constructor new.target here,
// since that's the second thing the Construct/ConstructWithArrayLike
// builtins will do.
// 4a. Construct the target with the given new.target and argumentsList.
// 4. Construct the target with the given new.target and argumentsList.
__ Jump(masm->isolate()->builtins()->ConstructWithArrayLike(),
RelocInfo::CODE_TARGET);
// 4b. The target is not a constructor, throw an appropriate TypeError.
__ bind(&target_not_constructor);
{
__ StoreP(r4, MemOperand(sp, 0));
__ TailCallRuntime(Runtime::kThrowNotConstructor);
}
// 4c. The new.target is not a constructor, throw an appropriate TypeError.
__ bind(&new_target_not_constructor);
{
__ StoreP(r6, MemOperand(sp, 0));
__ TailCallRuntime(Runtime::kThrowNotConstructor);
}
}
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
......
......@@ -2147,39 +2147,17 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
// -- sp[0] : receiver (undefined)
// -----------------------------------
// 2. Make sure the target is actually a constructor.
Label target_not_constructor;
__ JumpIfSmi(r3, &target_not_constructor);
__ LoadP(r6, FieldMemOperand(r3, HeapObject::kMapOffset));
__ LoadlB(r6, FieldMemOperand(r6, Map::kBitFieldOffset));
__ TestBit(r6, Map::kIsConstructor);
__ beq(&target_not_constructor);
// 2. We don't need to check explicitly for constructor target here,
// since that's the first thing the Construct/ConstructWithArrayLike
// builtins will do.
// 3. Make sure the target is actually a constructor.
Label new_target_not_constructor;
__ JumpIfSmi(r5, &new_target_not_constructor);
__ LoadP(r6, FieldMemOperand(r5, HeapObject::kMapOffset));
__ LoadlB(r6, FieldMemOperand(r6, Map::kBitFieldOffset));
__ TestBit(r6, Map::kIsConstructor);
__ beq(&new_target_not_constructor);
// 3. We don't need to check explicitly for constructor new.target here,
// since that's the second thing the Construct/ConstructWithArrayLike
// builtins will do.
// 4a. Construct the target with the given new.target and argumentsList.
// 4. Construct the target with the given new.target and argumentsList.
__ Jump(masm->isolate()->builtins()->ConstructWithArrayLike(),
RelocInfo::CODE_TARGET);
// 4b. The target is not a constructor, throw an appropriate TypeError.
__ bind(&target_not_constructor);
{
__ StoreP(r3, MemOperand(sp, 0));
__ TailCallRuntime(Runtime::kThrowNotConstructor);
}
// 4c. The new.target is not a constructor, throw an appropriate TypeError.
__ bind(&new_target_not_constructor);
{
__ StoreP(r5, MemOperand(sp, 0));
__ TailCallRuntime(Runtime::kThrowNotConstructor);
}
}
static void EnterArgumentsAdaptorFrame(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