]> gitweb.factorcode.org Git - factor.git/blob - basis/cpu/x86/x86-tests.factor
compiler.*: Remove the scrubbing part of the GC maps
[factor.git] / basis / cpu / x86 / x86-tests.factor
1 USING: compiler.cfg.instructions compiler.cfg.registers
2 compiler.codegen compiler.codegen.gc-maps compiler.codegen.relocation
3 compiler.test cpu.architecture cpu.x86 cpu.x86.assembler
4 cpu.x86.assembler.operands cpu.x86.features kernel kernel.private
5 layouts literals make math math.libm namespaces sequences system
6 tools.test ;
7 IN: cpu.x86.tests
8
9 { } [
10     [ { float } declare fsqrt ]
11     [ ##sqrt? ] contains-insn?
12     sse2?
13     assert=
14 ] unit-test
15
16 ! (%compare-tagged)
17 cpu x86.64? [
18     {
19         B{ 72 129 248 255 255 255 255 }
20     } [
21         init-relocation [ RAX RAX (%compare-tagged) ] B{ } make
22     ] unit-test
23 ] when
24
25 ! %add-imm
26 {
27     B{ 72 255 192 }
28     B{ 72 131 192 29 }
29 } [
30     [ RAX RAX 1 %add-imm ] B{ } make
31     [ RAX RAX 29 %add-imm ] B{ } make
32 ] unit-test
33
34 ! %and-imm
35 {
36     B{ 131 225 6 }
37 } [
38     [ RCX RCX 0x6 %and-imm ] B{ } make
39 ] unit-test
40
41 ! %alien-invoke
42 { 1 } [
43     [
44         f { } { } { } { } 0 0 { } "dll"
45         T{ gc-map { gc-roots V{ T{ spill-slot { n 0 } } } } }
46         %alien-invoke
47     ] with-fixup drop gc-maps get length
48 ] unit-test
49
50 ! %call-gc
51 { V{ } } [
52     [
53         T{ gc-map } %call-gc
54     ] with-fixup drop gc-maps get
55 ] unit-test
56
57 { 1 } [
58     [
59         T{ gc-map { gc-roots V{ T{ spill-slot { n 0 } } } } } %call-gc
60     ] with-fixup drop gc-maps get length
61 ] unit-test
62
63 ! %clear
64 { t } [
65     [ D: 0 %clear ] B{ } make
66     cpu x86.32? B{ 199 6 144 18 0 0 } B{ 73 199 6 144 18 0 0 } ? =
67 ] unit-test
68
69 ! %dispatch
70 cpu x86.64? [
71     {
72         B{ 72 187 0 0 0 0 0 0 0 0 72 255 100 3 6 0 }
73     }
74     [
75         init-relocation [ RAX RBX %dispatch ] B{ } make
76     ] unit-test
77 ] when
78
79 ! %load-immediate
80 { B{ 49 201 } } [
81     [ RCX 0 %load-immediate ] B{ } make
82 ] unit-test
83
84 ! %prepare-varargs
85 ${
86     ! xor eax, eax
87     cpu x86.64? os unix? and B{ 49 192 } B{ } ?
88     ! mov al, 2
89     cpu x86.64? os unix? and B{ 176 2 } B{ } ?
90 } [
91     [ { } %prepare-var-args ] B{ } make
92     [
93         {
94             { T{ spill-slot } int-rep RDI }
95             { T{ spill-slot { n 0 } } float-rep XMM0 }
96             { T{ spill-slot { n 8 } } double-rep XMM1 }
97         } %prepare-var-args
98     ] B{ } make
99 ] unit-test
100
101 ! %prologue
102 { t } [
103     [ 2 cells %prologue ] B{ } make
104     [ pic-tail-reg PUSH ] B{ } make =
105 ] unit-test
106
107 { t } [
108     [ 8 cells %prologue ] B{ } make
109     [ stack-reg 7 cells SUB ] B{ } make =
110 ] unit-test
111
112 !  %replace-imm
113 cpu x86.64? [
114     {
115         B{ 73 199 6 0 0 0 0 }
116     }
117     [
118         init-relocation [ 34.0 D: 0 %replace-imm ] B{ } make
119     ] unit-test
120 ] when