Changeset 1844 for trunk


Ignore:
Timestamp:
Mar 13, 2005, 12:14:15 PM (20 years ago)
Author:
bird
Message:

New alloca implementation which does 8 byte alignment and don't commit stack untill it's fully probed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gcc/gcc/config/i386/emx-libgcc1.asm

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1843 r1844  
     1/* $Id$ */
     2/** @file
     3 *
     4 * GCC alloca helper
     5 *
     6 * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net>
     7 *
     8 *
     9 * This file is part of InnoTek LIBC.
     10 *
     11 * InnoTek LIBC is free software; you can redistribute it and/or modify
     12 * it under the terms of the GNU Lesser General Public License as published
     13 * by the Free Software Foundation; either version 2 of the License, or
     14 * (at your option) any later version.
     15 *
     16 * InnoTek LIBC is distributed in the hope that it will be useful,
     17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
     22 * along with InnoTek LIBC; if not, write to the Free Software
     23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     24 *
     25 */
     26
    127        .text
    2        
     28
    329#ifdef L_alloca
    430        .globl __alloca
     
    834// CHG:  EAX. ESP
    935__alloca:
    10         pushl   %ecx                    /* save work registers */
    11         movl    %esp,%ecx               /* keep a pointer to stack frame */
     36        /*
     37         * Calc new %esp, store it in %eax.
     38         * The returned address is 8 byte aligned.
     39         */
    1240        negl    %eax
    13         leal    4+4(%esp,%eax),%esp     /* adjust stack pointer */
    14         leal    4+4(%ecx),%eax
     41        lea     (%esp, %eax), %eax
     42        andl    $0xfffffff8, %eax
     43
     44        /*
     45         * Setup the prober, %ecx, to point to the top of the stack page below.
     46         */
     47        pushl   %ecx
     48        movl    %esp, %ecx
     49        andl    $0xfffff000, %ecx
     50        subl    $8, %ecx
     51        /* Do we need to probe anything? */
     52        cmpl    %eax, %ecx
     53        jl      L2
     54
     55        /*
     56         * The probe loop
     57         */
    1558        .align 2, 0x90
    16 L1:     subl    $0x1000,%eax            /* step down */
    17         cmpl    %esp,%eax
    18         jb      L2
    19         testb   %al,(%eax)              /* probe stack */
    20         jmp     L1
    21 L2:     movl    4(%ecx),%eax            /* return address */
    22         movl    (%ecx),%ecx             /* pop ECX */
     59L1:
     60        movb    $0, (%ecx)              /* probe */
     61        subl    $0x1000, %ecx           /* next page */
     62        cmpl    %eax, %ecx              /* done? */
     63        jnl     L1                      /* jump if done */
     64
     65        /*
     66         * Done probing, commit the allocation and jump to the return address.
     67         */
     68L2:     popl    %ecx
     69        xchg    %esp, %eax              /* commit */
     70        movl    (%eax), %eax            /* load return address */
    2371#if defined (__EPILOGUE__)
    2472___POST$_alloca:
    25 #endif       
     73#endif
    2674        jmp     *%eax                   /* return */
    27 
    2875#endif // L_alloca
    29 
Note: See TracChangeset for help on using the changeset viewer.