aboutsummaryrefslogtreecommitdiffhomepage
path: root/notes/arena_cross_refs.txt
blob: 245174d480ac2ff54014983b9149e0072cf120f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

References between arenas
=========================

Outer-to-inner:
* This does NOT work because:
    * the inner arena might have a shorter lifetime, and
    * on exception, the inner arena will be invalidated,
      but not necessarily the outer arena.

Inner-to-outer:
* This should work.


Related problem: Accessing data from other areans
-------------------------------------------------

    func arena Thing.do_stuff(ref var Node n)
    {
        n.locked = true
        n.value /= this.divisor   # could be 0
        n.locked = false
    }

Exceptions are supposed to invalidate/kill all arenas that are reachable
from the call chain.

In this case, n could be used by an arena that is not a sub-arena
of the "this" arena. So the arena of "n" probably need to be invalidated
as well. Otherwise, "n" could get stuck in an intermediate state.

Solutions:
- Disallow passing "ref var" across exception isolation boundaries.
  Exceptions: "ref var threaded"


Related: How to handle exceptions?
----------------------------------
SLUL does not use thread-local state, but uses arenas instead.

Solution:
- Allow only exceptions in functions that have an arena either as
  the receiver (for methods) or as the first parameter (for non-methods).
- Invalidation of the callee-arena must invalidate all arenas in the current
  isolation boundary, but should not invalidate any other arenas.
    => All arenas should have a pointer to the current exception isolation
       boundary.