A monitor for every object

Robert Jacques sandford at jhu.edu
Fri Feb 4 20:22:54 PST 2011


On Fri, 04 Feb 2011 16:07:02 -0500, bearophile <bearophileHUGS at lycos.com>  
wrote:

> 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

Well, in DMD the monitor is null prior to use, so I'm not sure what's  
happening in LDC, but I'd doubt DMD is making such a call just to set it  
to 0.


More information about the Digitalmars-d mailing list