Commit 876ae425 authored by arv's avatar arv Committed by Commit bot

Unify the stack layout for construct frames

The stack layout was different for different ports.

BUG=v8:3887
LOG=N
R=dslomov@chromium.org, adamk@chromium.org

Review URL: https://codereview.chromium.org/1203103003

Cr-Commit-Position: refs/heads/master@{#29292}
parent 6434ec30
......@@ -624,16 +624,16 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&count_incremented);
}
__ pop(r1); // Constructor function.
__ push(r4);
__ push(r4);
// Reload the number of arguments and the constructor from the stack.
// Reload the number of arguments from the stack.
// sp[0]: receiver
// sp[1]: receiver
// sp[2]: constructor function
// sp[3]: number of arguments (smi-tagged)
__ ldr(r1, MemOperand(sp, 2 * kPointerSize));
__ ldr(r3, MemOperand(sp, 3 * kPointerSize));
// sp[2]: number of arguments (smi-tagged)
__ ldr(r3, MemOperand(sp, 2 * kPointerSize));
// Set up pointer to last argument.
__ add(r2, fp, Operand(StandardFrameConstants::kCallerSPOffset));
......@@ -648,8 +648,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// r3: number of arguments (smi-tagged)
// sp[0]: receiver
// sp[1]: receiver
// sp[2]: constructor function
// sp[3]: number of arguments (smi-tagged)
// sp[2]: number of arguments (smi-tagged)
Label loop, entry;
__ b(&entry);
__ bind(&loop);
......@@ -680,8 +679,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Restore context from the frame.
// r0: result
// sp[0]: receiver
// sp[1]: constructor function
// sp[2]: number of arguments (smi-tagged)
// sp[1]: number of arguments (smi-tagged)
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
// If the result is an object (in the ECMA sense), we should get rid
......@@ -692,8 +690,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// If the result is a smi, it is *not* an object in the ECMA sense.
// r0: result
// sp[0]: receiver (newly allocated object)
// sp[1]: constructor function
// sp[2]: number of arguments (smi-tagged)
// sp[1]: number of arguments (smi-tagged)
__ JumpIfSmi(r0, &use_receiver);
// If the type of the result (stored in its map) is less than
......@@ -711,9 +708,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&exit);
// r0: result
// sp[0]: receiver (newly allocated object)
// sp[1]: constructor function
// sp[2]: number of arguments (smi-tagged)
__ ldr(r1, MemOperand(sp, 2 * kPointerSize));
// sp[1]: number of arguments (smi-tagged)
__ ldr(r1, MemOperand(sp, kPointerSize));
// Leave construct frame.
}
......
......@@ -141,13 +141,12 @@ class ArgumentsAdaptorFrameConstants : public AllStatic {
class ConstructFrameConstants : public AllStatic {
public:
// FP-relative.
static const int kImplicitReceiverOffset = -6 * kPointerSize;
static const int kConstructorOffset = -5 * kPointerSize;
static const int kImplicitReceiverOffset = -5 * kPointerSize;
static const int kLengthOffset = -4 * kPointerSize;
static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
static const int kFrameSize =
StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize;
};
......
......@@ -592,16 +592,16 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&count_incremented);
}
__ Pop(constructor);
__ Push(x4, x4);
// Reload the number of arguments from the stack.
// Set it up in x0 for the function call below.
// jssp[0]: receiver
// jssp[1]: receiver
// jssp[2]: constructor function
// jssp[3]: number of arguments (smi-tagged)
__ Peek(constructor, 2 * kXRegSize); // Load constructor.
__ Peek(argc, 3 * kXRegSize); // Load number of arguments.
// jssp[2]: number of arguments (smi-tagged)
__ Peek(argc, 2 * kXRegSize); // Load number of arguments.
__ SmiUntag(argc);
// Set up pointer to last argument.
......@@ -614,8 +614,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// x2: address of last argument (caller sp)
// jssp[0]: receiver
// jssp[1]: receiver
// jssp[2]: constructor function
// jssp[3]: number of arguments (smi-tagged)
// jssp[2]: number of arguments (smi-tagged)
// Compute the start address of the copy in x3.
__ Add(x3, x2, Operand(argc, LSL, kPointerSizeLog2));
Label loop, entry, done_copying_arguments;
......@@ -653,8 +652,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Restore the context from the frame.
// x0: result
// jssp[0]: receiver
// jssp[1]: constructor function
// jssp[2]: number of arguments (smi-tagged)
// jssp[1]: number of arguments (smi-tagged)
__ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
// If the result is an object (in the ECMA sense), we should get rid
......@@ -665,8 +663,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// If the result is a smi, it is *not* an object in the ECMA sense.
// x0: result
// jssp[0]: receiver (newly allocated object)
// jssp[1]: constructor function
// jssp[2]: number of arguments (smi-tagged)
// jssp[1]: number of arguments (smi-tagged)
__ JumpIfSmi(x0, &use_receiver);
// If the type of the result (stored in its map) is less than
......@@ -683,9 +680,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ Bind(&exit);
// x0: result
// jssp[0]: receiver (newly allocated object)
// jssp[1]: constructor function
// jssp[2]: number of arguments (smi-tagged)
__ Peek(x1, 2 * kXRegSize);
// jssp[1]: number of arguments (smi-tagged)
__ Peek(x1, kXRegSize);
// Leave construct frame.
}
......
......@@ -78,11 +78,10 @@ class ConstructFrameConstants : public AllStatic {
// FP-relative.
static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
static const int kLengthOffset = -4 * kPointerSize;
static const int kConstructorOffset = -5 * kPointerSize;
static const int kImplicitReceiverOffset = -6 * kPointerSize;
static const int kImplicitReceiverOffset = -5 * kPointerSize;
static const int kFrameSize =
StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize;
};
......
......@@ -1250,14 +1250,6 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator,
PrintF(trace_scope_->file(), "(%d)\n", height - 1);
}
// Constructor function being invoked by the stub (only present on some
// architectures, indicated by kConstructorOffset).
if (ConstructFrameConstants::kConstructorOffset != kMinInt) {
output_offset -= kPointerSize;
WriteValueToOutput(function, 0, frame_index, output_offset,
"constructor function ");
}
// The newly allocated object was passed as receiver in the artificial
// constructor stub environment created by HEnvironment::CopyForInlining().
output_offset -= kPointerSize;
......
......@@ -93,7 +93,6 @@ class ConstructFrameConstants : public AllStatic {
public:
// FP-relative.
static const int kImplicitReceiverOffset = -5 * kPointerSize;
static const int kConstructorOffset = kMinInt;
static const int kLengthOffset = -4 * kPointerSize;
static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
......
......@@ -641,15 +641,15 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&count_incremented);
}
__ Pop(a1);
__ Push(t4, t4);
// Reload the number of arguments from the stack.
// sp[0]: receiver
// sp[1]: receiver
// sp[2]: constructor function
// sp[3]: number of arguments (smi-tagged)
__ lw(a1, MemOperand(sp, 2 * kPointerSize));
__ lw(a3, MemOperand(sp, 3 * kPointerSize));
// sp[2]: number of arguments (smi-tagged)
__ lw(a3, MemOperand(sp, 2 * kPointerSize));
// Set up pointer to last argument.
__ Addu(a2, fp, Operand(StandardFrameConstants::kCallerSPOffset));
......@@ -664,8 +664,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// a3: number of arguments (smi-tagged)
// sp[0]: receiver
// sp[1]: receiver
// sp[2]: constructor function
// sp[3]: number of arguments (smi-tagged)
// sp[2]: number of arguments (smi-tagged)
Label loop, entry;
__ jmp(&entry);
__ bind(&loop);
......@@ -706,8 +705,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// If the result is a smi, it is *not* an object in the ECMA sense.
// v0: result
// sp[0]: receiver (newly allocated object)
// sp[1]: constructor function
// sp[2]: number of arguments (smi-tagged)
// sp[1]: number of arguments (smi-tagged)
__ JumpIfSmi(v0, &use_receiver);
// If the type of the result (stored in its map) is less than
......@@ -725,9 +723,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&exit);
// v0: result
// sp[0]: receiver (newly allocated object)
// sp[1]: constructor function
// sp[2]: number of arguments (smi-tagged)
__ lw(a1, MemOperand(sp, 2 * kPointerSize));
// sp[1]: number of arguments (smi-tagged)
__ lw(a1, MemOperand(sp, kPointerSize));
// Leave construct frame.
}
......
......@@ -182,13 +182,12 @@ class ArgumentsAdaptorFrameConstants : public AllStatic {
class ConstructFrameConstants : public AllStatic {
public:
// FP-relative.
static const int kImplicitReceiverOffset = -6 * kPointerSize;
static const int kConstructorOffset = -5 * kPointerSize;
static const int kImplicitReceiverOffset = -5 * kPointerSize;
static const int kLengthOffset = -4 * kPointerSize;
static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
static const int kFrameSize =
StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize;
};
......
......@@ -649,15 +649,15 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&count_incremented);
}
__ Pop(a1);
__ Push(t0, t0);
// Reload the number of arguments from the stack.
// sp[0]: receiver
// sp[1]: receiver
// sp[2]: constructor function
// sp[3]: number of arguments (smi-tagged)
__ ld(a1, MemOperand(sp, 2 * kPointerSize));
__ ld(a3, MemOperand(sp, 3 * kPointerSize));
// sp[2]: number of arguments (smi-tagged)
__ ld(a3, MemOperand(sp, 2 * kPointerSize));
// Set up pointer to last argument.
__ Daddu(a2, fp, Operand(StandardFrameConstants::kCallerSPOffset));
......@@ -672,8 +672,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// a3: number of arguments (smi-tagged)
// sp[0]: receiver
// sp[1]: receiver
// sp[2]: constructor function
// sp[3]: number of arguments (smi-tagged)
// sp[2]: number of arguments (smi-tagged)
Label loop, entry;
__ SmiUntag(a3);
__ jmp(&entry);
......@@ -715,8 +714,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// If the result is a smi, it is *not* an object in the ECMA sense.
// v0: result
// sp[0]: receiver (newly allocated object)
// sp[1]: constructor function
// sp[2]: number of arguments (smi-tagged)
// sp[1]: number of arguments (smi-tagged)
__ JumpIfSmi(v0, &use_receiver);
// If the type of the result (stored in its map) is less than
......@@ -734,9 +732,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&exit);
// v0: result
// sp[0]: receiver (newly allocated object)
// sp[1]: constructor function
// sp[2]: number of arguments (smi-tagged)
__ ld(a1, MemOperand(sp, 2 * kPointerSize));
// sp[1]: number of arguments (smi-tagged)
__ ld(a1, MemOperand(sp, kPointerSize));
// Leave construct frame.
}
......
......@@ -182,13 +182,12 @@ class ArgumentsAdaptorFrameConstants : public AllStatic {
class ConstructFrameConstants : public AllStatic {
public:
// FP-relative.
static const int kImplicitReceiverOffset = -6 * kPointerSize;
static const int kConstructorOffset = -5 * kPointerSize;
static const int kImplicitReceiverOffset = -5 * kPointerSize;
static const int kLengthOffset = -4 * kPointerSize;
static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
static const int kFrameSize =
StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize;
};
......
......@@ -626,15 +626,15 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&count_incremented);
}
__ Pop(r4);
__ Push(r7, r7);
// Reload the number of arguments and the constructor from the stack.
// sp[0]: receiver
// sp[1]: receiver
// sp[2]: constructor function
// sp[3]: number of arguments (smi-tagged)
__ LoadP(r4, MemOperand(sp, 2 * kPointerSize));
__ LoadP(r6, MemOperand(sp, 3 * kPointerSize));
// sp[2]: number of arguments (smi-tagged)
__ LoadP(r6, MemOperand(sp, 2 * kPointerSize));
// Set up pointer to last argument.
__ addi(r5, fp, Operand(StandardFrameConstants::kCallerSPOffset));
......@@ -649,8 +649,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// r6: number of arguments (smi-tagged)
// sp[0]: receiver
// sp[1]: receiver
// sp[2]: constructor function
// sp[3]: number of arguments (smi-tagged)
// sp[2]: number of arguments (smi-tagged)
Label loop, no_args;
__ cmpi(r3, Operand::Zero());
__ beq(&no_args);
......@@ -683,8 +682,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Restore context from the frame.
// r3: result
// sp[0]: receiver
// sp[1]: constructor function
// sp[2]: number of arguments (smi-tagged)
// sp[1]: number of arguments (smi-tagged)
__ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
// If the result is an object (in the ECMA sense), we should get rid
......@@ -695,8 +693,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// If the result is a smi, it is *not* an object in the ECMA sense.
// r3: result
// sp[0]: receiver (newly allocated object)
// sp[1]: constructor function
// sp[2]: number of arguments (smi-tagged)
// sp[1]: number of arguments (smi-tagged)
__ JumpIfSmi(r3, &use_receiver);
// If the type of the result (stored in its map) is less than
......@@ -714,9 +711,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&exit);
// r3: result
// sp[0]: receiver (newly allocated object)
// sp[1]: constructor function
// sp[2]: number of arguments (smi-tagged)
__ LoadP(r4, MemOperand(sp, 2 * kPointerSize));
// sp[1]: number of arguments (smi-tagged)
__ LoadP(r4, MemOperand(sp, kPointerSize));
// Leave construct frame.
}
......
......@@ -161,13 +161,12 @@ class ArgumentsAdaptorFrameConstants : public AllStatic {
class ConstructFrameConstants : public AllStatic {
public:
// FP-relative.
static const int kImplicitReceiverOffset = -6 * kPointerSize;
static const int kConstructorOffset = -5 * kPointerSize;
static const int kImplicitReceiverOffset = -5 * kPointerSize;
static const int kLengthOffset = -4 * kPointerSize;
static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
static const int kFrameSize =
StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize;
};
......
......@@ -85,7 +85,6 @@ class ConstructFrameConstants : public AllStatic {
public:
// FP-relative.
static const int kImplicitReceiverOffset = -5 * kPointerSize;
static const int kConstructorOffset = kMinInt;
static const int kLengthOffset = -4 * kPointerSize;
static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
......
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