2009-02-16 20:00:09 -05:00
|
|
|
! Copyright (C) 2007, 2009 Slava Pestov.
|
2007-10-06 13:37:47 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-08-27 21:29:16 -04:00
|
|
|
USING: arrays accessors io.backend io.streams.c init fry
|
|
|
|
namespaces math make assocs kernel parser parser.notes lexer
|
|
|
|
strings.parser vocabs sequences sequences.deep sequences.private
|
|
|
|
words memory kernel.private continuations io vocabs.loader
|
|
|
|
system strings sets vectors quotations byte-arrays sorting
|
|
|
|
compiler.units definitions generic generic.standard
|
|
|
|
generic.single tools.deploy.config combinators classes
|
|
|
|
classes.builtin slots.private grouping ;
|
2008-03-13 04:46:25 -04:00
|
|
|
QUALIFIED: bootstrap.stage2
|
2008-04-04 11:11:31 -04:00
|
|
|
QUALIFIED: command-line
|
2008-11-16 14:46:30 -05:00
|
|
|
QUALIFIED: compiler.errors
|
2008-03-13 04:46:25 -04:00
|
|
|
QUALIFIED: continuations
|
|
|
|
QUALIFIED: definitions
|
|
|
|
QUALIFIED: init
|
|
|
|
QUALIFIED: layouts
|
|
|
|
QUALIFIED: source-files
|
2009-04-19 18:38:48 -04:00
|
|
|
QUALIFIED: source-files.errors
|
2008-03-13 04:46:25 -04:00
|
|
|
QUALIFIED: vocabs
|
2007-10-06 13:37:47 -04:00
|
|
|
IN: tools.deploy.shaker
|
|
|
|
|
2008-07-02 16:57:38 -04:00
|
|
|
! This file is some hairy shit.
|
|
|
|
|
2007-10-06 13:37:47 -04:00
|
|
|
: strip-init-hooks ( -- )
|
|
|
|
"Stripping startup hooks" show
|
2009-05-08 03:35:46 -04:00
|
|
|
{
|
2009-08-24 03:26:13 -04:00
|
|
|
"alien.strings"
|
2009-05-08 03:35:46 -04:00
|
|
|
"command-line"
|
|
|
|
"cpu.x86"
|
2009-08-24 03:26:13 -04:00
|
|
|
"destructors"
|
2009-05-08 03:35:46 -04:00
|
|
|
"environment"
|
|
|
|
"libc"
|
|
|
|
}
|
2008-12-01 20:51:01 -05:00
|
|
|
[ init-hooks get delete-at ] each
|
2008-02-28 02:21:30 -05:00
|
|
|
deploy-threads? get [
|
|
|
|
"threads" init-hooks get delete-at
|
|
|
|
] unless
|
|
|
|
native-io? [
|
|
|
|
"io.thread" init-hooks get delete-at
|
|
|
|
] unless
|
|
|
|
strip-io? [
|
2008-09-19 01:26:27 -04:00
|
|
|
"io.files" init-hooks get delete-at
|
2008-02-28 02:21:30 -05:00
|
|
|
"io.backend" init-hooks get delete-at
|
2009-05-12 05:20:02 -04:00
|
|
|
"io.thread" init-hooks get delete-at
|
2008-09-19 01:26:27 -04:00
|
|
|
] when
|
|
|
|
strip-dictionary? [
|
2009-05-08 03:35:46 -04:00
|
|
|
{
|
2009-05-11 17:20:16 -04:00
|
|
|
! "compiler.units"
|
2009-05-08 03:35:46 -04:00
|
|
|
"vocabs"
|
|
|
|
"vocabs.cache"
|
|
|
|
"source-files.errors"
|
|
|
|
} [ init-hooks get delete-at ] each
|
2008-02-28 02:21:30 -05:00
|
|
|
] when ;
|
2007-10-06 13:37:47 -04:00
|
|
|
|
|
|
|
: strip-debugger ( -- )
|
2008-12-08 15:58:00 -05:00
|
|
|
strip-debugger? "debugger" vocab and [
|
2007-10-06 13:37:47 -04:00
|
|
|
"Stripping debugger" show
|
2009-02-15 20:53:21 -05:00
|
|
|
"vocab:tools/deploy/shaker/strip-debugger.factor"
|
2007-10-06 13:37:47 -04:00
|
|
|
run-file
|
2007-11-03 15:42:30 -04:00
|
|
|
] when ;
|
|
|
|
|
|
|
|
: strip-libc ( -- )
|
|
|
|
"libc" vocab [
|
|
|
|
"Stripping manual memory management debug code" show
|
2009-02-15 20:53:21 -05:00
|
|
|
"vocab:tools/deploy/shaker/strip-libc.factor"
|
2007-11-03 15:42:30 -04:00
|
|
|
run-file
|
2007-10-06 13:37:47 -04:00
|
|
|
] when ;
|
|
|
|
|
2009-08-24 03:26:13 -04:00
|
|
|
: strip-destructors ( -- )
|
2009-08-31 17:34:58 -04:00
|
|
|
"Stripping destructor debug code" show
|
|
|
|
"vocab:tools/deploy/shaker/strip-destructors.factor"
|
|
|
|
run-file ;
|
|
|
|
|
|
|
|
: strip-struct-arrays ( -- )
|
|
|
|
"struct-arrays" vocab [
|
|
|
|
"Stripping dynamic struct array code" show
|
|
|
|
"vocab:tools/deploy/shaker/strip-struct-arrays.factor"
|
2009-08-24 03:26:13 -04:00
|
|
|
run-file
|
|
|
|
] when ;
|
|
|
|
|
2009-03-13 20:39:32 -04:00
|
|
|
: strip-call ( -- )
|
2009-03-18 18:08:18 -04:00
|
|
|
"Stripping stack effect checking from call( and execute(" show
|
|
|
|
"vocab:tools/deploy/shaker/strip-call.factor" run-file ;
|
2009-03-13 20:39:32 -04:00
|
|
|
|
2007-10-06 13:37:47 -04:00
|
|
|
: strip-cocoa ( -- )
|
|
|
|
"cocoa" vocab [
|
|
|
|
"Stripping unused Cocoa methods" show
|
2009-02-15 20:53:21 -05:00
|
|
|
"vocab:tools/deploy/shaker/strip-cocoa.factor"
|
2007-10-06 13:37:47 -04:00
|
|
|
run-file
|
|
|
|
] when ;
|
|
|
|
|
|
|
|
: strip-word-names ( words -- )
|
|
|
|
"Stripping word names" show
|
2008-06-30 17:06:14 -04:00
|
|
|
[ f >>name f >>vocabulary drop ] each ;
|
2007-10-06 13:37:47 -04:00
|
|
|
|
|
|
|
: strip-word-defs ( words -- )
|
2008-01-07 16:14:21 -05:00
|
|
|
"Stripping symbolic word definitions" show
|
2008-06-19 00:29:56 -04:00
|
|
|
[ "no-def-strip" word-prop not ] filter
|
2008-06-30 17:06:14 -04:00
|
|
|
[ [ ] >>def drop ] each ;
|
2007-10-06 13:37:47 -04:00
|
|
|
|
2008-07-02 16:57:38 -04:00
|
|
|
: sift-assoc ( assoc -- assoc' ) [ nip ] assoc-filter ;
|
|
|
|
|
2008-06-25 21:47:07 -04:00
|
|
|
: strip-word-props ( stripped-props words -- )
|
2007-10-06 13:37:47 -04:00
|
|
|
"Stripping word properties" show
|
|
|
|
[
|
2008-09-19 01:26:27 -04:00
|
|
|
swap '[
|
|
|
|
[
|
|
|
|
[ drop _ member? not ] assoc-filter sift-assoc
|
|
|
|
>alist f like
|
|
|
|
] change-props drop
|
|
|
|
] each
|
2008-08-05 05:38:01 -04:00
|
|
|
] [
|
|
|
|
H{ } clone '[
|
|
|
|
[ [ _ [ ] cache ] map ] change-props drop
|
|
|
|
] each
|
2008-12-08 15:58:00 -05:00
|
|
|
] bi ;
|
2007-10-06 13:37:47 -04:00
|
|
|
|
2008-06-25 21:47:07 -04:00
|
|
|
: stripped-word-props ( -- seq )
|
2007-10-06 13:37:47 -04:00
|
|
|
[
|
2008-06-25 21:47:07 -04:00
|
|
|
strip-dictionary? [
|
|
|
|
{
|
2008-08-05 05:38:01 -04:00
|
|
|
"alias"
|
2008-09-19 01:26:27 -04:00
|
|
|
"boa-check"
|
2008-06-25 21:47:07 -04:00
|
|
|
"coercer"
|
2008-11-22 20:58:23 -05:00
|
|
|
"combination"
|
2008-08-31 20:17:04 -04:00
|
|
|
"compiled-generic-uses"
|
2008-06-25 21:47:07 -04:00
|
|
|
"compiled-uses"
|
2009-08-27 21:29:16 -04:00
|
|
|
"constant"
|
2008-06-25 21:47:07 -04:00
|
|
|
"constraints"
|
2008-09-19 01:26:27 -04:00
|
|
|
"custom-inlining"
|
2009-04-30 21:35:55 -04:00
|
|
|
"decision-tree"
|
2008-06-25 21:47:07 -04:00
|
|
|
"declared-effect"
|
2008-07-05 04:07:10 -04:00
|
|
|
"default"
|
|
|
|
"default-method"
|
2008-06-25 21:47:07 -04:00
|
|
|
"default-output-classes"
|
2008-07-05 04:07:10 -04:00
|
|
|
"derived-from"
|
2008-12-03 09:12:28 -05:00
|
|
|
"ebnf-parser"
|
2008-08-31 20:17:04 -04:00
|
|
|
"engines"
|
2008-09-19 01:26:27 -04:00
|
|
|
"forgotten"
|
|
|
|
"identities"
|
2008-08-31 20:17:04 -04:00
|
|
|
"inline"
|
|
|
|
"inlined-block"
|
2008-07-12 02:08:30 -04:00
|
|
|
"input-classes"
|
2009-03-17 19:53:44 -04:00
|
|
|
"instances"
|
2008-06-25 21:47:07 -04:00
|
|
|
"interval"
|
2009-04-30 21:35:55 -04:00
|
|
|
"intrinsic"
|
2008-08-31 20:17:04 -04:00
|
|
|
"lambda"
|
2008-06-25 21:47:07 -04:00
|
|
|
"loc"
|
2008-08-31 20:17:04 -04:00
|
|
|
"local-reader"
|
|
|
|
"local-reader?"
|
|
|
|
"local-writer"
|
|
|
|
"local-writer?"
|
|
|
|
"local?"
|
2009-08-27 21:29:16 -04:00
|
|
|
"low-order"
|
2008-08-31 20:17:04 -04:00
|
|
|
"macro"
|
2008-11-22 20:58:23 -05:00
|
|
|
"members"
|
2008-08-31 20:17:04 -04:00
|
|
|
"memo-quot"
|
2008-11-22 20:58:23 -05:00
|
|
|
"methods"
|
2008-09-19 01:26:27 -04:00
|
|
|
"mixin"
|
2008-07-05 04:07:10 -04:00
|
|
|
"method-class"
|
|
|
|
"method-generic"
|
2008-09-19 01:26:27 -04:00
|
|
|
"modular-arithmetic"
|
2008-07-05 04:07:10 -04:00
|
|
|
"no-compile"
|
2009-04-30 21:35:55 -04:00
|
|
|
"owner-generic"
|
2008-08-31 20:17:04 -04:00
|
|
|
"outputs"
|
2008-06-25 21:47:07 -04:00
|
|
|
"participants"
|
|
|
|
"predicate"
|
|
|
|
"predicate-definition"
|
|
|
|
"predicating"
|
2008-09-19 01:26:27 -04:00
|
|
|
"primitive"
|
2008-08-31 20:17:04 -04:00
|
|
|
"reader"
|
|
|
|
"reading"
|
|
|
|
"recursive"
|
2008-08-05 05:38:01 -04:00
|
|
|
"register"
|
|
|
|
"register-size"
|
2008-08-31 20:17:04 -04:00
|
|
|
"shuffle"
|
|
|
|
"slots"
|
|
|
|
"special"
|
2008-06-25 21:47:07 -04:00
|
|
|
"specializer"
|
2009-04-03 10:48:16 -04:00
|
|
|
! UI needs this
|
|
|
|
! "superclass"
|
2008-08-31 20:17:04 -04:00
|
|
|
"transform-n"
|
|
|
|
"transform-quot"
|
2008-06-25 21:47:07 -04:00
|
|
|
"type"
|
2008-08-31 20:17:04 -04:00
|
|
|
"writer"
|
|
|
|
"writing"
|
2008-06-25 21:47:07 -04:00
|
|
|
} %
|
|
|
|
] when
|
|
|
|
|
|
|
|
strip-prettyprint? [
|
|
|
|
{
|
|
|
|
"delimiter"
|
|
|
|
"flushable"
|
|
|
|
"foldable"
|
|
|
|
"inline"
|
|
|
|
"lambda"
|
|
|
|
"macro"
|
|
|
|
"memo-quot"
|
|
|
|
"parsing"
|
|
|
|
"word-style"
|
|
|
|
} %
|
2007-10-06 13:37:47 -04:00
|
|
|
] when
|
|
|
|
] { } make ;
|
|
|
|
|
|
|
|
: strip-words ( props -- )
|
|
|
|
[ word? ] instances
|
2007-11-04 22:52:25 -05:00
|
|
|
deploy-word-props? get [ 2dup strip-word-props ] unless
|
|
|
|
deploy-word-defs? get [ dup strip-word-defs ] unless
|
2007-10-31 01:09:24 -04:00
|
|
|
strip-word-names? [ dup strip-word-names ] when
|
2007-11-04 22:52:25 -05:00
|
|
|
2drop ;
|
2007-10-06 13:37:47 -04:00
|
|
|
|
2009-08-23 18:54:37 -04:00
|
|
|
: compiler-classes ( -- seq )
|
|
|
|
{ "compiler" "stack-checker" }
|
|
|
|
[ child-vocabs [ words ] map concat [ class? ] filter ]
|
|
|
|
map concat unique ;
|
|
|
|
|
|
|
|
: prune-decision-tree ( tree classes -- )
|
|
|
|
[ tuple class>type ] 2dip '[
|
|
|
|
dup array? [
|
|
|
|
[
|
|
|
|
dup array? [
|
|
|
|
[
|
|
|
|
2 group
|
|
|
|
[ drop _ key? not ] assoc-filter
|
|
|
|
concat
|
|
|
|
] map
|
|
|
|
] when
|
|
|
|
] map
|
|
|
|
] when
|
|
|
|
] change-nth ;
|
|
|
|
|
2009-05-10 22:33:13 -04:00
|
|
|
: strip-compiler-classes ( -- )
|
2009-05-12 17:56:36 -04:00
|
|
|
strip-dictionary? [
|
|
|
|
"Stripping compiler classes" show
|
2009-08-23 18:54:37 -04:00
|
|
|
[ single-generic? ] instances
|
|
|
|
compiler-classes '[ "decision-tree" word-prop _ prune-decision-tree ] each
|
2009-05-12 17:56:36 -04:00
|
|
|
] when ;
|
2009-05-10 22:33:13 -04:00
|
|
|
|
2009-08-22 20:26:56 -04:00
|
|
|
: recursive-subst ( seq old new -- )
|
|
|
|
'[
|
|
|
|
_ _
|
|
|
|
{
|
|
|
|
! old becomes new
|
|
|
|
{ [ 3dup drop eq? ] [ 2nip ] }
|
|
|
|
! recurse into arrays
|
|
|
|
{ [ pick array? ] [ [ dup ] 2dip recursive-subst ] }
|
|
|
|
! otherwise do nothing
|
|
|
|
[ 2drop ]
|
|
|
|
} cond
|
|
|
|
] change-each ;
|
|
|
|
|
|
|
|
: strip-default-method ( generic new-default -- )
|
|
|
|
[
|
|
|
|
[ "decision-tree" word-prop ]
|
|
|
|
[ "default-method" word-prop ] bi
|
|
|
|
] dip
|
|
|
|
recursive-subst ;
|
|
|
|
|
|
|
|
: new-default-method ( -- gensym )
|
|
|
|
[ [ "No method" throw ] (( -- * )) define-temp ] with-compilation-unit ;
|
|
|
|
|
2008-12-08 20:14:38 -05:00
|
|
|
: strip-default-methods ( -- )
|
2009-08-22 20:26:56 -04:00
|
|
|
! In a development image, each generic has its own default method.
|
|
|
|
! This gives better error messages for runtime type errors, but
|
|
|
|
! takes up space. For deployment we merge them all together.
|
2008-12-08 20:14:38 -05:00
|
|
|
strip-debugger? [
|
|
|
|
"Stripping default methods" show
|
2009-08-22 20:26:56 -04:00
|
|
|
[ single-generic? ] instances
|
|
|
|
new-default-method '[ _ strip-default-method ] each
|
2008-12-08 20:14:38 -05:00
|
|
|
] when ;
|
|
|
|
|
2008-03-13 04:46:25 -04:00
|
|
|
: strip-vocab-globals ( except names -- words )
|
2009-03-23 23:36:51 -04:00
|
|
|
[ child-vocabs [ words ] map concat ] map concat
|
|
|
|
swap [ first2 lookup ] map sift diff ;
|
2008-03-13 04:46:25 -04:00
|
|
|
|
|
|
|
: stripped-globals ( -- seq )
|
|
|
|
[
|
2008-07-02 01:20:01 -04:00
|
|
|
"inspector-hook" "inspector" lookup ,
|
|
|
|
|
2008-03-13 04:46:25 -04:00
|
|
|
{
|
|
|
|
continuations:error
|
|
|
|
continuations:error-continuation
|
|
|
|
continuations:error-thread
|
|
|
|
continuations:restarts
|
|
|
|
init:init-hooks
|
|
|
|
source-files:source-files
|
2008-05-05 03:19:25 -04:00
|
|
|
input-stream
|
|
|
|
output-stream
|
|
|
|
error-stream
|
2008-03-13 04:46:25 -04:00
|
|
|
} %
|
|
|
|
|
2008-10-02 06:14:05 -04:00
|
|
|
"io-thread" "io.thread" lookup ,
|
|
|
|
|
2009-08-24 03:26:13 -04:00
|
|
|
"disposables" "destructors" lookup ,
|
|
|
|
|
2009-08-30 06:36:16 -04:00
|
|
|
"functor-words" "functors.backend" lookup ,
|
|
|
|
|
2008-03-13 04:46:25 -04:00
|
|
|
deploy-threads? [
|
2008-07-29 01:05:01 -04:00
|
|
|
"initial-thread" "threads" lookup ,
|
2008-03-13 04:46:25 -04:00
|
|
|
] unless
|
|
|
|
|
2008-10-02 04:38:36 -04:00
|
|
|
strip-io? [ io-backend , ] when
|
2008-03-13 04:46:25 -04:00
|
|
|
|
2008-06-25 21:47:07 -04:00
|
|
|
{ } {
|
|
|
|
"alarms"
|
|
|
|
"tools"
|
|
|
|
"io.launcher"
|
2008-08-05 05:38:01 -04:00
|
|
|
"random"
|
2008-11-22 20:58:23 -05:00
|
|
|
"stack-checker"
|
|
|
|
"bootstrap"
|
|
|
|
"listener"
|
2008-06-25 21:47:07 -04:00
|
|
|
} strip-vocab-globals %
|
2008-03-13 04:46:25 -04:00
|
|
|
|
|
|
|
strip-dictionary? [
|
2008-08-05 05:38:01 -04:00
|
|
|
"libraries" "alien" lookup ,
|
|
|
|
|
2009-03-23 23:36:51 -04:00
|
|
|
{ { "yield-hook" "compiler.utilities" } }
|
|
|
|
{ "cpu" "compiler" } strip-vocab-globals %
|
2008-03-13 04:46:25 -04:00
|
|
|
|
|
|
|
{
|
2008-04-04 11:11:31 -04:00
|
|
|
gensym
|
2008-05-31 01:07:30 -04:00
|
|
|
name>char-hook
|
2009-05-10 22:33:13 -04:00
|
|
|
next-method-quot-cache
|
|
|
|
class-and-cache
|
|
|
|
class-not-cache
|
|
|
|
class-or-cache
|
|
|
|
class<=-cache
|
|
|
|
classes-intersect-cache
|
|
|
|
implementors-map
|
|
|
|
update-map
|
2008-04-04 11:11:31 -04:00
|
|
|
command-line:main-vocab-hook
|
2008-03-24 21:15:42 -04:00
|
|
|
compiled-crossref
|
2008-08-31 20:17:04 -04:00
|
|
|
compiled-generic-crossref
|
2009-03-13 20:39:32 -04:00
|
|
|
compiler-impl
|
2009-04-19 18:38:48 -04:00
|
|
|
compiler.errors:compiler-errors
|
2008-03-24 21:15:42 -04:00
|
|
|
lexer-factory
|
2008-11-20 22:54:07 -05:00
|
|
|
print-use-hook
|
2008-03-24 21:15:42 -04:00
|
|
|
root-cache
|
2009-04-19 18:38:48 -04:00
|
|
|
source-files.errors:error-types
|
2009-05-08 03:35:46 -04:00
|
|
|
source-files.errors:error-observers
|
2008-03-24 21:15:42 -04:00
|
|
|
vocabs:dictionary
|
|
|
|
vocabs:load-vocab-hook
|
2009-05-08 03:35:46 -04:00
|
|
|
vocabs:vocab-observers
|
2008-03-13 04:46:25 -04:00
|
|
|
word
|
2008-09-19 01:26:27 -04:00
|
|
|
parser-notes
|
2008-03-13 04:46:25 -04:00
|
|
|
} %
|
2008-05-31 01:07:30 -04:00
|
|
|
|
2009-05-08 03:35:46 -04:00
|
|
|
{ } { "layouts" } strip-vocab-globals %
|
|
|
|
|
2008-09-02 23:40:18 -04:00
|
|
|
{ } { "math.partial-dispatch" } strip-vocab-globals %
|
2008-12-03 09:12:28 -05:00
|
|
|
|
2009-08-09 05:48:44 -04:00
|
|
|
{ } { "math.vectors.specialization" } strip-vocab-globals %
|
|
|
|
|
2008-12-03 09:12:28 -05:00
|
|
|
{ } { "peg" } strip-vocab-globals %
|
2008-03-13 04:46:25 -04:00
|
|
|
] when
|
|
|
|
|
|
|
|
strip-prettyprint? [
|
2008-12-08 15:58:00 -05:00
|
|
|
{ } { "prettyprint.config" } strip-vocab-globals %
|
2008-03-13 04:46:25 -04:00
|
|
|
] when
|
|
|
|
|
|
|
|
strip-debugger? [
|
|
|
|
{
|
2008-11-16 14:46:30 -05:00
|
|
|
compiler.errors:compiler-errors
|
2008-03-13 04:46:25 -04:00
|
|
|
continuations:thread-error-hook
|
|
|
|
} %
|
2009-05-11 17:20:16 -04:00
|
|
|
|
|
|
|
deploy-ui? get [
|
|
|
|
"ui-error-hook" "ui.gadgets.worlds" lookup ,
|
|
|
|
] when
|
2008-03-13 04:46:25 -04:00
|
|
|
] when
|
|
|
|
|
|
|
|
deploy-c-types? get [
|
|
|
|
"c-types" "alien.c-types" lookup ,
|
|
|
|
] unless
|
|
|
|
|
2008-04-04 11:05:52 -04:00
|
|
|
"windows-messages" "windows.messages" lookup [ , ] when*
|
2008-03-13 04:46:25 -04:00
|
|
|
] { } make ;
|
|
|
|
|
|
|
|
: strip-globals ( stripped-globals -- )
|
2007-10-31 01:09:24 -04:00
|
|
|
strip-globals? [
|
2008-03-13 04:46:25 -04:00
|
|
|
"Stripping globals" show
|
|
|
|
global swap
|
2008-09-10 23:11:40 -04:00
|
|
|
'[ drop _ member? not ] assoc-filter
|
2008-04-26 00:17:08 -04:00
|
|
|
[ drop string? not ] assoc-filter ! strip CLI args
|
2008-07-02 16:57:38 -04:00
|
|
|
sift-assoc
|
2008-03-13 04:46:25 -04:00
|
|
|
21 setenv
|
2007-10-06 13:37:47 -04:00
|
|
|
] [ drop ] if ;
|
|
|
|
|
2008-10-02 04:38:36 -04:00
|
|
|
: strip-c-io ( -- )
|
2009-05-12 05:20:02 -04:00
|
|
|
strip-io?
|
|
|
|
deploy-io get 3 = os windows? not and
|
|
|
|
or [
|
2008-10-02 04:38:36 -04:00
|
|
|
[
|
|
|
|
c-io-backend forget
|
|
|
|
"io.streams.c" forget-vocab
|
2009-05-12 05:20:02 -04:00
|
|
|
"io-thread-running?" "io.thread" lookup [
|
|
|
|
global delete-at
|
|
|
|
] when*
|
2008-10-02 04:38:36 -04:00
|
|
|
] with-compilation-unit
|
2009-05-12 05:20:02 -04:00
|
|
|
] when ;
|
2008-10-02 04:38:36 -04:00
|
|
|
|
2008-11-24 16:59:27 -05:00
|
|
|
: compress ( pred post-process string -- )
|
2008-07-05 04:07:10 -04:00
|
|
|
"Compressing " prepend show
|
2008-11-24 16:59:27 -05:00
|
|
|
[ instances dup H{ } clone [ [ ] cache ] curry map ] dip call
|
2008-07-05 04:07:10 -04:00
|
|
|
become ; inline
|
|
|
|
|
2009-05-11 01:32:22 -04:00
|
|
|
: compress-object? ( obj -- ? )
|
|
|
|
{
|
|
|
|
{ [ dup array? ] [ empty? ] }
|
|
|
|
{ [ dup byte-array? ] [ drop t ] }
|
|
|
|
{ [ dup string? ] [ drop t ] }
|
|
|
|
{ [ dup wrapper? ] [ drop t ] }
|
|
|
|
[ drop f ]
|
|
|
|
} cond ;
|
|
|
|
|
2009-05-10 22:33:13 -04:00
|
|
|
: compress-objects ( -- )
|
2009-05-11 01:32:22 -04:00
|
|
|
[ compress-object? ] [ ] "objects" compress ;
|
2008-11-24 16:59:27 -05:00
|
|
|
|
|
|
|
: remain-compiled ( old new -- old new )
|
2009-08-22 20:26:56 -04:00
|
|
|
! Quotations which were formerly compiled must remain
|
|
|
|
! compiled.
|
2008-11-24 16:59:27 -05:00
|
|
|
2dup [
|
2009-05-12 05:20:02 -04:00
|
|
|
2dup [ quot-compiled? ] [ quot-compiled? not ] bi* and
|
2008-11-24 16:59:27 -05:00
|
|
|
[ nip jit-compile ] [ 2drop ] if
|
|
|
|
] 2each ;
|
2008-07-05 04:07:10 -04:00
|
|
|
|
|
|
|
: compress-quotations ( -- )
|
2009-03-17 19:53:44 -04:00
|
|
|
[ quotation? ] [ remain-compiled ] "quotations" compress
|
|
|
|
[ quotation? ] instances [ f >>cached-effect f >>cache-counter drop ] each ;
|
2008-07-05 04:07:10 -04:00
|
|
|
|
2007-10-06 13:37:47 -04:00
|
|
|
SYMBOL: deploy-vocab
|
|
|
|
|
2009-02-16 20:00:09 -05:00
|
|
|
: [:c] ( -- word ) ":c" "debugger" lookup ;
|
|
|
|
|
|
|
|
: [print-error] ( -- word ) "print-error" "debugger" lookup ;
|
|
|
|
|
|
|
|
: deploy-boot-quot ( word -- )
|
2007-10-06 13:37:47 -04:00
|
|
|
[
|
2009-02-16 20:00:09 -05:00
|
|
|
[ boot ] %
|
2007-10-06 13:37:47 -04:00
|
|
|
init-hooks get values concat %
|
2009-02-16 20:00:09 -05:00
|
|
|
strip-debugger? [ , ] [
|
2009-08-22 20:26:56 -04:00
|
|
|
! Don't reference 'try' directly since we don't want
|
|
|
|
! to pull in the debugger and prettyprinter into every
|
|
|
|
! deployed app
|
2009-02-16 20:00:09 -05:00
|
|
|
[:c]
|
|
|
|
[print-error]
|
|
|
|
'[
|
2009-04-17 15:44:08 -04:00
|
|
|
[ _ execute( obj -- ) ] [
|
|
|
|
_ execute( obj -- ) nl
|
|
|
|
_ execute( obj -- )
|
2009-02-16 20:00:09 -05:00
|
|
|
] recover
|
|
|
|
] %
|
|
|
|
] if
|
|
|
|
strip-io? [ [ flush ] % ] unless
|
2008-12-13 05:10:39 -05:00
|
|
|
[ 0 exit ] %
|
2008-12-08 15:58:00 -05:00
|
|
|
] [ ] make
|
2007-10-06 13:37:47 -04:00
|
|
|
set-boot-quot ;
|
|
|
|
|
2008-10-02 07:41:17 -04:00
|
|
|
: init-stripper ( -- )
|
|
|
|
t "quiet" set-global
|
|
|
|
f output-stream set-global ;
|
|
|
|
|
2009-08-23 20:18:12 -04:00
|
|
|
: next-method* ( method -- quot )
|
2009-05-10 22:33:13 -04:00
|
|
|
[ "method-class" word-prop ]
|
|
|
|
[ "method-generic" word-prop ] bi
|
2009-08-23 20:18:12 -04:00
|
|
|
next-method ;
|
2009-05-10 22:33:13 -04:00
|
|
|
|
2009-08-27 21:29:16 -04:00
|
|
|
: calls-next-method? ( method -- ? )
|
|
|
|
def>> flatten \ (call-next-method) swap memq? ;
|
|
|
|
|
2008-11-22 20:58:23 -05:00
|
|
|
: compute-next-methods ( -- )
|
|
|
|
[ standard-generic? ] instances [
|
2009-08-27 21:29:16 -04:00
|
|
|
"methods" word-prop values [ calls-next-method? ] filter
|
|
|
|
[ dup next-method* "next-method" set-word-prop ] each
|
2008-11-22 20:58:23 -05:00
|
|
|
] each
|
2009-02-15 20:53:21 -05:00
|
|
|
"vocab:tools/deploy/shaker/next-methods.factor" run-file ;
|
2008-11-22 20:58:23 -05:00
|
|
|
|
2009-05-12 05:20:02 -04:00
|
|
|
: (clear-megamorphic-cache) ( i array -- )
|
2009-08-23 18:54:37 -04:00
|
|
|
! Can't do any dispatch while clearing caches since that
|
|
|
|
! might leave them in an inconsistent state.
|
2009-05-12 05:20:02 -04:00
|
|
|
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 ;
|
|
|
|
|
2008-01-07 16:14:21 -05:00
|
|
|
: strip ( -- )
|
2008-10-02 07:41:17 -04:00
|
|
|
init-stripper
|
2008-01-07 16:14:21 -05:00
|
|
|
strip-libc
|
2009-08-31 17:34:58 -04:00
|
|
|
strip-struct-arrays
|
2009-08-24 03:26:13 -04:00
|
|
|
strip-destructors
|
2009-03-13 20:39:32 -04:00
|
|
|
strip-call
|
2007-10-06 13:37:47 -04:00
|
|
|
strip-cocoa
|
|
|
|
strip-debugger
|
2008-11-22 20:58:23 -05:00
|
|
|
compute-next-methods
|
2007-10-06 13:37:47 -04:00
|
|
|
strip-init-hooks
|
2008-10-02 07:41:17 -04:00
|
|
|
strip-c-io
|
2009-05-10 22:33:13 -04:00
|
|
|
strip-default-methods
|
2009-08-23 18:54:37 -04:00
|
|
|
strip-compiler-classes
|
2008-10-02 07:41:17 -04:00
|
|
|
f 5 setenv ! we can't use the Factor debugger or Factor I/O anymore
|
2009-02-16 20:00:09 -05:00
|
|
|
deploy-vocab get vocab-main deploy-boot-quot
|
2009-05-12 05:20:02 -04:00
|
|
|
find-megamorphic-caches
|
2008-12-03 09:12:28 -05:00
|
|
|
stripped-word-props
|
2008-03-13 04:46:25 -04:00
|
|
|
stripped-globals strip-globals
|
2009-05-10 22:33:13 -04:00
|
|
|
compress-objects
|
2008-07-05 04:07:10 -04:00
|
|
|
compress-quotations
|
2009-05-12 05:20:02 -04:00
|
|
|
strip-words
|
|
|
|
clear-megamorphic-caches ;
|
2007-10-06 13:37:47 -04:00
|
|
|
|
2009-02-16 20:00:09 -05:00
|
|
|
: deploy-error-handler ( quot -- )
|
|
|
|
[
|
|
|
|
strip-debugger?
|
2009-04-17 21:38:55 -04:00
|
|
|
[ error-continuation get call>> callstack>array die 1 exit ]
|
2009-02-16 20:00:09 -05:00
|
|
|
! Don't reference these words literally, if we're stripping the
|
|
|
|
! debugger out we don't want to load the prettyprinter at all
|
2009-04-17 21:38:55 -04:00
|
|
|
[ [:c] execute( -- ) nl [print-error] execute( error -- ) flush ] if
|
2009-02-16 20:00:09 -05:00
|
|
|
1 exit
|
|
|
|
] recover ; inline
|
|
|
|
|
2007-10-06 13:37:47 -04:00
|
|
|
: (deploy) ( final-image vocab config -- )
|
|
|
|
#! Does the actual work of a deployment in the slave
|
|
|
|
#! stage2 image
|
|
|
|
[
|
|
|
|
[
|
2009-02-16 20:00:09 -05:00
|
|
|
strip-debugger? [
|
|
|
|
"debugger" require
|
|
|
|
"inspector" require
|
2009-05-11 17:20:16 -04:00
|
|
|
deploy-ui? get [
|
|
|
|
"ui.debugger" require
|
|
|
|
] when
|
2009-02-16 20:00:09 -05:00
|
|
|
] unless
|
2007-10-06 13:37:47 -04:00
|
|
|
deploy-vocab set
|
|
|
|
deploy-vocab get require
|
2009-02-16 20:00:09 -05:00
|
|
|
deploy-vocab get vocab-main [
|
|
|
|
"Vocabulary has no MAIN: word." print flush 1 exit
|
|
|
|
] unless
|
2007-10-06 13:37:47 -04:00
|
|
|
strip
|
2009-05-05 11:29:22 -04:00
|
|
|
"Saving final image" show
|
|
|
|
save-image-and-exit
|
2009-02-16 20:00:09 -05:00
|
|
|
] deploy-error-handler
|
2007-10-06 13:37:47 -04:00
|
|
|
] bind ;
|
|
|
|
|
|
|
|
: do-deploy ( -- )
|
|
|
|
"output-image" get
|
|
|
|
"deploy-vocab" get
|
|
|
|
"Deploying " write dup write "..." print
|
2008-12-08 15:58:00 -05:00
|
|
|
"deploy-config" get parse-file first
|
2007-10-06 13:37:47 -04:00
|
|
|
(deploy) ;
|
|
|
|
|
|
|
|
MAIN: do-deploy
|