summaryrefslogtreecommitdiff
path: root/smark.s
blob: 6e8a2531b18ff79508954f87df6ea30bb6be22f6 (plain) (blame)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
	ldg	(heap_size_33,d0)

_fill_ones:	btst	3,d0
	beq	_end_fill_ones
	mov	-1,%o1

	stb	%o1,[%o4+d0]
	ba	_fill_ones
	inc	1,d0
_end_fill_ones:

	clr	d4
	ldg	(heap_size_33,d7)
	stg	(d4,lazy_array_list)
	sethi	%hi 0x80000000,%g3
	
	sub	sp,4000,a3
	sll	d7,5,d7

	ldg	(caf_list,d0)
	
	st	a4,[sp-4]
	
	tst	d0
	be	_end_mark_cafs
	dec	4,sp

	dec	4,sp

_mark_cafs_lp:
	ld	[d0-4],%g1
	add	d0,4,a2
	ld	[d0],d0
	st	%g1,[sp]
	sll	d0,2,d0
	add	a2,d0,a4

	dec	4,sp
	call	_mark_stack_nodes
	st	%o7,[sp]

	ld	[sp],d0
	addcc	d0,0,d0
	bne	_mark_cafs_lp
	nop

	inc	4,sp

_end_mark_cafs:
	ldg	(stack_p,a2)

	ld	[sp],a4
	call	_mark_stack_nodes
	st	%o7,[sp]

	ldg	(lazy_array_list,a0)

	tst	a0
	beq	end_restore_arrays
	nop

restore_arrays:
	ld	[a0],d3		! size
	ld	[a0+4],d1	! second last element

	set	__ARRAY__+2,%o0
	ld	[a0+8],d2	! last element

	cmp	d3,1
	beq	restore_array_size_1
	st	%o0,[a0]

	sll	d3,2,a1
	add	a0,a1,a1
	
	ld	[a1+8],d0	! descriptor

	tst	d0
	beq	restore_lazy_array
	nop

	lduh	[d0-2+2],%o0
	udiv	d3,%o0,d3

restore_lazy_array:
	st	d3,[a0+4]
	ld	[a1+4],a3	! next
	st	d0,[a0+8]

	st	d1,[a1+4]

	tst	d0
	beq	no_reorder_array
	st	d2,[a1+8]

	lduh	[d0-2],%o1
	dec	256,%o1
	cmp	%o1,%o0
	beq	no_reorder_array
	nop
	
	mov	%o1,d0
	mov	%o0,d1
	sll	d3,2,d3
	umul	d3,d0,d3
	inc	12,a0
	add	a0,d3,a1
	sub	d0,d1,d0

	call	reorder	
	mov	d4,%g1

	mov	%g1,d4

no_reorder_array:
	addcc	a3,0,a0
	bne	restore_arrays
	nop

	b,a	end_restore_arrays

restore_array_size_1:
	st	d3,[a0+4]
	ld	[a0+12],a3	! descriptor
	
	st	d1,[a0+12]
	st	a3,[a0+8]

	addcc	d2,0,a0
	bne	restore_arrays
	nop

end_restore_arrays:

#ifdef FINALIZERS
	set	finalizer_list,a0
	set	free_finalizer_list,a1

	ld	[a0],a2
determine_free_finalizers_after_mark:
	set	__Nil-8,%o0
	cmp	%o0,a2
	beq	end_finalizers_after_mark
	sub	a2,d6,d1

	srl	d1,2,d1

	srl	d1,3,%o0
	andn	%o0,3,%o0
	ld	[%o4+%o0],%o1
	srl	%g3,d1,%o3

	btst	%o3,%o1
	beq	finalizer_not_used_after_mark
	nop

	add	a2,4,a0
	ba	determine_free_finalizers_after_mark
	ld	[a2+4],a2

finalizer_not_used_after_mark:
	st	a2,[a1]
	add	a2,4,a1

	ld	[a2+4],a2
	ba	determine_free_finalizers_after_mark
	st	a2,[a0]

end_finalizers_after_mark:
	st	a2,[a1]
#endif

	dec	4,sp
	call	add_garbage_collect_time
	st	%o7,[sp]

	ldg	(heap_size_33,d5)
	inc	3,d5
	srl	d5,2,d5
	
	stg	(d5,bit_counter)
	stg	(%o4,bit_vector_p)

	sll	d4,2,d4

	ldg	(heap_size_33,d0)
	sll	d0,5,d0
	sub	d0,d4,d0

	stg	(d0,last_heap_free)

#ifdef COUNT_GARBAGE_COLLECTIONS
	sethi	%hi n_garbage_collections,%o1
	ld	[%o1+%lo n_garbage_collections],%o2
	inc	1,%o2
#endif
	ldg	(@flags,%o0)
	btst	2,%o0
	beq	_no_heap_use_message2
#ifdef COUNT_GARBAGE_COLLECTIONS
	st	%o2,[%o1+%lo n_garbage_collections]
#else
	nop
#endif

	st	%o4,[sp-4]

	seth	(marked_gc_string_1,%o0)
	call	@ew_print_string
	setl	(marked_gc_string_1,%o0)

	call	@ew_print_int
	mov	d4,%o0

	seth	(heap_use_after_gc_string_2,%o0)
	call	@ew_print_string
	setl	(heap_use_after_gc_string_2,%o0)

	ld	[sp-4],%o4

_no_heap_use_message2:
#ifdef FINALIZERS
	call	call_finalizers
	nop
	ldg	(heap_vector,%o4)
#endif

	ldg	(alloc_size,d2)
	mov	d5,d0
	mov	%o4,a0

	stg	(%g0,free_after_mark)

_scan_bits:
	ld	[a0],%o0	!
	inc	4,a0
	tst	%o0
	beq	_zero_bits
	deccc	d0
	clr	[a0-4]
	bne,a	_scan_bits+4
	ld	[a0],%o0

	b,a	_end_scan

_zero_bits:
	beq	_end_bits
	mov	a0,a1

_skip_zero_bits_lp:
	ld	[a0],d1
	inc	4,a0
	tst	d1
	bne	_end_zero_bits
	deccc	d0
	bne,a	_skip_zero_bits_lp+4
	ld	[a0],d1

	ba	_end_bits+4
	sub	a0,a1,d1	

