Re-work flushed dependencies into new compiler cross-referencing framework

release
Slava Pestov 2010-01-30 02:58:39 +13:00
parent c058343167
commit 09ead56652
12 changed files with 29 additions and 32 deletions

View File

@ -203,7 +203,7 @@ M: optimizing-compiler recompile ( words -- alist )
M: optimizing-compiler to-recompile ( -- words ) M: optimizing-compiler to-recompile ( -- words )
changed-definitions get compiled-usages changed-definitions get compiled-usages
changed-classes get outdated-class-usages maybe-changed get outdated-conditional-usages
append assoc-combine keys ; append assoc-combine keys ;
M: optimizing-compiler process-forgotten-words M: optimizing-compiler process-forgotten-words

View File

@ -17,13 +17,7 @@ compiled-generic-crossref [ H{ } clone ] initialize
compiled-crossref get at ; compiled-crossref get at ;
: (compiled-usages) ( word -- assoc ) : (compiled-usages) ( word -- assoc )
#! If the word is not flushable anymore, we have to recompile compiled-usage [ nip inlined-dependency dependency>= ] assoc-filter ;
#! 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-usages ( assoc -- assocs ) : compiled-usages ( assoc -- assocs )
[ drop word? ] assoc-filter [ drop word? ] assoc-filter
@ -32,7 +26,7 @@ compiled-generic-crossref [ H{ } clone ] initialize
: dependencies-satisfied? ( word -- ? ) : dependencies-satisfied? ( word -- ? )
"conditional-dependencies" word-prop [ satisfied? ] all? ; "conditional-dependencies" word-prop [ satisfied? ] all? ;
: outdated-class-usages ( assoc -- assocs ) : outdated-conditional-usages ( assoc -- assocs )
[ [
drop drop
compiled-usage compiled-usage

View File

@ -90,7 +90,7 @@ M: #push remove-dead-code*
] [ drop f ] if ; ] [ drop f ] if ;
: remove-flushable-call ( #call -- node ) : remove-flushable-call ( #call -- node )
[ word>> flushed-dependency depends-on ] [ word>> depends-on-flushable ]
[ in-d>> #drop remove-dead-code* ] [ in-d>> #drop remove-dead-code* ]
bi ; bi ;

View File

@ -32,4 +32,4 @@ M: macro definition "macro" word-prop ;
M: macro reset-word M: macro reset-word
[ call-next-method ] [ f "macro" set-word-prop ] bi ; [ call-next-method ] [ f "macro" set-word-prop ] bi ;
M: macro bump-effect-counter* drop t ; M: macro always-bump-effect-counter? drop t ;

View File

@ -28,10 +28,3 @@ SYMBOL: b
b inlined-dependency depends-on b inlined-dependency depends-on
] computing-dependencies ] computing-dependencies
] unit-test ] 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

View File

@ -79,6 +79,15 @@ TUPLE: depends-on-method class generic method ;
M: depends-on-method satisfied? M: depends-on-method satisfied?
[ [ class>> ] [ generic>> ] bi method-for-class ] [ method>> ] bi eq? ; [ [ 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 ( -- ) : init-dependencies ( -- )
H{ } clone dependencies set H{ } clone dependencies set
H{ } clone generic-dependencies set H{ } clone generic-dependencies set

View File

@ -28,7 +28,7 @@ TUPLE: check-mixin-class class ;
: redefine-mixin-class ( class members -- ) : redefine-mixin-class ( class members -- )
[ (define-union-class) ] [ (define-union-class) ]
[ drop changed-class ] [ drop changed-conditionally ]
[ drop t "mixin" set-word-prop ] [ drop t "mixin" set-word-prop ]
2tri ; 2tri ;

View File

@ -223,7 +223,7 @@ M: tuple-class update-class
2drop 2drop
[ [
[ update-tuples-after ] [ update-tuples-after ]
[ changed-class ] [ changed-conditionally ]
bi bi
] each-subclass ] each-subclass
] ]

View File

