From dd38a6ef076dac321ef0fdcbeb2bb99b3172eeef Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Fri, 16 Jun 2023 12:48:42 +0100 Subject: [PATCH] Enforcing parking restrictions when adding references to transforms in response to review . --- mps/code/trans.c | 13 ++++++++++--- mps/design/transform.txt | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mps/code/trans.c b/mps/code/trans.c index 3fb0d2c304d..2fa6bac0595 100644 --- a/mps/code/trans.c +++ b/mps/code/trans.c @@ -152,19 +152,26 @@ Res TransformAddOldNew(Transform transform, Res res; Index i; Count added = 0; + Arena arena; AVERT(Transform, transform); AVER(old_list != NULL); AVER(new_list != NULL); /* count: cannot check */ - + + /* .assume.parked: If the mutator isn't adding references while the + arena is parked, we might need to access the client-provided + lists (old_list, new_list), using ArenaRead. Insisting on + parking keeps things simple. */ + arena = transform->arena; + AVER(ArenaGlobals(arena)->clamped); + AVER(arena->busyTraces == TraceSetEMPTY); + res = TableGrow(transform->oldToNew, count); if (res != ResOK) return res; for (i = 0; i < count; ++i) { - /* NOTE: If the mutator isn't adding references while the arena is parked, - we might need to access the client-provided lists, using ArenaRead. */ if (old_list[i] == NULL) continue; /* permitted, but no transform to do */ if (old_list[i] == new_list[i]) diff --git a/mps/design/transform.txt b/mps/design/transform.txt index 5767283e882..0975215a013 100644 --- a/mps/design/transform.txt +++ b/mps/design/transform.txt @@ -90,7 +90,7 @@ Not yet written * Nice side-effect is that "old" objects are killed. * Why the arena must be parked [When writing this up see - impl.c.trans.park. RB 2023-06-16]. + impl.c.trans.park and impl.c.trans.assume.parked. RB 2023-06-16]. * Why we can't transform arbitrary references (see impl.c.trans.old-white).