@@ -461,7 +461,7 @@ void CEntryStub::Generate(MacroAssembler* masm) {
461461 __ Peek (argc, 2 * kPointerSize );
462462 __ Peek (target, 3 * kPointerSize );
463463
464- __ LeaveExitFrame (save_doubles (), x10, true );
464+ __ LeaveExitFrame (save_doubles (), x10);
465465 DCHECK (jssp.Is (__ StackPointer ()));
466466 if (!argv_in_register ()) {
467467 // Drop the remaining stack slots and return from the stub.
@@ -1558,8 +1558,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
15581558 Register function_address,
15591559 ExternalReference thunk_ref,
15601560 int stack_space, int spill_offset,
1561- MemOperand return_value_operand,
1562- MemOperand* context_restore_operand) {
1561+ MemOperand return_value_operand) {
15631562 ASM_LOCATION (" CallApiFunctionAndReturn" );
15641563 Isolate* isolate = masm->isolate ();
15651564 ExternalReference next_address =
@@ -1661,12 +1660,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
16611660 __ Peek (x21, (spill_offset + 2 ) * kXRegSize );
16621661 __ Peek (x22, (spill_offset + 3 ) * kXRegSize );
16631662
1664- bool restore_context = context_restore_operand != nullptr ;
1665- if (restore_context) {
1666- __ Ldr (cp, *context_restore_operand);
1667- }
1668-
1669- __ LeaveExitFrame (false , x1, !restore_context);
1663+ __ LeaveExitFrame (false , x1);
16701664
16711665 // Check if the function scheduled an exception.
16721666 __ Mov (x5, ExternalReference::scheduled_exception_address (isolate));
@@ -1706,7 +1700,6 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
17061700 // -- ...
17071701 // -- sp[(argc - 1) * 8] : first argument
17081702 // -- sp[argc * 8] : receiver
1709- // -- sp[(argc + 1) * 8] : accessor_holder
17101703 // -----------------------------------
17111704
17121705 Register callee = x0;
@@ -1717,9 +1710,8 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
17171710
17181711 typedef FunctionCallbackArguments FCA ;
17191712
1720- STATIC_ASSERT (FCA ::kArgsLength == 8 );
1721- STATIC_ASSERT (FCA ::kNewTargetIndex == 7 );
1722- STATIC_ASSERT (FCA ::kContextSaveIndex == 6 );
1713+ STATIC_ASSERT (FCA ::kArgsLength == 7 );
1714+ STATIC_ASSERT (FCA ::kNewTargetIndex == 6 );
17231715 STATIC_ASSERT (FCA ::kCalleeIndex == 5 );
17241716 STATIC_ASSERT (FCA ::kDataIndex == 4 );
17251717 STATIC_ASSERT (FCA ::kReturnValueOffset == 3 );
@@ -1730,8 +1722,8 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
17301722 Register undef = x7;
17311723 __ LoadRoot (undef, Heap::kUndefinedValueRootIndex );
17321724
1733- // Push new target, context , callee and call data.
1734- __ Push (undef, context , callee, call_data);
1725+ // Push alignment filler, new target , callee and call data.
1726+ __ Push (undef, undef , callee, call_data);
17351727
17361728 Register isolate_reg = x5;
17371729 __ Mov (isolate_reg, ExternalReference::isolate_address (masm->isolate ()));
@@ -1741,35 +1733,7 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
17411733 __ Push (undef, undef, isolate_reg, holder);
17421734
17431735 // Enter a new context.
1744- if (is_lazy ()) {
1745- // ----------- S t a t e -------------------------------------
1746- // -- sp[0] : holder
1747- // -- ...
1748- // -- sp[(FCA::kArgsLength - 1) * 8] : new_target
1749- // -- sp[FCA::kArgsLength * 8] : last argument
1750- // -- ...
1751- // -- sp[(FCA::kArgsLength + argc - 1) * 8] : first argument
1752- // -- sp[(FCA::kArgsLength + argc) * 8] : receiver
1753- // -- sp[(FCA::kArgsLength + argc + 1) * 8] : accessor_holder
1754- // -----------------------------------------------------------
1755-
1756- // Load context from accessor_holder.
1757- Register accessor_holder = context;
1758- Register scratch = undef;
1759- Register scratch2 = callee;
1760- __ Ldr (accessor_holder,
1761- MemOperand (__ StackPointer (),
1762- (FCA ::kArgsLength + 1 + argc ()) * kPointerSize ));
1763- // Look for the constructor if |accessor_holder| is not a function.
1764- Label skip_looking_for_constructor;
1765- __ Ldr (scratch, FieldMemOperand (accessor_holder, HeapObject::kMapOffset ));
1766- __ Ldrb (scratch2, FieldMemOperand (scratch, Map::kBitFieldOffset ));
1767- __ Tst (scratch2, Operand (1 << Map::kIsConstructor ));
1768- __ B (ne, &skip_looking_for_constructor);
1769- __ GetMapConstructor (context, scratch, scratch, scratch2);
1770- __ Bind (&skip_looking_for_constructor);
1771- __ Ldr (context, FieldMemOperand (context, JSFunction::kContextOffset ));
1772- } else {
1736+ if (!is_lazy ()) {
17731737 // Load context from callee.
17741738 __ Ldr (context, FieldMemOperand (callee, JSFunction::kContextOffset ));
17751739 }
@@ -1794,7 +1758,9 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
17941758 // Arguments is after the return address.
17951759 __ SlotAddress (x0, 1 );
17961760 // FunctionCallbackInfo::implicit_args_ and FunctionCallbackInfo::values_
1797- __ Add (x10, args, Operand ((FCA ::kArgsLength - 1 + argc ()) * kPointerSize ));
1761+ // + 1 to account for the alignment filler.
1762+ __ Add (x10, args,
1763+ Operand ((FCA ::kArgsLength - 1 + argc () + 1 ) * kPointerSize ));
17981764 __ Stp (args, x10, MemOperand (x0, 0 * kPointerSize ));
17991765 // FunctionCallbackInfo::length_ = argc
18001766 __ Mov (x10, argc ());
@@ -1804,8 +1770,6 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
18041770 ExternalReference::invoke_function_callback (masm->isolate ());
18051771
18061772 AllowExternalCallThatCantCauseGC scope (masm);
1807- MemOperand context_restore_operand (
1808- fp, (2 + FCA ::kContextSaveIndex ) * kPointerSize );
18091773 // Stores return the first js argument
18101774 int return_value_offset = 0 ;
18111775 if (is_store ()) {
@@ -1815,14 +1779,15 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
18151779 }
18161780 MemOperand return_value_operand (fp, return_value_offset * kPointerSize );
18171781 // The number of arguments might be odd, but will be padded when calling the
1818- // stub. We do not round up stack_space here, this will be done in
1819- // CallApiFunctionAndReturn.
1820- const int stack_space = argc () + FCA ::kArgsLength + 2 ;
1821- DCHECK_EQ ((stack_space - argc ()) % 2 , 0 );
1782+ // stub. We do not round up stack_space to account for odd argc here, this
1783+ // will be done in CallApiFunctionAndReturn. The current frame needs to be
1784+ // aligned here, which is why we push a filler before FCA.
1785+ const int stack_space = (argc () + 1 ) + FCA ::kArgsLength + 1 ;
1786+
1787+ DCHECK_EQ ((stack_space - (argc () + 1 )) % 2 , 0 );
18221788 const int spill_offset = 1 + kApiStackSpace ;
18231789 CallApiFunctionAndReturn (masm, api_function_address, thunk_ref, stack_space,
1824- spill_offset, return_value_operand,
1825- &context_restore_operand);
1790+ spill_offset, return_value_operand);
18261791}
18271792
18281793
@@ -1899,7 +1864,7 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) {
18991864 fp, (PropertyCallbackArguments::kReturnValueOffset + 3 ) * kPointerSize );
19001865 CallApiFunctionAndReturn (masm, api_function_address, thunk_ref,
19011866 kStackUnwindSpace , spill_offset,
1902- return_value_operand, nullptr );
1867+ return_value_operand);
19031868}
19041869
19051870#undef __
0 commit comments