aboutsummaryrefslogtreecommitdiffhomepage
path: root/notes/stack_alloc_arena.txt
blob: d0fa987dd33c0d52fb3c0ad70af5877ac9ab0ea1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

If the current arena is restricted to the current thread, we can do
First-in-Last-out allocations at the end (like a stack, but without
the risk of stack overflow).

Arena:

    header ppppp ppp pppp ......... ssss sss ssssss

    p = permanent allocations (normal arena allocation)
    s = temporary allocations, allocated in a stack like fashion from the end

How to communicate this to called functions?

- If we were using separate arena pointers, we could use the lowest bit in the
  arena pointer. This requires at least 16 bit alignment, so it does not work
  when the arena is derived from an object pointer, and the object has byte
  alignment (like strings and byte arrays).