_end_zero_bits:
	clr	[a0-4]

	sub	a0,a1,d1
	sll	d1,3,d1

	seth	(free_after_mark,%o0)
	ld	[%o0+%lo free_after_mark],%o1
	cmp	d1,d2
	add	%o1,d1,%o1
	blu	_scan_next
	st	%o1,[%o0+%lo free_after_mark]

_found_free_memory:
	stg	(d0,bit_counter)
	stg	(a0,bit_vector_p)

	sub	d1,d2,d7

	ldg	(heap_vector,%o1)
	sub	a1,4,d0
	sub	d0,%o1,d0
	ldg	(heap_p3,%o1)
	sll	d0,5,d0
	add	d0,%o1,d0
	mov	d0,a6

	sll	d1,2,d1
	add	d0,d1,d0
	stg	(d0,heap_end_after_gc)

	ld	[sp],d0
	ld	[sp+4],d1
	ld	[sp+8],d2
	ld	[sp+12],d3
	ld	[sp+16],d4
	ld	[sp+20],d5
	ld	[sp+24],d6

	ld	[sp+28],%o7
	retl
	inc	32,sp

_scan_next:
	tst	d0
	bne,a	_scan_bits+4
	ld	[a0],%o0

	b,a	_end_scan

_end_bits:
	sub	a0,a1,d1	!
	inc	4,d1
	sll	d1,3,d1

	seth	(free_after_mark,%o0)
	ld	[%o0+%lo free_after_mark],%o1
	cmp	d1,d2
	add	%o1,d1,%o1
	bgeu	_found_free_memory
	st	%o1,[%o0+%lo free_after_mark]

_end_scan:
	stg	(d0,bit_counter)
	b,a	compact_gc


_mark_stack_nodes:
	cmp	a2,a4
	be	_end_mark_nodes
	inc	4,a2

	ld	[a2-4],a0

	sub	a0,d6,d1
#ifdef SHARE_CHAR_INT
	cmp	d1,d7
	bcc	_mark_stack_nodes
#endif
	srl	d1,5,%o0
	srl	d1,2,d1
	andn	%o0,3,%o0
	ld	[%o4+%o0],%o1
	srl	%g3,d1,%o3

	btst	%o3,%o1
	bne	_mark_stack_nodes
	nop

#if 0
	add	a2,-4,%o0
	mov	0,d3
	mov	1,d5
	st	%o0,[sp-4]
	call	__mark__node
	dec	4,sp

_mark_next_node:
	b,a	_mark_stack_nodes
#else
	clr	[sp-4]
	ba	_mark_arguments
	dec	4,sp

_mark_hnf_2:
	cmp	%o3,4
	bgeu	fits_in_word_6
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits_in_word_6:
	st	%o1,[%o4+%o0]
	inc	3,d4

_mark_record_2_c:
	ld	[a0+4],%o0
	dec	4,sp
	cmp	sp,a3
	blu	__mark_using_reversal
	st	%o0,[sp]
	
	ld	[a0],a0

_mark_node:
	sub	a0,d6,d1
	cmp	d1,d7
	bcc	_mark_next_node
	srl	d1,2,d1

	srl	d1,3,%o0
	andn	%o0,3,%o0
	ld	[%o4+%o0],%o1
	srl	%g3,d1,%o3

	btst	%o3,%o1
	bne	_mark_next_node
	nop

_mark_arguments:
	ld	[a0],d0
	btst	2,d0
	be	_mark_lazy_node
	ldsh	[d0-2],d2

	tst	d2
	be	_mark_hnf_0
	cmp	d2,256
	bgeu	_mark_record
	inc	4,a0

	deccc	2,d2
	be	_mark_hnf_2
	nop
	bcs	_mark_hnf_1
	nop

_mark_hnf_3:
	cmp	%o3,4
	bgeu	fits_in_word_1
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits_in_word_1:
	st	%o1,[%o4+%o0]

	ld	[a0+4],a1
	
	sub	a1,d6,d0
	srl	d0,5,%o0
	srl	d0,2,d0
	andn	%o0,3,%o0
	ld	[%o4+%o0],%o1
	srl	%g3,d0,%o3

	btst	%o3,%o1
	bne	_shared_argument_part
	inc	3,d4

_no_shared_argument_part:
	sll	d2,2,%o2
	inc	1,d2

	add	a1,%o2,a1
	and	d0,31,%o2

	add	%o2,d2,%o2
	add	d4,d2,d4

	cmp	%o2,32
	bleu	fits_in_word_2
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits_in_word_2:
	st	%o1,[%o4+%o0]

	ld	[a1],%o0
	dec	2,d2
	st	%o0,[sp-4]
	dec	4,sp

_push_hnf_args:
	ld	[a1-4],%o0
	dec	4,a1
	st	%o0,[sp-4]
	deccc	d2
	bcc	_push_hnf_args
	dec	4,sp

	cmp	sp,a3
	bgeu,a	_mark_node
	ld	[a0],a0
	
	b,a	__mark_using_reversal

_mark_hnf_1:
	cmp	%o3,2
	bgeu	fits_in_word_4
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits_in_word_4:
	st	%o1,[%o4+%o0]
	inc	2,d4

_shared_argument_part:
	ba	_mark_node
	ld	[a0],a0

_mark_lazy_node_1:
	cmp	%o3,4
	bgeu	fits_in_word_3
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits_in_word_3:
	st	%o1,[%o4+%o0]

	cmp	d2,1
	bne	_mark_selector_node_1
	inc	3,d4

	ba	_mark_node
	ld	[a0],a0

_mark_selector_node_1:
	inccc	2,d2
	beq 	_mark_indirection_node
	ld	[a0],a1

	sub	a1,d6,d1
	srl	d1,5,%o0

	inccc	1,d2
	ble	_mark_record_selector_node_1
	srl	d1,2,d1

	andn	%o0,3,%o0
	ld	[%o4+%o0],%o1
	srl	%g3,d1,%o3

	btst	%o3,%o1
	bne,a	_mark_node
	mov	a1,a0

	ld	[a1],d2
	btst	2,d2
	be,a	_mark_node
	mov	a1,a0

	ldsh	[d2-2],%g1
	cmp	%g1,2
	bleu	_small_tuple_or_record
	nop
	
