compiler: tweak recompilation logic. speeds up '"terrain" require' by 8 seconds
parent
22fbe01c17
commit
c011380a19
|
@ -1,9 +1,10 @@
|
||||||
! Copyright (C) 2004, 2010 Slava Pestov.
|
! Copyright (C) 2004, 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors kernel namespaces arrays sequences io words fry
|
USING: accessors kernel namespaces arrays sequences io words fry
|
||||||
continuations vocabs assocs dlists definitions math graphs generic
|
continuations vocabs assocs dlists definitions math graphs
|
||||||
generic.single combinators deques search-deques macros
|
generic generic.single combinators combinators.smart deques
|
||||||
source-files.errors combinators.short-circuit classes.algebra
|
search-deques macros source-files.errors
|
||||||
|
combinators.short-circuit classes.algebra
|
||||||
|
|
||||||
stack-checker stack-checker.dependencies stack-checker.inlining
|
stack-checker stack-checker.dependencies stack-checker.inlining
|
||||||
stack-checker.errors
|
stack-checker.errors
|
||||||
|
@ -35,15 +36,6 @@ SYMBOL: compiled
|
||||||
: queue-compile ( word -- )
|
: queue-compile ( word -- )
|
||||||
dup compile? [ compile-queue get push-front ] [ drop ] if ;
|
dup compile? [ compile-queue get push-front ] [ drop ] if ;
|
||||||
|
|
||||||
: recompile-callers? ( word -- ? )
|
|
||||||
changed-effects get key? ;
|
|
||||||
|
|
||||||
: recompile-callers ( word -- )
|
|
||||||
#! If a word's stack effect changed, recompile all words
|
|
||||||
#! that have compiled calls to it.
|
|
||||||
dup recompile-callers?
|
|
||||||
[ effect-dependencies-of keys [ queue-compile ] each ] [ drop ] if ;
|
|
||||||
|
|
||||||
: compiler-message ( string -- )
|
: compiler-message ( string -- )
|
||||||
"trace-compilation" get [ global [ print flush ] bind ] [ drop ] if ;
|
"trace-compilation" get [ global [ print flush ] bind ] [ drop ] if ;
|
||||||
|
|
||||||
|
@ -81,7 +73,6 @@ M: word combinator? inline? ;
|
||||||
#! Recompile callers if the word's stack effect changed, then
|
#! Recompile callers if the word's stack effect changed, then
|
||||||
#! save the word's dependencies so that if they change, the
|
#! save the word's dependencies so that if they change, the
|
||||||
#! word can get recompiled too.
|
#! word can get recompiled too.
|
||||||
[ recompile-callers ]
|
|
||||||
[ compiled-unxref ]
|
[ compiled-unxref ]
|
||||||
[
|
[
|
||||||
dup crossref? [
|
dup crossref? [
|
||||||
|
@ -89,7 +80,7 @@ M: word combinator? inline? ;
|
||||||
[ conditional-dependencies get set-dependency-checks ]
|
[ conditional-dependencies get set-dependency-checks ]
|
||||||
bi
|
bi
|
||||||
] [ drop ] if
|
] [ drop ] if
|
||||||
] tri ;
|
] bi ;
|
||||||
|
|
||||||
: deoptimize-with ( word def -- * )
|
: deoptimize-with ( word def -- * )
|
||||||
#! If the word failed to infer, compile it with the
|
#! If the word failed to infer, compile it with the
|
||||||
|
@ -202,9 +193,12 @@ M: optimizing-compiler recompile ( words -- alist )
|
||||||
"--- compile done" compiler-message ;
|
"--- compile done" compiler-message ;
|
||||||
|
|
||||||
M: optimizing-compiler to-recompile ( -- words )
|
M: optimizing-compiler to-recompile ( -- words )
|
||||||
changed-definitions get compiled-usages
|
[
|
||||||
maybe-changed get outdated-conditional-usages
|
changed-effects get new-words get assoc-diff outdated-effect-usages
|
||||||
append assoc-combine keys ;
|
changed-definitions get new-words get assoc-diff outdated-definition-usages
|
||||||
|
maybe-changed get new-words get assoc-diff outdated-conditional-usages
|
||||||
|
changed-definitions get [ drop word? ] assoc-filter 1array
|
||||||
|
] append-outputs assoc-combine keys ;
|
||||||
|
|
||||||
M: optimizing-compiler process-forgotten-words
|
M: optimizing-compiler process-forgotten-words
|
||||||
[ delete-compiled-xref ] each ;
|
[ delete-compiled-xref ] each ;
|
||||||
|
|
|
@ -22,9 +22,13 @@ generic-call-site-crossref [ H{ } clone ] initialize
|
||||||
: conditional-dependencies-of ( word -- assoc )
|
: conditional-dependencies-of ( word -- assoc )
|
||||||
effect-dependencies-of [ nip conditional-dependency dependency>= ] assoc-filter ;
|
effect-dependencies-of [ nip conditional-dependency dependency>= ] assoc-filter ;
|
||||||
|
|
||||||
: compiled-usages ( assoc -- assocs )
|
: outdated-definition-usages ( assoc -- assocs )
|
||||||
[ drop word? ] assoc-filter
|
[ drop word? ] assoc-filter
|
||||||
[ [ drop definition-dependencies-of ] { } assoc>map ] keep suffix ;
|
[ drop definition-dependencies-of ] { } assoc>map ;
|
||||||
|
|
||||||
|
: outdated-effect-usages ( assoc -- assocs )
|
||||||
|
[ drop word? ] assoc-filter
|
||||||
|
[ drop effect-dependencies-of ] { } assoc>map ;
|
||||||
|
|
||||||
: dependencies-satisfied? ( word cache -- ? )
|
: dependencies-satisfied? ( word cache -- ? )
|
||||||
[ "dependency-checks" word-prop ] dip
|
[ "dependency-checks" word-prop ] dip
|
||||||
|
|
Loading…
Reference in New Issue