Commit 57ea01af authored by Georgia Kouveli's avatar Georgia Kouveli Committed by Commit Bot

Add padding to builtin exit frames.

This is part of JSSP removal for arm64. The padding is needed so
that the extra arguments, which are pushed separately from the rest
of the arguments, will take up an even number of slots, to avoid
copying the rest of the arguments one slot down.

Bug: v8:6644
Change-Id: I00a8730c375e4b4cc8fa0c8b6372751f92754466
Reviewed-on: https://chromium-review.googlesource.com/713255
Commit-Queue: Georgia Kouveli <georgia.kouveli@arm.com>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48547}
parent 5e4dcf74
......@@ -62,10 +62,10 @@ void AdaptorWithExitFrameType(MacroAssembler* masm,
// CEntryStub expects r0 to contain the number of arguments including the
// receiver and the extra arguments.
const int num_extra_args = 3;
__ add(r0, r0, Operand(num_extra_args + 1));
__ add(r0, r0, Operand(BuiltinExitFrameConstants::kNumExtraArgsWithReceiver));
// Insert extra arguments.
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ SmiTag(r0);
__ Push(r0, r1, r3);
__ SmiUntag(r0);
......
......@@ -69,18 +69,18 @@ void AdaptorWithExitFrameType(MacroAssembler* masm,
// CEntryStub expects x0 to contain the number of arguments including the
// receiver and the extra arguments.
const int num_extra_args = 3;
__ Add(x0, x0, num_extra_args + 1);
__ Add(x0, x0, BuiltinExitFrameConstants::kNumExtraArgsWithReceiver);
// Insert extra arguments.
__ SmiTag(x0);
__ Push(x0, x1, x3);
__ SmiUntag(x0);
Register padding = x10;
__ LoadRoot(padding, Heap::kTheHoleValueRootIndex);
__ SmiTag(x11, x0);
__ Push(padding, x11, x1, x3);
// Jump to the C entry runtime stub directly here instead of using
// JumpToExternalReference. We have already loaded entry point to x5
// in Generate_adaptor.
__ mov(x1, x5);
__ Mov(x1, x5);
CEntryStub stub(masm->isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
exit_frame_type == Builtins::BUILTIN_EXIT);
__ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);
......
......@@ -205,7 +205,8 @@ MaybeHandle<Object> Builtins::InvokeApiFunction(Isolate* isolate,
for (int i = 0; i < argc; ++i) {
argv[cursor--] = *args[i];
}
DCHECK(cursor == BuiltinArguments::kArgcOffset);
DCHECK(cursor == BuiltinArguments::kPaddingOffset);
argv[BuiltinArguments::kPaddingOffset] = isolate->heap()->the_hole_value();
argv[BuiltinArguments::kArgcOffset] = Smi::FromInt(frame_argc);
argv[BuiltinArguments::kTargetOffset] = *function;
argv[BuiltinArguments::kNewTargetOffset] = *new_target;
......
......@@ -46,8 +46,10 @@ class BuiltinArguments : public Arguments {
static const int kNewTargetOffset = 0;
static const int kTargetOffset = 1;
static const int kArgcOffset = 2;
static const int kNumExtraArgs = 3;
static const int kNumExtraArgsWithReceiver = 4;
static const int kPaddingOffset = 3;
static const int kNumExtraArgs = 4;
static const int kNumExtraArgsWithReceiver = 5;
Handle<JSFunction> target() {
return Arguments::at<JSFunction>(Arguments::length() - 1 - kTargetOffset);
......
......@@ -55,12 +55,12 @@ void AdaptorWithExitFrameType(MacroAssembler* masm,
// CEntryStub expects eax to contain the number of arguments including the
// receiver and the extra arguments.
const int num_extra_args = 3;
__ add(eax, Immediate(num_extra_args + 1));
__ add(eax, Immediate(BuiltinExitFrameConstants::kNumExtraArgsWithReceiver));
// Insert extra arguments.
__ PopReturnAddressTo(ecx);
__ SmiTag(eax);
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ Push(eax);
__ SmiUntag(eax);
__ Push(edi);
......
......@@ -55,10 +55,10 @@ void AdaptorWithExitFrameType(MacroAssembler* masm,
// CEntryStub expects a0 to contain the number of arguments including the
// receiver and the extra arguments.
const int num_extra_args = 3;
__ Addu(a0, a0, num_extra_args + 1);
__ Addu(a0, a0, BuiltinExitFrameConstants::kNumExtraArgsWithReceiver);
// Insert extra arguments.
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ SmiTag(a0);
__ Push(a0, a1, a3);
__ SmiUntag(a0);
......
......@@ -55,10 +55,10 @@ void AdaptorWithExitFrameType(MacroAssembler* masm,
// CEntryStub expects a0 to contain the number of arguments including the
// receiver and the extra arguments.
const int num_extra_args = 3;
__ Daddu(a0, a0, num_extra_args + 1);
__ Daddu(a0, a0, BuiltinExitFrameConstants::kNumExtraArgsWithReceiver);
// Insert extra arguments.
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ SmiTag(a0);
__ Push(a0, a1, a3);
__ SmiUntag(a0);
......
......@@ -54,10 +54,11 @@ void AdaptorWithExitFrameType(MacroAssembler* masm,
// CEntryStub expects r3 to contain the number of arguments including the
// receiver and the extra arguments.
const int num_extra_args = 3;
__ addi(r3, r3, Operand(num_extra_args + 1));
__ addi(r3, r3,
Operand(BuiltinExitFrameConstants::kNumExtraArgsWithReceiver));
// Insert extra arguments.
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ SmiTag(r3);
__ Push(r3, r4, r6);
__ SmiUntag(r3);
......
......@@ -54,10 +54,11 @@ void AdaptorWithExitFrameType(MacroAssembler* masm,
// CEntryStub expects r2 to contain the number of arguments including the
// receiver and the extra arguments.
const int num_extra_args = 3;
__ AddP(r2, r2, Operand(num_extra_args + 1));
__ AddP(r2, r2,
Operand(BuiltinExitFrameConstants::kNumExtraArgsWithReceiver));
// Insert extra arguments.
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ SmiTag(r2);
__ Push(r2, r3, r5);
__ SmiUntag(r2);
......
......@@ -59,13 +59,13 @@ void AdaptorWithExitFrameType(MacroAssembler* masm,
// CEntryStub expects rax to contain the number of arguments including the
// receiver and the extra arguments.
const int num_extra_args = 3;
__ addp(rax, Immediate(num_extra_args + 1));
__ addp(rax, Immediate(BuiltinExitFrameConstants::kNumExtraArgsWithReceiver));
// Unconditionally insert argc, target and new target as extra arguments. They
// will be used by stack frame iterators when constructing the stack trace.
__ PopReturnAddressTo(kScratchRegister);
__ Integer32ToSmi(rax, rax);
__ PushRoot(Heap::kTheHoleValueRootIndex); // Padding.
__ Push(rax);
__ SmiToInteger32(rax, rax);
__ Push(rdi);
......
......@@ -1252,9 +1252,10 @@ Reduction JSBuiltinReducer::ReduceArrayShift(Node* node) {
Node* argc =
jsgraph()->Constant(BuiltinArguments::kNumExtraArgsWithReceiver);
if_false1 = efalse1 = vfalse1 =
graph()->NewNode(common()->Call(desc), stub_code, receiver, argc,
target, jsgraph()->UndefinedConstant(), entry,
argc, context, frame_state, efalse1, if_false1);
graph()->NewNode(common()->Call(desc), stub_code, receiver,
jsgraph()->PaddingConstant(), argc, target,
jsgraph()->UndefinedConstant(), entry, argc,
context, frame_state, efalse1, if_false1);
}
if_false0 = graph()->NewNode(common()->Merge(2), if_true1, if_false1);
......
......@@ -67,6 +67,9 @@ class V8_EXPORT_PRIVATE JSGraph : public NON_EXPORTED_BASE(ZoneObject) {
Node* NaNConstant();
Node* MinusOneConstant();
// Used for padding frames.
Node* PaddingConstant() { return TheHoleConstant(); }
// Creates a HeapConstant node, possibly canonicalized, and may access the
// heap to inspect the object.
Node* HeapConstant(Handle<HeapObject> value);
......
......@@ -1647,6 +1647,7 @@ void ReduceBuiltin(Isolate* isolate, JSGraph* jsgraph, Node* node,
static const int kStubAndReceiver = 2;
int cursor = arity + kStubAndReceiver;
node->InsertInput(zone, cursor++, jsgraph->PaddingConstant());
node->InsertInput(zone, cursor++, argc_node);
node->InsertInput(zone, cursor++, target);
node->InsertInput(zone, cursor++, new_target);
......
......@@ -269,6 +269,9 @@ class BuiltinExitFrameConstants : public CommonFrameConstants {
static const int kNewTargetOffset = kCallerPCOffset + 1 * kPointerSize;
static const int kTargetOffset = kNewTargetOffset + 1 * kPointerSize;
static const int kArgcOffset = kTargetOffset + 1 * kPointerSize;
static const int kPaddingOffset = kArgcOffset + 1 * kPointerSize;
static const int kFirstArgumentOffset = kPaddingOffset + 1 * kPointerSize;
static const int kNumExtraArgsWithReceiver = 5;
};
class InterpreterFrameConstants : public AllStatic {
......
......@@ -636,7 +636,8 @@ bool BuiltinExitFrame::IsConstructor() const {
Object* BuiltinExitFrame::GetParameter(int i) const {
DCHECK(i >= 0 && i < ComputeParametersCount());
int offset = BuiltinExitFrameConstants::kArgcOffset + (i + 1) * kPointerSize;
int offset =
BuiltinExitFrameConstants::kFirstArgumentOffset + i * kPointerSize;
return Memory::Object_at(fp() + offset);
}
......
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