Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 19, 2002 optimizations? | ||||
---|---|---|---|---|
| ||||
The following program was compiled with optimizations turned on (-O), but in debug mode (no -release): class foo { void bar() { } } Compiler generated the following assembler code: L0: call near ptr _Dinvariant__d_invariant_FC6ObjectZv call near ptr _Dinvariant__d_invariant_FC6ObjectZv ret ROTFL =) |
January 19, 2002 Re: optimizations? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | What's happening is that a call to the class invariant is made at the beginning and end of each public member function. -Walter "Pavel Minayev" <evilone@omen.ru> wrote in message news:a2bq13$10i8$1@digitaldaemon.com... > The following program was compiled with optimizations > turned on (-O), but in debug mode (no -release): > > class foo > { > void bar() { } > } > > Compiler generated the following assembler code: > > L0: call near ptr _Dinvariant__d_invariant_FC6ObjectZv > call near ptr _Dinvariant__d_invariant_FC6ObjectZv > ret > > ROTFL =) > > > |
January 19, 2002 Re: optimizations? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:a2cdql$1ep3$1@digitaldaemon.com... > What's happening is that a call to the class invariant is made at the beginning and end of each public member function. -Walter Yes, I know. But what's the reason in checking invariant for a function that does nothing? =) I think this should be optimized away... |
January 20, 2002 Re: optimizations? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:a2ched$1h26$1@digitaldaemon.com... > "Walter" <walter@digitalmars.com> wrote in message news:a2cdql$1ep3$1@digitaldaemon.com... > > > What's happening is that a call to the class invariant is made at the beginning and end of each public member function. -Walter > > Yes, I know. But what's the reason in checking invariant for a function that does nothing? =) I think this should be optimized away... Ah, a very good question. And the answer (!) is that if that function is invoked via a pointer to a derived class object, then the invariant for that derived class needs to be run. You could argue that it doesn't need it on both entry and exit since no code is executed between them. You'd be correct. |
Copyright © 1999-2021 by the D Language Foundation