A monitor for every object

bearophile bearophileHUGS at lycos.com
Fri Feb 4 13:07:02 PST 2011


Steven Schveighoffer:

> D's monitors are lazily created, so there should be no issue with resource  
> allocation.  If you don't ever lock an object instance, it's not going to  
> consume any resources.

One more thing.
I remember working with LDC some developers to speed up the stack (scope) allocation of class instances (in D1), and I remember one of the slows down comes from the need to call something that sets the monitor pointer. This call to the runtime was never inlined by ldc, so it was a significant cost compared to similar class instances stack allocated by the JavaVM through escape analysis. So moniror management has a cost in LDC and I presume in DMD too, unless some inlining here will be somehow forced.

Bye,
bearophile


More information about the Digitalmars-d mailing list