9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Joel C. Salomon" <joelcsalomon@gmail.com>
To: 9fans@9fans.net
Subject: Re: [9fans] assembly syntax in plan 9
Date: Mon, 16 Jan 2012 11:07:47 -0500	[thread overview]
Message-ID: <4F144B53.6070906@gmail.com> (raw)
In-Reply-To: <CAOw7k5ifn8knOApHOCY5ZM-8TDJaXKPReHAhB-ZYgSxYFRi7Rw@mail.gmail.com>

On 01/16/2012 08:08 AM, Charles Forsyth wrote:
> Plan 9 doesn't use a base pointer, because everything can be addressed
> relative to the stack pointer, and the loader keeps track of the SP
> level. thus FP is a virtual register, that the loader implements by
> replacing offsets relative to it by the current appropriate offset from
> the hardware stack pointer register (whatever that might be on a given
> platform). That's esp on the x86. the TEXT directive specifies the
> space a function requires for its stack frame, and the loader then adds
> appropriate code at start and end to provide it. 0(FP) is the first
> argument, 4(FP) is the second, and so on. 0(SP) is the bottom of the
> current frame, and 0(SP), 4(SP) etc are referenced to build the
> arguments for outgoing calls (but that space must be accounted for in
> the TEXT directive).

This would make it difficult to implement C99's variable-length
(actually, run-time-determined--length) arrays.  The best compiler-only
change I can think of would be to define a hidden variable `size_t
__size_of_all_vlas`, and add code to adjust SP by that amount before &
after each function call.

[Or we could just skip C99, and make the compiler C11-compliant by
pre-defining __STDC_NO_VLA__. ☺]

> (it's probably not very different in effect from -fno-frame-pointer or
> whatever it is for gcc, which also doesn't use ebp except that is
> implemented entirely by the compiler.)

Google turns up <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39337>,
indicating that GCC had issues combining VLAs and -fomit-frame-pointer;
I don't know how they managed the combination.

--Joel



  parent reply	other threads:[~2012-01-16 16:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-16 12:30 Alexander Kapshuk
2012-01-16 13:08 ` Charles Forsyth
2012-01-16 13:27   ` Alexander Kapshuk
2012-01-16 15:41   ` Bakul Shah
2012-01-16 18:51     ` Comeau At9Fans
2012-01-16 19:03       ` Bakul Shah
2012-01-16 19:39         ` Charles Forsyth
2012-01-17 19:27           ` Comeau At9Fans
     [not found]         ` <CAOw7k5iYxoVUHYYxf1Dg9ESWwTon_aGFxhNkuyUGbkXwiKO9DA@mail.gmail.c>
2012-01-16 19:49           ` erik quanstrom
2012-01-17 19:29             ` Comeau At9Fans
2012-01-16 20:11         ` Joel C. Salomon
2012-01-16 23:18           ` Bakul Shah
2012-01-17 19:31           ` Comeau At9Fans
2012-01-17 19:21         ` Comeau At9Fans
2012-01-18 17:48           ` Bakul Shah
2012-01-18 18:32             ` Comeau At9Fans
2012-01-16 16:07   ` Joel C. Salomon [this message]
2012-01-16 16:27     ` erik quanstrom
2012-01-16 16:40     ` Charles Forsyth
2012-01-16 16:54     ` Bakul Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F144B53.6070906@gmail.com \
    --to=joelcsalomon@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).