]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/codegen/fixup/fixup-tests.factor
GC maps for more compact inline GC checks
[factor.git] / basis / compiler / codegen / fixup / fixup-tests.factor
1 USING: namespaces byte-arrays make compiler.codegen.fixup
2 bit-arrays accessors classes.struct tools.test kernel math
3 sequences alien.c-types specialized-arrays boxes ;
4 SPECIALIZED-ARRAY: uint
5 IN: compiler.codegen.fixup.tests
6
7 STRUCT: gc-info
8 { scrub-d-count uint }
9 { scrub-r-count uint }
10 { gc-root-count uint }
11 { return-address-count uint } ;
12
13 [ ] [
14     [
15         init-fixup
16
17         50 <byte-array> %
18
19         { { } { } { } } set-next-gc-map
20         gc-map-here
21
22         50 <byte-array> %
23
24         { { 0 4 } { 1 } { 1 3 } } set-next-gc-map
25         gc-map-here
26
27         emit-gc-info
28     ] B{ } make
29     "result" set
30 ] unit-test
31
32 [ 0 ] [ "result" get length 16 mod ] unit-test
33
34 [ ] [
35     [
36         100 <byte-array> %
37
38         ! The below data is 22 bytes -- 6 bytes padding needed to
39         ! align
40         6 <byte-array> %
41
42         ! Bitmap - 2 bytes
43         ?{
44             ! scrub-d
45             t f f f t
46             ! scrub-r
47             f t
48             ! gc-roots
49             f t f t
50         } underlying>> %
51
52         ! Return addresses - 4 bytes
53         uint-array{ 100 } underlying>> %
54
55         ! GC info footer - 16 bytes
56         S{ gc-info
57             { scrub-d-count 5 }
58             { scrub-r-count 2 }
59             { gc-root-count 4 }
60             { return-address-count 1 }
61         } (underlying)>> %
62     ] B{ } make
63     "expect" set
64 ] unit-test
65
66 [ ] [ "result" get length "expect" get length assert= ] unit-test
67 [ ] [ "result" get "expect" get assert= ] unit-test