Commit 5bb70fd7 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

PPC/s390: [runtime] Don't set ConstructedNonConstructable as a construct_stub

Port d6636145

Original Commit Message:

    Part of ongoing work to remove the construct_stub.

    For non-constructable functions, don't use the non-constructable stub,
    instead handle non-constructables explicitly in ConstructFunction.

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

Change-Id: I2e81b03b8fbbde025881fd3b65fe2fa0604f6ff5
Reviewed-on: https://chromium-review.googlesource.com/981116
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#52234}
parent 5cf2ae5a
...@@ -2316,6 +2316,7 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { ...@@ -2316,6 +2316,7 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
// -- r4 : the constructor to call (checked to be a JSFunction) // -- r4 : the constructor to call (checked to be a JSFunction)
// -- r6 : the new target (checked to be a constructor) // -- r6 : the new target (checked to be a constructor)
// ----------------------------------- // -----------------------------------
__ AssertConstructor(r4);
__ AssertFunction(r4); __ AssertFunction(r4);
// Calling convention for function specific ConstructStubs require // Calling convention for function specific ConstructStubs require
...@@ -2337,6 +2338,7 @@ void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) { ...@@ -2337,6 +2338,7 @@ void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) {
// -- r4 : the function to call (checked to be a JSBoundFunction) // -- r4 : the function to call (checked to be a JSBoundFunction)
// -- r6 : the new target (checked to be a constructor) // -- r6 : the new target (checked to be a constructor)
// ----------------------------------- // -----------------------------------
__ AssertConstructor(r4);
__ AssertBoundFunction(r4); __ AssertBoundFunction(r4);
// Push the [[BoundArguments]] onto the stack. // Push the [[BoundArguments]] onto the stack.
...@@ -2369,16 +2371,17 @@ void Builtins::Generate_Construct(MacroAssembler* masm) { ...@@ -2369,16 +2371,17 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
Label non_constructor, non_proxy; Label non_constructor, non_proxy;
__ JumpIfSmi(r4, &non_constructor); __ JumpIfSmi(r4, &non_constructor);
// Dispatch based on instance type.
__ CompareObjectType(r4, r7, r8, JS_FUNCTION_TYPE);
__ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction),
RelocInfo::CODE_TARGET, eq);
// Check if target has a [[Construct]] internal method. // Check if target has a [[Construct]] internal method.
__ LoadP(r7, FieldMemOperand(r4, HeapObject::kMapOffset));
__ lbz(r5, FieldMemOperand(r7, Map::kBitFieldOffset)); __ lbz(r5, FieldMemOperand(r7, Map::kBitFieldOffset));
__ TestBit(r5, Map::IsConstructorBit::kShift, r0); __ TestBit(r5, Map::IsConstructorBit::kShift, r0);
__ beq(&non_constructor, cr0); __ beq(&non_constructor, cr0);
// Dispatch based on instance type.
__ CompareInstanceType(r7, r8, JS_FUNCTION_TYPE);
__ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction),
RelocInfo::CODE_TARGET, eq);
// Only dispatch to bound functions after checking whether they are // Only dispatch to bound functions after checking whether they are
// constructors. // constructors.
__ cmpi(r8, Operand(JS_BOUND_FUNCTION_TYPE)); __ cmpi(r8, Operand(JS_BOUND_FUNCTION_TYPE));
......
...@@ -2325,6 +2325,7 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { ...@@ -2325,6 +2325,7 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
// -- r3 : the constructor to call (checked to be a JSFunction) // -- r3 : the constructor to call (checked to be a JSFunction)
// -- r5 : the new target (checked to be a constructor) // -- r5 : the new target (checked to be a constructor)
// ----------------------------------- // -----------------------------------
__ AssertConstructor(r3, r1);
__ AssertFunction(r3); __ AssertFunction(r3);
// Calling convention for function specific ConstructStubs require // Calling convention for function specific ConstructStubs require
...@@ -2346,6 +2347,7 @@ void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) { ...@@ -2346,6 +2347,7 @@ void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) {
// -- r3 : the function to call (checked to be a JSBoundFunction) // -- r3 : the function to call (checked to be a JSBoundFunction)
// -- r5 : the new target (checked to be a constructor) // -- r5 : the new target (checked to be a constructor)
// ----------------------------------- // -----------------------------------
__ AssertConstructor(r3, r1);
__ AssertBoundFunction(r3); __ AssertBoundFunction(r3);
// Push the [[BoundArguments]] onto the stack. // Push the [[BoundArguments]] onto the stack.
...@@ -2378,16 +2380,17 @@ void Builtins::Generate_Construct(MacroAssembler* masm) { ...@@ -2378,16 +2380,17 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
Label non_constructor, non_proxy; Label non_constructor, non_proxy;
__ JumpIfSmi(r3, &non_constructor); __ JumpIfSmi(r3, &non_constructor);
// Dispatch based on instance type.
__ CompareObjectType(r3, r6, r7, JS_FUNCTION_TYPE);
__ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction),
RelocInfo::CODE_TARGET, eq);
// Check if target has a [[Construct]] internal method. // Check if target has a [[Construct]] internal method.
__ LoadP(r6, FieldMemOperand(r3, HeapObject::kMapOffset));
__ LoadlB(r4, FieldMemOperand(r6, Map::kBitFieldOffset)); __ LoadlB(r4, FieldMemOperand(r6, Map::kBitFieldOffset));
__ TestBit(r4, Map::IsConstructorBit::kShift); __ TestBit(r4, Map::IsConstructorBit::kShift);
__ beq(&non_constructor); __ beq(&non_constructor);
// Dispatch based on instance type.
__ CompareInstanceType(r6, r7, JS_FUNCTION_TYPE);
__ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction),
RelocInfo::CODE_TARGET, eq);
// Only dispatch to bound functions after checking whether they are // Only dispatch to bound functions after checking whether they are
// constructors. // constructors.
__ CmpP(r7, Operand(JS_BOUND_FUNCTION_TYPE)); __ CmpP(r7, Operand(JS_BOUND_FUNCTION_TYPE));
......
...@@ -1746,6 +1746,20 @@ void MacroAssembler::AssertFixedArray(Register object) { ...@@ -1746,6 +1746,20 @@ void MacroAssembler::AssertFixedArray(Register object) {
} }
} }
void MacroAssembler::AssertConstructor(Register object) {
if (emit_debug_code()) {
STATIC_ASSERT(kSmiTag == 0);
TestIfSmi(object, r0);
Check(ne, AbortReason::kOperandIsASmiAndNotAConstructor);
push(object);
LoadP(object, FieldMemOperand(object, HeapObject::kMapOffset));
lbz(object, FieldMemOperand(object, Map::kBitFieldOffset));
andi(object, object, Operand(Map::IsConstructorBit::kMask));
pop(object);
Check(ne, AbortReason::kOperandIsNotAConstructor, cr0);
}
}
void MacroAssembler::AssertFunction(Register object) { void MacroAssembler::AssertFunction(Register object) {
if (emit_debug_code()) { if (emit_debug_code()) {
STATIC_ASSERT(kSmiTag == 0); STATIC_ASSERT(kSmiTag == 0);
......
...@@ -1008,6 +1008,10 @@ class MacroAssembler : public TurboAssembler { ...@@ -1008,6 +1008,10 @@ class MacroAssembler : public TurboAssembler {
// Abort execution if argument is not a FixedArray, enabled via --debug-code. // Abort execution if argument is not a FixedArray, enabled via --debug-code.
void AssertFixedArray(Register object); void AssertFixedArray(Register object);
// Abort execution if argument is not a Constructor, enabled via --debug-code.
void AssertConstructor(Register object);
// Abort execution if argument is not a JSFunction, enabled via --debug-code.
void AssertFunction(Register object); void AssertFunction(Register object);
// Abort execution if argument is not a JSBoundFunction, // Abort execution if argument is not a JSBoundFunction,
......
...@@ -1654,6 +1654,18 @@ void MacroAssembler::AssertFixedArray(Register object) { ...@@ -1654,6 +1654,18 @@ void MacroAssembler::AssertFixedArray(Register object) {
} }
} }
void MacroAssembler::AssertConstructor(Register object, Register scratch) {
if (emit_debug_code()) {
STATIC_ASSERT(kSmiTag == 0);
TestIfSmi(object);
Check(ne, AbortReason::kOperandIsASmiAndNotAConstructor);
LoadP(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset));
tm(FieldMemOperand(scratch, Map::kBitFieldOffset),
Operand(Map::IsConstructorBit::kMask));
Check(ne, AbortReason::kOperandIsNotAConstructor);
}
}
void MacroAssembler::AssertFunction(Register object) { void MacroAssembler::AssertFunction(Register object) {
if (emit_debug_code()) { if (emit_debug_code()) {
STATIC_ASSERT(kSmiTag == 0); STATIC_ASSERT(kSmiTag == 0);
......
...@@ -1238,6 +1238,10 @@ class MacroAssembler : public TurboAssembler { ...@@ -1238,6 +1238,10 @@ class MacroAssembler : public TurboAssembler {
// Abort execution if argument is not a FixedArray, enabled via --debug-code. // Abort execution if argument is not a FixedArray, enabled via --debug-code.
void AssertFixedArray(Register object); void AssertFixedArray(Register object);
// Abort execution if argument is not a Constructor, enabled via --debug-code.
void AssertConstructor(Register object, Register scratch);
// Abort execution if argument is not a JSFunction, enabled via --debug-code.
void AssertFunction(Register object); void AssertFunction(Register object);
// Abort execution if argument is not a JSBoundFunction, // Abort execution if argument is not a JSBoundFunction,
......
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