From ce87173db00e2983b90cc7c06de2b7d6bbf955d4 Mon Sep 17 00:00:00 2001 From: Fengyun Liu Date: Sun, 29 Sep 2024 22:08:28 +0200 Subject: [PATCH] Add TODO about optimization --- .../tools/dotc/transform/init/Objects.scala | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala index e1751c647dd0..b69d0600af38 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala @@ -731,6 +731,33 @@ class Objects(using Context @constructorOnly): /** Cache used to terminate the check */ object Cache: + /** + * TODO: heap optimization with memory side-effect analysis + * + * Observation: + * + * 1. Most methods will not read/mutate the heap (it may create more heap + * cells), despite the fact that portions of the heap is reachable from + * the method arugments and global objects. + * + * 2. If a particular execution of a method does not read any memory + * addresses of the initial heap, then execution of the method with the + * same arguments but a different heap cannot read memory addresses of + * the initial heap. + * + * The above implies that in analyzing most methods, it suffices to use the + * empty heap which will be a better version of the footprint optimization. + * + * To figure out the memory effects of a method, we need to perform an + * analysis of the method. This effect analysis result can be computed as + * part of the analysis as part of the fixed-point computation: + * + * Method x Env => HeapSensitive | HeapInsensitive + * + * Initially, we can assume a method to be heap-insensitive. If it is + * discovered to be heap-sensitive, another round of computation can be + * performed. + */ enum Config: val heap: Heap.Data