GC: make gcLock.lock/unlock inlinable#1178
Conversation
src/core/sync/mutex.d
Outdated
There was a problem hiding this comment.
That's fairly ugly to change the API, and you can't use package protection here.
Maybe we just copy over the implementation to the GC?
There was a problem hiding this comment.
And someone should fix the DMD bug, is it reported in Bugzilla?
There was a problem hiding this comment.
And someone should fix the DMD bug, is it reported in Bugzilla?
|
Nice |
|
Yeah, a struct with the implementation from core sync mutex would be best, because I want to replace it with a spinlock anyhow. |
… make it inlinable
d6f9ad7 to
4420a33
Compare
Good idea, done that. |
|
Looks like destroying the mutex fails because of an unbalanced calls to unlock. |
|
Thanks for the info. I'm not sure why this works with the original GCMutex, though. We could also add some minimalistic cleanup in case of a finalization error:
|
|
dlang/dmd#4427 added the devirtualization, so this PR is obsolete. |
|
Nice |
While looking at the disassembly for #1147 I noticed that lock/unlock on GCMutex are still called through the virtual function table, even though GCMutex is declared as final.
Calling Mutex.lock/unlock through a final method in GCMutex fails to inline, so I made final versions of the methods in Mutex.
In addition, making gcLock a property instead of a pointer avoids an indirection.
This change caused a 0-5% speedup for the benchmarks.