_large_tuple_or_record:
	ld	[a1+8],d1
	sub	d1,d6,%o0
	srl	%o0,5,%g1
	srl	%o0,2,%o0

	andn	%g1,3,%g1
	ld	[%o4+%g1],%g1
	srl	%g3,%o0,%o3

	btst	%o3,%g1
	bne,a	_mark_node
	mov	a1,a0

#ifdef NEW_DESCRIPTORS
	ld	[d0-8],d0
	set	__indirection,%g1
	st	%g1,[a0-4]
	sub	a0,4,d2
	lduh	[d0+4],d0
	cmp	d0,8
	bltu,a	_mark_tuple_selector_node_1
	ld	[a1+d0],a0

	beq	_mark_tuple_selector_node_2
	mov	d1,a1

	sub	d0,12,d0
	ld	[a1+d0],a0
	ba	_mark_node
	st	a0,[d2+4]

_mark_tuple_selector_node_2:
	ld	[a1],a0
	ba	_mark_node
	st	a0,[d2+4]
#endif

_small_tuple_or_record:
#ifdef NEW_DESCRIPTORS
	ld	[d0-8],d0
	set	__indirection,%g1
	st	%g1,[a0-4]
	sub	a0,4,d2
	lduh	[d0+4],d0
	ld	[a1+d0],a0
_mark_tuple_selector_node_1:
	ba	_mark_node
	st	a0,[d2+4]
#else
	sub	a0,4,d2

	ld	[d0-8],%g1
	mov	a1,a0
	ld	[%g1+4],%g1

	dec	4,sp
	call	%g1
	st	%o7,[sp]

	set	__indirection,%g1
	st	%g1,[d2]
	ba	_mark_node
	st	a0,[d2+4]
#endif

_mark_record_selector_node_1:
	beq	_mark_strict_record_selector_node_1
	andn	%o0,3,%o0

	ld	[%o4+%o0],%o1
	srl	%g3,d1,%o3

	btst	%o3,%o1
	bne,a	_mark_node
	mov	a1,a0

	ld	[a1],d2
	btst	2,d2
	be,a	_mark_node
	mov	a1,a0

	ldsh	[d2-2],%g1
	cmp	%g1,258
	bleu	_small_tuple_or_record
	nop

#ifdef NEW_DESCRIPTORS
	ld	[a1+8],d1

	sub	d1,d6,%o0
	srl	%o0,5,%g1
	srl	%o0,2,%o0

	andn	%g1,3,%g1
	ld	[%o4+%g1],%g1
	srl	%g3,%o0,%o3

	btst	%o3,%g1
	bne,a	_mark_node
	mov	a1,a0

	ld	[d0-8],d0
	set	__indirection,%g1
	st	%g1,[a0-4]
	mov	a0,d2
	lduh	[d0+4],d0
	cmp	d0,8
	bleu	_mark_record_selector_node_2
	nop
	
	mov	d1,a1
	sub	d0,12,d0
_mark_record_selector_node_2:
	ld	[a1+d0],a0
	ba	_mark_node
	st	a0,[d2]
#else
	b,a	_large_tuple_or_record
#endif

_mark_strict_record_selector_node_1:
	ld	[%o4+%o0],%o1
	srl	%g3,d1,%o3

	btst	%o3,%o1
	bne,a	_mark_node
	mov	a1,a0

	ld	[a1],d2
	btst	2,d2
	be,a	_mark_node
	mov	a1,a0

	ldsh	[d2-2],%g1
	cmp	%g1,258
	bleu	_select_from_small_record
	nop
	
	ld	[a1+8],d1
	sub	d1,d6,d1
	srl	d1,5,%o0
	srl	d1,2,d1

	andn	%o0,3,%o0
	ld	[%o4+%o0],%g1
	srl	%g3,d1,%o3

	btst	%o3,%g1
	bne,a	_mark_node
	mov	a1,a0

_select_from_small_record:
#ifdef NEW_DESCRIPTORS
	ld	[d0-8],d0
	dec	4,a0
	lduh	[d0+4],%g1
	cmp	%g1,8
	bleu,a	_mark_strict_record_selector_node_2
	ld	[a1+%g1],%g1

	dec	12,%g1
	ld	[d1+%g1],%g1

_mark_strict_record_selector_node_2:
	st	%g1,[a0+4]
	
	lduh	[d0+6],%g1
	tst	%g1
	beq	_mark_strict_record_selector_node_5
	ld	[d0-4],d0

	cmp	%g1,8
	bleu,a	_mark_strict_record_selector_node_4
	ld	[a1+%g1],%g1

	dec	12,%g1
	ld	[d1+%g1],%g1
_mark_strict_record_selector_node_4:
	st	%g1,[a0+8]
_mark_strict_record_selector_node_5:
	ba	_mark_next_node
	st	d0,[a0]
#else
	ld	[d0-8],%g1
	dec	4,a0
	ld	[%g1+4],%g1

	dec	4,sp
	call	%g1
	st	%o7,[sp]

	b,a	_mark_next_node
#endif

_mark_indirection_node:
	ba	_mark_node
	mov	a1,a0

_mark_next_node:
	ld	[sp],a0
	inc	4,sp
	tst	a0
	bne	_mark_node
	nop
	b,a	_mark_stack_nodes

_mark_lazy_node:
	tst	d2
	be	_mark_real_or_file
	add	d0,-2,a1

	cmp	d2,1
	ble,a	_mark_lazy_node_1
	inc	4,a0
	
	cmp	d2,256
	bge	_mark_closure_with_unboxed_arguments
	nop

	inc	1,d2
	and	d1,31,%o2
	add	d4,d2,d4
	add	%o2,d2,%o2

	cmp	%o2,32
	bleu	fits_in_word_7
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits_in_word_7:
	st	%o1,[%o4+%o0]

	sll	d2,2,%g2
	add	a0,%g2,a0

	dec	3,d2
_push_lazy_args:
	ld	[a0-4],%o0
	dec	4,a0
	st	%o0,[sp-4]
	deccc	d2
	bcc	_push_lazy_args
	dec	4,sp

	cmp	sp,a3
	bgeu,a	_mark_node
	ld	[a0-4],a0
	
	ba	__mark_using_reversal
	dec	4,a0

