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
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
: dependencies-satisfied? ( word -- ? )
"conditional-dependencies" word-prop [ satisfied? ] all? ;
-: outdated-class-usages ( assoc -- assocs )
+: outdated-conditional-usages ( assoc -- assocs )
[
drop
compiled-usage
] [ drop f ] if ;
: remove-flushable-call ( #call -- node )
- [ word>> flushed-dependency depends-on ]
+ [ word>> depends-on-flushable ]
[ in-d>> #drop remove-dead-code* ]
bi ;
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 ;
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
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
: redefine-mixin-class ( class members -- )
[ (define-union-class) ]
- [ drop changed-class ]
+ [ drop changed-conditionally ]
[ drop t "mixin" set-word-prop ]
2tri ;
2drop
[
[ update-tuples-after ]
- [ changed-class ]
+ [ changed-conditionally ]
bi
] each-subclass
]
: define-union-class ( class members -- )
[ (define-union-class) ]
- [ drop changed-class ]
+ [ drop changed-conditionally ]
[ drop update-classes ]
2tri ;
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 ( -- )
: 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 ;
: 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
: 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
: 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
: 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"
: 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 ;