tools.image-analyzer.*: new word for removing the tag bits

char-rename
Björn Lindqvist 2016-09-02 07:51:42 +02:00
parent af7e4903a2
commit 61bbb9be06
5 changed files with 34 additions and 23 deletions

View File

@ -71,7 +71,7 @@ GENERIC: read-payload ( rel-base struct -- tuple )
0 swap seek-past-padding { } ; 0 swap seek-past-padding { } ;
: layout-address ( rel-base tuple -- address ) : layout-address ( rel-base tuple -- address )
layout>> 15 unmask - neg ; layout>> untag - neg ;
M: array-payload read-payload ( rel-base object -- payload ) M: array-payload read-payload ( rel-base object -- payload )
nip read-array-payload ; nip read-array-payload ;

View File

@ -26,13 +26,15 @@ QUALIFIED: opencl
[ gc-map-needed? ] filter ; [ gc-map-needed? ] filter ;
: tally-gc-maps ( gc-maps -- seq/f ) : tally-gc-maps ( gc-maps -- seq/f )
[ f ] [ { [ f ] [
[ [ scrub-d>> length ] map supremum ] {
[ [ scrub-r>> length ] map supremum ] [ [ scrub-d>> length ] map supremum ]
[ [ gc-root-offsets ] map largest-spill-slot ] [ [ scrub-r>> length ] map supremum ]
[ [ derived-root-offsets ] map [ keys ] map largest-spill-slot ] [ [ gc-root-offsets ] map largest-spill-slot ]
[ length ] [ [ derived-root-offsets ] map [ keys ] map largest-spill-slot ]
} cleave 5 narray ] if-empty ; [ length ]
} cleave 5 narray
] if-empty ;
! Like word>gc-info but uses the compiler ! Like word>gc-info but uses the compiler
: word>gc-info-expected ( word -- seq/f ) : word>gc-info-expected ( word -- seq/f )
@ -87,7 +89,6 @@ QUALIFIED: opencl
[ [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info? ] reject [ [ word>gc-info-expected ] [ word>gc-info ] bi same-gc-info? ] reject
] unit-test ] unit-test
! Originally from llvm.types, but llvm moved to unmaintained ! Originally from llvm.types, but llvm moved to unmaintained
TYPEDEF: void* LLVMTypeRef TYPEDEF: void* LLVMTypeRef
TYPEDEF: void* LLVMTypeHandleRef TYPEDEF: void* LLVMTypeHandleRef
@ -102,7 +103,7 @@ FUNCTION: void LLVMDisposeTypeHandle ( LLVMTypeHandleRef TypeHandle )
! base-pointer-groups ! base-pointer-groups
{ t } [ { t } [
\ resolve-types \ resolve-types
[ base-pointer-groups-expected ] [ base-pointer-groups-decoded ] bi = [ base-pointer-groups-expected ] [ base-pointer-groups-decoded ] bi =
] unit-test ] unit-test
@ -147,3 +148,7 @@ FUNCTION: void LLVMDisposeTypeHandle ( LLVMTypeHandleRef TypeHandle )
{ t } [ { t } [
\ opencl:cl-queue-kernel deterministic-gc-info? \ opencl:cl-queue-kernel deterministic-gc-info?
] unit-test ] unit-test
! TODO: try on 32 bit \ feedback-format:

View File

@ -1,9 +1,9 @@
! Copyright (C) 2013 Björn Lindqvist ! Copyright (C) 2015 - 2016 Björn Lindqvist
! See http://factorcode.org/license.txt for BSD license ! See http://factorcode.org/license.txt for BSD license
USING: accessors alien.strings assocs classes fry graphviz USING: accessors alien.strings assocs classes fry graphviz
graphviz.attributes graphviz.notation math.bitwise sequences graphviz.attributes graphviz.notation math.bitwise sequences sets
sets system tools.image-analyzer.references tools.image-analyzer.vm system tools.image-analyzer.references tools.image-analyzer.utils
vocabs.parser ; tools.image-analyzer.vm vocabs.parser ;
IN: tools.image-analyzer.graphviz IN: tools.image-analyzer.graphviz
FROM: arrays => 1array 2array ; FROM: arrays => 1array 2array ;
FROM: byte-arrays => >byte-array ; FROM: byte-arrays => >byte-array ;
@ -63,7 +63,7 @@ CONSTANT: node-colors {
: add-root-node ( graph ptr index -- graph ) : add-root-node ( graph ptr index -- graph )
over 15 mask 1 <= [ 2drop ] [ over 15 mask 1 <= [ 2drop ] [
[ swap 15 unmask add-edge ] keep <root-node> add [ swap untag add-edge ] keep <root-node> add
] if ; ] if ;
: add-root-nodes ( graph image -- graph ) : add-root-nodes ( graph image -- graph )

View File

@ -1,18 +1,21 @@
! Copyright (C) 2013 Björn Lindqvist ! Copyright (C) 2015 Björn Lindqvist
! See http://factorcode.org/license.txt for BSD license ! See http://factorcode.org/license.txt for BSD license
! !
! Tools to follow references in the loaded image. ! Tools to follow references in the loaded image.
USING: accessors arrays byte-arrays fry kernel layouts math USING: accessors arrays byte-arrays fry kernel layouts math
math.bitwise math.order sequences sets slots.syntax math.bitwise sequences slots.syntax tools.image-analyzer.relocations
tools.image-analyzer.relocations ; tools.image-analyzer.utils ;
IN: tools.image-analyzer.references IN: tools.image-analyzer.references
QUALIFIED-WITH: tools.image-analyzer.vm vm QUALIFIED-WITH: tools.image-analyzer.vm vm
! Edges in the heap ! Edges in the heap
GENERIC: pointers ( heap heap-node struct -- seq ) GENERIC: pointers ( heap heap-node struct -- seq )
: find-heap-node* ( heap untagged-ptr -- node )
'[ address>> _ = ] find nip ;
: find-heap-node ( heap ptr -- node ) : find-heap-node ( heap ptr -- node )
15 unmask '[ address>> _ = ] find nip ; untag find-heap-node* ;
: load-relocations ( heap code-block -- seq ) : load-relocations ( heap code-block -- seq )
relocation>> find-heap-node payload>> >byte-array byte-array>relocations relocation>> find-heap-node payload>> >byte-array byte-array>relocations
@ -47,4 +50,4 @@ M: object pointers ( heap heap-node struct -- seq )
3drop { } ; 3drop { } ;
: collect-pointers ( heap heap-node -- seq ) : collect-pointers ( heap heap-node -- seq )
dup object>> pointers [ 1 <= ] reject [ 15 unmask ] map ; dup object>> pointers [ 1 <= ] reject [ untag ] map ;

View File

@ -1,8 +1,11 @@
USING: accessors alien alien.c-types alien.data arrays bit-arrays classes USING: accessors alien alien.c-types alien.data arrays bit-arrays
continuations destructors fry io io.streams.throwing kernel locals classes continuations destructors fry io io.streams.throwing kernel
math namespaces sequences words ; locals math math.bitwise namespaces sequences words ;
IN: tools.image-analyzer.utils IN: tools.image-analyzer.utils
: untag ( ptr -- ptr' )
15 unmask ;
: class-heap-size ( instance -- n ) : class-heap-size ( instance -- n )
class-of heap-size ; class-of heap-size ;