_mark_closure_with_unboxed_arguments:
	srl	d2,8,%g2
	and	d2,255,d2
	deccc	1,d2
	beq	_mark_real_or_file
	inc	2,d2

	and	d1,31,%o2
	add	d4,d2,d4
	add	%o2,d2,%o2

	cmp	%o2,32
	bleu	fits_in_word_7_
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits_in_word_7_:
	st	%o1,[%o4+%o0]

	sub	d2,%g2,d2
	sll	d2,2,%g2
	deccc	2,d2
	blt	_mark_next_node
	nop
	
	bne	_push_lazy_args
	add	a0,%g2,a0

_mark_closure_with_one_boxed_argument:
	ba	_mark_node
	ld	[a0-4],a0

_mark_hnf_0:
	set	INT+2,%g1
	cmp	d0,%g1
	blu	_mark_real_file_or_string
	seth	(CHAR+2,%g1)

	setl	(CHAR+2,%g1)
	cmp	d0,%g1
	bgu	_mark_normal_hnf_0
	nop

_mark_bool_or_small_string:
	cmp	%o3,2
	bgeu	fits_in_word_8
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits_in_word_8:
	st	%o1,[%o4+%o0]
	ba	_mark_next_node
	inc	2,d4

_mark_normal_hnf_0:
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	ba	_mark_next_node
	inc	1,d4

_mark_real_file_or_string:
	set	__STRING__+2,%g1
	cmp	d0,%g1
	bleu	_mark_string_or_array
	nop

_mark_real_or_file:
	cmp	%o3,4
	bgeu	fits_in_word_9
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits_in_word_9:
	st	%o1,[%o4+%o0]
	ba	_mark_next_node
	inc	3,d4

_mark_record:
	deccc	258,d2
	be,a	_mark_record_2
	lduh	[d0-2+2],%g1

	blu,a	_mark_record_1
	lduh	[d0-2+2],%g1

_mark_record_3:
	cmp	%o3,4
	lduh	[d0-2+2],d1
	bgeu	fits_in_word_13
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits_in_word_13:
	st	%o1,[%o4+%o0]

	ld	[a0+4],a1
	inc	3,d4

	sub	a1,d6,d0
	srl	d0,5,%o0
	srl	d0,2,d0
	andn	%o0,3,%o0

	deccc	1,d1
	ld	[%o4+%o0],%o1
	blu	_mark_record_3_bb
	srl	%g3,d0,%o3

	btst	%o3,%o1
	bne,a	_mark_node
	ld	[a0],a0

	inc	1,d2
	and	d0,31,%o2
	add	d4,d2,d4
	add	%o2,d2,%o2

	bset	%o3,%o1
	cmp	%o2,32
	bleu	_push_record_arguments
	st	%o1,[%o4+%o0]

	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
	st	%o1,[%o4+%o0]

_push_record_arguments:
	subcc	d1,1,d2

	sll	d1,2,d1
	bgeu	_push_hnf_args
	add	a1,d1,a1

	ba	_mark_node
	ld	[a0],a0

_mark_record_3_bb:
	btst	%o3,%o1
	bne	_mark_next_node
	inc	1,d2

	and	d0,31,%o2
	add	d4,d2,d4
	add	%o2,d2,%o2

	bset	%o3,%o1
	cmp	%o2,32
	bleu	_mark_next_node
	st	%o1,[%o4+%o0]

	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
	ba	_mark_next_node
	st	%o1,[%o4+%o0]

_mark_record_2:
	cmp	%o3,4
	bgeu	fits_in_word_12
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits_in_word_12:
	st	%o1,[%o4+%o0]

	cmp	%g1,1
	bgu	_mark_record_2_c
	inc	3,d4

	be,a	_mark_node
	ld	[a0],a0

	b,a	_mark_next_node

_mark_record_1:
	tst	%g1
	bne	_mark_hnf_1
	nop
	b,a	_mark_bool_or_small_string

_mark_string_or_array:
	beq,a	_mark_string
	ld	[a0+4],d0

_mark_array:
	ld	[a0+8],d1
	tst	d1
	be	_mark_lazy_array
	nop

	lduh	[d1-2],d0
	tst	d0
	be	_mark_strict_basic_array
	nop

	lduh	[d1-2+2],d1
	tst	d1
	be	_mark_b_record_array
	nop
	cmp	sp,a3
	blu	__mark_array_using_reversal
	nop

	ld	[a0+4],d2
	sub	d0,256,d3
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	umul	d2,d3,d0

	cmp	d1,d3
	beq	_mark_lazy_or_a_record_array
	inc	d4

_mark_ab_record_array:
	inc	3-1,d0
	add	d4,d0,d4

	sll	d0,2,d0
	add	a0,d0,d0
	
	sub	d0,d6,d0
	srl	d0,5,d0
	andn	d0,3,d0
	cmp	%o0,d0
	bgeu	_end_set_ab_array_bits
	nop
	
	inc	4,%o0
	cmp	%o0,d0
	bgeu	_last_ab_array_bits
	nop

_mark_ab_array_lp:
	st	%g3,[%o4+%o0]
	inc	4,%o0
	cmp	%o0,d0
	bltu,a	_mark_ab_array_lp+4
	st	%g3,[%o4+%o0]

_last_ab_array_bits:
	ld	[%o4+%o0],%o1
	bset	%g3,%o1
	st	%o1,[%o4+%o0]
	
_end_set_ab_array_bits:
	st	a2,[sp-8]
	st	a4,[sp-4]

	sll	d3,2,d3
	add	a0,12,a2

	st	d3,[sp-20]
	sll	d1,2,d1
	st	d1,[sp-16]
	dec	28,sp
	
	cmp	d2,0
	beq	_mark_ab_array_0
	nop

_mark_ab_array:
	ld	[sp+12],d1
	st	d2,[sp+4]
	st	a2,[sp]
	
	add	a2,d1,a4

	dec	4,sp
	call	_mark_stack_nodes
	st	%o7,[sp]

	ld	[sp+4],d2
	ld	[sp],a2
	ld	[sp+8],d3

	deccc	d2
	bne	_mark_ab_array
	add	a2,d3,a2

