dmd codegen improvements
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Wed Aug 19 23:37:11 PDT 2015
On 2015-08-19 20:41, Walter Bright wrote:
> It's true that if generating an exe, the compiler can mark leaf classes
> as final and get devirtualization.
Since D has the "override" keyword it should be possible to devirtualize
a call to a non leaf classes as well, as long as the method is not
overridden.
> (Of course, you can manually add'final' to classes.)
The same way as you can manually do many of the other optimizations as well.
One case where "final" does not help is if there's a piece of code the
is shared between two projects. In one project there is a subclass with
a method overridden but in the other project there's not.
// shared code
module base;
class Base
{
void foo () {}
}
// project A
import base;
class A : Base { }
// project B
import base;
class B : Base
{
override void foo () {}
}
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list