This doesn't work if the stack is close to the bottom of memory and the
array is large.

Also it throws apply overflow errors if a preemption occurs at a bad moment.

I have a change out that I believe fixes these things (but it doesn't
respect the check_stack flag).  I was expecting Ivan to take another look at
it after the first version was rejected in review.

On Fri, Sep 26, 2008 at 11:00 AM, <[EMAIL PROTECTED]> wrote:

>
> Reviewers: bak,
>
> Description:
> Stack checks in generated code for function apply is now controlled
> by the check-stack flag. Changed the condition code from greater to
> above_equal as the SP should be unsigned (this matches the stack
> check in function entry).
>
> Please review this at http://codereview.chromium.org/4296
>
> Affected files:
>   M     src/builtins-ia32.cc
>
>
> Index: src/builtins-ia32.cc
> ===================================================================
> --- src/builtins-ia32.cc        (revision 380)
> +++ src/builtins-ia32.cc        (working copy)
> @@ -517,21 +517,23 @@
>
>    // Eagerly check for stack-overflow before pushing all the arguments
>    // to the stack.
> -  Label okay;
> -  __ lea(ecx, Operand(esp, -3 * kPointerSize));  // receiver, limit, index
> -  __ mov(edx, Operand(eax));
> -  __ shl(edx, kPointerSizeLog2 - kSmiTagSize);
> -  __ sub(ecx, Operand(edx));
> -  ExternalReference stack_guard_limit_address =
> -      ExternalReference::address_of_stack_guard_limit();
> -  __ cmp(ecx, Operand::StaticVariable(stack_guard_limit_address));
> -  __ j(greater, &okay, taken);
> +  if (true && FLAG_check_stack) {
> +    Label okay;
> +    __ lea(ecx, Operand(esp, -3 * kPointerSize));  // receiver, limit,
> index
> +    __ mov(edx, Operand(eax));
> +    __ shl(edx, kPointerSizeLog2 - kSmiTagSize);
> +    __ sub(ecx, Operand(edx));
> +    ExternalReference stack_guard_limit_address =
> +        ExternalReference::address_of_stack_guard_limit();
> +    __ cmp(ecx, Operand::StaticVariable(stack_guard_limit_address));
> +    __ j(above_equal, &okay, taken);
>
> -  // Too bad: Out of stack space.
> -  __ push(Operand(ebp, 4 * kPointerSize));  // push this
> -  __ push(eax);
> -  __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_FUNCTION);
> -  __ bind(&okay);
> +    // Too bad: Out of stack space.
> +    __ push(Operand(ebp, 4 * kPointerSize));  // push this
> +    __ push(eax);
> +    __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_FUNCTION);
> +    __ bind(&okay);
> +  }
>
>    // Push current index and limit.
>    const int kLimitOffset =
>
>
>
> >
>


-- 
Erik Corry, Software Engineer
Google Denmark ApS.  CVR nr. 28 86 69 84
c/o Philip & Partners, 7 Vognmagergade, P.O. Box 2227, DK-1018 Copenhagen K,
Denmark.

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to