Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Dec 1999 18:57:06 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Dmitrij Tejblum <tejblum@arc.hq.cti.ru>
Cc:        current@FreeBSD.ORG
Subject:   Re: kernel: -mpreferred-stack-boundary=2 ?? 
Message-ID:  <Pine.BSF.4.10.9912011806370.16906-100000@alphplex.bde.org>
In-Reply-To: <199911302306.CAA02391@tejblum.pp.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 1 Dec 1999, Dmitrij Tejblum wrote:

> Bruce Evans wrote:
> >  I would have
> > expected the most generally efficient way to align doubles and the new PIII
> > obkects to be aligning the stack only in functions that have such objects
      j
> > on the stack.  This requires at most one extra instruction:
> > 
> > 	andl $~0xf,$esp		16-byte alignment
                   %
> 
> I think, it's not that simple in the usual case when the object is accessed via 
> (%ebp-<someconstant>).

%ebp would have to be aligned relative to %esp, but this would require an
unusal function prologue with possible complications in debuggers, and seems
to require 2 or 3 more extra instructions to recover the original %esp:

        pushl %ebp
        movl %esp,%eax      # extra
        andl $0xf,%esp      # extra
        movl %esp,%ebp
        pushl %eax          # extra
        ...                 # worst case: no registers saved, no local space
        ...                 # allocated, and no alloca() allowance
        movl -4(%ebp),%esp  # extra
        popl %ebp
        ret

If the caller has passed a double, then the stack alignment can be determined
at compile time and the current subl-type adjustment can be used.

If alloca() is not allowed for, then %esp-relative accesses can be used for
auto and temporary variables, and %ebp-relative accesses for args.

Bruce



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.9912011806370.16906-100000>