Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9460eb7
Widen values in assignment
liufengyun Aug 20, 2024
6b95450
Implement garbage collection
liufengyun Aug 20, 2024
5cbc51b
Add footprint optimization based on separation logic
liufengyun Aug 23, 2024
78c8c4a
Fix crash in footprint computation
liufengyun Aug 23, 2024
7b861a1
Fix another crash in footprint computation
liufengyun Aug 23, 2024
cf1515f
Fix crash with footprint comput related to local var
liufengyun Aug 23, 2024
75c5ff0
Move comment closer to code
liufengyun Aug 23, 2024
cb485c0
Only perform footprint optimization when caching result
liufengyun Aug 23, 2024
0af7e00
More efficient reachability computation
liufengyun Aug 29, 2024
9f61f34
Fix crash due to out-of-band return values using return keyword
liufengyun Aug 29, 2024
86e39de
Fix bug in capture analysis of closures
liufengyun Aug 29, 2024
a8dbaeb
Fix typo
liufengyun Sep 3, 2024
3e69d03
Elided object access should return Bottom
liufengyun Sep 3, 2024
a84a8d1
Return values already included in result
liufengyun Sep 3, 2024
4dd781c
Tolerate missing address error
liufengyun Sep 9, 2024
77fc613
Don't crash if address is missing
liufengyun Sep 9, 2024
c418982
Avoid stackoverflow in printing internal errors
liufengyun Sep 9, 2024
19d92aa
Don't apply memory optimization for constructor calls
liufengyun Sep 9, 2024
47f944d
Flatten captured variables in lambdas using the correct environment
liufengyun Sep 9, 2024
08b4e66
Add test for footprint optimization related to secondary constructor
liufengyun Sep 15, 2024
59e5412
Add debug facility for gc
liufengyun Sep 18, 2024
6de4e60
Join heaps properly
liufengyun Sep 22, 2024
7c909f4
Overhaul of caching for instantiation
liufengyun Sep 29, 2024
fdc2a66
Fix identity of instance values and widen all member values
liufengyun Sep 29, 2024
f15ec64
Fix return in secondary constructor
liufengyun Sep 29, 2024
aa27034
Fix cache for function and lazy vals
liufengyun Sep 29, 2024
ce87173
Add TODO about optimization
liufengyun Sep 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 22 additions & 28 deletions compiler/src/dotty/tools/dotc/transform/init/Cache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ class Cache[Config, Res]:
*
* The algorithmic skeleton is as follows:
*
* if don't cache result then
* return eval(expr)
* if this.current.contains(config, expr) then
* return cached value
* else
Expand All @@ -107,32 +105,28 @@ class Cache[Config, Res]:
* this.current(config, expr) = actual
*
*/
def cachedEval(config: Config, expr: Tree, cacheResult: Boolean, default: Res)(eval: Tree => Res): Res =
if !cacheResult then
eval(expr)
else
this.get(config, expr) match
case Some(value) => value
case None =>
val assumeValue: Res =
this.last.get(config, expr) match
case Some(value) => value
case None =>
this.last = this.last.updatedNested(config, expr, default)
default

this.current = this.current.updatedNested(config, expr, assumeValue)

val actual = eval(expr)
if actual != assumeValue then
// println("Changed! from = " + assumeValue + ", to = " + actual)
this.changed = true
this.current = this.current.updatedNested(config, expr, actual)
// this.current = this.current.removed(config, expr)
end if

actual
end if
def cachedEval(config: Config, expr: Tree, default: Res)(doEval: => Res): Res =
this.get(config, expr) match
case Some(value) => value
case None =>
val assumeValue: Res =
this.last.get(config, expr) match
case Some(value) => value
case None =>
this.last = this.last.updatedNested(config, expr, default)
default

this.current = this.current.updatedNested(config, expr, assumeValue)

val actual = doEval
if actual != assumeValue then
// println("Changed! from = " + assumeValue + ", to = " + actual)
this.changed = true
this.current = this.current.updatedNested(config, expr, actual)
// this.current = this.current.removed(config, expr)
end if

actual
end cachedEval

def hasChanged = changed
Expand Down
Loading
Loading