You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ee9a047
Browse filesBrowse the repository at this point in the historyBrowse files
temporary), plus `typedpython.aot.explain_alloc(...)` and `python -m typedpython aot-build
1503
1503
--explain-alloc`.
1504
+
-**Tier O PR-O2b (N-12b/c step 2, scope regions)** (agent proposal, not owner-confirmed): adds scope
1505
+
bump regions (`aot/alloc.py` region analysis, `tpa_region` in `runtime/tp_aot.h`). In a function `F`,
1506
+
every allocation site of a class `C` that is not virtual, where `C` has a simple `__init__`, no
1507
+
`__del__` and at least one field (a class with no fields stays heap-rc: a zero-size region object
1508
+
would give every object one address, and `is` must tell them apart), is region-allocated (a distinct C type `struct tpa_reg_<F>__<C>` with no reference count,
1509
+
bump-allocated in one region per `(F, C)` that `F`'s body owns, or one iteration of one loop of `F`
1510
+
owns, and freed together at `tp_cleanup:` on every exit: the end of the body, an early `return`, a
1511
+
failing operation; a per-iteration region is released and reset at the top of every iteration) if and
1512
+
only if, in `F`: no region pointer of `C` is returned (R1), stored into a heap object, a virtual
1513
+
object, a container or a region object whose region outlives `C`'s (R2), or passed to any call, a
1514
+
method call included (R3); no heap pointer of `C` (a parameter, a call result, a field of a heap or
1515
+
virtual object) is assigned to a local of `C` or stored into a region object's field of class `C`
1516
+
(so a local of `C` has exactly one C type); and `is` never compares a region pointer with a heap
1517
+
pointer. A region object's field of class `K` is a region pointer when `(F, K)` is region, else an
1518
+
owned heap reference; owned heap references held by region objects (lists, big ints, heap-rc objects)
1519
+
are released by a per-class walk when the region is freed or reset (R4 relaxed to that; a region
1520
+
pointer is never stored where a heap object could reach it). The scope is the innermost loop whose
1521
+
body holds every use of `C` in `F` and in which every local of `C` is definitely assigned before it
1522
+
is read, widened to the loop of any region object that holds `C` pointers, else the function body.
1523
+
Region pointers never reach a library export (R5 holds by R1 and R3). `--explain-alloc` reports
1524
+
`region (function scope)` or `region (per-iteration scope of the <for|while> loop, depth <k>)` for a
1525
+
region site and, after a heap-rc site's reason, `[region: R1 ...]`. The escape rules see every
1526
+
sub-expression of a statement, the length and fill of a `[v] * n` and the callee and arguments of
1527
+
an object call included.
1528
+
Not in this step: region specialisations of callees (R3 with `make__reg` / `check__reg`), so
1529
+
`benchmarks/typedpython/py/binary_trees.py` stays heap-rc (`[region: R1: escapes via return]`), and
0 commit comments