_mark_ab_array_0:
	inc	28,sp
	ld	[sp-8],a2
	ba	_mark_next_node
	ld	[sp-4],a4

_mark_lazy_array:
	cmp	sp,a3
	blu	__mark_array_using_reversal
	nop

	ld	[a0+4],d0
	bset	%o3,%o1
	inc	d4
	st	%o1,[%o4+%o0]

_mark_lazy_or_a_record_array:
	mov	d0,d2

	inc	3-1,d0
	st	a2,[sp-8]
	add	a0,12,a2

	add	d4,d0,d4
	sll	d0,2,d0
	add	a0,d0,d0
	
	sub	d0,d6,d0
	srl	d0,5,d0
	andn	d0,3,d0

	cmp	%o0,d0
	bgeu	_end_set_lazy_array_bits
	sll	d2,2,d2
	
	inc	4,%o0
	cmp	%o0,d0
	bgeu	_last_lazy_array_bits
	nop

_mark_lazy_array_lp:
	st	%g3,[%o4+%o0]
	inc	4,%o0
	cmp	%o0,d0
	bltu,a	_mark_lazy_array_lp+4
	st	%g3,[%o4+%o0]

_last_lazy_array_bits:
	ld	[%o4+%o0],%o1
	bset	%g3,%o1
	st	%o1,[%o4+%o0]
	
_end_set_lazy_array_bits:
	st	a4,[sp-4]
	st	d1,[sp-12]
	add	a2,d2,a4

	dec	16,sp
	call	_mark_stack_nodes
	st	%o7,[sp]

	ld	[sp],d1
	inc	12,sp
	ld	[sp-8],a2
	ba	_mark_next_node
	ld	[sp-4],a4

__mark_array_using_reversal:
	mov	0,d3
	st	d3,[sp-4]
	mov	1,d5
	b	__mark__node
	dec	4,sp

_mark_strict_basic_array:
	ld	[a0+4],d0
	set	INT+2,%g1
	cmp	d1,%g1
	beq,a	_mark_basic_array_
	inc	3,d0
	set	BOOL+2,%g1
	cmp	d1,%g1
	beq,a	_mark_strict_bool_array
	inc	12+3,d0
_mark_strict_real_array:
	add	d0,d0,d0
	ba	_mark_basic_array_
	inc	3,d0
_mark_strict_bool_array:
	ba	_mark_basic_array_
	srl	d0,2,d0

_mark_b_record_array:
	ld	[a0+4],d1
	dec	256,d0
	umul	d1,d0,d0

	ba	_mark_basic_array_
	inc	3,d0

_mark_string:
	inc	8+3,d0
	srl	d0,2,d0

_mark_basic_array_:
	bset	%o3,%o1
	st	%o1,[%o4+%o0]
	add	d4,d0,d4

	sll	d0,2,d0
	add	a0,d0,a0
	dec	4,a0
	sub	a0,d6,d0
	srl	d0,5,d0
	andn	d0,3,d0
	
	cmp	%o0,d0
	bge	_mark_next_node
	inc	4,%o0

	cmp	%o0,d0
	bge	_last_string_bits
	nop
	
_mark_string_lp:
	st	%g3,[%o4+%o0]
	inc	4,%o0
	cmp	%o0,d0
	bltu,a	_mark_string_lp+4
	st	%g3,[%o4+%o0]

_last_string_bits:
	ld	[%o4+%o0],%o1
	bset	%g3,%o1
	ba	_mark_next_node
	st	%o1,[%o4+%o0]
#endif

_end_mark_nodes:
	ld	[sp],%o7
	retl
	inc	4,sp

__end__mark__using__reversal:
	ld	[sp],a1
	tst	a1
	beq	_mark_next_node
	inc	4,sp
	ba	_mark_next_node
	st	a0,[a1]	

__end__mark__using__reversal__after__static:
	ld	[sp],a1
	st	a0,[a1]
	ba	_mark_next_node
	inc	4,sp

__mark_using_reversal:
	st	a0,[sp-4]
	mov	0,d3
	ld	[a0],a0
	mov	1,d5
	ba	__mark__node
	dec	4,sp

__mark__arguments:
	ld	[a0],d0
	btst	2,d0
	be	__mark__lazy__node
	ldsh	[d0-2],d2

	tst	d2
	be	__mark__hnf__0
	cmp	d2,256
	bgeu	__mark__record
	inc	4,a0

	deccc	2,d2
	be	__mark__hnf__2
	nop
	bcs	__mark__hnf__1
	nop

__mark__hnf__3:
	cmp	%o3,4
	bset	%o3,%o1
	bgeu	fits__in__word__1
	ld	[a0+4],a1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word__1:
	st	%o1,[%o4+%o0]
	
	sub	a1,d6,d0
	srl	d0,5,%o0
	srl	d0,2,d0
	andn	%o0,3,%o0
	ld	[%o4+%o0],%o1
	srl	%g3,d0,%o3

	btst	%o3,%o1
	bne	__shared__argument__part
	inc	3,d4

__no__shared__argument__part:
	bset	d5,d3
	st	d3,[a0+4]
	inc	4,a0

	ld	[a1],%g1
	sll	d2,2,d1
	inc	1,d2

	bset	1,%g1
	add	d4,d2,d4

	and	d0,31,%o2
	st	%g1,[a1]
	add	%o2,d2,%o2
	add	a1,d1,a1

	cmp	%o2,32
	bleu	fits__in__word__2
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word__2:
	st	%o1,[%o4+%o0]

	ld	[a1],d2
	clr	d5
	st	a0,[a1]
	mov	a1,d3
	ba	__mark__node
	mov	d2,a0

__mark__lazy__node__1:
	bne	__mark__selector__node__1
	nop

__mark__selector__1:
	cmp	%o3,4
	bgeu	fits__in__word__3
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word__3:
	st	%o1,[%o4+%o0]
	ba	__shared__argument__part
	inc	3,d4

__mark__hnf__1:
	cmp	%o3,2
	bgeu	fits__in__word__4
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word__4:
	st	%o1,[%o4+%o0]
	inc	2,d4

__shared__argument__part:
	ld	[a0],d2
	bset	d5,d3
	st	d3,[a0]
	mov	a0,d3
	mov	2,d5
	ba	__mark__node
	mov	d2,a0