@ -32,7 +32,7 @@ PRIVATE>
: define-union-class ( class members -- ) : define-union-class ( class members -- )
[ (define-union-class) ] [ (define-union-class) ]
[ drop changed-class ] [ drop changed-conditionally ]
[ drop update-classes ] [ drop update-classes ]
2tri ; 2tri ;

View File

@ -123,7 +123,7 @@ M: object always-bump-effect-counter? drop f ;
dup new-definitions get first update dup new-definitions get first update
dup new-definitions get second update dup new-definitions get second update
dup changed-definitions get update dup changed-definitions get update
dup changed-classes get update dup maybe-changed get update
dup dup changed-vocabs update ; dup dup changed-vocabs update ;
: process-forgotten-definitions ( -- ) : process-forgotten-definitions ( -- )
@ -134,7 +134,7 @@ M: object always-bump-effect-counter? drop f ;
: bump-effect-counter? ( -- ? ) : bump-effect-counter? ( -- ? )
changed-effects get changed-effects get
changed-classes get maybe-changed get
changed-definitions get [ drop always-bump-effect-counter? ] assoc-filter changed-definitions get [ drop always-bump-effect-counter? ] assoc-filter
3array assoc-combine new-words get assoc-diff assoc-empty? not ; 3array assoc-combine new-words get assoc-diff assoc-empty? not ;
@ -165,7 +165,7 @@ PRIVATE>
: with-nested-compilation-unit ( quot -- ) : with-nested-compilation-unit ( quot -- )
[ [
H{ } clone changed-definitions set H{ } clone changed-definitions set
H{ } clone changed-classes set H{ } clone maybe-changed set
H{ } clone changed-effects set H{ } clone changed-effects set
H{ } clone outdated-generics set H{ } clone outdated-generics set
H{ } clone outdated-tuples set H{ } clone outdated-tuples set
@ -176,7 +176,7 @@ PRIVATE>
: with-compilation-unit ( quot -- ) : with-compilation-unit ( quot -- )
[ [
H{ } clone changed-definitions set H{ } clone changed-definitions set
H{ } clone changed-classes set H{ } clone maybe-changed set
H{ } clone changed-effects set H{ } clone changed-effects set
H{ } clone outdated-generics set H{ } clone outdated-generics set
H{ } clone forgotten-definitions set H{ } clone forgotten-definitions set

View File

@ -15,10 +15,10 @@ SYMBOL: changed-definitions
: changed-definition ( defspec -- ) : changed-definition ( defspec -- )
dup changed-definitions get set-in-unit ; dup changed-definitions get set-in-unit ;
SYMBOL: changed-classes SYMBOL: maybe-changed
: changed-class ( class -- ) : changed-conditionally ( class -- )
dup changed-classes get set-in-unit ; dup maybe-changed get set-in-unit ;
SYMBOL: changed-effects SYMBOL: changed-effects

View File

@ -110,9 +110,14 @@ M: word make-inline
: define-inline ( word def effect -- ) : define-inline ( word def effect -- )
[ define-declared ] [ 2drop make-inline ] 3bi ; [ define-declared ] [ 2drop make-inline ] 3bi ;
GENERIC: flushable? ( word -- ? )
M: word flushable? "flushable" word-prop ;
GENERIC: reset-word ( word -- ) GENERIC: reset-word ( word -- )
M: word reset-word M: word reset-word
dup flushable? [ dup changed-conditionally ] when
{ {
"unannotated-def" "parsing" "inline" "recursive" "unannotated-def" "parsing" "inline" "recursive"
"foldable" "flushable" "reading" "writing" "reader" "foldable" "flushable" "reading" "writing" "reader"
@ -182,10 +187,6 @@ M: parsing-word definer drop \ SYNTAX: \ ; ;
: deprecated? ( obj -- ? ) : deprecated? ( obj -- ? )
dup word? [ "deprecated" word-prop ] [ drop f ] if ; dup word? [ "deprecated" word-prop ] [ drop f ] if ;
GENERIC: flushable? ( word -- ? )
M: word flushable? "flushable" word-prop ;
! Definition protocol ! Definition protocol
M: word where "loc" word-prop ; M: word where "loc" word-prop ;