public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Wink Saville" <wink@saville.com>
To: "Matthew Wilcox" <willy@debian.org>
Cc: <gcc@gcc.gnu.org>
Subject: Re: More space efficient virtual function calls
Date: Sun, 07 Jul 2002 10:11:00 -0000	[thread overview]
Message-ID: <004601c225cd$4caa0750$1200a8c0@saville.com> (raw)
In-Reply-To: <20020707160307.K27706@parcelfarce.linux.theplanet.co.uk>

Whoops Matthew is correct on both of his points.

I also looked at the ATPCS document and it looks like register 12 can be
used, its other name is IP (Intra-Procedure-call scratch register) and as
Mathew pointed out the savings of 8 bytes per call.

So the new suggestion is:

    MOV    R0,R4    /* R0 = this */
    BL    __VTFunc1     /* Branch and Link to virtual thunk function 1  */

...

__VTFunc0:
    MOV    R12,[R0]        /* Get vtable pointer */
    LDR    PC,[R12,#0]    /* Jump to the function 0 */
__VTFunc1:
    MOV    R12,[R0]        /* Get vtable pointer */
    LDR    PC,[R12,#4]    /* Jump to the function 1 */
__VTFunc2:
    MOV    R12,[R0]        /* Get vtable pointer */
    LDR    PC,[R12,#8]    /* Jump to the function 2 */
...

As I said before there is a performance hit and this would have to be
optional. I looked at the compiler switches and a first suggestion would be
to enabled this feature when the -Os (save space switch was used).

So:

Is this already possible with an existing switch/pragma?
Are there comparable savings for other architectures?
Is this practical?
Should the VTFuncX function be emitted by the compiler or required to be in
the runtime?
If required to be in the runtime, what would be the best approach for
handling large vtables?

I'm sure there are other questions/issues and probably bugs:) and any
suggestions are welcome.

Thanks,

Wink


  reply	other threads:[~2002-07-07 15:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-07 10:03 Matthew Wilcox
2002-07-07 10:11 ` Wink Saville [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-07-07  8:45 Wink Saville
2002-07-07 15:45 ` mike stump
2002-07-07 21:35   ` Wink Saville

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='004601c225cd$4caa0750$1200a8c0@saville.com' \
    --to=wink@saville.com \
    --cc=gcc@gcc.gnu.org \
    --cc=willy@debian.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).