Chromium Code Reviews| Index: src/x64/builtins-x64.cc |
| diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc |
| index d14a935543e1696a223b343aa37ab16892970c15..5803ad772318c98f1cfe3b5f15317e5312c4565c 100644 |
| --- a/src/x64/builtins-x64.cc |
| +++ b/src/x64/builtins-x64.cc |
| @@ -1017,7 +1017,7 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
| // Out of stack space. |
| __ Push(Operand(rbp, kFunctionOffset)); |
| __ Push(rax); |
| - __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_FUNCTION); |
| + __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); |
| __ bind(&okay); |
| // End of stack check. |
| @@ -1322,6 +1322,31 @@ void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { |
| } |
| +static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, |
| + Label* stack_overflow) { |
| + // ----------- S t a t e ------------- |
| + // -- rax : actual number of arguments |
| + // -- rbx : expected number of arguments |
| + // -- rdi: function (passed through to callee) |
| + // ----------------------------------- |
| + // 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. |
| + Label okay; |
| + __ LoadRoot(rdx, Heap::kRealStackLimitRootIndex); |
| + __ movp(rcx, rsp); |
| + // Make rcx the space we have left. The stack might already be overflowed |
| + // here which will cause rcx to become negative. |
| + __ subp(rcx, rdx); |
| + // Make rdx the space we need for the array when it is unrolled onto the |
| + // stack. |
| + __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rax, kPointerSizeLog2); |
|
haitao.feng
2014/04/17 07:42:55
It seems that rax and rbx are raw integers, instea
|
| + // Check if the arguments will overflow the stack. |
| + __ cmpp(rcx, rdx); |
| + __ j(less_equal, stack_overflow); // Signed comparison. |
| +} |
| + |
| + |
| static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
| __ pushq(rbp); |
| __ movp(rbp, rsp); |
| @@ -1367,6 +1392,9 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
| Counters* counters = masm->isolate()->counters(); |
| __ IncrementCounter(counters->arguments_adaptors(), 1); |
| + Label stack_overflow; |
| + ArgumentsAdaptorStackCheck(masm, &stack_overflow); |
| + |
| Label enough, too_few; |
| __ movp(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
| __ cmpp(rax, rbx); |
| @@ -1439,6 +1467,14 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
| // ------------------------------------------- |
| __ bind(&dont_adapt_arguments); |
| __ jmp(rdx); |
| + |
| + __ bind(&stack_overflow); |
| + { |
| + FrameScope frame(masm, StackFrame::MANUAL); |
| + EnterArgumentsAdaptorFrame(masm); |
| + __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); |
| + __ int3(); |
| + } |
| } |