unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ken Raeburn <raeburn@raeburn.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Juanma Barranquero <lekktu@gmail.com>, emacs-devel@gnu.org
Subject: Re: stop using P_, __P in header files
Date: Mon, 5 Jul 2010 14:59:45 -0400	[thread overview]
Message-ID: <EE37B94F-85D4-4BCD-B5D2-1E14E35F2FCE@raeburn.org> (raw)
In-Reply-To: <83k4p996o0.fsf@gnu.org>

On Jul 5, 2010, at 13:31, Eli Zaretskii wrote:
> I'm not an expert, so I don't know.  Maybe someone else could chime
> in.  One issue that I'd be interested in is to know whether GCC uses
> this hint at some low optimization level,

From skimming some GCC code, it looks to me like either having the optimizer on, or using "register", may cause registers to be used.  (Specifically, if the optimizer is off and "register" is not used, then automatic variables appear to get stack slots unconditionally; otherwise, types and other restrictions permitting, they get "pseudo-registers" which may be assigned either registers or stack slots.)  So, for -O0, the register declarations might make a difference (I don't know how good the "stupid" allocator is for non-optimizing compiles), though my attitude is generally that for -O0, performance considerations don't matter much...  For -O1, I don't think the register declarations matter.

> FWIW, the ones I put in some code I wrote long ago were not naive at
> all.  And I don't think those we have in Emacs are naive, either.  But
> if these hints are not used, it doesn't really matter.

If we assume we don't have to tune the code for builds without decent optimization (including gcc -O0), I think at least some of them are kind of useless -- like any place where *all* the non-addressable variables are declared "register".  If that's a meaningful hint these days, the compiler's not doing a very good job.  Back in the '80s, when PCC was one of the more popular compilers around, you had to say "register" or everything would go in stack slots, even with the optimizer on.  And the first N register variables got assigned to a specific set of machine registers -- I recall working with VAX BSD kernel code that made use of known registers this way.  So for small functions, it made sense to make everything "register", when that was the common technology.

After a quick "grep register *.[chm]", the first one I pulled up was data.c:Fsetq_default, where all the automatic variables but "gcpro1" are "register", though the argument wasn't.  Next was data.c:Fneq, where both arguments are.  In data.c:Fash, all arguments and automatics are.  These really look like cases of PCC workarounds.  In dbusbind.c:Fdbus_method_return_internal, only "args" is; maybe that's possibly helpful, to some compiler somewhere; but shouldn't a decent optimizer figure it out from the large number of uses of the variable?

Ken


  reply	other threads:[~2010-07-05 18:59 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-01 21:16 stop using P_, __P in header files Dan Nicolaescu
2010-07-02  8:50 ` Juanma Barranquero
2010-07-02  9:31   ` Jan Djärv
2010-07-02  9:37     ` Juanma Barranquero
2010-07-02 13:09       ` Jan Djärv
2010-07-02 14:19         ` Juanma Barranquero
2010-07-02 15:55           ` Jan Djärv
2010-07-02 17:31             ` Juanma Barranquero
2010-07-02 20:41               ` Eli Zaretskii
2010-07-02 20:57                 ` Andreas Schwab
2010-07-03  7:07                   ` Eli Zaretskii
2010-07-02 18:26         ` Dan Nicolaescu
2010-07-02 10:58     ` Eli Zaretskii
2010-07-02 18:28       ` Dan Nicolaescu
2010-07-03  0:58       ` Dan Nicolaescu
     [not found]       ` <yxq7hlblldz.fsf@fencepost.gnu.org>
2010-07-04 15:35         ` Juanma Barranquero
2010-07-04 15:55           ` Dan Nicolaescu
2010-07-04 16:26             ` Juanma Barranquero
2010-07-04 16:42               ` Dan Nicolaescu
2010-07-04 20:42                 ` Juanma Barranquero
2010-07-04 20:20           ` Chong Yidong
2010-07-04 16:46       ` Dan Nicolaescu
2010-07-04 19:12         ` Dan Nicolaescu
2010-07-04 19:16           ` Dan Nicolaescu
2010-07-04 23:58             ` Juanma Barranquero
2010-07-05  0:05               ` Juanma Barranquero
2010-07-05  0:28                 ` Juanma Barranquero
2010-07-05  1:25                   ` Juanma Barranquero
2010-07-05  4:57                     ` Dan Nicolaescu
2010-07-05 17:19                 ` Andreas Schwab
2010-07-04 21:24         ` Ken Raeburn
2010-07-05  0:29           ` Juanma Barranquero
2010-07-05  3:05           ` Eli Zaretskii
2010-07-05  3:38             ` Juanma Barranquero
2010-07-05 17:31               ` Eli Zaretskii
2010-07-05 18:59                 ` Ken Raeburn [this message]
2010-07-05 23:48                 ` Juanma Barranquero
2010-07-06  3:00                   ` Eli Zaretskii
2010-07-06  3:23                 ` Dan Nicolaescu
2010-07-09 22:19                 ` Dan Nicolaescu
2010-07-10  8:45               ` David Kastrup
2010-07-10 23:51                 ` Juanma Barranquero
2010-07-05  3:42             ` Ken Raeburn
2010-07-06  4:32               ` Stephen J. Turnbull
2010-07-06  6:37                 ` Ken Raeburn
2010-07-06  7:50                   ` Stephen J. Turnbull
2010-07-05  5:51           ` Dan Nicolaescu
2010-07-05  6:14             ` Ken Raeburn
2010-07-06  2:50               ` Dan Nicolaescu
2010-07-02  8:56 ` Andreas Schwab
2010-07-02 18:30   ` Dan Nicolaescu

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=EE37B94F-85D4-4BCD-B5D2-1E14E35F2FCE@raeburn.org \
    --to=raeburn@raeburn.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).