Index: src/arm/builtins-arm.cc |
diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc |
index f138146417410c185ddeb44d72d001fc25a5a4fa..b11b49bcec84a79a0fe115f27d3ad395c2e142a9 100644 |
--- a/src/arm/builtins-arm.cc |
+++ b/src/arm/builtins-arm.cc |
@@ -1407,6 +1407,22 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
} |
+ |
+static void ArgumentAdaptorStackCheck(MacroAssembler* masm, |
+ Label* stack_overflow) { |
+ // Check the stack for overflow. We are not trying to catch |
+ // interruptions (e.g. debug break and preemption) here, so the "real stack |
+ // limit" is checked. |
+ __ LoadRoot(r5, Heap::kRealStackLimitRootIndex); |
+ // Make r5 the space we have left. The stack might already be overflowed |
+ // here which will cause r5 to become negative. |
+ __ sub(r5, sp, r5); |
+ // Check if the arguments will overflow the stack. |
+ __ cmp(r5, Operand(r2, LSL, kPointerSizeLog2)); |
+ __ b(le, stack_overflow); // Signed comparison. |
+} |
+ |
+ |
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
__ SmiTag(r0); |
__ mov(r4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
@@ -1446,6 +1462,8 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
// -- r2 : expected number of arguments |
// ----------------------------------- |
+ Label stack_overflow; |
+ ArgumentAdaptorStackCheck(masm, &stack_overflow); |
Label invoke, dont_adapt_arguments; |
Label enough, too_few; |
@@ -1545,6 +1563,10 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
// ------------------------------------------- |
__ bind(&dont_adapt_arguments); |
__ Jump(r3); |
+ |
+ __ bind(&stack_overflow); |
+ EnterArgumentsAdaptorFrame(masm); |
+ __ InvokeBuiltin(Builtins::STACK_OVERFLOW, JUMP_FUNCTION); |
} |