1 USING: accessors alien.c-types alien.syntax arrays assocs bit-arrays
2 classes.struct combinators combinators.short-circuit compiler compiler.cfg
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: gtk-samples.opengl
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 set ] [ cfg>gc-maps tally-gc-maps ] bi ;
41 ! Handle f f as input. Deferred words don't have any gc-info. See #1394.
42 : same-gc-info? ( compiler-gc-info/f gc-info/f -- ? )
46 [ struct-slot-values = ]
47 [ [ not ] dip return-address-count>> 0 = and ] 2bi or
50 : base-pointer-groups-expected ( word -- seq )
51 test-regs first cfg>gc-maps [ derived-root-offsets { } like ] { } map-as ;
53 : base-pointer-groups-decoded ( word -- seq )
55 second second [ swap 2array ] map-index
56 [ nip -1 = ] assoc-reject
59 ! byte-array>bit-array
66 B{ 239 1 } byte-array>bit-array
69 { ?{ t t t t t t t t } } [ B{ 255 } byte-array>bit-array ] unit-test
73 \ effects:<effect> word>gc-maps empty?
77 \ + word>gc-maps empty?
81 \ word>gc-maps word>gc-maps
86 all-words [ normal? ] filter 50 sample
87 [ [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info? ] reject
91 ! Originally from llvm.types, but llvm moved to unmaintained
92 TYPEDEF: void* LLVMTypeRef
93 TYPEDEF: void* LLVMTypeHandleRef
94 FUNCTION: LLVMTypeRef LLVMResolveTypeHandle ( LLVMTypeHandleRef TypeHandle )
95 FUNCTION: LLVMTypeHandleRef LLVMCreateTypeHandle ( LLVMTypeRef PotentiallyAbstractTy )
96 FUNCTION: void LLVMRefineType ( LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy )
97 FUNCTION: void LLVMDisposeTypeHandle ( LLVMTypeHandleRef TypeHandle )
99 : resolve-types ( typeref typeref -- typeref )
100 over LLVMCreateTypeHandle [ LLVMRefineType ] dip
101 [ LLVMResolveTypeHandle ] keep LLVMDisposeTypeHandle ;
103 ! base-pointer-groups
106 [ base-pointer-groups-expected ] [ base-pointer-groups-decoded ] bi =
113 [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info?
117 \ opencl:cl-queue-kernel
118 [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info?
122 \ crypto.aes.utils:bytes>words
123 [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info?
127 \ cpu.x86.features.private:(sse-version)
128 [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info?
133 \ gtk-samples.opengl:opengl-main
134 [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info?
137 ! Ensure deterministic gc map generation.
138 : recompile-word>gc-info ( word -- gc-info )
139 [ 1array compile ] keep word>gc-info ;
141 : deterministic-gc-info? ( word -- ? )
143 _ recompile-word>gc-info struct-slot-values
144 dup last 0 = [ drop f ] when
145 ] replicate all-equal? ;
148 \ opencl:cl-queue-kernel deterministic-gc-info?