File tree Expand file tree Collapse file tree 1 file changed +23
-6
lines changed
compiler/src/dotty/tools/dotc/transform/init Expand file tree Collapse file tree 1 file changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -268,14 +268,25 @@ object Semantic {
268
268
*
269
269
*/
270
270
271
- class Cache (val in : Cache .CacheIn , var out : Cache .CacheOut ) {
272
- var changed : Boolean = false
273
- }
274
-
275
271
object Cache {
276
272
opaque type CacheIn = mutable.Map [Value , EqHashMap [Tree , Value ]]
277
273
opaque type CacheOut = mutable.Map [Value , EqHashMap [Tree , Value ]]
278
274
275
+ class Cache (val in : CacheIn , var out : CacheOut ) {
276
+ var changed : Boolean = false
277
+
278
+ /** Copy out to in and reset out to empty */
279
+ def update () = {
280
+ out.foreach { (v, m) =>
281
+ m.iterator.foreach { (e, res) =>
282
+ in.put(v, e, res)
283
+ }
284
+ }
285
+
286
+ out = mutable.Map .empty
287
+ }
288
+ }
289
+
279
290
val empty : Cache = new Cache (mutable.Map .empty, mutable.Map .empty)
280
291
281
292
extension (cache : CacheIn | CacheOut )
@@ -770,9 +781,15 @@ object Semantic {
770
781
final def work ()(using State , Context ): Unit =
771
782
pendingTasks match
772
783
case task :: rest =>
773
- pendingTasks = rest
774
- checkedTasks = checkedTasks + task
775
784
doTask(task)
785
+
786
+ if cache.changed then
787
+ // discard heap changes and copy cache.out to cache.in
788
+ cache.update()
789
+ else
790
+ pendingTasks = rest
791
+ checkedTasks = checkedTasks + task
792
+
776
793
work()
777
794
case _ =>
778
795
You can’t perform that action at this time.
0 commit comments