Commit cd0377c0 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

PPC/s390: Fix overzealous assert in CallOrConstructVarArgs

Port 34225a6a

Original Commit Message:

    For spread calls with arrays with double elements but zero length,
    we skip the box-as-heapnumber step; so in this corner case the
    Call builtin sees a FixedDoubleArray, which is fine because it
    doesn't read any of the raw double values from it.
    This patch doesn't change the implementation, it only updates the
    assert to match reality.

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

Change-Id: Iafa52f21fb0bbee5656fdfd6c5f3a50894ff683f
Reviewed-on: https://chromium-review.googlesource.com/1126212Reviewed-by: 's avatarMichael Dawson <michael_dawson@ca.ibm.com>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#54227}
parent 2377c460
...@@ -1641,7 +1641,28 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm, ...@@ -1641,7 +1641,28 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
// -- r6 : new.target (for [[Construct]]) // -- r6 : new.target (for [[Construct]])
// ----------------------------------- // -----------------------------------
__ AssertFixedArray(r5); Register scratch = ip;
if (masm->emit_debug_code()) {
// Allow r5 to be a FixedArray, or a FixedDoubleArray if r7 == 0.
Label ok, fail;
__ AssertNotSmi(r5);
__ LoadP(scratch, FieldMemOperand(r5, HeapObject::kMapOffset));
__ LoadHalfWord(scratch,
FieldMemOperand(scratch, Map::kInstanceTypeOffset));
__ cmpi(scratch, Operand(FIXED_ARRAY_TYPE));
__ beq(&ok);
__ cmpi(scratch, Operand(FIXED_DOUBLE_ARRAY_TYPE));
__ bne(&fail);
__ cmpi(r7, Operand::Zero());
__ beq(&ok);
// Fall through.
__ bind(&fail);
__ Abort(AbortReason::kOperandIsNotAFixedArray);
__ bind(&ok);
}
// Check for stack overflow. // Check for stack overflow.
{ {
// Check the stack for overflow. We are not trying to catch interruptions // Check the stack for overflow. We are not trying to catch interruptions
......
...@@ -1645,7 +1645,28 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm, ...@@ -1645,7 +1645,28 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
// -- r5 : new.target (for [[Construct]]) // -- r5 : new.target (for [[Construct]])
// ----------------------------------- // -----------------------------------
__ AssertFixedArray(r4); Register scratch = ip;
if (masm->emit_debug_code()) {
// Allow r4 to be a FixedArray, or a FixedDoubleArray if r6 == 0.
Label ok, fail;
__ AssertNotSmi(r4);
__ LoadP(scratch, FieldMemOperand(r4, HeapObject::kMapOffset));
__ LoadHalfWordP(scratch,
FieldMemOperand(scratch, Map::kInstanceTypeOffset));
__ CmpP(scratch, Operand(FIXED_ARRAY_TYPE));
__ beq(&ok);
__ CmpP(scratch, Operand(FIXED_DOUBLE_ARRAY_TYPE));
__ bne(&fail);
__ CmpP(r6, Operand::Zero());
__ beq(&ok);
// Fall through.
__ bind(&fail);
__ Abort(AbortReason::kOperandIsNotAFixedArray);
__ bind(&ok);
}
// Check for stack overflow. // Check for stack overflow.
{ {
// Check the stack for overflow. We are not trying to catch interruptions // Check the stack for overflow. We are not trying to catch interruptions
......
...@@ -1841,18 +1841,6 @@ void MacroAssembler::AssertSmi(Register object) { ...@@ -1841,18 +1841,6 @@ void MacroAssembler::AssertSmi(Register object) {
} }
} }
void MacroAssembler::AssertFixedArray(Register object) {
if (emit_debug_code()) {
STATIC_ASSERT(kSmiTag == 0);
TestIfSmi(object, r0);
Check(ne, AbortReason::kOperandIsASmiAndNotAFixedArray, cr0);
push(object);
CompareObjectType(object, object, object, FIXED_ARRAY_TYPE);
pop(object);
Check(eq, AbortReason::kOperandIsNotAFixedArray);
}
}
void MacroAssembler::AssertConstructor(Register object) { void MacroAssembler::AssertConstructor(Register object) {
if (emit_debug_code()) { if (emit_debug_code()) {
STATIC_ASSERT(kSmiTag == 0); STATIC_ASSERT(kSmiTag == 0);
......
...@@ -1023,9 +1023,6 @@ class MacroAssembler : public TurboAssembler { ...@@ -1023,9 +1023,6 @@ class MacroAssembler : public TurboAssembler {
#define SmiWordOffset(offset) offset #define SmiWordOffset(offset) offset
#endif #endif
// Abort execution if argument is not a FixedArray, enabled via --debug-code.
void AssertFixedArray(Register object);
// Abort execution if argument is not a Constructor, enabled via --debug-code. // Abort execution if argument is not a Constructor, enabled via --debug-code.
void AssertConstructor(Register object); void AssertConstructor(Register object);
......
...@@ -1780,18 +1780,6 @@ void MacroAssembler::AssertSmi(Register object) { ...@@ -1780,18 +1780,6 @@ void MacroAssembler::AssertSmi(Register object) {
} }
} }
void MacroAssembler::AssertFixedArray(Register object) {
if (emit_debug_code()) {
STATIC_ASSERT(kSmiTag == 0);
TestIfSmi(object);
Check(ne, AbortReason::kOperandIsASmiAndNotAFixedArray, cr0);
push(object);
CompareObjectType(object, object, object, FIXED_ARRAY_TYPE);
pop(object);
Check(eq, AbortReason::kOperandIsNotAFixedArray);
}
}
void MacroAssembler::AssertConstructor(Register object, Register scratch) { void MacroAssembler::AssertConstructor(Register object, Register scratch) {
if (emit_debug_code()) { if (emit_debug_code()) {
STATIC_ASSERT(kSmiTag == 0); STATIC_ASSERT(kSmiTag == 0);
......
...@@ -1266,9 +1266,6 @@ class MacroAssembler : public TurboAssembler { ...@@ -1266,9 +1266,6 @@ class MacroAssembler : public TurboAssembler {
#define SmiWordOffset(offset) offset #define SmiWordOffset(offset) offset
#endif #endif
// Abort execution if argument is not a FixedArray, enabled via --debug-code.
void AssertFixedArray(Register object);
// Abort execution if argument is not a Constructor, enabled via --debug-code. // Abort execution if argument is not a Constructor, enabled via --debug-code.
void AssertConstructor(Register object, Register scratch); void AssertConstructor(Register object, Register scratch);
......
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