forked from froggey/Mezzano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata-layout
90 lines (61 loc) · 2.35 KB
/
data-layout
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
Fixnum:
...data|0|
Non-fixnum:
...data|ttt1|
t are tag bits
All non-cons objects have a 1-word header at the start.
...data|tttttttt|00|
Data is specific to the object type, t are type tag bits, the low two bits must be zero during normal operation and are used by the GC.
Having bit 0 always be 0 allows the header to be treated as a fixnum.
1D simple arrays treat data as the number of elements in the array and store the array data immediately after the header.
Certain 1D simple arrays insert a word of padding after the header for alignment:
single-float, double-float, long-float, complex-single-float, complex-double-float, complex-long-float, xmm-vector
Symbols are exactly 6 words long (including the header).
Header data layout:
...0|SSSSSSSSSSSSSSSS|tttttttt|00|
S is the symbol's TLS offset. 0 when no offset has been specified.
Symbol layout:
-1 header
+0 Name (always a string)
+1 Package (may be anything, but usually either NIL or a package)
+2 Value (may be anything, including unbound-value)
+3 Function (either NIL or a function reference) (could be weak ref?)
+4 Plist (must be a list)
Function layout:
-1 header
+0 primary entry point address, unboxed machine integer
+1 start of machine code
+n end of machine code & start of gc info
+n+m end of gc info & start of constant pool
+n+m+p end of constant pool
Function header -1:
GGGGGGGGGGGGGGGG|PPPPPPPPPPPPPPPP|MMMMMMMMMMMMMMMM|00000000|tttttttt|00|
M is machine code size in double-word units (128 bits/16 bytes)
P is constant pool size in double-word units (128 bits/16 bytes)
G is GC info length in bytes
Struct layout:
-1 header
+0 structure definition or 0 (uninitialized)
+1 slots
struct header data holds the number of slots plus one (the definition slot).
Complex array layout:
This layout is used for all non-simple-1d and non-memory arrays.
-1 header
+0 storage
+1 fill-pointer
+2 displacement (fixnum index if displaced, nil otherwise)
+3... Dimensions as fixnums
header data contains the array rank.
Memory array layout
-1 header
+0 storage (fixnum memory address)
+1 fill-pointer
+2 element-type (as what?)
+3... Dimensions as fixnums
header data contains the array rank.
Function reference
-1 header
+0 name
+1 function
+2 entry-point (unbound functions have entry-point point to undefined-function thunk)
Calls via function reference must have fref in r13 for the undefined-function thunk.