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