__mark__selector__node__1:
	inccc	2,d2
	beq	__mark__indirection__node
	ld	[a0],a1

	inccc	1,d2

	sub	a1,d6,%o2
	srl	%o2,5,d2
	srl	%o2,2,%o2
	andn	d2,3,d2
	ld	[%o4+d2],%g1

	ble	__mark__record__selector__node__1
	srl	%g3,%o2,%g2

	btst	%g2,%g1
	bne	__mark__selector__1
	nop

	ld	[a1],d2
	btst	2,d2
	be	__mark__selector__1
	nop

	ldsh	[d2-2],%g1
	cmp	%g1,2
	bleu	__small__tuple__or__record
	nop

__large__tuple__or__record:
	ld	[a1+8],d1
	sub	d1,d6,%o2
	srl	%o2,5,d2
	srl	%o2,2,%o2
	andn	d2,3,d2
	ld	[%o4+d2],%g1
	srl	%g3,%o2,%g2

	btst	%g2,%g1
	bne	__mark__selector__1
	nop

#ifdef NEW_DESCRIPTORS
	ld	[d0-8],d0
	set	__indirection,%g1
	st	%g1,[a0-4]

	mov	a0,d2
	lduh	[d0+4],d0
	cmp	d0,8
	bltu,a	__mark_tuple_selector_node_1
	ld	[a1+d0],a0

	beq	__mark_tuple_selector_node_2
	mov	d1,a1

	dec	12,d0
	ld	[a1+d0],a0
	ba	__mark__node
	st	a0,[d2]

__mark_tuple_selector_node_2:
	ld	[a1],a0
	ba	__mark__node
	st	a0,[d2]
#endif

__small__tuple__or__record:
#ifdef NEW_DESCRIPTORS
	ld	[d0-8],d0
	set	__indirection,%g1
	st	%g1,[a0-4]
	mov	a0,d2
	lduh	[d0+4],d0
	ld	[a1+d0],a0
__mark_tuple_selector_node_1:
	ba	__mark__node
	st	a0,[d2]
#else
	sub	a0,4,d2

	ld	[d0-8],%g1
	mov	a1,a0
	ld	[%g1+4],%g1

	dec	4,sp
	call	%g1
	st	%o7,[sp]

	set	__indirection,%g1
	st	%g1,[d2]
	ba	__mark__node
	st	a0,[d2+4]
#endif

__mark__record__selector__node__1:
	beq	__mark__strict__record__selector__node__1
	btst	%g2,%g1
	bne	__mark__selector__1
	nop

	ld	[a1],d2
	btst	2,d2
	be	__mark__selector__1
	nop

	ldsh	[d2-2],%g1
	cmp	%g1,258
#ifdef NEW_DESCRIPTORS
	bleu	__small__record
	nop

	ld	[a1+8],d1

	sub	d1,d6,%o0
	srl	%o0,5,%g1
	srl	%o0,2,%o0

	andn	%g1,3,%g1
	ld	[%o4+%g1],%g1
	srl	%g3,%o0,%o3

	btst	%o3,%g1
	bne	__mark__selector__1
	nop

__small__record:
	ld	[d0-8],d0
	set	__indirection,%g1
	st	%g1,[a0-4]
	lduh	[d0+4],d0
	cmp	d0,8
	bleu	__mark_record_selector_node_2
	mov	a0,d2

	mov	d1,a1
	dec	12,d0
__mark_record_selector_node_2:
	ld	[a1+d0],a0
	ba	__mark__node
	st	a0,[d2]
#else
	bleu	__small__tuple__or__record
	nop
	b,a	__large__tuple__or__record
#endif

__mark__strict__record__selector__node__1:
	bne	__mark__selector__1
	nop

	ld	[a1],d2
	btst	2,d2
	be	__mark__selector__1
	nop

	ldsh	[d2-2],%g1
	cmp	%g1,258
	ble	__select__from__small__record
	nop

	ld	[a1+8],%o2
	sub	%o2,d6,%o2
	srl	%o2,5,d2
	srl	%o2,2,%o2
	andn	d2,3,d2
	ld	[%o4+d2],%g1
	srl	%g3,%o2,%g2

	btst	%g2,%g1
	bne	__mark__selector__1
	nop

__select__from__small__record:
#ifdef NEW_DESCRIPTORS
	ld	[d0-8],d0
	dec	4,a0
	lduh	[d0+4],%g1
	cmp	%g1,8
	bleu,a	__mark_strict_record_selector_node_2
	ld	[a1+%g1],%g1

	dec	12,%g1
	ld	[d1+%g1],%g1
__mark_strict_record_selector_node_2:
	st	%g1,[a0+4]

	lduh	[d0+6],%g1
	tst	%g1
	beq	__mark_strict_record_selector_node_5
	ld	[d0-4],d0

	cmp	%g1,8
	bleu,a	__mark_strict_record_selector_node_4
	ld	[a1+%g1],%g1

	mov	d1,a1
	dec	12,%g1
	ld	[a1+%g1],%g1
__mark_strict_record_selector_node_4:
	st	%g1,[a0+8]
__mark_strict_record_selector_node_5:
	ba	__mark__node
	st	d0,[a0]
#else
	ld	[d0-8],%g1
	dec	4,a0
	ld	[%g1+4],%g1

	dec	4,sp
	call	%g1
	st	%o7,[sp]

	b,a	__mark__node
#endif

__mark__indirection__node:
	ba	__mark__node
	mov	a1,a0

__mark__hnf__2:
	cmp	%o3,4
	bgeu	fits__in__word__6
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word__6:
	st	%o1,[%o4+%o0]
	inc	3,d4

__mark__record__2__c:
	ld	[a0],%o0
	bset	d5,d3
	bset	2,%o0
	st	%o0,[a0]
	ld	[a0+4],d2
	st	d3,[a0+4]
	add	a0,4,d3
	clr	d5
	mov	d2,a0

__mark__node:
	sub	a0,d6,d1
#ifdef SHARE_CHAR_INT
	cmp	d1,d7
	bcc	__mark__next__node__after__static
