[fpc-pascal] Virtual object methods
Marco van de Voort
fpc at pascalprogramming.org
Tue Jul 2 21:34:33 CEST 2019
Op 2019-07-02 om 19:41 schreef Ryan Joseph:
>> On Jul 2, 2019, at 10:32 AM, Michael Van Canneyt <michael at freepascal.org> wrote:
>> It overwrites the first. There is no such thing as '2 VMT tables'.
> That’s what I thought. How costly is this? Not sure what it’s doing under the hood but I’d like to know more.
You'd expect a mov of a constant to a memory location, but it is a bit
more involved, and it doesn't look very optimal. Maybe because it is
compiler generated, the optimizer doesn't run over it? (this is -O4 code)
#  begin
leal -8(%esp),%esp //
# Var $vmt located at ebp-4, size=OS_32
# Var $self located at ebp-8, size=OS_32
leal -4(%ebp),%edx // self,
movl %eax,-8(%ebp) // save result
#  end;
movl -8(%ebp),%eax // and reload
that result. All instructions after call are no effective purpose.
call P$PROGRAM$_$TA_$__$$_CREATE$$LONGBOOL // tried to inline
ta.create, not accepted.
More information about the fpc-pascal