Re: Optimizing constructors/destructors for embedded systems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2007. június 25. 12.59 dátummal Daniel Lohmann ezt írta:
> 1) I am not sure if I understand your problem. Can you give an exampel
> for such an (automatically generated) destructore that implicitly calls
> delete?
>
It is just a test class:

class valami
{
public:
    valami();
    virtual ~valami();
    virtual void kiir();
    int adat;
};

The source:

valami::~valami()
{
}

Those instances of destructors are generated:

00000142 <valami::~valami()>:
 142:   fc 01           movw    r30, r24
 144:   84 e0           ldi     r24, 0x04       ; 4
 146:   91 e0           ldi     r25, 0x01       ; 1
 148:   91 83           std     Z+1, r25        ; 0x01
 14a:   80 83           st      Z, r24
 14c:   cf 01           movw    r24, r30
 14e:   0e 94 67 00     call    0xce <operator delete(void*)>
 152:   08 95           ret

00000154 <valami::~valami()>:
 154:   fc 01           movw    r30, r24
 156:   84 e0           ldi     r24, 0x04       ; 4
 158:   91 e0           ldi     r25, 0x01       ; 1
 15a:   91 83           std     Z+1, r25        ; 0x01
 15c:   80 83           st      Z, r24
 15e:   08 95           ret

00000160 <valami::~valami()>:
 160:   fc 01           movw    r30, r24
 162:   84 e0           ldi     r24, 0x04       ; 4
 164:   91 e0           ldi     r25, 0x01       ; 1
 166:   91 83           std     Z+1, r25        ; 0x01
 168:   80 83           st      Z, r24
 16a:   08 95           ret

> 2) If they aren't necessary anyway, why don't you just provide your own
> (empty) implementations of new and delete to avoid the inclusion of
> whatever runtime library?

It is a solution, but it just increases the number of unnecessary function 
calls. The number of constructors/destructors is discussed in an other 
thread, it would be another optimization step. As far as I understand, the 
different constructors/destructors are useful for different purposes. If I 
avoid using the new() and delete() operators, I can save their space. It 
would be useful to disable the corresponding constructors/destructors in this 
case.

Regards
Gyorgy Kovesdi


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux