1 USING: accessors alien.c-types alien.syntax arrays assocs bit-arrays
2 classes.struct combinators combinators.short-circuit compiler
3 compiler.cfg.debugger compiler.cfg.instructions compiler.cfg.linearization
4 compiler.cfg.stack-frame compiler.codegen.gc-maps compiler.units fry generic
5 grouping io io.encodings.binary io.streams.byte-array kernel math namespaces
6 random sequences sequences.generalizations
7 tools.image-analyzer.gc-info tools.image-analyzer.utils tools.test vm
9 IN: tools.image-analyzer.gc-info.tests
10 QUALIFIED: cpu.x86.features.private
11 QUALIFIED: crypto.aes.utils
13 QUALIFIED: gml.coremath
16 : normal? ( word -- ? )
17 { [ generic? ] [ primitive? ] [ inline? ] [ no-compile? ] } 1|| not ;
19 : word>gc-info ( word -- gc-info )
20 word>byte-array binary <byte-reader> <backwards-reader> [
21 gc-info read-struct-safe
24 : cfg>gc-maps ( cfg -- gc-maps )
25 cfg>insns [ gc-map-insn? ] filter [ gc-map>> ] map
26 [ gc-map-needed? ] filter ;
28 : tally-gc-maps ( gc-maps -- seq/f )
30 [ [ scrub-d>> length ] map supremum ]
31 [ [ scrub-r>> length ] map supremum ]
32 [ [ gc-root-offsets ] map largest-spill-slot ]
33 [ [ derived-root-offsets ] map [ keys ] map largest-spill-slot ]
35 } cleave 5 narray ] if-empty ;
37 ! Like word>gc-info but uses the compiler
38 : word>gc-info-expected ( word -- seq/f )
39 test-regs first cfg>gc-maps tally-gc-maps ;
41 : same-gc-info? ( compiler-gc-info gc-info -- ? )
42 [ struct-slot-values = ]
43 [ [ not ] dip return-address-count>> 0 = and ] 2bi or ;
45 : base-pointer-groups-expected ( word -- seq )
46 test-regs first cfg>gc-maps [ derived-root-offsets { } like ] { } map-as ;
48 : base-pointer-groups-decoded ( word -- seq )
50 second second [ swap 2array ] map-index
51 [ nip -1 = ] assoc-reject
54 ! byte-array>bit-array
61 B{ 239 1 } byte-array>bit-array
64 { ?{ t t t t t t t t } } [ B{ 255 } byte-array>bit-array ] unit-test
68 \ effects:<effect> word>gc-maps empty?
72 \ + word>gc-maps empty?
76 \ word>gc-maps word>gc-maps
81 all-words [ normal? ] filter 50 sample
82 [ [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info? ] reject
86 ! Originally from llvm.types, but llvm moved to unmaintained
87 TYPEDEF: void* LLVMTypeRef
88 TYPEDEF: void* LLVMTypeHandleRef
89 FUNCTION: LLVMTypeRef LLVMResolveTypeHandle ( LLVMTypeHandleRef TypeHandle )
90 FUNCTION: LLVMTypeHandleRef LLVMCreateTypeHandle ( LLVMTypeRef PotentiallyAbstractTy )
91 FUNCTION: void LLVMRefineType ( LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy )
92 FUNCTION: void LLVMDisposeTypeHandle ( LLVMTypeHandleRef TypeHandle )
94 : resolve-types ( typeref typeref -- typeref )
95 over LLVMCreateTypeHandle [ LLVMRefineType ] dip
96 [ LLVMResolveTypeHandle ] keep LLVMDisposeTypeHandle ;
101 [ base-pointer-groups-expected ] [ base-pointer-groups-decoded ] bi =
108 [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info?
112 \ opencl:cl-queue-kernel
113 [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info?
117 \ crypto.aes.utils:bytes>words
118 [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info?
122 \ cpu.x86.features.private:(sse-version)
123 [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info?
126 ! Ensure deterministic gc map generation.
127 : recompile-word>gc-info ( word -- gc-info )
128 [ 1array compile ] keep word>gc-info ;
130 : deterministic-gc-info? ( word -- ? )
132 _ recompile-word>gc-info struct-slot-values
133 dup last 0 = [ drop f ] when
134 ] replicate all-equal? ;
137 \ opencl:cl-queue-kernel deterministic-gc-info?
138 \ gml.coremath:gml-determinant deterministic-gc-info?