#endif
	srl	d1,5,%o0
	srl	d1,2,d1
	andn	%o0,3,%o0
	ld	[%o4+%o0],%o1
	srl	%g3,d1,%o3

	btst	%o3,%o1
	beq	__mark__arguments
	nop

__mark__next__node:
	tst	d5
	bne	__mark__parent
	nop

__mark__next__node2:
	ld	[d3-4],d2
	dec	4,d3
	ld	[d3+4],%o0
	and	d2,3,d5

	st	%o0,[d3]

	st	a0,[d3+4]
	ba	__mark__node
	andn	d2,3,a0

__mark__lazy__node:
	tst	d2
	beq	__mark__real__or__file
	cmp	d2,1
	ble	__mark__lazy__node__1
	inc	4,a0

 	cmp	d2,256
	bgeu	__mark_closure_with_unboxed_arguments
	nop

	inc	1,d2
	and	d1,31,%o2
	add	d4,d2,d4
	add	%o2,d2,%o2
	cmp	%o2,32
	bleu	fits__in__word__7
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word__7:
	st	%o1,[%o4+%o0]
	
	dec	2,d2
__mark_closure_with_unboxed_arguments__2:
	ld	[a0],%o0
	sll	d2,2,d2
	bset	2,%o0
	st	%o0,[a0]
	add	a0,d2,a0

	ld	[a0],d2
	bset	d5,d3
	st	d3,[a0]
	mov	a0,d3
	clr	d5
	ba	__mark__node
	mov	d2,a0	

__mark_closure_with_unboxed_arguments:
	srl	d2,8,d0
	and	d2,255,d2
	deccc	1,d2
	beq	__mark_closure_1_with_unboxed_argument
	inc	2,d2

	and	d1,31,%o2
	add	d4,d2,d4
	add	%o2,d2,%o2

	cmp	%o2,32
	bleu	fits__in__word__7_
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word__7_:
	st	%o1,[%o4+%o0]

	sub	d2,d0,d2
	deccc	2,d2
	bgt	__mark_closure_with_unboxed_arguments__2
	nop
	beq	__shared__argument__part
	nop
	ba	__mark__next__node
	dec	4,a0

__mark_closure_1_with_unboxed_argument:	
	ba	__mark__real__or__file
	dec	4,a0

__mark__hnf__0:
	set	INT+2,%g1
	cmp	d0,%g1
	bne	__no__int__3
	nop

	ld	[a0+4],d2
	cmp	d2,33
	bcs	____small____int
	sll	d2,3,d2

__mark__bool__or__small__string:
	cmp	%o3,2
	bgeu	fits__in__word__8
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word__8:
	st	%o1,[%o4+%o0]
	ba	__mark__next__node
	inc	2,d4

____small____int:
	set	small_integers,a0
	ba	__mark__next__node__after__static
	add	a0,d2,a0

__no__int__3:
	blu	__mark__real__file__or__string	
	seth	(CHAR+2,%g1)

	setl	(CHAR+2,%g1)
 	cmp	d0,%g1
 	bne	__no__char__3
	nop

	ldub	[a0+7],d2
	set	static_characters,a0
	sll	d2,3,d2
	ba	__mark__next__node__after__static
	add	a0,d2,a0

__no__char__3:
	blu	__mark__bool__or__small__string
	nop

	ba	__mark__next__node__after__static
	sub	d0,2-ZERO_ARITY_DESCRIPTOR_OFFSET,a0

__mark__real__file__or__string:
	set	__STRING__+2,%g1
	cmp	d0,%g1
	bleu	__mark__string__or__array
	nop

__mark__real__or__file:
	cmp	%o3,4
	bgeu	fits__in__word__9
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word__9:
	st	%o1,[%o4+%o0]
	ba	__mark__next__node
	inc	3,d4

__mark__record:
	deccc	258,d2
	be,a	__mark__record__2
	lduh	[d0-2+2],%g1

	blu,a	__mark__record__1
	lduh	[d0-2+2],%g1

__mark__record__3:
	cmp	%o3,4
	bset	%o3,%o1
	bgeu	fits__in__word__13
	ld	[a0+4],a1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word__13:
	st	%o1,[%o4+%o0]

	lduh	[d0-2+2],d1

	sub	a1,d6,d0
	srl	d0,5,%o0
	srl	d0,2,d0
	andn	%o0,3,%o0
	ld	[%o4+%o0],%o1
	srl	%g3,d0,%o3

	btst	%o3,%o1
	bne	__shared__record__argument__part
	inc	3,d4

	inc	1,d2
	and	d0,31,%o2

	add	%o2,d2,%o2
	add	d4,d2,d4

	cmp	%o2,32
	bleu	fits__in__word__14
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word__14:
	st	%o1,[%o4+%o0]

	deccc	1,d1
	blu,a	__mark__next__node
	dec	4,a0

	be	__shared__argument__part
	nop

	deccc	1,d1
	bset	d5,d3
	st	d3,[a0+4]
	be	__mark__record__3__aab
	inc	4,a0

	ld	[a1],%g1
	sll	d1,2,d1
	bset	1,%g1
	st	%g1,[a1]

	add	a1,d1,a1

	ld	[a1],d2
	clr	d5
	st	a0,[a1]
	mov	a1,d3
	ba	__mark__node
	mov	d2,a0

__mark__record__3__aab:	
	ld	[a1],d2
	mov	1,d5
	st	a0,[a1]
	mov	a1,d3
	ba	__mark__node
	mov	d2,a0

__shared__record__argument__part:
	tst	d1
	bne	__shared__argument__part
	nop
	ba	__mark__next__node
	dec	4,a0

__mark__record__2:
	cmp	%o3,4
	bgeu	fits__in__word_12
	bset	%o3,%o1

	st	%o1,[%o4+%o0]
	inc	4,%o0

	ld	[%o4+%o0],%o1
	bset	%g3,%o1
fits__in__word_12:
	st	%o1,[%o4+%o0]
	inc	3,d4

	cmp	%g1,1
	bgu	__mark__record__2__c
	nop
	be	__shared__argument__part
	nop
	ba	__mark__next__node
	dec	4,a0

__mark__record__1:
	tst	%g1
	bne	__mark__hnf__1
	nop
	ba	__mark__bool__or__small__string
	dec	4,a0

