Object file questions

Johannes Pfau via D.gnu d.gnu at puremagic.com
Sun Aug 17 04:42:04 PDT 2014


Am Sun, 17 Aug 2014 10:44:34 +0000
schrieb "Mike" <none at none.com>:

> On Sunday, 17 August 2014 at 08:26:40 UTC, Johannes Pfau wrote:
> >
> > Great! But I think this pull request addresses a different 
> > monitor
> > problem: There's an implicit __monitor field in every class 
> > right now,
> > which makes every class _instance_ bigger.
> >
> > But the monitor in TypeInfo/ClassInfo is different: ClassInfo 
> > exists
> > only once per class, it doesn't matter how many class instances 
> > you've
> > got. AFAIR this monitor is to support synchronize(ClassType) 
> > which
> > synchronizes on the class type, not on an instance.
> 
> I looked through the source code, and couldn't find any such
> monitor.  Can you please point it out for me?
> 
> Thanks,
> Mike

In gcc/d/d-objfile.cc: Search for

  /* Put out the ClassInfo.
   * The layout is:
   *  void **vptr;
   *  monitor_t monitor;
   *  byte[] initializer;         // static initialisation data

Actually I just realized that this is also true for all TypeInfo, so
I'll have to revert the commit which placed TypeInfo into .rodata

(Thinking more about it, it's more or less the same monitor as the
one referred in the pull request: TypeInfo are classes and for every
type there is one instance, then these instances have __monitor fields.
But the implementation in the compiler is slightly different)


More information about the D.gnu mailing list