This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: More space efficient virtual function calls


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]