Dennis <de...@avidsoft.com.hk> schrieb am Fr., 24. Aug. 2018, 13:11:

> The run results:
> Object call Time Taken Seconds: 2.1899964194744825E-001
> Interface call Time Taken Seconds: 2.7999999001622200E-001
>
> so, the time difference is about 27%
>
>
> My question is, where is this extra time spent?
>
> I am assuming an interface variable has a table with entries storing (
> pointer to the object instance AND an offset of method address in the
> Virtual Method Table of that object.)
>
> Am I correct?
>

Using an interface is always calling virtual methods.

It's however a table that contains pointers to compiler generated wrappers
that adjust the Self Pointer and call the correct method.


> What is the memory occupied by the interface variable?
> I know the sizeof(i) = 8 (in 64 bit windows), but what is the size of
> the instance?
>

The instance is essentially only the VMT, cause for interfaces implemented
by FPC classes the interface variable points to a shifted Self pointer that
is "fixed" c the wrappers mentioned above.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to