tools.deploy.shaker: better I/O stripping, and more effective compiler class stripping by clearing megamorphic caches

db4
Slava Pestov 2009-05-12 04:20:02 -05:00
parent aa0e954633
commit 2508ba2e6d
1 changed files with 37 additions and 9 deletions

View File

@ -1,10 +1,12 @@
! Copyright (C) 2007, 2009 Slava Pestov. ! Copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays accessors io.backend io.streams.c init fry namespaces USING: arrays accessors io.backend io.streams.c init fry namespaces
make assocs kernel parser lexer strings.parser vocabs sequences words math make assocs kernel parser lexer strings.parser vocabs sequences
memory kernel.private continuations io vocabs.loader system strings sequences.private words memory kernel.private continuations io
sets vectors quotations byte-arrays sorting compiler.units definitions vocabs.loader system strings sets vectors quotations byte-arrays
generic generic.standard tools.deploy.config combinators classes ; sorting compiler.units definitions generic generic.standard
generic.single tools.deploy.config combinators classes
slots.private ;
QUALIFIED: bootstrap.stage2 QUALIFIED: bootstrap.stage2
QUALIFIED: command-line QUALIFIED: command-line
QUALIFIED: compiler.errors QUALIFIED: compiler.errors
@ -38,6 +40,7 @@ IN: tools.deploy.shaker
strip-io? [ strip-io? [
"io.files" init-hooks get delete-at "io.files" init-hooks get delete-at
"io.backend" init-hooks get delete-at "io.backend" init-hooks get delete-at
"io.thread" init-hooks get delete-at
] when ] when
strip-dictionary? [ strip-dictionary? [
{ {
@ -193,7 +196,8 @@ IN: tools.deploy.shaker
: strip-compiler-classes ( -- ) : strip-compiler-classes ( -- )
"Stripping compiler classes" show "Stripping compiler classes" show
"compiler" child-vocabs [ words ] map concat [ class? ] filter { "compiler" "stack-checker" }
[ child-vocabs [ words ] map concat [ class? ] filter ] map concat
[ dup implementors [ "methods" word-prop delete-at ] with each ] each ; [ dup implementors [ "methods" word-prop delete-at ] with each ] each ;
: strip-default-methods ( -- ) : strip-default-methods ( -- )
@ -325,12 +329,17 @@ IN: tools.deploy.shaker
] [ drop ] if ; ] [ drop ] if ;
: strip-c-io ( -- ) : strip-c-io ( -- )
deploy-io get 2 = os windows? or [ strip-io?
deploy-io get 3 = os windows? not and
or [
[ [
c-io-backend forget c-io-backend forget
"io.streams.c" forget-vocab "io.streams.c" forget-vocab
"io-thread-running?" "io.thread" lookup [
global delete-at
] when*
] with-compilation-unit ] with-compilation-unit
] unless ; ] when ;
: compress ( pred post-process string -- ) : compress ( pred post-process string -- )
"Compressing " prepend show "Compressing " prepend show
@ -353,7 +362,7 @@ IN: tools.deploy.shaker
#! Quotations which were formerly compiled must remain #! Quotations which were formerly compiled must remain
#! compiled. #! compiled.
2dup [ 2dup [
2dup [ compiled>> ] [ compiled>> not ] bi* and 2dup [ quot-compiled? ] [ quot-compiled? not ] bi* and
[ nip jit-compile ] [ 2drop ] if [ nip jit-compile ] [ 2drop ] if
] 2each ; ] 2each ;
@ -406,6 +415,23 @@ SYMBOL: deploy-vocab
] each ] each
"vocab:tools/deploy/shaker/next-methods.factor" run-file ; "vocab:tools/deploy/shaker/next-methods.factor" run-file ;
: (clear-megamorphic-cache) ( i array -- )
2dup 1 slot < [
2dup [ f ] 2dip set-array-nth
[ 1 + ] dip (clear-megamorphic-cache)
] [ 2drop ] if ;
: clear-megamorphic-cache ( array -- )
[ 0 ] dip (clear-megamorphic-cache) ;
: find-megamorphic-caches ( -- seq )
"Finding megamorphic caches" show
[ standard-generic? ] instances [ def>> third ] map ;
: clear-megamorphic-caches ( cache -- )
"Clearing megamorphic caches" show
[ clear-megamorphic-cache ] each ;
: strip ( -- ) : strip ( -- )
init-stripper init-stripper
strip-libc strip-libc
@ -419,11 +445,13 @@ SYMBOL: deploy-vocab
strip-default-methods strip-default-methods
f 5 setenv ! we can't use the Factor debugger or Factor I/O anymore f 5 setenv ! we can't use the Factor debugger or Factor I/O anymore
deploy-vocab get vocab-main deploy-boot-quot deploy-vocab get vocab-main deploy-boot-quot
find-megamorphic-caches
stripped-word-props stripped-word-props
stripped-globals strip-globals stripped-globals strip-globals
compress-objects compress-objects
compress-quotations compress-quotations
strip-words ; strip-words
clear-megamorphic-caches ;
: deploy-error-handler ( quot -- ) : deploy-error-handler ( quot -- )
[ [