| Index: src/ppc/builtins-ppc.cc
|
| diff --git a/src/ppc/builtins-ppc.cc b/src/ppc/builtins-ppc.cc
|
| index c6f0336c4e407e79774eb57514e0cd21e10dfea8..ac2a7da3b66b0fb7a0e51f953bed6d714c126e6c 100644
|
| --- a/src/ppc/builtins-ppc.cc
|
| +++ b/src/ppc/builtins-ppc.cc
|
| @@ -827,6 +827,43 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) {
|
| }
|
|
|
|
|
| +enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt };
|
| +
|
| +
|
| +// Clobbers r5; preserves all other registers.
|
| +static void Generate_CheckStackOverflow(MacroAssembler* masm,
|
| + const int calleeOffset, Register argc,
|
| + IsTagged argc_is_tagged) {
|
| + // 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(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.
|
| + if (argc_is_tagged == kArgcIsSmiTagged) {
|
| + __ SmiToPtrArrayOffset(r0, argc);
|
| + } else {
|
| + DCHECK(argc_is_tagged == kArgcIsUntaggedInt);
|
| + __ ShiftLeftImm(r0, argc, Operand(kPointerSizeLog2));
|
| + }
|
| + __ cmp(r5, r0);
|
| + __ bgt(&okay); // Signed comparison.
|
| +
|
| + // Out of stack space.
|
| + __ LoadP(r4, MemOperand(fp, calleeOffset));
|
| + if (argc_is_tagged == kArgcIsUntaggedInt) {
|
| + __ SmiTag(argc);
|
| + }
|
| + __ Push(r4, argc);
|
| + __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION);
|
| +
|
| + __ bind(&okay);
|
| +}
|
| +
|
| +
|
| static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
|
| bool is_construct) {
|
| // Called from Generate_JS_Entry
|
| @@ -854,6 +891,14 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
|
| __ push(r4);
|
| __ push(r5);
|
|
|
| + // Check if we have enough stack space to push all arguments.
|
| + // The function is the first thing that was pushed above after entering
|
| + // the internal frame.
|
| + const int kFunctionOffset =
|
| + InternalFrameConstants::kCodeOffset - kPointerSize;
|
| + // Clobbers r5.
|
| + Generate_CheckStackOverflow(masm, kFunctionOffset, r6, kArgcIsUntaggedInt);
|
| +
|
| // Copy arguments to the stack in a loop.
|
| // r4: function
|
| // r6: argc
|
| @@ -1366,30 +1411,6 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
|
| }
|
|
|
|
|
| -static void Generate_CheckStackOverflow(MacroAssembler* masm,
|
| - const int calleeOffset) {
|
| - // 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(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.
|
| - __ SmiToPtrArrayOffset(r0, r3);
|
| - __ cmp(r5, r0);
|
| - __ bgt(&okay); // Signed comparison.
|
| -
|
| - // Out of stack space.
|
| - __ LoadP(r4, MemOperand(fp, calleeOffset));
|
| - __ Push(r4, r3);
|
| - __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION);
|
| -
|
| - __ bind(&okay);
|
| -}
|
| -
|
| -
|
| static void Generate_PushAppliedArguments(MacroAssembler* masm,
|
| const int argumentsOffset,
|
| const int indexOffset,
|
| @@ -1447,7 +1468,7 @@ static void Generate_ApplyHelper(MacroAssembler* masm, bool targetIsArgument) {
|
| __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION);
|
| }
|
|
|
| - Generate_CheckStackOverflow(masm, kFunctionOffset);
|
| + Generate_CheckStackOverflow(masm, kFunctionOffset, r3, kArgcIsSmiTagged);
|
|
|
| // Push current limit and index.
|
| const int kIndexOffset =
|
| @@ -1584,7 +1605,7 @@ static void Generate_ConstructHelper(MacroAssembler* masm) {
|
| __ push(r3);
|
| __ InvokeBuiltin(Builtins::REFLECT_CONSTRUCT_PREPARE, CALL_FUNCTION);
|
|
|
| - Generate_CheckStackOverflow(masm, kFunctionOffset);
|
| + Generate_CheckStackOverflow(masm, kFunctionOffset, r3, kArgcIsSmiTagged);
|
|
|
| // Push current limit and index.
|
| const int kIndexOffset =
|
|
|