m2 schrieb:
> Florian Klaempfl a écrit :
>> George Birbilis schrieb:
>>>>       let me ask you a few questions:
>>>>       are you still using 1.44 floppies?
>>>>       are you sending compiled execs 20 times a day via 56k
>>>> modem connection?
>>>>       no? then why 1 or 2 mb bigger is so bad for you?
>>>>       btw, delphi is NOT multiplatform. whant smaller exec
>>>> linux+windows?
>>>>       buy delphi, buy kylix, have a hard time porting
>>>> everything and tuning
>>>>       everything to work similar.
>>>>       size is a cost of multiplatform and RAD+functionality power.
>>>>       enough arguments? or should i add more?
>>>>
>>>>
>>>> I can't say anything.
>>>>
>>>>
>>> I know this is an old thread, but regarding Delphi silly .exe
>>> bloating, for
>>> command-line apps, if you removed some units like forms or sysutils
>>> and uses
>>> windows unit (and respective API - even for just one call to MessageBox
>>> instead of ShowMessage) the .EXE would become say 50kb instead of 500kb.
>>
>> The abstraction layers of sysutils and classes simply require space.
>> Either
>> people has to live with it or don't use it. E.g. a simple uses of
>> sysutils pulls
>> in a lot of code because of the rte to exception conversion including
>> a lot of
>> resourcestrings etc.
> 
> Yes but this is not the only explanation. For instance, consider the
> following small function
> 
> function IWeight(A: PBigInt): SInt32;
> begin
>   Result := RawWeight(A^.Digits,A^.Size);
> end;
> 
> When it is not inlined, Turbo Delphi codes it this way:
> 
>    push  ebp
>    mov   ebp, esp
>    mov   edx, [eax+$08]
>    mov   eax, [eax]
>    call  RawWeight
>    pop   ebp
>    ret
> 
> That's almost perfect. 

Look below what's perfect.

> Now, here is the way Free Pascal (2.0.4) codes
> it:
> 
>    push  ebp
>    mov   ebp, esp
>    sub   esp, 8
>    mov   [ebp-8], ebx
>    mov   [ebp-4], esi
>    mov   ebx, eax
>    mov   edx, [ebx+8]
>    mov   eax, [ebx]
>    call  KERNEL_RAWWEIGHT$PUINT32$LONGINT$$LONGINT
>    mov   esi, eax
>    mov   ebx, [ebp-8]
>    mov   esi, [ebp-4]
>    leave
>    ret
> 
> This is simply catastrophic. There are 7 useless instructions, 7 out of
> 14. Here, the code is twice bigger and this has nothing to do with
> resourcestrings.

2.x got a completely new register allocator which fits the needs of CISC and
RISC CPUs. We didn't have the time in 2.0.x times to take full advantage of this
register allocator. 2.1.1 does much better:

.section .text.n_p$program_iweight$pbigint$$longint
        .balign 16,0x90
.globl  P$PROGRAM_IWEIGHT$PBIGINT$$LONGINT
P$PROGRAM_IWEIGHT$PBIGINT$$LONGINT:
# Temps allocated between esp+0 and esp+0
# Var A located in register eax
# Var $result located in register eax
# [18] begin
# [19] Result := RawWeight(A^.Digits,A^.Size);
        movl    4(%eax),%edx
        movl    (%eax),%eax
        call    P$PROGRAM_RAWWEIGHT$LONGINT$LONGINT$$LONGINT
# [20] end;
        ret

though pure instruction count doesn't matter much for modern CPUs.

> Btw, why does Free Pascal make use of the esi register?

Because nobody provides compilable examples and you didn't use -O3r :)?

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to