diff options
-rw-r--r-- | build-aux/measurestack/analyze.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/build-aux/measurestack/analyze.py b/build-aux/measurestack/analyze.py index 3601707..93bf885 100644 --- a/build-aux/measurestack/analyze.py +++ b/build-aux/measurestack/analyze.py @@ -10,10 +10,14 @@ import typing from . import vcg +# Whether to print "//dbg-cache:" on cache writes +dbg_cache = False # Whether to print the graph in a /* comment */ before processing it dbg_dumpgraph = False # Whether to print "//dbg-nstatic:" lines that trace nstatic() execution dbg_nstatic = False +# Whether to disable nstatic() caching (but does NOT disable any cache-related debug logging) +dbg_nocache = False # Whether to sort things for consistently-ordered execution, or shuffle things to detect bugs dbg_sort: typing.Literal["unsorted", "sorted", "shuffled"] = "unsorted" @@ -512,7 +516,11 @@ def analyze( continue # 3. Call - if skip_nchain == 0 and call_qname in _nstatic_cache: + if ( + (not dbg_nocache) + and skip_nchain == 0 + and call_qname in _nstatic_cache + ): call_nstatic = _nstatic_cache[call_qname] if dbg_nstatic: putdbg(f"{call_qname}\ttotal={call_nstatic} (cache-read)") @@ -524,7 +532,13 @@ def analyze( if skip_nchain == 0 and call_nchain == 0: if dbg_nstatic: putdbg(f"{call_qname}\ttotal={call_nstatic} (cache-write)") - _nstatic_cache[call_qname] = call_nstatic + if call_qname not in _nstatic_cache: + if dbg_cache: + print(f"//dbg-cache: {call_qname} = {call_nstatic}") + _nstatic_cache[call_qname] = call_nstatic + else: + assert dbg_nocache + assert _nstatic_cache[call_qname] == call_nstatic elif dbg_nstatic: putdbg(f"{call_qname}\ttotal={call_nstatic} (do-not-cache)") chain.pop() |