diff --git a/basis/compiler/compiler.factor b/basis/compiler/compiler.factor index 2bdff71781..cce33c2f8d 100644 --- a/basis/compiler/compiler.factor +++ b/basis/compiler/compiler.factor @@ -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 diff --git a/basis/compiler/crossref/crossref.factor b/basis/compiler/crossref/crossref.factor index 72e2c07c34..d0595f53b6 100644 --- a/basis/compiler/crossref/crossref.factor +++ b/basis/compiler/crossref/crossref.factor @@ -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 diff --git a/basis/compiler/tree/dead-code/simple/simple.factor b/basis/compiler/tree/dead-code/simple/simple.factor index 0856920679..5582f4dc6f 100644 --- a/basis/compiler/tree/dead-code/simple/simple.factor +++ b/basis/compiler/tree/dead-code/simple/simple.factor @@ -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 ; diff --git a/basis/macros/macros.factor b/basis/macros/macros.factor index 29c4fb6093..46fd1ce748 100644 --- a/basis/macros/macros.factor +++ b/basis/macros/macros.factor @@ -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 ; diff --git a/basis/stack-checker/dependencies/dependencies-tests.factor b/basis/stack-checker/dependencies/dependencies-tests.factor index 9bcec64033..2b6686e247 100644 --- a/basis/stack-checker/dependencies/dependencies-tests.factor +++ b/basis/stack-checker/dependencies/dependencies-tests.factor @@ -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 diff --git a/basis/stack-checker/dependencies/dependencies.factor b/basis/stack-checker/dependencies/dependencies.factor index 004c1dd07d..865fedebca 100644 --- a/basis/stack-checker/dependencies/dependencies.factor +++ b/basis/stack-checker/dependencies/dependencies.factor @@ -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 diff --git a/core/classes/mixin/mixin.factor b/core/classes/mixin/mixin.factor index 16e4ff124e..8a48a25160 100644 --- a/core/classes/mixin/mixin.factor +++ b/core/classes/mixin/mixin.factor @@ -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 ; diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor index 12d90e036b..620c65c865 100644 --- a/core/classes/tuple/tuple.factor +++ b/core/classes/tuple/tuple.factor @@ -223,7 +223,7 @@ M: tuple-class update-class 2drop [ [ update-tuples-after ] - [ changed-class ] + [ changed-conditionally ] bi ] each-subclass ] diff --git a/core/classes/union/union.factor b/core/classes/union/union.factor index 44a1c22774..518ba37d7c 100644 --- a/core/classes/union/union.factor +++ b/core/classes/union/union.factor @@ -32,7 +32,7 @@ PRIVATE> : define-union-class ( class members -- ) [ (define-union-class) ] - [ drop changed-class ] + [ drop changed-conditionally ] [ drop update-classes ] 2tri ; diff --git a/core/compiler/units/units.factor b/core/compiler/units/units.factor index 21ab578ccc..386d5750bf 100644 --- a/core/compiler/units/units.factor +++ b/core/compiler/units/units.factor @@ -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 diff --git a/core/definitions/definitions.factor b/core/definitions/definitions.factor index 7110e27e04..e255b161ee 100644 --- a/core/definitions/definitions.factor +++ b/core/definitions/definitions.factor @@ -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 diff --git a/core/words/words.factor b/core/words/words.factor index 106cca29fa..4fe00d1edf 100644 --- a/core/words/words.factor +++ b/core/words/words.factor @@ -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 ;