aboutsummaryrefslogtreecommitdiff
path: root/notes/object_invalidation.txt
blob: b50c8fec6981db5e9cdddef0d5b7d155f4f42e0b (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
47
48
49
50
51
52
53
54

It would be nice to be able to invalidate objects that should no longer be
used.

The API could be similar to `free()` in C, but it should also allow
individual fields to be invalidated.

For some types of objects it can actually be done without additional
meta-data (but it would still be checked at time of access, unless a GC run
happens):

* short/int/long (that are not signed/unsigned)
* integers that don't use the full unsigned/singed range.
* non-nullable objects.
* references (if the platform doesn't use the full address space,
  so there's room for a sentinel value such as `(void *)-1`)
* bool
* padding in structs (assuming that it is required to be 0)

I.e. all except for the following types (and only when there's no
alignment padding):

* byte
* unsigned (short/int/long)
* signed (short/int/long)

Object invalidation for "all-bits-used" types
---------------------------------------------

How to support invalidation of the "all-bits-used" types,
i.e. full-range byte/unsigned/signed.

Solution 1: A small metadata bit flag could be inserted:

    struct Thing {
        unsigned char _SLUL_infobyte;
        unsigned long l1;
        unsigned long l2;
    }

Solution 2: Track uninitialized data in each arena chunk?

Solution 3: Track all "all-bits-used" types in each arena chunk?


Related: "Uninitialized" and Sentinel values
--------------------------------------------

It would actually be quite nice to have 2 different values:

* Invalidated (including uninitialized)
* `none`

Note that `none` is trickier, because a struct can be none, but its
fields can also be none. And structs can be nested.