shared libraries in D

Iain Buclaw ibuclaw at ubuntu.com
Tue Feb 15 17:14:20 PST 2011


== Quote from Christian Kamm (kamm-incasoftware at removethis.de)'s article
> Iain Buclaw wrote:
> > Will be making shared libraries default in GDC pretty soon now...
> Did you adjust the GC to check the shared libraries' data sections for
> references? When we looked at this for LDC that turned out to slow down GC
> runs significantly.
> I'm pretty sure bearophile benchmarked it at the time.
> As far as I remember the main problem was that we were scanning all data
> sections - even of plain C libraries.
> Regards,
> Christian

When adding more ranges in the GC to check, slowdowns are inevitable. So far in my
personal testing, the slowdowns seem pretty negligible in comparison (never more
than 0.300 seconds, though that could be a sign that I'm not pushing it in the
right way).

To prevent the GC from scanning C libraries, I've added an extra check to only add
ranges that have a D module inside them.

Think:
  ModuleReference *mr;
  for ( mr = _Dmodule_ref; mr; mr = mr.next )
  {
      if ( mr >= start && mr <= end )
      {
          addrange = 1;
          break;
      }
  }

This is viable for GDC, as all platforms share the same implementation. Note, this
also adds a variable overhead at startup, but I think the unskewed runtime
justifies it to remain.

Regards


More information about the Digitalmars-d mailing list