This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: More space efficient virtual function calls
- From: "Wink Saville" <wink at saville dot com>
- To: "Matthew Wilcox" <willy at debian dot org>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Sun, 7 Jul 2002 08:45:15 -0700
- Subject: Re: More space efficient virtual function calls
- References: <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