From cd8fd7b2a07a161181ffd5d022eda37953b6cafb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Lindqvist?= Date: Thu, 9 Jul 2015 15:54:55 +0200 Subject: [PATCH] tools.image-analyzer.gc-info: ported the docs so now tools.gc-decode is not needed anymore --- extra/tools/gc-decode/gc-decode-tests.factor | 128 ------------------ extra/tools/gc-decode/gc-decode.factor | 59 -------- .../gc-info/gc-info-docs.factor} | 18 +-- 3 files changed, 7 insertions(+), 198 deletions(-) delete mode 100644 extra/tools/gc-decode/gc-decode-tests.factor delete mode 100644 extra/tools/gc-decode/gc-decode.factor rename extra/tools/{gc-decode/gc-decode-docs.factor => image-analyzer/gc-info/gc-info-docs.factor} (65%) diff --git a/extra/tools/gc-decode/gc-decode-tests.factor b/extra/tools/gc-decode/gc-decode-tests.factor deleted file mode 100644 index 8471d11b23..0000000000 --- a/extra/tools/gc-decode/gc-decode-tests.factor +++ /dev/null @@ -1,128 +0,0 @@ -USING: accessors arrays assocs bit-arrays classes.struct combinators -combinators.short-circuit compiler compiler.cfg.debugger -compiler.cfg.instructions compiler.cfg.stack-frame compiler.cfg.utilities -compiler.codegen.gc-maps compiler.units fry generic grouping kernel math -namespaces random sequences sequences.generalizations slots.syntax -tools.gc-decode tools.test vm vocabs words compiler.cfg.linearization ; -QUALIFIED: cpu.x86.features.private -QUALIFIED: crypto.aes.utils -QUALIFIED: effects -QUALIFIED: llvm.types -QUALIFIED: opencl -IN: tools.gc-decode.tests - -! byte-array>bit-array -{ - ?{ - t t t t f t t t - t f f f f f f f - } -} [ - B{ 239 1 } byte-array>bit-array -] unit-test - -{ ?{ t t t t t t t t } } [ B{ 255 } byte-array>bit-array ] unit-test - -! scrub-bits -{ - { } -} [ - \ decode-gc-maps word>gc-info scrub-bits -] unit-test - -! decode-gc-maps -{ f } [ - \ effects: decode-gc-maps empty? -] unit-test - -{ f } [ - \ + decode-gc-maps empty? -] unit-test - -! read-gc-maps -{ { } } [ - \ decode-gc-maps decode-gc-maps -] unit-test - -: cfg>gc-maps ( cfg -- gc-maps ) - cfg>insns [ gc-map-insn? ] filter [ gc-map>> ] map - [ gc-map-needed? ] filter ; - -: tally-gc-maps ( gc-maps -- seq/f ) - [ f ] [ { - [ [ scrub-d>> length ] map supremum ] - [ [ scrub-r>> length ] map supremum ] - [ [ gc-root-offsets ] map largest-spill-slot ] - [ [ derived-root-offsets ] map [ keys ] map largest-spill-slot ] - [ length ] - } cleave 5 narray ] if-empty ; - -! Like word>gc-info but uses the compiler -: word>gc-info-expected ( word -- seq/f ) - test-regs first dup stack-frame>> stack-frame - [ cfg>gc-maps tally-gc-maps ] with-variable ; - -: same-gc-info? ( compiler-gc-info gc-info -- ? ) - [ struct-slot-values = ] - [ [ not ] dip return-address-count>> 0 = and ] 2bi or ; - -! Do it also for a bunch of random words -: normal? ( word -- ? ) - { [ generic? ] [ primitive? ] [ inline? ] [ no-compile? ] } 1|| not ; - -{ { } } [ - all-words [ normal? ] filter 50 sample - [ [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info? ] reject -] unit-test - -: base-pointer-groups-expected ( word -- seq ) - test-regs first dup stack-frame>> stack-frame [ - cfg>gc-maps [ derived-root-offsets { } like ] { } map-as - ] with-variable ; - -: base-pointer-groups-decoded ( word -- seq ) - word>gc-info base-pointer-groups [ - [ swap 2array ] map-index [ nip -1 = ] assoc-reject - ] map ; - -! base-pointer-groups -{ t } [ - \ llvm.types:resolve-types - [ base-pointer-groups-expected ] [ base-pointer-groups-decoded ] bi = -] unit-test - -! Tough words #1227 -{ t } [ - \ llvm.types:resolve-types - [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info? -] unit-test - -{ t } [ - \ opencl:cl-queue-kernel - [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info? -] unit-test - -{ t } [ - \ crypto.aes.utils:bytes>words - [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info? -] unit-test - -{ t } [ - \ cpu.x86.features.private:(sse-version) - [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info? -] unit-test - -! Ensure deterministic gc map generation. -: recompile-word>gc-info ( word -- gc-info ) - [ 1array compile ] keep word>gc-info ; - -: deterministic-gc-info? ( word -- ? ) - 20 swap '[ - _ recompile-word>gc-info struct-slot-values - dup last 0 = [ drop f ] when - ] replicate all-equal? ; - - -{ t } [ - \ opencl:cl-queue-kernel deterministic-gc-info? -] unit-test diff --git a/extra/tools/gc-decode/gc-decode.factor b/extra/tools/gc-decode/gc-decode.factor deleted file mode 100644 index 457ae55853..0000000000 --- a/extra/tools/gc-decode/gc-decode.factor +++ /dev/null @@ -1,59 +0,0 @@ -USING: accessors alien alien.c-types alien.data arrays assocs bit-arrays -bit-arrays.private classes.struct fry grouping kernel math math.statistics -sequences sequences.repeating splitting vm words ; -IN: tools.gc-decode - -! Utils -: byte-array>bit-array ( byte-array -- bit-array ) - [ integer>bit-array 8 f pad-tail ] { } map-as concat ; - -: (cut-points) ( counts times -- seq ) - cum-sum but-last ; - -: reshape-sequence ( seq counts times -- seqs ) - [ (cut-points) split-indices ] keep flip ; - -: end-address>direct-array ( obj count type -- seq ) - [ heap-size * [ >c-ptr alien-address ] dip - ] 2keep - c-direct-array-constructor execute( alien len -- seq ) ; - -: bit-counts ( gc-info -- counts ) - struct-slot-values 3 head ; - -: total-bitmap-bits ( gc-info -- n ) - [ bit-counts sum ] [ return-address-count>> ] bi * ; - -: return-addresses ( gc-info -- seq ) - dup return-address-count>> uint end-address>direct-array ; - -: base-pointers ( gc-info -- seq ) - [ return-addresses ] - [ return-address-count>> ] - [ derived-root-count>> ] tri * - int end-address>direct-array ; - -: base-pointer-groups ( gc-info -- seqs ) - dup base-pointers - [ return-address-count>> { } ] - [ swap derived-root-count>> [ >array ] map ] if-empty ; - -: scrub-bytes ( gc-info -- seq ) - [ base-pointers ] [ total-bitmap-bits bits>bytes ] bi - uchar end-address>direct-array ; - -: scrub-bits ( gc-info -- seq ) - [ scrub-bytes byte-array>bit-array ] keep total-bitmap-bits head ; - -: scrub-bit-groups ( gc-info -- scrub-groups ) - [ scrub-bits ] [ bit-counts ] [ return-address-count>> ] tri - [ 2drop { } ] [ reshape-sequence ] if-zero ; - -: read-gc-maps ( gc-info -- assoc ) - [ return-addresses ] [ scrub-bit-groups ] [ base-pointer-groups ] tri - zip zip ; - -: word>gc-info ( word -- gc-info ) - word-code nip gc-info struct-size - gc-info memory>struct ; - -: decode-gc-maps ( word -- assoc ) - word>gc-info read-gc-maps ; diff --git a/extra/tools/gc-decode/gc-decode-docs.factor b/extra/tools/image-analyzer/gc-info/gc-info-docs.factor similarity index 65% rename from extra/tools/gc-decode/gc-decode-docs.factor rename to extra/tools/image-analyzer/gc-info/gc-info-docs.factor index 74fd10c61d..bda105b9e6 100644 --- a/extra/tools/gc-decode/gc-decode-docs.factor +++ b/extra/tools/image-analyzer/gc-info/gc-info-docs.factor @@ -1,15 +1,11 @@ USING: assocs help.markup help.syntax vm words ; -IN: tools.gc-decode +IN: tools.image-analyzer.gc-info -ARTICLE: "tools.gc-decode" "GC maps decoder" +ARTICLE: "tools.image-analyzer.gc-info" "GC maps decoder" "A vocab that disassembles words gc maps. It's useful to have when debugging garbage collection issues." ; -HELP: word>gc-info -{ $values { "word" word } { "gc-info" gc-info } } -{ $description "Gets the gc-info struct for a word." } ; - -HELP: decode-gc-maps -{ $values { "word" word } { "assoc" assoc } } +HELP: word>gc-maps +{ $values { "word" word } { "gc-maps" assoc } } { $description "Main word of the vocab. Decodes the gc maps for a word into an assoc with the following format:" { $list "Each key is the return addess of a gc callsite (delta relative to the start of the code block)." @@ -25,9 +21,9 @@ HELP: decode-gc-maps { $examples { $unchecked-example "USING: effects prettyprint ;" - "\\ decode-gc-maps ." - "{ { 151 { { ?{ } ?{ t t t } ?{ } ?{ } ?{ f t t t t } } { } } } }" + "\\ word>gc-maps ." + "{ { 153 { { ?{ t } ?{ t t t } ?{ f t t t t } } { } } } }" } } ; -ABOUT: "tools.gc-decode" +ABOUT: "tools.image-analyzer.gc-info" -- 2.34.1