[Issue 14251] synchronized (mtx) doesn't check attributes (pure, const)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Sep 20 17:57:32 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=14251

--- Comment #17 from Martin Nowak <code at dawg.eu> ---
(In reply to Andrei Alexandrescu from comment #15)
> That's not the case. The compiler knows the object has mutable metadata and
> won't allow placing it in read-only pages.

Not allowing to put any class into read-only segments, just b/c someone might
want to synchronize on it, is not very convincing.
Also remember that we wanted to get rid of the extra 8-byte for monitor unless
explicitly requested
http://forum.dlang.org/post/xpliectmvwrwthamquke@forum.dlang.org.

Turning synchronized into a lowering for lock/unlock (with monitor support as
fallback) would not only allow correct attribute inference (w/o making global
decisions for everyone, @nogc, ...), it's also a less overhead for the
core.sync classes to not go through the virtual monitor indirections [¹].

[¹]:
https://github.com/dlang/druntime/blob/15a227477a344583c4748d95492703901417f4f8/src/rt/monitor_.d#L59

--


More information about the Digitalmars-d-bugs mailing list