Caching in druntime TypeInfo classes
Mike via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jun 30 16:23:43 PDT 2015
On Tuesday, 30 June 2015 at 21:17:13 UTC, H. S. Teoh wrote:
> since TypeInfo's are supposed to be const, this operation is
> illegal. Unless I cast away const, but that's a rather dirty
> hack. The other problem is that the compiler hardcodes the
> sizes of each TypeInfo instance, so it will refuse to compile
> object.d anyway if the TypeInfo is expanded to have an extra
> field for caching the result of hasCustomTohash(). But since we
> have to modify the compiler now, my reaction was, why not have
> the compiler compute this value itself? Since the compiler
> already has all the information needed to compute this value.
> We don't have to wait till runtime. The only drawback is adding
> more complexity to the compiler, making it hard for other
> efforts like SDC to implement D.
>
IMO the root cause of the trouble implementing your idea is the
fact that the whole TypeInfo implementation is janky. I think we
should implement some flavor of Adam Ruppe's idea to move
TypeInfo to the runtime
(https://issues.dlang.org/show_bug.cgi?id=12270). Then the
implementation would be more straightforward...and it would solve
another major problem that I'm having trying to use D for
resource-constrained systems
(http://bugzilla.gdcproject.org/show_bug.cgi?id=184) without
having to resort to so much hackery. It may also help reduce
binary sizes on other platforms, which has come up a few times
recently.
That's probably much more than you bargained for, but I have
every intention on implementing it this year, and could use some
help.
Mike
More information about the Digitalmars-d
mailing list