aboutsummaryrefslogtreecommitdiff
path: root/include/data.s
blob: 51f31dcf05798c23eb7ba27f5db0a719630b1195 (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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

.ifndef _data_s_file
_data_s_file:

# Simple values and boxed machine integers
# | ptr | value |
CON_evacuate1:
	retq # TODO
CON_scavenge1:
	add $0x10, %rsi
	retq

# Format of the info tables:
# - code
# ----- code pointer
# - 8B helper information for eval/apply (generally this is 0, and only gets used for FUN/PAP)
# - 8B pointer to scavenge
# - 8B pointer to evacuate

INT_info_table:
	cell CON_evacuate1
	cell CON_scavenge1
	cell 0
INT_code:
	continue

# List
# | ptr | 0 |
# | ptr | 1 | a | b |
LIST_evacuate:
	# [] | a : b
	retq #TODO
LIST_scavenge:
	mov 0x8(%rbp), %rax
	shl $1, %rax
	add $2, %rax
	shl $3, %rax
	add %rax, %rsi
	retq
LIST_info_table:
	cell LIST_evacuate
	cell LIST_scavenge
	cell 0
LIST_code:
	continue

# FUN objects
# | ptr | thunkptr | args | arg[0] | arg[1] | ... | arg[args] |
FUN_evacuate:
	retq #TODO
FUN_scavenge:
	mov 0x10(%rbp), %rax
	add $3, %rax
	shl $3, %rax
	add %rax, %rsi
	retq

# Info tables for FUN objects.
FUN0_info_table:
	cell FUN_evacuate
	cell FUN_scavenge
	cell 0
FUN0_code:
	continue

FUN1_info_table:
	cell FUN_evacuate
	cell FUN_scavenge
	cell 1
FUN1_code:
	continue

FUN2_info_table:
	cell FUN_evacuate
	cell FUN_scavenge
	cell 2
FUN2_code:
	continue

FUN3_info_table:
	cell FUN_evacuate
	cell FUN_scavenge
	cell 3
FUN3_code:
	continue

FUN4_info_table:
	cell FUN_evacuate
	cell FUN_scavenge
	cell 4
FUN4_code:
	continue

# TODO: add more funN here as needed

# indirection (Q: how to recognize IND and THUNK on return?)
# | ptr | indptr |
IND_evacuate:
	retq #TODO
IND_scavenge:
	add $0x10,%rsi
	retq
IND_info:
	cell IND_evacuate
	cell IND_scavenge
	cell 0
IND_code:
	enter 0x8(%rbp)

# THU objects (gc implementation only, actual THUs are defined by functions)
# | ptr | args | arg[0] | arg[1] | ... | arg[args] |
# args wouldn't need to be here but let's keep them for gc simplicity
THU_evacuate:
	retq #TODO
THU_scavenge:
	mov 0x8(%rbp), %rax
	add $2,%rax
	shl $3,%rax
	add %rax,%rsi
	retq

.endif # _data_s_file

# evacuate and scavenge:
# - evacuate just copies the object
# - scavenge evacuates all children (to the new location IF they are in the old
#   location), changes the pointer, and moves the scavenge pointer to the next
#   object (because everything needs to be scavenged)