summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/runtime/Gil.scala
Commit message (Collapse)AuthorAgeFilesLines
* makes all locks and tlses private and lazyEugene Burmako2013-10-181-1/+1
| | | | | | | | | We do need lazy to be robust, because initialization sequence might trigger synced operations in unexpected order, leading to NPE's. Even if this is optimizable by removing some of the lazies or by carefully reordering cake layers, there's no guarantee that all this effort won't break after another reflection refactoring.
* optimizes Scala reflection GILEugene Burmako2013-10-181-5/+8
| | | | | | | | | | | | | | | | | | | | | | First of all, GIL should only apply to runtime reflection, because noone is going to run toolboxes in multiple threads: a) that's impossible, b/c the compiler isn't thread safe, b) ToolBox api prevents that. Secondly, the only things in symbols which require synchronization are: 1) info/validTo (completers aren't thread-safe), 2) rawInfo and its dependencies (it shares a mutable field with info) 3) non-trivial caches like in typeAsMemberOfLock If you think about it, other things like sourceModule or associatedFile don't need synchronization, because they are either set up when a symbol is created or cloned or when it's completed. The former is obviously safe, while the latter is safe as well, because before acquiring init-dependent state of symbols, the compiler calls `initialize`, which is synchronized. We can say that symbols can be in four possible states: 1) being created, 2) created, but not yet initialized, 3) initializing, 4) initialized. Of those only #3 is dangerous and needs protection, which is what this commit does.
* SI-6240 introduces GIL to Scala reflectionEugene Burmako2013-10-181-0/+22
On a serious note, I feel really uncomfortable about having to juggle this slew of locks. Despite that I can't immediately find a deadlock, I'm 100% sure there is one hiding in the shadows. Hence, I'm abandoning all runtime reflection locks in favor of a single per-universe one.