run bootstrap and startup hooks inside a with-destructors. use &dispose instead of setting shutdown hooks in a couple of places

db4
Doug Coleman 2009-10-20 18:26:10 -04:00
parent f2b159529c
commit 5b4c1aea5d
7 changed files with 28 additions and 35 deletions

View File

@ -1,17 +1,19 @@
USING: init command-line debugger system continuations
namespaces eval kernel vocabs.loader io ;
namespaces eval kernel vocabs.loader io destructors ;
[
boot
do-startup-hooks
[
(command-line) parse-command-line
load-vocab-roots
run-user-init
"e" get [ eval( -- ) ] when*
ignore-cli-args? not script get and
[ run-script ] [ "run" get run ] if*
output-stream get [ stream-flush ] when*
0 exit
] [ print-error 1 exit ] recover
do-startup-hooks
[
(command-line) parse-command-line
load-vocab-roots
run-user-init
"e" get [ eval( -- ) ] when*
ignore-cli-args? not script get and
[ run-script ] [ "run" get run ] if*
output-stream get [ stream-flush ] when*
0
] [ print-error 1 ] recover
] with-destructors exit
] set-boot-quot

View File

@ -3,9 +3,10 @@ io ;
[
boot
do-startup-hooks
(command-line) parse-command-line
"run" get run
output-stream get [ stream-flush ] when*
0 exit
[
do-startup-hooks
(command-line) parse-command-line
"run" get run
output-stream get [ stream-flush ] when*
] with-destructors 0 exit
] set-boot-quot

View File

@ -56,6 +56,7 @@ SYMBOL: bootstrap-time
error-continuation set-global
error set-global ; inline
[
! We time bootstrap
millis

View File

@ -113,8 +113,7 @@ SYMBOL: receive-buffer
CONSTANT: packet-size 65536
[ packet-size malloc receive-buffer set-global ] "io.sockets.unix" add-startup-hook
[ receive-buffer get-global free ] "io.sockets.unix" add-shutdown-hook
[ packet-size malloc &free receive-buffer set-global ] "io.sockets.unix" add-startup-hook
:: do-receive ( port -- packet sockaddr )
port addr>> empty-sockaddr/size :> len :> sockaddr

View File

@ -16,19 +16,12 @@ M: unix-random random-bytes* ( n tuple -- byte-array )
os openbsd? [
[
"/dev/srandom" <unix-random> secure-random-generator set-global
"/dev/arandom" <unix-random> system-random-generator set-global
"/dev/srandom" <unix-random> &dispose secure-random-generator set-global
"/dev/arandom" <unix-random> &dispose system-random-generator set-global
] "random.unix" add-startup-hook
] [
[
"/dev/random" <unix-random> secure-random-generator set-global
"/dev/urandom" <unix-random> system-random-generator set-global
"/dev/random" <unix-random> &dispose secure-random-generator set-global
"/dev/urandom" <unix-random> &dispose system-random-generator set-global
] "random.unix" add-startup-hook
] if
[
[
secure-random-generator get-global &dispose drop
system-random-generator get-global &dispose drop
] with-destructors
] "random.unix" add-shutdown-hook

View File

@ -113,8 +113,5 @@ SYMBOL: cached-script-strings
: cached-script-string ( font string -- script-string )
cached-script-strings get-global [ <script-string> ] 2cache ;
[ <cache-assoc> cached-script-strings set-global ]
[ <cache-assoc> &dispose cached-script-strings set-global ]
"windows.uniscribe" add-startup-hook
[ cached-script-strings get-global dispose ]
"windows.uniscribe" add-shutdown-hook

View File

@ -3,7 +3,7 @@
USING: arrays assocs continuations debugger generic hashtables
init io io.files kernel kernel.private make math memory
namespaces parser prettyprint sequences splitting system
vectors vocabs vocabs.loader words ;
vectors vocabs vocabs.loader words destructors ;
QUALIFIED: bootstrap.image.private
IN: bootstrap.stage1
@ -42,7 +42,7 @@ load-help? off
[
"resource:basis/bootstrap/stage2.factor"
dup exists? [
run-file
[ run-file ] with-destructors
] [
"Cannot find " write write "." print
"Please move " write image write " to the same directory as the Factor sources," print