__mark__string__or__array:
	beq	__mark__string__
	nop

__mark__array:
	ld	[a0+8],d1
	tst	d1
	be	__mark__lazy__array
	nop

	lduh	[d1-2],d0
	tst	d0
	be,a	__mark__strict__basic__array
	ld	[a0+4],d0

	lduh	[d1-2+2],d1
	tst	d1
	beq	__mark__b__record__array
	dec	256,d0

	cmp	d0,d1
	be,a	__mark__a__record__array
	ld	[a0+4],%g1

__mark__ab__record__array:
	mov	d2,%o2
	st	d3,[sp-12]
	mov	d4,%g1
	mov	d5,%o5
	mov	d6,%g2

	ld	[a0+4],d2
	inc	8,a0

	sll	d2,2,d2
	st	a0,[sp-4]
	umul	d2,d0,a1
	st	%o0,[sp-8]

	sub	d0,d1,d0
	inc	4,a0
	call	reorder
	add	a1,a0,a1
	
	ld	[sp-8],%o0
	mov	%g2,d6
	mov	%o5,d5
	ld	[sp-4],a0
	mov	%g1,d4
	ld	[sp-12],d3
	mov	%o2,d2

	ld	[a0-4],%g1
	mov	d0,a1
	umul	%g1,d1,d0
	umul	%g1,a1,d1
	add	d4,d1,d4
	add	d1,d0,d1

	sll	d1,2,d1
	add	a0,d1,d1
	sll	d0,2,a1
	add	a0,a1,a1
	ba	__mark__r__array
	sub	d1,d6,d1

__mark__a__record__array:
	umul	%g1,d0,d0
	inc	8,a0
	b,a	__mark__lr__array

__mark__lazy__array:
	ld	[a0+4],d0
	inc	8,a0

__mark__lr__array:
	sll	d0,2,a1
	add	a0,a1,a1
	sub	a1,d6,d1
__mark__r__array:
	srl	d1,5,d1
	inc	3,d4
	bset	%o3,%o1

	andn	d1,3,d1

	cmp	%o0,d1
	bgeu	__skip__mark__lazy__array__bits
	st	%o1,[%o4+%o0]

__mark__lazy__array__bits:
	inc	4,%o0
	ld	[%o4+%o0],%o1
	bset	%g3,%o1
	cmp	%o0,d1
	bltu	__mark__lazy__array__bits
	st	%o1,[%o4+%o0]

__skip__mark__lazy__array__bits:
	set	lazy_array_list,%o2
	cmp	d0,1
	bleu	__mark__array__length__0__1
	add	d4,d0,d4

	ld	[a1],d2
	ld	[a0],%o0
	st	d2,[a0]
	st	%o0,[a1]
	
	ld	[a1-4],d2
	dec	4,a1
	ld	[%o2],%o1
	inc	2,d2
	st	%o1,[a1]
	st	d2,[a0-4]
	st	d0,[a0-8]
	dec	8,a0
	st	a0,[%o2]

	ld	[a1-4],a0
	dec	4,a1

	bset	d5,d3
	mov	0,d5
	st	d3,[a1]
	ba	__mark__node
	mov	a1,d3

__mark__array__length__0__1:
	blu	__mark__next__node
	dec	8,a0

	ld	[a0+12],d1
	ld	[a0+8],%o0
	ld	[%o2],%o3
	st	%o0,[a0+12]
	st	%o3,[a0+8]
	st	d0,[a0]

	st	a0,[%o2]
	st	d1,[a0+4]

	inc	4,a0

	ld	[a0],d2
	bset	d5,d3
	mov	2,d5
	st	d3,[a0]
	mov	a0,d3
	ba	__mark__node
	mov	d2,a0

__mark__b__record__array:
	ld	[a0+4],d1
	umul	d1,d0,d0
	ba	__mark__basic__array
	inc	3,d0

__mark__strict__basic__array:
	set	INT+2,%g1
	cmp	d1,%g1
	beq,a	__mark__basic__array
	inc	3,d0
	set	BOOL+2,%g1
	cmp	d1,%g1
	beq	__mark__strict__bool__array
	nop
__mark__strict__real__array:
	add	d0,d0,d0
	ba	__mark__basic__array
	inc	3,d0
__mark__strict__bool__array:
	inc	12+3,d0
	b	__mark__basic__array
	srl	d0,2,d0

__mark__string__:
	ld	[a0+4],d0
	inc	8+3,d0

	srl	d0,2,d0

__mark__basic__array:
	bset	%o3,%o1
	add	d4,d0,d4

	st	%o1,[%o4+%o0]

	sll	d0,2,d0
	add	a0,d0,d0
	dec	4,d0

	sub	d0,d6,d0
	srl	d0,5,d0
	andn	d0,3,d0
	
	cmp	%o0,d0
	bge	__mark__next__node
	inc	4,%o0

	cmp	%o0,d0
	bge	__last__string__bits
	nop
	
__mark__string__lp:
	st	%g3,[%o4+%o0]
	inc	4,%o0
	cmp	%o0,d0
	bltu,a	__mark__string__lp+4
	st	%g3,[%o4+%o0]

__last__string__bits:
	ld	[%o4+%o0],%o1
	bset	%g3,%o1
	ba	__mark__next__node
	st	%o1,[%o4+%o0]

__mark__parent:
	tst	d3
	be	__end__mark__using__reversal

	deccc	d5
	ld	[d3],d2
	be	__argument__part__parent
	st	a0,[d3]
	
	sub	d3,4,a0
	and	d2,3,d5
	ba	__mark__next__node
	andn	d2,3,d3
	
__argument__part__parent:
	mov	d3,a1

	andn	d2,3,d3
	dec	4,d3

	ld	[d3],a0
	ld	[d3+4],%o0
	mov	2,d5
	st	%o0,[d3]

	ba	__mark__node
	st	a1,[d3+4]

__mark__next__node__after__static:
	tst	d5
	beq	__mark__next__node2

	tst	d3
	be	__end__mark__using__reversal__after__static

	deccc	d5
	ld	[d3],d2
	be	__argument__part__parent
	st	a0,[d3]

	sub	d3,4,a0
	and	d2,3,d5
	ba	__mark__next__node
	andn	d2,3,d3