Re-work flushed dependencies into new compiler cross-referencing framework
parent
c058343167
commit
09ead56652
|
@ -203,7 +203,7 @@ M: optimizing-compiler recompile ( words -- alist )
|
|||
|
||||
M: optimizing-compiler to-recompile ( -- words )
|
||||
changed-definitions get compiled-usages
|
||||
changed-classes get outdated-class-usages
|
||||
maybe-changed get outdated-conditional-usages
|
||||
append assoc-combine keys ;
|
||||
|
||||
M: optimizing-compiler process-forgotten-words
|
||||
|
|
|
@ -17,13 +17,7 @@ compiled-generic-crossref [ H{ } clone ] initialize
|
|||
compiled-crossref get at ;
|
||||
|
||||
: (compiled-usages) ( word -- assoc )
|
||||
#! If the word is not flushable anymore, we have to recompile
|
||||
#! all words which flushable away a call (presumably when the
|
||||
#! word was still flushable). If the word is flushable, we
|
||||
#! don't have to recompile words that folded this away.
|
||||
[ compiled-usage ]
|
||||
[ "flushable" word-prop inlined-dependency flushed-dependency ? ] bi
|
||||
'[ nip _ dependency>= ] assoc-filter ;
|
||||
compiled-usage [ nip inlined-dependency dependency>= ] assoc-filter ;
|
||||
|
||||
: compiled-usages ( assoc -- assocs )
|
||||
[ drop word? ] assoc-filter
|
||||
|
@ -32,7 +26,7 @@ compiled-generic-crossref [ H{ } clone ] initialize
|
|||
: dependencies-satisfied? ( word -- ? )
|
||||
"conditional-dependencies" word-prop [ satisfied? ] all? ;
|
||||
|
||||
: outdated-class-usages ( assoc -- assocs )
|
||||
: outdated-conditional-usages ( assoc -- assocs )
|
||||
[
|
||||
drop
|
||||
compiled-usage
|
||||
|
|
|
@ -90,7 +90,7 @@ M: #push remove-dead-code*
|
|||
] [ drop f ] if ;
|
||||
|
||||
: remove-flushable-call ( #call -- node )
|
||||
[ word>> flushed-dependency depends-on ]
|
||||
[ word>> depends-on-flushable ]
|
||||
[ in-d>> #drop remove-dead-code* ]
|
||||
bi ;
|
||||
|
||||
|
|
|
@ -32,4 +32,4 @@ M: macro definition "macro" word-prop ;
|
|||
M: macro reset-word
|
||||
[ call-next-method ] [ f "macro" set-word-prop ] bi ;
|
||||
|
||||
M: macro bump-effect-counter* drop t ;
|
||||
M: macro always-bump-effect-counter? drop t ;
|
||||
|
|
|
@ -28,10 +28,3 @@ SYMBOL: b
|
|||
b inlined-dependency depends-on
|
||||
] computing-dependencies
|
||||
] unit-test
|
||||
|
||||
[ flushed-dependency ] [ f flushed-dependency strongest-dependency ] unit-test
|
||||
[ flushed-dependency ] [ flushed-dependency f strongest-dependency ] unit-test
|
||||
[ inlined-dependency ] [ flushed-dependency inlined-dependency strongest-dependency ] unit-test
|
||||
[ inlined-dependency ] [ called-dependency inlined-dependency strongest-dependency ] unit-test
|
||||
[ flushed-dependency ] [ called-dependency flushed-dependency strongest-dependency ] unit-test
|
||||
[ called-dependency ] [ called-dependency f strongest-dependency ] unit-test
|
||||
|
|
|
@ -79,6 +79,15 @@ TUPLE: depends-on-method class generic method ;
|
|||
M: depends-on-method satisfied?
|
||||
[ [ class>> ] [ generic>> ] bi method-for-class ] [ method>> ] bi eq? ;
|
||||
|
||||
TUPLE: depends-on-flushable word ;
|
||||
|
||||
: depends-on-flushable ( word -- )
|
||||
[ depends-on-conditionally ]
|
||||
[ \ depends-on-flushable add-conditional-dependency ] bi ;
|
||||
|
||||
M: depends-on-flushable satisfied?
|
||||
word>> flushable? ;
|
||||
|
||||
: init-dependencies ( -- )
|
||||
H{ } clone dependencies set
|
||||
H{ } clone generic-dependencies set
|
||||
|
|
|
@ -28,7 +28,7 @@ TUPLE: check-mixin-class class ;
|
|||
|
||||
: redefine-mixin-class ( class members -- )
|
||||
[ (define-union-class) ]
|
||||
[ drop changed-class ]
|
||||
[ drop changed-conditionally ]
|
||||
[ drop t "mixin" set-word-prop ]
|
||||
2tri ;
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ M: tuple-class update-class
|
|||
2drop
|
||||
[
|
||||
[ update-tuples-after ]
|
||||
[ changed-class ]
|
||||
[ changed-conditionally ]
|
||||
bi
|
||||
] each-subclass
|
||||
]
|
||||
|
|
|
@ -32,7 +32,7 @@ PRIVATE>
|
|||
|
||||
: define-union-class ( class members -- )
|
||||
[ (define-union-class) ]
|
||||
[ drop changed-class ]
|
||||
[ drop changed-conditionally ]
|
||||
[ drop update-classes ]
|
||||
2tri ;
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ M: object always-bump-effect-counter? drop f ;
|
|||
dup new-definitions get first update
|
||||
dup new-definitions get second update
|
||||
dup changed-definitions get update
|
||||
dup changed-classes get update
|
||||
dup maybe-changed get update
|
||||
dup dup changed-vocabs update ;
|
||||
|
||||
: process-forgotten-definitions ( -- )
|
||||
|
@ -134,7 +134,7 @@ M: object always-bump-effect-counter? drop f ;
|
|||
|
||||
: bump-effect-counter? ( -- ? )
|
||||
changed-effects get
|
||||
changed-classes get
|
||||
maybe-changed get
|
||||
changed-definitions get [ drop always-bump-effect-counter? ] assoc-filter
|
||||
3array assoc-combine new-words get assoc-diff assoc-empty? not ;
|
||||
|
||||
|
@ -165,7 +165,7 @@ PRIVATE>
|
|||
: with-nested-compilation-unit ( quot -- )
|
||||
[
|
||||
H{ } clone changed-definitions set
|
||||
H{ } clone changed-classes set
|
||||
H{ } clone maybe-changed set
|
||||
H{ } clone changed-effects set
|
||||
H{ } clone outdated-generics set
|
||||
H{ } clone outdated-tuples set
|
||||
|
@ -176,7 +176,7 @@ PRIVATE>
|
|||
: with-compilation-unit ( quot -- )
|
||||
[
|
||||
H{ } clone changed-definitions set
|
||||
H{ } clone changed-classes set
|
||||
H{ } clone maybe-changed set
|
||||
H{ } clone changed-effects set
|
||||
H{ } clone outdated-generics set
|
||||
H{ } clone forgotten-definitions set
|
||||
|
|
|
@ -15,10 +15,10 @@ SYMBOL: changed-definitions
|
|||
: changed-definition ( defspec -- )
|
||||
dup changed-definitions get set-in-unit ;
|
||||
|
||||
SYMBOL: changed-classes
|
||||
SYMBOL: maybe-changed
|
||||
|
||||
: changed-class ( class -- )
|
||||
dup changed-classes get set-in-unit ;
|
||||
: changed-conditionally ( class -- )
|
||||
dup maybe-changed get set-in-unit ;
|
||||
|
||||
SYMBOL: changed-effects
|
||||
|
||||
|
|
|
@ -110,9 +110,14 @@ M: word make-inline
|
|||
: define-inline ( word def effect -- )
|
||||
[ define-declared ] [ 2drop make-inline ] 3bi ;
|
||||
|
||||
GENERIC: flushable? ( word -- ? )
|
||||
|
||||
M: word flushable? "flushable" word-prop ;
|
||||
|
||||
GENERIC: reset-word ( word -- )
|
||||
|
||||
M: word reset-word
|
||||
dup flushable? [ dup changed-conditionally ] when
|
||||
{
|
||||
"unannotated-def" "parsing" "inline" "recursive"
|
||||
"foldable" "flushable" "reading" "writing" "reader"
|
||||
|
@ -182,10 +187,6 @@ M: parsing-word definer drop \ SYNTAX: \ ; ;
|
|||
: deprecated? ( obj -- ? )
|
||||
dup word? [ "deprecated" word-prop ] [ drop f ] if ;
|
||||
|
||||
GENERIC: flushable? ( word -- ? )
|
||||
|
||||
M: word flushable? "flushable" word-prop ;
|
||||
|
||||
! Definition protocol
|
||||
M: word where "loc" word-prop ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue