summaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-12-10 13:50:02 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-12-10 13:50:02 -0700
commit20fffeabddb5754e1c26bb099229df4507265fda (patch)
treebe468cc4101d379cc8f40b25f272061df628860f /build-aux
parent22d27936b3d771a36b170b1f4b4ba58badbf3971 (diff)
stack.c.gen: Better handling of dynamic nodes
Diffstat (limited to 'build-aux')
-rwxr-xr-xbuild-aux/stack.c.gen18
1 files changed, 14 insertions, 4 deletions
diff --git a/build-aux/stack.c.gen b/build-aux/stack.c.gen
index 2ce874d..7af8bc4 100755
--- a/build-aux/stack.c.gen
+++ b/build-aux/stack.c.gen
@@ -95,6 +95,8 @@ def parse_vcg(reader: typing.TextIO) -> typing.Iterator[VCGElem]:
################################################################################
# Main analysis
+UsageKind: typing.TypeAlias = typing.Literal["static", "dynamic", "dynamic,bounded"]
+
class Node:
# from .title (`static` and `__weak` functions are prefixed with
@@ -103,6 +105,7 @@ class Node:
funcname: str
# .label is "{funcname}\n{location}\n{nstatic} bytes (static}\n{ndynamic} dynamic objects"
location: str
+ usage_kind: UsageKind
nstatic: int
ndynamic: int
@@ -116,6 +119,7 @@ def synthetic_node(name: str, nstatic: int, calls: set[str] = set()) -> Node:
n.funcname = name
n.location = "<synthetic>"
+ n.usage_kind = "static"
n.nstatic = nstatic
n.ndynamic = 0
@@ -163,9 +167,10 @@ def analyze(
raise ValueError(
f"unexpected label value {repr(v)}"
)
- if m.group("usage_kind") == "dynamic":
- print(f"// warning: can't handle dynamic stack usage: {repr(elem.attrs.get("title", ""))}")
node.location = m.group("location")
+ node.usage_kind = typing.cast(
+ UsageKind, m.group("usage_kind")
+ )
node.nstatic = int(m.group("nstatic"))
node.ndynamic = int(m.group("ndynamic"))
case "shape":
@@ -219,8 +224,7 @@ def analyze(
graph[node.funcname] = node
missing: set[str] = set()
-
- print("/*")
+ dynamic: set[str] = set()
dbg = False
@@ -258,10 +262,14 @@ def analyze(
node = graph[funcname]
if dbg:
print(f"//dbg: {funcname}\t{node.nstatic}")
+ if node.usage_kind == "dynamic" or node.ndynamic > 0:
+ dynamic.add(funcname)
return node.nstatic + max(
[0, *[nstatic(call, chain + [funcname]) for call in node.calls]]
)
+ print("/*")
+
for grp_name, grp_filter in app_func_filters.items():
# Gather the data.
nmax = 0
@@ -292,6 +300,8 @@ def analyze(
for funcname in sorted(missing):
print(f"warning: missing: {funcname}")
+ for funcname in sorted(dynamic):
+ print(f"warning: dynamic: {funcname}")
print("*/")