diff --git a/build-support/factor.sh b/build-support/factor.sh index 476e885257..ea0c35aa83 100755 --- a/build-support/factor.sh +++ b/build-support/factor.sh @@ -89,11 +89,6 @@ set_md5sum() { set_gcc() { case $OS in openbsd) ensure_program_installed egcc; CC=egcc;; - netbsd) if [[ $WORD -eq 64 ]] ; then - CC=/usr/pkg/gcc34/bin/gcc - else - CC=gcc - fi ;; *) CC=gcc;; esac } diff --git a/core/assocs/assocs.factor b/core/assocs/assocs.factor index 6b6bd3d51a..adb69d317c 100755 --- a/core/assocs/assocs.factor +++ b/core/assocs/assocs.factor @@ -155,6 +155,9 @@ M: assoc >alist [ 2array ] { } assoc>map ; : value-at ( value assoc -- key/f ) swap [ = nip ] curry assoc-find 2drop ; +: zip ( keys values -- alist ) + 2array flip ; inline + : search-alist ( key alist -- pair i ) [ first = ] with find swap ; inline @@ -204,7 +207,7 @@ M: enum set-at seq>> set-nth ; M: enum delete-at enum-seq delete-nth ; M: enum >alist ( enum -- alist ) - seq>> [ length ] keep 2array flip ; + seq>> [ length ] keep zip ; M: enum assoc-size seq>> length ; diff --git a/core/classes/tuple/tuple-tests.factor b/core/classes/tuple/tuple-tests.factor index 729997d3b2..2575570d2f 100755 --- a/core/classes/tuple/tuple-tests.factor +++ b/core/classes/tuple/tuple-tests.factor @@ -529,3 +529,12 @@ TUPLE: another-forget-accessors-test ; ] unit-test [ t ] [ \ another-forget-accessors-test class? ] unit-test + +! Shadowing test +[ f ] [ + t parser-notes? [ + [ + "IN: classes.tuple.tests TUPLE: shadow-1 a b ; TUPLE: shadow-2 < shadow-1 a b ;" eval + ] with-string-writer empty? + ] with-variable +] unit-test diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor index 608fb8cf6c..aa8ef6cdb7 100755 --- a/core/classes/tuple/tuple.factor +++ b/core/classes/tuple/tuple.factor @@ -55,6 +55,9 @@ PRIVATE> "slot-names" word-prop [ dup array? [ second ] when ] map ; +: all-slot-names ( class -- slots ) + superclasses [ slot-names ] map concat \ class prefix ; + : define-tuple-layout ( class -- ) dup make-tuple-layout "layout" set-word-prop ; -: all-slot-names ( class -- slots ) - superclasses [ slot-names ] map concat \ class prefix ; - : compute-slot-permutation ( class old-slot-names -- permutation ) >r all-slot-names r> [ index ] curry map ; diff --git a/core/combinators/combinators.factor b/core/combinators/combinators.factor index 139c6d8fdf..96c4009ba9 100755 --- a/core/combinators/combinators.factor +++ b/core/combinators/combinators.factor @@ -59,6 +59,10 @@ ERROR: no-case ; M: sequence hashcode* [ sequence-hashcode ] recursive-hashcode ; +M: reversed hashcode* [ sequence-hashcode ] recursive-hashcode ; + +M: slice hashcode* [ sequence-hashcode ] recursive-hashcode ; + M: hashtable hashcode* [ dup assoc-size 1 number= diff --git a/core/compiler/compiler.factor b/core/compiler/compiler.factor index a0599f79a1..6f75ca873d 100755 --- a/core/compiler/compiler.factor +++ b/core/compiler/compiler.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel namespaces arrays sequences io inference.backend -inference.state generator debugger math.parser prettyprint words -compiler.units continuations vocabs assocs alien.compiler dlists -optimizer definitions math compiler.errors threads graphs -generic inference ; +inference.state generator debugger words compiler.units +continuations vocabs assocs alien.compiler dlists optimizer +definitions math compiler.errors threads graphs generic +inference ; IN: compiler : ripple-up ( word -- ) diff --git a/core/cpu/ppc/architecture/architecture.factor b/core/cpu/ppc/architecture/architecture.factor index bd5273efcb..09ffead029 100755 --- a/core/cpu/ppc/architecture/architecture.factor +++ b/core/cpu/ppc/architecture/architecture.factor @@ -146,7 +146,7 @@ M: int-regs %save-param-reg drop 1 rot local@ STW ; M: int-regs %load-param-reg drop 1 rot local@ LWZ ; -GENERIC: STF ( src dst reg-class -- ) +GENERIC: STF ( src dst off reg-class -- ) M: single-float-regs STF drop STFS ; @@ -154,7 +154,7 @@ M: double-float-regs STF drop STFD ; M: float-regs %save-param-reg >r 1 rot local@ r> STF ; -GENERIC: LF ( src dst reg-class -- ) +GENERIC: LF ( dst src off reg-class -- ) M: single-float-regs LF drop LFS ; diff --git a/core/generator/registers/registers.factor b/core/generator/registers/registers.factor index b5b3f0b2c0..f3dc0fb10e 100755 --- a/core/generator/registers/registers.factor +++ b/core/generator/registers/registers.factor @@ -322,7 +322,7 @@ M: phantom-retainstack finalize-height : (live-locs) ( phantom -- seq ) #! Discard locs which haven't moved - [ phantom-locs* ] [ stack>> ] bi 2array flip + [ phantom-locs* ] [ stack>> ] bi zip [ live-loc? ] assoc-subset values ; @@ -421,7 +421,7 @@ M: loc lazy-store : slow-shuffle-mapping ( locs tmp -- pairs ) >r dup length r> - [ swap - ] curry map 2array flip ; + [ swap - ] curry map zip ; : slow-shuffle ( locs -- ) #! We don't have enough free registers to load all shuffle diff --git a/core/inference/known-words/known-words.factor b/core/inference/known-words/known-words.factor index 8f505c21a1..33a5da87f4 100755 --- a/core/inference/known-words/known-words.factor +++ b/core/inference/known-words/known-words.factor @@ -373,7 +373,7 @@ set-primitive-effect \ data-room { } { integer array } set-primitive-effect \ data-room make-flushable -\ code-room { } { integer integer } set-primitive-effect +\ code-room { } { integer integer integer integer } set-primitive-effect \ code-room make-flushable \ os-env { string } { object } set-primitive-effect diff --git a/core/mirrors/mirrors.factor b/core/mirrors/mirrors.factor index a13e1331fa..61cdbdad24 100755 --- a/core/mirrors/mirrors.factor +++ b/core/mirrors/mirrors.factor @@ -42,7 +42,7 @@ M: mirror delete-at ( key mirror -- ) M: mirror >alist ( mirror -- alist ) >mirror< [ [ slot-spec-offset slot ] with map ] keep - [ slot-spec-name ] map swap 2array flip ; + [ slot-spec-name ] map swap zip ; M: mirror assoc-size mirror-slots length ; diff --git a/core/optimizer/optimizer-tests.factor b/core/optimizer/optimizer-tests.factor index 6c6adfa3e6..c8d7a0a0a0 100755 --- a/core/optimizer/optimizer-tests.factor +++ b/core/optimizer/optimizer-tests.factor @@ -370,4 +370,7 @@ HINTS: recursive-inline-hang-2 array ; HINTS: recursive-inline-hang-3 array ; +! Regression +USE: sequences.private +[ ] [ { (3append) } compile ] unit-test diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor index d11f036445..e7984f7ec3 100755 --- a/core/parser/parser-docs.factor +++ b/core/parser/parser-docs.factor @@ -153,6 +153,8 @@ ARTICLE: "parser-files" "Parsing source files" { $subsection parse-file } { $subsection bootstrap-file } "The parser cross-references source files and definitions. This allows it to keep track of removed definitions, and prevent forward references and accidental redefinitions." +$nl +"While the above words are useful for one-off experiments, real programs should be written to use the vocabulary system instead; see " { $link "vocabs.loader" } "." { $see-also "source-files" } ; ARTICLE: "parser-usage" "Reflective parser usage" @@ -161,6 +163,13 @@ ARTICLE: "parser-usage" "Reflective parser usage" "The parser can also parse from a stream:" { $subsection parse-stream } ; +ARTICLE: "top-level-forms" "Top level forms" +"Any code outside of a definition is known as a " { $emphasis "top-level form" } "; top-level forms are run after the entire source file has been parsed, regardless of their position in the file." +$nl +"Top-level forms do not have access to the " { $link in } " and " { $link use } " variables that were set at parse time, nor do they run inside " { $link with-compilation-unit } "; so meta-programming might require extra work in a top-level form compared with a parsing word." +$nl +"Also, top-level forms run in a new dynamic scope, so using " { $link set } " to store values is almost always wrong, since the values will be lost after the top-level form completes. To save values computed by a top-level form, either use " { $link set-global } " or define a new word with the value." ; + ARTICLE: "parser" "The parser" "This parser is a general facility for reading textual representations of objects and definitions. The parser is implemented in the " { $vocab-link "parser" } " and " { $vocab-link "syntax" } " vocabularies." $nl @@ -168,6 +177,7 @@ $nl { $subsection "vocabulary-search" } { $subsection "parser-files" } { $subsection "parser-usage" } +{ $subsection "top-level-forms" } "The parser can be extended." { $subsection "parsing-words" } { $subsection "parser-lexer" } diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 6d091fd1c0..6c09e08f84 100755 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -1,12 +1,11 @@ ! Copyright (C) 2005, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays definitions generic assocs kernel math -namespaces prettyprint sequences strings vectors words -quotations inspector io.styles io combinators sorting -splitting math.parser effects continuations debugger -io.files io.streams.string vocabs io.encodings.utf8 -source-files classes hashtables compiler.errors compiler.units -accessors ; +USING: arrays definitions generic assocs kernel math namespaces +prettyprint sequences strings vectors words quotations inspector +io.styles io combinators sorting splitting math.parser effects +continuations debugger io.files io.streams.string vocabs +io.encodings.utf8 source-files classes classes.tuple hashtables +compiler.errors compiler.units accessors ; IN: parser TUPLE: lexer text line line-text line-length column ; @@ -285,13 +284,27 @@ M: no-word-error summary : CREATE-METHOD ( -- method ) scan-word bootstrap-word scan-word create-method-in ; +: shadowed-slots ( superclass slots -- shadowed ) + >r all-slot-names r> seq-intersect ; + +: check-slot-shadowing ( class superclass slots -- ) + shadowed-slots [ + [ + "Definition of slot ``" % + % + "'' in class ``" % + word-name % + "'' shadows a superclass slot" % + ] "" make note. + ] with each ; + : parse-tuple-definition ( -- class superclass slots ) CREATE-CLASS scan { { ";" [ tuple f ] } { "<" [ scan-word ";" parse-tokens ] } [ >r tuple ";" parse-tokens r> prefix ] - } case ; + } case 3dup check-slot-shadowing ; ERROR: staging-violation word ; diff --git a/core/sequences/sequences-tests.factor b/core/sequences/sequences-tests.factor index 3a30824084..281b27d540 100755 --- a/core/sequences/sequences-tests.factor +++ b/core/sequences/sequences-tests.factor @@ -1,6 +1,6 @@ USING: arrays kernel math namespaces sequences kernel.private sequences.private strings sbufs tools.test vectors bit-arrays -generic ; +generic vocabs.loader ; IN: sequences.tests [ V{ 1 2 3 4 } ] [ 1 5 dup >vector ] unit-test @@ -100,6 +100,16 @@ unit-test [ [ ] ] [ [ 1 2 3 ] 3 tail ] unit-test [ [ 3 ] ] [ [ 1 2 3 ] 2 tail ] unit-test +[ "blah" ] [ "blahxx" 2 head* ] unit-test + +[ "xx" ] [ "blahxx" 2 tail* ] unit-test + +[ t ] [ "xxfoo" 2 head-slice "xxbar" 2 head-slice = ] unit-test +[ t ] [ "xxfoo" 2 head-slice "xxbar" 2 head-slice [ hashcode ] bi@ = ] unit-test + +[ t ] [ "xxfoo" 2 head-slice SBUF" barxx" 2 tail-slice* = ] unit-test +[ t ] [ "xxfoo" 2 head-slice SBUF" barxx" 2 tail-slice* [ hashcode ] bi@ = ] unit-test + [ t ] [ [ 1 2 3 ] [ 1 2 3 ] sequence= ] unit-test [ t ] [ [ 1 2 3 ] { 1 2 3 } sequence= ] unit-test [ t ] [ { 1 2 3 } [ 1 2 3 ] sequence= ] unit-test @@ -195,6 +205,12 @@ unit-test ! Pathological case [ "ihbye" ] [ "hi" "bye" append ] unit-test +[ t ] [ "hi" SBUF" hi" = ] unit-test + +[ t ] [ "hi" SBUF" hi" = ] unit-test + +[ t ] [ "hi" SBUF" hi" [ hashcode ] bi@ = ] unit-test + [ -10 "hi" "bye" copy ] must-fail [ 10 "hi" "bye" copy ] must-fail @@ -244,3 +260,5 @@ unit-test [ "asdf " ] [ " asdf " [ CHAR: \s = ] left-trim ] unit-test [ " asdf" ] [ " asdf " [ CHAR: \s = ] right-trim ] unit-test +! Hardcore +[ ] [ "sequences" reload ] unit-test diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 01a1cb9b6a..996aba8e6e 100755 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -172,7 +172,9 @@ TUPLE: reversed seq ; C: reversed M: reversed virtual-seq reversed-seq ; + M: reversed virtual@ reversed-seq [ length swap - 1- ] keep ; + M: reversed length reversed-seq length ; INSTANCE: reversed virtual-sequence @@ -198,7 +200,9 @@ ERROR: slice-error reason ; slice construct-boa ; inline M: slice virtual-seq slice-seq ; + M: slice virtual@ [ slice-from + ] keep slice-seq ; + M: slice length dup slice-to swap slice-from - ; : head-slice ( seq n -- slice ) (head) ; @@ -466,6 +470,21 @@ M: sequence <=> 2dup [ length ] bi@ number= [ mismatch not ] [ 2drop f ] if ; inline +: sequence-hashcode-step ( oldhash newpart -- newhash ) + swap [ + dup -2 fixnum-shift-fast swap 5 fixnum-shift-fast + fixnum+fast fixnum+fast + ] keep fixnum-bitxor ; inline + +: sequence-hashcode ( n seq -- x ) + 0 -rot [ + hashcode* >fixnum sequence-hashcode-step + ] with each ; inline + +M: reversed equal? over reversed? [ sequence= ] [ 2drop f ] if ; + +M: slice equal? over slice? [ sequence= ] [ 2drop f ] if ; + : move ( to from seq -- ) 2over number= [ 3drop ] [ [ nth swap ] keep set-nth ] if ; inline @@ -692,14 +711,3 @@ PRIVATE> dup [ length ] map infimum [ dup like ] with map ] unless ; - -: sequence-hashcode-step ( oldhash newpart -- newhash ) - swap [ - dup -2 fixnum-shift-fast swap 5 fixnum-shift-fast - fixnum+fast fixnum+fast - ] keep fixnum-bitxor ; inline - -: sequence-hashcode ( n seq -- x ) - 0 -rot [ - hashcode* >fixnum sequence-hashcode-step - ] with each ; inline diff --git a/extra/assocs/lib/lib.factor b/extra/assocs/lib/lib.factor index b23ee1f830..92fb9aac81 100755 --- a/extra/assocs/lib/lib.factor +++ b/extra/assocs/lib/lib.factor @@ -37,9 +37,6 @@ IN: assocs.lib : insert ( value variable -- ) namespace insert-at ; -: 2seq>assoc ( keys values exemplar -- assoc ) - >r 2array flip r> assoc-like ; - : generate-key ( assoc -- str ) >r 256 random-bits >hex r> 2dup key? [ nip generate-key ] [ drop ] if ; diff --git a/extra/builder/builder.factor b/extra/builder/builder.factor index 8e9565f82a..0e3a794e24 100644 --- a/extra/builder/builder.factor +++ b/extra/builder/builder.factor @@ -106,7 +106,7 @@ IN: builder +closed+ >>stdin "../test-log" >>stdout +stdout+ >>stderr - 120 minutes >>timeout ; + 240 minutes >>timeout ; : do-builder-test ( -- ) builder-test [ "Test error" print "../test-log" 100 cat-n ] run-or-bail ; diff --git a/extra/db/db.factor b/extra/db/db.factor index 55e672ec80..1a1a18c942 100755 --- a/extra/db/db.factor +++ b/extra/db/db.factor @@ -11,14 +11,19 @@ TUPLE: db update-statements delete-statements ; -: ( handle -- obj ) - H{ } clone H{ } clone H{ } clone - db construct-boa ; +: construct-db ( class -- obj ) + construct-empty + H{ } clone >>insert-statements + H{ } clone >>update-statements + H{ } clone >>delete-statements ; GENERIC: make-db* ( seq class -- db ) -GENERIC: db-open ( db -- ) + +: make-db ( seq class -- db ) + construct-db make-db* ; + +GENERIC: db-open ( db -- db ) HOOK: db-close db ( handle -- ) -: make-db ( seq class -- db ) construct-empty make-db* ; : dispose-statements ( seq -- ) [ dispose drop ] assoc-each ; @@ -30,10 +35,13 @@ HOOK: db-close db ( handle -- ) handle>> db-close ] with-variable ; +! TUPLE: sql sql in-params out-params ; TUPLE: statement handle sql in-params out-params bind-params bound? ; -TUPLE: simple-statement ; -TUPLE: prepared-statement ; -TUPLE: nonthrowable-statement ; +TUPLE: simple-statement < statement ; +TUPLE: prepared-statement < statement ; +TUPLE: nonthrowable-statement < statement ; +TUPLE: throwable-statement < statement ; + : make-nonthrowable ( obj -- obj' ) dup sequence? [ [ make-nonthrowable ] map @@ -41,14 +49,13 @@ TUPLE: nonthrowable-statement ; nonthrowable-statement construct-delegate ] if ; -MIXIN: throwable-statement -INSTANCE: statement throwable-statement -INSTANCE: simple-statement throwable-statement -INSTANCE: prepared-statement throwable-statement - TUPLE: result-set sql in-params out-params handle n max ; -: ( sql in out -- statement ) - { (>>sql) (>>in-params) (>>out-params) } statement construct ; + +: construct-statement ( sql in out class -- statement ) + construct-empty + swap >>out-params + swap >>in-params + swap >>sql ; HOOK: db ( str in out -- statement ) HOOK: db ( str in out -- statement ) @@ -88,11 +95,14 @@ M: nonthrowable-statement execute-statement ( statement -- ) dup #rows >>max 0 >>n drop ; -: ( query handle tuple -- result-set ) - >r >r { sql>> in-params>> out-params>> } get-slots r> - { (>>sql) (>>in-params) (>>out-params) (>>handle) } result-set - construct r> construct-delegate ; - +: construct-result-set ( query handle class -- result-set ) + construct-empty + swap >>handle + >r [ sql>> ] [ in-params>> ] [ out-params>> ] tri r> + swap >>out-params + swap >>in-params + swap >>sql ; + : sql-row ( result-set -- seq ) dup #columns [ row-column ] with map ; @@ -110,7 +120,7 @@ M: nonthrowable-statement execute-statement ( statement -- ) accumulator >r query-each r> { } like ; inline : with-db ( db seq quot -- ) - >r make-db dup db-open db r> + >r make-db db-open db r> [ db get swap [ drop ] swap compose with-disposal ] curry with-variable ; : default-query ( query -- result-set ) diff --git a/extra/db/postgresql/ffi/ffi.factor b/extra/db/postgresql/ffi/ffi.factor index 7925989bf5..7f428bb6b6 100755 --- a/extra/db/postgresql/ffi/ffi.factor +++ b/extra/db/postgresql/ffi/ffi.factor @@ -6,7 +6,8 @@ IN: db.postgresql.ffi << "postgresql" { { [ os winnt? ] [ "libpq.dll" ] } - { [ os macosx? ] [ "/opt/local/lib/postgresql82/libpq.dylib" ] } + { [ os macosx? ] [ "/opt/local/lib/postgresql83/libpq.dylib" ] } + ! { [ os macosx? ] [ "libpq.dylib" ] } { [ os unix? ] [ "libpq.so" ] } } cond "cdecl" add-library >> diff --git a/extra/db/postgresql/postgresql.factor b/extra/db/postgresql/postgresql.factor index f9805560ad..322143e7a2 100755 --- a/extra/db/postgresql/postgresql.factor +++ b/extra/db/postgresql/postgresql.factor @@ -5,40 +5,39 @@ kernel math math.parser namespaces prettyprint quotations sequences debugger db db.postgresql.lib db.postgresql.ffi db.tuples db.types tools.annotations math.ranges combinators sequences.lib classes locals words tools.walker -namespaces.lib ; +namespaces.lib accessors ; IN: db.postgresql -TUPLE: postgresql-db host port pgopts pgtty db user pass ; -TUPLE: postgresql-statement ; -INSTANCE: postgresql-statement throwable-statement -TUPLE: postgresql-result-set ; +TUPLE: postgresql-db < db + host port pgopts pgtty db user pass ; + +TUPLE: postgresql-statement < throwable-statement ; + +TUPLE: postgresql-result-set < result-set ; + : ( statement in out -- postgresql-statement ) - - postgresql-statement construct-delegate ; + postgresql-statement construct-statement ; M: postgresql-db make-db* ( seq tuple -- db ) - >r first4 r> [ - { - set-postgresql-db-host - set-postgresql-db-user - set-postgresql-db-pass - set-postgresql-db-db - } set-slots - ] keep ; + >r first4 r> + swap >>db + swap >>pass + swap >>user + swap >>host ; -M: postgresql-db db-open ( db -- ) - dup { - postgresql-db-host - postgresql-db-port - postgresql-db-pgopts - postgresql-db-pgtty - postgresql-db-db - postgresql-db-user - postgresql-db-pass - } get-slots connect-postgres swap set-delegate ; +M: postgresql-db db-open ( db -- db ) + dup { + [ host>> ] + [ port>> ] + [ pgopts>> ] + [ pgtty>> ] + [ db>> ] + [ user>> ] + [ pass>> ] + } cleave connect-postgres >>handle ; M: postgresql-db dispose ( db -- ) - db-handle PQfinish ; + handle>> PQfinish ; M: postgresql-statement bind-statement* ( statement -- ) drop ; @@ -50,10 +49,10 @@ M: postgresql-statement bind-tuple ( tuple statement -- ) ] keep set-statement-bind-params ; M: postgresql-result-set #rows ( result-set -- n ) - result-set-handle PQntuples ; + handle>> PQntuples ; M: postgresql-result-set #columns ( result-set -- n ) - result-set-handle PQnfields ; + handle>> PQnfields ; M: postgresql-result-set row-column ( result-set column -- obj ) >r dup result-set-handle swap result-set-n r> pq-get-string ; @@ -69,7 +68,7 @@ M: postgresql-statement query-results ( query -- result-set ) ] [ dup do-postgresql-statement ] if* - postgresql-result-set + postgresql-result-set construct-result-set dup init-result-set ; M: postgresql-result-set advance-row ( result-set -- ) @@ -90,7 +89,7 @@ M: postgresql-result-set dispose ( result-set -- ) M: postgresql-statement prepare-statement ( statement -- ) [ - >r db get db-handle "" r> + >r db get handle>> "" r> dup statement-sql swap statement-in-params length f PQprepare postgresql-error ] keep set-statement-handle ; diff --git a/extra/db/sqlite/sqlite.factor b/extra/db/sqlite/sqlite.factor index 9b3185bcf2..11c0150cd2 100755 --- a/extra/db/sqlite/sqlite.factor +++ b/extra/db/sqlite/sqlite.factor @@ -5,61 +5,48 @@ hashtables io.files kernel math math.parser namespaces prettyprint sequences strings classes.tuple alien.c-types continuations db.sqlite.lib db.sqlite.ffi db.tuples words combinators.lib db.types combinators -io namespaces.lib ; -USE: tools.walker +io namespaces.lib accessors ; IN: db.sqlite -TUPLE: sqlite-db path ; +TUPLE: sqlite-db < db path ; M: sqlite-db make-db* ( path db -- db ) - [ set-sqlite-db-path ] keep ; + swap >>path ; -M: sqlite-db db-open ( db -- ) - dup sqlite-db-path sqlite-open - swap set-delegate ; +M: sqlite-db db-open ( db -- db ) + [ path>> sqlite-open ] [ swap >>handle ] bi ; M: sqlite-db db-close ( handle -- ) sqlite-close ; M: sqlite-db dispose ( db -- ) dispose-db ; -: with-sqlite ( path quot -- ) sqlite-db swap with-db ; inline -TUPLE: sqlite-statement ; -INSTANCE: sqlite-statement throwable-statement +TUPLE: sqlite-statement < throwable-statement ; -TUPLE: sqlite-result-set has-more? ; +TUPLE: sqlite-result-set < result-set has-more? ; M: sqlite-db ( str in out -- obj ) ; M: sqlite-db ( str in out -- obj ) - { - set-statement-sql - set-statement-in-params - set-statement-out-params - } statement construct - sqlite-statement construct-delegate ; + sqlite-statement construct-statement ; : sqlite-maybe-prepare ( statement -- statement ) - dup statement-handle [ - [ - delegate - db get db-handle over statement-sql sqlite-prepare - swap set-statement-handle - ] keep + dup handle>> [ + db get handle>> over sql>> sqlite-prepare + >>handle ] unless ; M: sqlite-statement dispose ( statement -- ) - statement-handle + handle>> [ [ sqlite3_reset drop ] keep sqlite-finalize ] when* ; M: sqlite-result-set dispose ( result-set -- ) - f swap set-result-set-handle ; + f >>handle drop ; : sqlite-bind ( triples handle -- ) swap [ first3 sqlite-bind-type ] with each ; : reset-statement ( statement -- ) - sqlite-maybe-prepare - statement-handle sqlite-reset ; + sqlite-maybe-prepare handle>> sqlite-reset ; M: sqlite-statement bind-statement* ( statement -- ) sqlite-maybe-prepare @@ -69,11 +56,11 @@ M: sqlite-statement bind-statement* ( statement -- ) M: sqlite-statement bind-tuple ( tuple statement -- ) [ - statement-in-params + in-params>> [ - [ sql-spec-column-name ":" prepend ] - [ sql-spec-slot-name rot get-slot-named ] - [ sql-spec-type ] tri 3array + [ column-name>> ":" prepend ] + [ slot-name>> rot get-slot-named ] + [ type>> ] tri 3array ] with map ] keep bind-statement ; @@ -86,25 +73,24 @@ M: sqlite-db insert-tuple* ( tuple statement -- ) execute-statement last-insert-id swap set-primary-key ; M: sqlite-result-set #columns ( result-set -- n ) - result-set-handle sqlite-#columns ; + handle>> sqlite-#columns ; M: sqlite-result-set row-column ( result-set n -- obj ) - >r result-set-handle r> sqlite-column ; + [ handle>> ] [ sqlite-column ] bi* ; M: sqlite-result-set row-column-typed ( result-set n -- obj ) - dup pick result-set-out-params nth sql-spec-type - >r >r result-set-handle r> r> sqlite-column-typed ; + dup pick out-params>> nth type>> + >r >r handle>> r> r> sqlite-column-typed ; M: sqlite-result-set advance-row ( result-set -- ) - [ result-set-handle sqlite-next ] keep - set-sqlite-result-set-has-more? ; + dup handle>> sqlite-next >>has-more? drop ; M: sqlite-result-set more-rows? ( result-set -- ? ) - sqlite-result-set-has-more? ; + has-more?>> ; M: sqlite-statement query-results ( query -- result-set ) sqlite-maybe-prepare - dup statement-handle sqlite-result-set + dup handle>> sqlite-result-set construct-result-set dup advance-row ; M: sqlite-db begin-transaction ( -- ) "BEGIN" sql-command ; @@ -119,9 +105,9 @@ M: sqlite-db create-sql-statement ( class -- statement ) [ "create table " 0% 0% "(" 0% [ ", " 0% ] [ - dup sql-spec-column-name 0% + dup column-name>> 0% " " 0% - dup sql-spec-type t lookup-type 0% + dup type>> t lookup-type 0% modifiers 0% ] interleave ");" 0% ] sqlite-make ; @@ -134,7 +120,7 @@ M: sqlite-db ( tuple -- statement ) "insert into " 0% 0% "(" 0% maybe-remove-id - dup [ ", " 0% ] [ sql-spec-column-name 0% ] interleave + dup [ ", " 0% ] [ column-name>> 0% ] interleave ") values(" 0% [ ", " 0% ] [ bind% ] interleave ");" 0% @@ -145,11 +131,11 @@ M: sqlite-db ( tuple -- statement ) : where-primary-key% ( specs -- ) " where " 0% - find-primary-key dup sql-spec-column-name 0% " = " 0% bind% ; + find-primary-key dup column-name>> 0% " = " 0% bind% ; : where-clause ( specs -- ) " where " 0% - [ " and " 0% ] [ dup sql-spec-column-name 0% " = " 0% bind% ] interleave ; + [ " and " 0% ] [ dup column-name>> 0% " = " 0% bind% ] interleave ; M: sqlite-db ( class -- statement ) [ @@ -157,7 +143,7 @@ M: sqlite-db ( class -- statement ) 0% " set " 0% dup remove-id - [ ", " 0% ] [ dup sql-spec-column-name 0% " = " 0% bind% ] interleave + [ ", " 0% ] [ dup column-name>> 0% " = " 0% bind% ] interleave where-primary-key% ] sqlite-make ; @@ -166,23 +152,23 @@ M: sqlite-db ( specs table -- sql ) "delete from " 0% 0% " where " 0% find-primary-key - dup sql-spec-column-name 0% " = " 0% bind% + dup column-name>> 0% " = " 0% bind% ] sqlite-make ; ! : select-interval ( interval name -- ) ; ! : select-sequence ( seq name -- ) ; M: sqlite-db bind% ( spec -- ) - dup 1, sql-spec-column-name ":" prepend 0% ; + dup 1, column-name>> ":" prepend 0% ; M: sqlite-db ( tuple class -- statement ) [ "select " 0% over [ ", " 0% ] - [ dup sql-spec-column-name 0% 2, ] interleave + [ dup column-name>> 0% 2, ] interleave " from " 0% 0% - [ sql-spec-slot-name swap get-slot-named ] with subset + [ slot-name>> swap get-slot-named ] with subset dup empty? [ drop ] [ where-clause ] if ";" 0% ] sqlite-make ; diff --git a/extra/db/tuples/tuples-tests.factor b/extra/db/tuples/tuples-tests.factor index 6b61981119..951ded32ea 100755 --- a/extra/db/tuples/tuples-tests.factor +++ b/extra/db/tuples/tuples-tests.factor @@ -260,10 +260,10 @@ C: secret ! [ test-random-id ] test-sqlite [ native-person-schema test-tuples ] test-sqlite [ assigned-person-schema test-tuples ] test-sqlite -! [ assigned-person-schema test-repeated-insert ] test-sqlite -! [ native-person-schema test-tuples ] test-postgresql -! [ assigned-person-schema test-tuples ] test-postgresql -! [ assigned-person-schema test-repeated-insert ] test-postgresql + [ assigned-person-schema test-repeated-insert ] test-sqlite + [ native-person-schema test-tuples ] test-postgresql + [ assigned-person-schema test-tuples ] test-postgresql + [ assigned-person-schema test-repeated-insert ] test-postgresql ! \ insert-tuple must-infer ! \ update-tuple must-infer diff --git a/extra/hardware-info/backend/backend.factor b/extra/hardware-info/backend/backend.factor index 95a56da2d2..283fea6fcc 100644 --- a/extra/hardware-info/backend/backend.factor +++ b/extra/hardware-info/backend/backend.factor @@ -2,6 +2,7 @@ USING: system ; IN: hardware-info.backend HOOK: cpus os ( -- n ) +HOOK: cpu-mhz os ( -- n ) HOOK: memory-load os ( -- n ) HOOK: physical-mem os ( -- n ) HOOK: available-mem os ( -- n ) diff --git a/extra/hardware-info/hardware-info.factor b/extra/hardware-info/hardware-info.factor index 6d27cf5252..53aab483a1 100755 --- a/extra/hardware-info/hardware-info.factor +++ b/extra/hardware-info/hardware-info.factor @@ -3,11 +3,12 @@ combinators vocabs.loader hardware-info.backend system ; IN: hardware-info : write-unit ( x n str -- ) - [ 2^ /i number>string write bl ] [ write ] bi* ; + [ 2^ /f number>string write bl ] [ write ] bi* ; : kb ( x -- ) 10 "kB" write-unit ; : megs ( x -- ) 20 "MB" write-unit ; : gigs ( x -- ) 30 "GB" write-unit ; +: ghz ( x -- ) 1000000000 /f number>string write bl "GHz" write ; << { { [ os windows? ] [ "hardware-info.windows" ] } @@ -18,4 +19,5 @@ IN: hardware-info : hardware-report. ( -- ) "CPUs: " write cpus number>string write nl + "CPU Speed: " write cpu-mhz ghz nl "Physical RAM: " write physical-mem megs nl ; diff --git a/extra/hardware-info/macosx/macosx.factor b/extra/hardware-info/macosx/macosx.factor index dac052a1de..91838d2a53 100644 --- a/extra/hardware-info/macosx/macosx.factor +++ b/extra/hardware-info/macosx/macosx.factor @@ -41,7 +41,7 @@ M: macosx physical-mem ( -- n ) { 6 5 } sysctl-query-uint ; : machine-arch ( -- n ) { 6 12 } sysctl-query-string ; : vector-unit ( -- n ) { 6 13 } sysctl-query-uint ; : bus-frequency ( -- n ) { 6 14 } sysctl-query-uint ; -: cpu-frequency ( -- n ) { 6 15 } sysctl-query-uint ; +M: macosx cpu-mhz ( -- n ) { 6 15 } sysctl-query-uint ; : cacheline-size ( -- n ) { 6 16 } sysctl-query-uint ; : l1-icache-size ( -- n ) { 6 17 } sysctl-query-uint ; : l1-dcache-size ( -- n ) { 6 18 } sysctl-query-uint ; diff --git a/extra/math/points/points.factor b/extra/math/points/points.factor new file mode 100644 index 0000000000..5efd6e07e0 --- /dev/null +++ b/extra/math/points/points.factor @@ -0,0 +1,22 @@ + +USING: kernel arrays math.vectors ; + +IN: math.points + + + +: v+x ( seq x -- seq ) X v+ ; +: v-x ( seq x -- seq ) X v- ; + +: v+y ( seq y -- seq ) Y v+ ; +: v-y ( seq y -- seq ) Y v- ; + +: v+z ( seq z -- seq ) Z v+ ; +: v-z ( seq z -- seq ) Z v- ; + diff --git a/extra/newfx/newfx.factor b/extra/newfx/newfx.factor index df826dc295..b123fef2a3 100644 --- a/extra/newfx/newfx.factor +++ b/extra/newfx/newfx.factor @@ -1,7 +1,8 @@ -USING: kernel sequences assocs qualified ; +USING: kernel sequences assocs qualified circular ; QUALIFIED: sequences +QUALIFIED: circular IN: newfx @@ -53,8 +54,10 @@ IN: newfx ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: push ( seq obj -- seq ) over sequences:push ; -: push-on ( obj seq -- seq ) tuck sequences:push ; +: push ( seq obj -- seq ) over sequences:push ; +: push-on ( obj seq -- seq ) tuck sequences:push ; +: pushed ( seq obj -- ) swap sequences:push ; +: pushed-on ( obj seq -- ) sequences:push ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -91,6 +94,10 @@ IN: newfx ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +: push-circular ( seq elt -- seq ) over circular:push-circular ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! A note about the 'mutate' qualifier. Other words also technically mutate ! their primary object. However, the 'mutate' qualifier is supposed to ! indicate that this is the main objective of the word, as a side effect. \ No newline at end of file diff --git a/extra/peg/peg.factor b/extra/peg/peg.factor index ee9037ff25..3b1d408ae2 100755 --- a/extra/peg/peg.factor +++ b/extra/peg/peg.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2007, 2008 Chris Double. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences strings fry namespaces math assocs shuffle - vectors arrays combinators.lib math.parser - unicode.categories sequences.lib compiler.units parser + vectors arrays math.parser + unicode.categories compiler.units parser words quotations effects memoize accessors locals effects splitting ; IN: peg diff --git a/extra/processing/gallery/bubble-chamber/bubble-chamber-docs.factor b/extra/processing/gallery/bubble-chamber/bubble-chamber-docs.factor new file mode 100644 index 0000000000..21a845e089 --- /dev/null +++ b/extra/processing/gallery/bubble-chamber/bubble-chamber-docs.factor @@ -0,0 +1,97 @@ + +USING: help.syntax help.markup ; + +IN: processing.gallery.bubble-chamber + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +HELP: muon + + { $class-description + "The muon is a colorful particle with an entangled friend." + "It draws both itself and its horizontally symmetric partner." + "A high range of speed and almost no speed decay allow the" + "muon to reach the extents of the window, often forming rings" + "where theta has decayed but speed remains stable. The result" + "is color almost everywhere in the general direction of collision," + "stabilized into fuzzy rings." } ; + +HELP: quark + + { $class-description + "The quark draws as a translucent black. Their large numbers" + "create fields of blackness overwritten only by the glowing shadows of " + "Hadrons. " + "quarks are allowed to accelerate away with speed decay values above 1.0. " + "Each quark has an entangled friend. Both particles are drawn identically," + "mirrored along the y-axis." } ; + +HELP: hadron + + { $class-description + "Hadrons collide from totally random directions. " + "Those hadrons that do not exit the drawing area, " + "tend to stabilize into perfect circular orbits. " + "Each hadron draws with a slight glowing emboss. " + "The hadron itself is not drawn." } ; + +HELP: axion + + { $class-description + "The axion particle draws a bold black path. Axions exist " + "in a slightly higher dimension and as such are drawn with " + "elevated embossed shadows. Axions are quick to stabilize " + "and fall into single pixel orbits axions automatically " + "recollide themselves after stabilizing." } ; + +{ muon quark hadron axion } related-words + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +ARTICLE: "bubble-chamber" "Bubble Chamber" + + { $subsection "bubble-chamber-introduction" } + { $subsection "bubble-chamber-particles" } + { $subsection "bubble-chamber-author" } + { $subsection "bubble-chamber-running" } ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +ARTICLE: "bubble-chamber-introduction" "Introduction" + +"The Bubble Chamber is a generative painting system of imaginary " +"colliding particles. A single super-massive collision produces a " +"discrete universe of four particle types. Particles draw their " +"positions over time as pixel exposures. " ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +ARTICLE: "bubble-chamber-particles" "Particles" + +"Four types of particles exist. The behavior and graphic appearance of " +"each particle type is unique." + + { $subsection muon } + { $subsection quark } + { $subsection hadron } + { $subsection axion } ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +ARTICLE: "bubble-chamber-author" "Author" + + "Bubble Chamber was created by Jared Tarbell. " + "It was originally implemented in Processing. " + "It was ported to Factor by Eduardo Cavazos. " + "The original work is on display here: " + { $url + "http://www.complexification.net/gallery/machines/bubblechamber/" } ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +ARTICLE: "bubble-chamber-running" "How to use" + + "After you run the vocabulary, a window will appear. Click the " + "mouse in a random area to fire 11 particles of each type. " + "Another way to fire particles is to press the " + "spacebar. This fires all the particles." ; \ No newline at end of file diff --git a/extra/processing/gallery/bubble-chamber/bubble-chamber.factor b/extra/processing/gallery/bubble-chamber/bubble-chamber.factor index c6e000e74f..2efa04efad 100644 --- a/extra/processing/gallery/bubble-chamber/bubble-chamber.factor +++ b/extra/processing/gallery/bubble-chamber/bubble-chamber.factor @@ -7,6 +7,7 @@ USING: kernel namespaces sequences combinators arrays threads math.ranges math.constants math.functions + math.points ui ui.gadgets @@ -25,12 +26,6 @@ IN: processing.gallery.bubble-chamber ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: 2random ( a b -- num ) 2dup swap - 100 / random ; - -: 1random ( b -- num ) 0 swap 2random ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - : move-by ( obj delta -- obj ) over pos>> v+ >>pos ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -82,17 +77,8 @@ VARS: particles muons quarks hadrons axions ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: x>> ( particle -- x ) pos>> first ; -: y>> ( particle -- x ) pos>> second ; - -: >>x ( particle x -- particle ) over y>> 2array >>pos ; -: >>y ( particle y -- particle ) over x>> swap 2array >>pos ; - -: x x>> ; -: y y>> ; - -: v+y ( seq y -- seq ) >r first2 r> + 2array ; -: v-y ( seq y -- seq ) >r first2 r> - 2array ; +: x ( particle -- x ) pos>> first ; +: y ( particle -- x ) pos>> second ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -103,23 +89,34 @@ VARS: particles muons quarks hadrons axions ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +TUPLE: particle pos vel speed speed-d theta theta-d theta-dd myc mya ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: initialize-particle ( particle -- particle ) + + 0 0 {2} >>pos + 0 0 {2} >>vel + + 0 >>speed + 0 >>speed-d + 0 >>theta + 0 >>theta-d + 0 >>theta-dd + + 0 0 0 1 >>myc + 0 0 0 1 >>mya ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + GENERIC: collide ( particle -- ) GENERIC: move ( particle -- ) ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -TUPLE: muon pos speed theta speed-d theta-d theta-dd myc mya ; +TUPLE: muon < particle ; -: ( -- muon ) - muon construct-empty - 0 0 2array >>pos - 0 >>speed - 0 >>speed-d - 0 >>theta - 0 >>theta-d - 0 >>theta-dd - 0 0 0 1 >>myc - 0 0 0 1 >>mya ; +: ( -- muon ) muon construct-empty initialize-particle ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -177,18 +174,9 @@ METHOD: move { muon } ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -TUPLE: quark pos vel speed theta speed-d theta-d theta-dd myc ; +TUPLE: quark < particle ; -: ( -- quark ) - quark construct-empty - 0 0 2array >>pos - 0 0 2array >>vel - 0 >>speed - 0 >>speed-d - 0 >>theta - 0 >>theta-d - 0 >>theta-dd - 0 0 0 1 >>myc ; +: ( -- quark ) quark construct-empty initialize-particle ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -228,7 +216,8 @@ METHOD: move { quark } [ ] [ theta-d>> ] [ theta-dd>> ] tri + >>theta-d [ ] [ speed>> ] [ speed-d>> ] tri * >>speed - 1000 random 997 > + ! 1000 random 997 > + 3/1000 chance [ dup speed>> neg >>speed 2 over speed-d>> - >>speed-d @@ -242,18 +231,9 @@ METHOD: move { quark } ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -TUPLE: hadron pos vel speed theta speed-d theta-d theta-dd myc ; +TUPLE: hadron < particle ; -: ( -- hadron ) - hadron construct-empty - 0 0 2array >>pos - 0 0 2array >>vel - 0 >>speed - 0 >>speed-d - 0 >>theta - 0 >>theta-d - 0 >>theta-dd - 0 0 0 1 >>myc ; +: ( -- hadron ) hadron construct-empty initialize-particle ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -296,12 +276,14 @@ METHOD: move { hadron } [ ] [ theta-d>> ] [ theta-dd>> ] tri + >>theta-d [ ] [ speed>> ] [ speed-d>> ] tri * >>speed - 1000 random 997 > + ! 1000 random 997 > + 3/1000 chance [ 1.0 >>speed-d 0.00001 >>theta-dd - 100 random 70 > + ! 100 random 70 > + 30/100 chance [ dim 2 / dup 2array >>pos dup collide @@ -317,17 +299,9 @@ METHOD: move { hadron } ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -TUPLE: axion pos vel speed theta speed-d theta-d theta-dd ; +TUPLE: axion < particle ; -: ( -- axion ) - axion construct-empty - 0 0 2array >>pos - 0 0 2array >>vel - 0 >>speed - 0 >>speed-d - 0 >>theta - 0 >>theta-d - 0 >>theta-dd ; +: ( -- axion ) axion construct-empty initialize-particle ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -381,12 +355,14 @@ METHOD: move { axion } [ ] [ speed-d>> 0.9999 * ] bi >>speed-d - 1000 random 996 > + ! 1000 random 996 > + 4/1000 chance [ dup speed>> neg >>speed dup speed-d>> neg 2 + >>speed-d - 100 random 30 > + ! 100 random 30 > + 70/100 chance [ dim 2 / dup 2array >>pos collide diff --git a/extra/processing/gallery/trails/trails.factor b/extra/processing/gallery/trails/trails.factor index f0a8889fbf..dc191bc439 100644 --- a/extra/processing/gallery/trails/trails.factor +++ b/extra/processing/gallery/trails/trails.factor @@ -1,5 +1,6 @@ -USING: kernel arrays sequences math qualified circular processing ui ; +USING: kernel arrays sequences math qualified + sequences.lib circular processing ui newfx ; IN: processing.gallery.trails @@ -9,22 +10,6 @@ IN: processing.gallery.trails ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -QUALIFIED: circular - -: push-circular ( seq elt -- seq ) over circular:push-circular ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: each-percent ( seq quot -- ) - >r - dup length - dup [ / ] curry - [ 1+ ] swap compose - r> compose - 2each ; inline - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - : point-list ( n -- seq ) [ drop 0 0 2array ] map ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/extra/processing/processing.factor b/extra/processing/processing.factor index acad02363b..02a8325663 100644 --- a/extra/processing/processing.factor +++ b/extra/processing/processing.factor @@ -1,6 +1,6 @@ USING: kernel namespaces threads combinators sequences arrays - math math.functions + math math.functions math.ranges random opengl.gl opengl.glu vars multi-methods shuffle ui ui.gestures @@ -16,6 +16,18 @@ IN: processing ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +: 2random ( a b -- num ) 2dup swap - 100 / random ; + +: 1random ( b -- num ) 0 swap 2random ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: chance ( fraction -- ? ) 0 1 2random > ; + +: percent-chance ( percent -- ? ) 100 / chance ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + VAR: fill-color VAR: stroke-color diff --git a/extra/sequences/lib/lib.factor b/extra/sequences/lib/lib.factor index 945ba1a3b7..0221d9b99a 100755 --- a/extra/sequences/lib/lib.factor +++ b/extra/sequences/lib/lib.factor @@ -4,7 +4,7 @@ USING: combinators.lib kernel sequences math namespaces assocs random sequences.private shuffle math.functions mirrors arrays math.parser math.private sorting strings ascii macros -assocs.lib quotations ; +assocs.lib quotations hashtables ; IN: sequences.lib : each-withn ( seq quot n -- ) nwith each ; inline @@ -37,6 +37,16 @@ MACRO: firstn ( n -- ) ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +: each-percent ( seq quot -- ) + >r + dup length + dup [ / ] curry + [ 1+ ] swap compose + r> compose + 2each ; inline + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + : sigma ( seq quot -- n ) [ rot slip + ] curry 0 swap reduce ; inline @@ -221,7 +231,7 @@ PRIVATE> [ swap nth ] with map ; : replace ( str oldseq newseq -- str' ) - H{ } 2seq>assoc substitute ; + zip >hashtable substitute ; : remove-nth ( seq n -- seq' ) cut-slice 1 tail-slice append ; diff --git a/extra/tools/memory/memory-tests.factor b/extra/tools/memory/memory-tests.factor index 9efbf63f7f..60b54c2a0d 100644 --- a/extra/tools/memory/memory-tests.factor +++ b/extra/tools/memory/memory-tests.factor @@ -1,4 +1,8 @@ USING: tools.test tools.memory ; IN: tools.memory.tests +\ room. must-infer +[ ] [ room. ] unit-test + +\ heap-stats. must-infer [ ] [ heap-stats. ] unit-test diff --git a/extra/tools/memory/memory.factor b/extra/tools/memory/memory.factor index 2077ea497e..b8fdcab280 100644 --- a/extra/tools/memory/memory.factor +++ b/extra/tools/memory/memory.factor @@ -1,22 +1,29 @@ -! Copyright (C) 2005, 2007 Slava Pestov. +! Copyright (C) 2005, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences vectors arrays generic assocs io math namespaces parser prettyprint strings io.styles vectors words -system sorting splitting math.parser classes memory ; +system sorting splitting math.parser classes memory combinators ; IN: tools.memory +string + dup length 4 > [ 3 cut* "," swap 3append ] when + " KB" append write-cell ; + : write-total/used/free ( free total str -- ) [ write-cell - dup number>string write-cell - over - number>string write-cell - number>string write-cell + dup write-size + over - write-size + write-size ] with-row ; : write-total ( n str -- ) [ write-cell - number>string write-cell + write-size [ ] with-cell [ ] with-cell ] with-row ; @@ -25,26 +32,41 @@ IN: tools.memory [ [ write-cell ] each ] with-row ; : (data-room.) ( -- ) - data-room 2 0 [ - "Generation " pick number>string append - >r first2 r> write-total/used/free 1+ - ] reduce drop + data-room 2 dup length [ + [ first2 ] [ number>string "Generation " prepend ] bi* + write-total/used/free + ] 2each "Cards" write-total ; -: (code-room.) ( -- ) - code-room "Code space" write-total/used/free ; +: write-labelled-size ( n string -- ) + [ write-cell write-size ] with-row ; -: room. ( -- ) - standard-table-style [ - { "" "Total" "Used" "Free" } write-headings - (data-room.) - (code-room.) - ] tabular-output ; +: (code-room.) ( -- ) + code-room { + [ "Size:" write-labelled-size ] + [ "Used:" write-labelled-size ] + [ "Total free space:" write-labelled-size ] + [ "Largest free block:" write-labelled-size ] + } spread ; : heap-stat-step ( counts sizes obj -- ) [ dup size swap class rot at+ ] keep 1 swap class rot at+ ; +PRIVATE> + +: room. ( -- ) + "==== DATA HEAP" print + standard-table-style [ + { "" "Total" "Used" "Free" } write-headings + (data-room.) + ] tabular-output + nl + "==== CODE HEAP" print + standard-table-style [ + (code-room.) + ] tabular-output ; + : heap-stats ( -- counts sizes ) H{ } clone H{ } clone [ >r 2dup r> heap-stat-step ] each-object ; diff --git a/extra/ui/tools/listener/listener-tests.factor b/extra/ui/tools/listener/listener-tests.factor index 13ce834df3..cc218533d8 100755 --- a/extra/ui/tools/listener/listener-tests.factor +++ b/extra/ui/tools/listener/listener-tests.factor @@ -2,7 +2,7 @@ USING: continuations documents ui.tools.interactor ui.tools.listener hashtables kernel namespaces parser sequences tools.test ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.panes vocabs words tools.test.ui slots.private -threads ; +threads arrays generic ; IN: ui.tools.listener.tests [ f ] [ "word" source-editor command-map empty? ] unit-test @@ -13,11 +13,11 @@ IN: ui.tools.listener.tests "listener" get [ [ "dup" ] [ - \ dup "listener" get word-completion-string + \ dup word-completion-string ] unit-test - [ "USE: slots.private slot" ] - [ \ slot "listener" get word-completion-string ] unit-test + [ "equal?" ] + [ \ array \ equal? method word-completion-string ] unit-test "i" set diff --git a/vm/code_gc.c b/vm/code_gc.c index 93eb49c1be..141f4abbfe 100755 --- a/vm/code_gc.c +++ b/vm/code_gc.c @@ -198,20 +198,33 @@ void free_unmarked(F_HEAP *heap) build_free_list(heap,heap->segment->size); } -/* Compute total sum of sizes of free blocks */ -CELL heap_usage(F_HEAP *heap, F_BLOCK_STATUS status) +/* Compute total sum of sizes of free blocks, and size of largest free block */ +void heap_usage(F_HEAP *heap, CELL *used, CELL *total_free, CELL *max_free) { - CELL size = 0; + *used = 0; + *total_free = 0; + *max_free = 0; + F_BLOCK *scan = first_block(heap); while(scan) { - if(scan->status == status) - size += scan->size; + switch(scan->status) + { + case B_ALLOCATED: + *used += scan->size; + break; + case B_FREE: + *total_free += scan->size; + if(scan->size > *max_free) + *max_free = scan->size; + break; + default: + critical_error("Invalid scan->status",(CELL)scan); + } + scan = next_block(heap,scan); } - - return size; } /* The size of the heap, not including the last block if it's free */ @@ -283,8 +296,12 @@ void recursive_mark(F_BLOCK *block) /* Push the free space and total size of the code heap */ DEFINE_PRIMITIVE(code_room) { - dpush(tag_fixnum(heap_usage(&code_heap,B_FREE) / 1024)); + CELL used, total_free, max_free; + heap_usage(&code_heap,&used,&total_free,&max_free); dpush(tag_fixnum((code_heap.segment->size) / 1024)); + dpush(tag_fixnum(used / 1024)); + dpush(tag_fixnum(total_free / 1024)); + dpush(tag_fixnum(max_free / 1024)); } /* Dump all code blocks for debugging */ diff --git a/vm/code_gc.h b/vm/code_gc.h index 32f304c16c..658dc990ae 100644 --- a/vm/code_gc.h +++ b/vm/code_gc.h @@ -32,7 +32,7 @@ void build_free_list(F_HEAP *heap, CELL size); CELL heap_allot(F_HEAP *heap, CELL size); void unmark_marked(F_HEAP *heap); void free_unmarked(F_HEAP *heap); -CELL heap_usage(F_HEAP *heap, F_BLOCK_STATUS status); +void heap_usage(F_HEAP *heap, CELL *used, CELL *total_free, CELL *max_free); CELL heap_size(F_HEAP *heap); INLINE F_BLOCK *next_block(F_HEAP *heap, F_BLOCK *block) diff --git a/vm/code_heap.c b/vm/code_heap.c index ec63441bcb..92915e49d1 100755 --- a/vm/code_heap.c +++ b/vm/code_heap.c @@ -229,7 +229,16 @@ CELL allot_code_block(CELL size) /* Insufficient room even after code GC, give up */ if(start == 0) + { + CELL used, total_free, max_free; + heap_usage(&code_heap,&used,&total_free,&max_free); + + fprintf(stderr,"Code heap stats:\n"); + fprintf(stderr,"Used: %ld\n",used); + fprintf(stderr,"Total free space: %ld\n",total_free); + fprintf(stderr,"Largest free block: %ld\n",max_free); fatal_error("Out of memory in add-compiled-block",0); + } } return start; diff --git a/vm/data_gc.h b/vm/data_gc.h index 0adcf0ca39..d3b8b6e39e 100755 --- a/vm/data_gc.h +++ b/vm/data_gc.h @@ -315,8 +315,6 @@ INLINE void* allot_object(CELL type, CELL a) { CELL *object; - /* If the object is bigger than the nursery, allocate it in - tenured space */ if(nursery->size - ALLOT_BUFFER_ZONE > a) { /* If there is insufficient room, collect the nursery */ @@ -325,6 +323,8 @@ INLINE void* allot_object(CELL type, CELL a) object = allot_zone(nursery,a); } + /* If the object is bigger than the nursery, allocate it in + tenured space */ else { F_ZONE *tenured = &data_heap->generations[TENURED]; diff --git a/vm/errors.s b/vm/errors.s deleted file mode 100644 index d6b3bdb6e5..0000000000 --- a/vm/errors.s +++ /dev/null @@ -1,687 +0,0 @@ - .file "errors.c" - .section .rdata,"dr" -LC0: - .ascii "fatal_error: %s %lx\12\0" - .text -.globl _fatal_error - .def _fatal_error; .scl 2; .type 32; .endef -_fatal_error: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - call ___getreent - movl %eax, %edx - movl 12(%ebp), %eax - movl %eax, 12(%esp) - movl 8(%ebp), %eax - movl %eax, 8(%esp) - movl $LC0, 4(%esp) - movl 12(%edx), %eax - movl %eax, (%esp) - call _fprintf - movl $1, (%esp) - call _exit - .section .rdata,"dr" - .align 4 -LC1: - .ascii "You have triggered a bug in Factor. Please report.\12\0" -LC2: - .ascii "critical_error: %s %lx\12\0" - .text -.globl _critical_error - .def _critical_error; .scl 2; .type 32; .endef -_critical_error: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - call ___getreent - movl $LC1, 4(%esp) - movl 12(%eax), %eax - movl %eax, (%esp) - call _fprintf - call ___getreent - movl %eax, %edx - movl 12(%ebp), %eax - movl %eax, 12(%esp) - movl 8(%ebp), %eax - movl %eax, 8(%esp) - movl $LC2, 4(%esp) - movl 12(%edx), %eax - movl %eax, (%esp) - call _fprintf - call _factorbug - leave - ret - .section .rdata,"dr" -LC3: - .ascii "early_error: \0" -LC4: - .ascii "\12\0" - .text -.globl _throw_error - .def _throw_error; .scl 2; .type 32; .endef -_throw_error: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - cmpl $7, _userenv+20 - je L4 - movb $0, _gc_off - movl _gc_locals_region, %eax - movl (%eax), %eax - subl $4, %eax - movl %eax, _gc_locals - movl _extra_roots_region, %eax - movl (%eax), %eax - subl $4, %eax - movl %eax, _extra_roots - call _fix_stacks - movl 8(%ebp), %eax - movl %eax, (%esp) - call _dpush - cmpl $0, 12(%ebp) - je L5 - movl _stack_chain, %eax - movl 4(%eax), %eax - movl %eax, 4(%esp) - movl 12(%ebp), %eax - movl %eax, (%esp) - call _fix_callstack_top - movl %eax, 12(%ebp) - jmp L6 -L5: - movl _stack_chain, %eax - movl (%eax), %eax - movl %eax, 12(%ebp) -L6: - movl 12(%ebp), %edx - movl _userenv+20, %eax - call _throw_impl - jmp L3 -L4: - call ___getreent - movl $LC1, 4(%esp) - movl 12(%eax), %eax - movl %eax, (%esp) - call _fprintf - call ___getreent - movl $LC3, 4(%esp) - movl 12(%eax), %eax - movl %eax, (%esp) - call _fprintf - movl 8(%ebp), %eax - movl %eax, (%esp) - call _print_obj - call ___getreent - movl $LC4, 4(%esp) - movl 12(%eax), %eax - movl %eax, (%esp) - call _fprintf - call _factorbug -L3: - leave - ret - .def _dpush; .scl 3; .type 32; .endef -_dpush: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - addl $4, %esi - movl 8(%ebp), %eax - movl %eax, 4(%esp) - movl %esi, (%esp) - call _put - leave - ret - .def _put; .scl 3; .type 32; .endef -_put: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %edx - movl 12(%ebp), %eax - movl %eax, (%edx) - popl %ebp - ret -.globl _general_error - .def _general_error; .scl 2; .type 32; .endef -_general_error: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - movl 8(%ebp), %eax - movl %eax, (%esp) - call _tag_fixnum - movl %eax, %edx - movl 16(%ebp), %eax - movl %eax, 12(%esp) - movl 12(%ebp), %eax - movl %eax, 8(%esp) - movl %edx, 4(%esp) - movl _userenv+24, %eax - movl %eax, (%esp) - call _allot_array_4 - movl %eax, %edx - movl 20(%ebp), %eax - movl %eax, 4(%esp) - movl %edx, (%esp) - call _throw_error - leave - ret - .def _tag_fixnum; .scl 3; .type 32; .endef -_tag_fixnum: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - sall $3, %eax - andl $-8, %eax - popl %ebp - ret -.globl _type_error - .def _type_error; .scl 2; .type 32; .endef -_type_error: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - movl 8(%ebp), %eax - movl %eax, (%esp) - call _tag_fixnum - movl %eax, %edx - movl $0, 12(%esp) - movl 12(%ebp), %eax - movl %eax, 8(%esp) - movl %edx, 4(%esp) - movl $3, (%esp) - call _general_error - leave - ret -.globl _not_implemented_error - .def _not_implemented_error; .scl 2; .type 32; .endef -_not_implemented_error: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - movl $0, 12(%esp) - movl $7, 8(%esp) - movl $7, 4(%esp) - movl $2, (%esp) - call _general_error - leave - ret -.globl _in_page - .def _in_page; .scl 2; .type 32; .endef -_in_page: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _getpagesize - movl %eax, -4(%ebp) - movl 16(%ebp), %edx - leal 12(%ebp), %eax - addl %edx, (%eax) - movl 20(%ebp), %eax - movl %eax, %edx - imull -4(%ebp), %edx - leal 12(%ebp), %eax - addl %edx, (%eax) - movb $0, -5(%ebp) - movl 8(%ebp), %eax - cmpl 12(%ebp), %eax - jb L15 - movl -4(%ebp), %eax - addl 12(%ebp), %eax - cmpl 8(%ebp), %eax - jb L15 - movb $1, -5(%ebp) -L15: - movzbl -5(%ebp), %eax - leave - ret - .section .rdata,"dr" - .align 4 -LC5: - .ascii "allot_object() missed GC check\0" -LC6: - .ascii "gc locals underflow\0" -LC7: - .ascii "gc locals overflow\0" -LC8: - .ascii "extra roots underflow\0" -LC9: - .ascii "extra roots overflow\0" - .text -.globl _memory_protection_error - .def _memory_protection_error; .scl 2; .type 32; .endef -_memory_protection_error: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - movl $-1, 12(%esp) - movl $0, 8(%esp) - movl _stack_chain, %eax - movl 24(%eax), %eax - movl (%eax), %eax - movl %eax, 4(%esp) - movl 8(%ebp), %eax - movl %eax, (%esp) - call _in_page - testb %al, %al - je L17 - movl 12(%ebp), %eax - movl %eax, 12(%esp) - movl $7, 8(%esp) - movl $7, 4(%esp) - movl $11, (%esp) - call _general_error - jmp L16 -L17: - movl $0, 12(%esp) - movl _ds_size, %eax - movl %eax, 8(%esp) - movl _stack_chain, %eax - movl 24(%eax), %eax - movl (%eax), %eax - movl %eax, 4(%esp) - movl 8(%ebp), %eax - movl %eax, (%esp) - call _in_page - testb %al, %al - je L19 - movl 12(%ebp), %eax - movl %eax, 12(%esp) - movl $7, 8(%esp) - movl $7, 4(%esp) - movl $12, (%esp) - call _general_error - jmp L16 -L19: - movl $-1, 12(%esp) - movl $0, 8(%esp) - movl _stack_chain, %eax - movl 28(%eax), %eax - movl (%eax), %eax - movl %eax, 4(%esp) - movl 8(%ebp), %eax - movl %eax, (%esp) - call _in_page - testb %al, %al - je L21 - movl 12(%ebp), %eax - movl %eax, 12(%esp) - movl $7, 8(%esp) - movl $7, 4(%esp) - movl $13, (%esp) - call _general_error - jmp L16 -L21: - movl $0, 12(%esp) - movl _rs_size, %eax - movl %eax, 8(%esp) - movl _stack_chain, %eax - movl 28(%eax), %eax - movl (%eax), %eax - movl %eax, 4(%esp) - movl 8(%ebp), %eax - movl %eax, (%esp) - call _in_page - testb %al, %al - je L23 - movl 12(%ebp), %eax - movl %eax, 12(%esp) - movl $7, 8(%esp) - movl $7, 4(%esp) - movl $14, (%esp) - call _general_error - jmp L16 -L23: - movl $0, 12(%esp) - movl $0, 8(%esp) - movl _nursery, %eax - movl 12(%eax), %eax - movl %eax, 4(%esp) - movl 8(%ebp), %eax - movl %eax, (%esp) - call _in_page - testb %al, %al - je L25 - movl $0, 4(%esp) - movl $LC5, (%esp) - call _critical_error - jmp L16 -L25: - movl $-1, 12(%esp) - movl $0, 8(%esp) - movl _gc_locals_region, %eax - movl (%eax), %eax - movl %eax, 4(%esp) - movl 8(%ebp), %eax - movl %eax, (%esp) - call _in_page - testb %al, %al - je L27 - movl $0, 4(%esp) - movl $LC6, (%esp) - call _critical_error - jmp L16 -L27: - movl $0, 12(%esp) - movl $0, 8(%esp) - movl _gc_locals_region, %eax - movl 8(%eax), %eax - movl %eax, 4(%esp) - movl 8(%ebp), %eax - movl %eax, (%esp) - call _in_page - testb %al, %al - je L29 - movl $0, 4(%esp) - movl $LC7, (%esp) - call _critical_error - jmp L16 -L29: - movl $-1, 12(%esp) - movl $0, 8(%esp) - movl _extra_roots_region, %eax - movl (%eax), %eax - movl %eax, 4(%esp) - movl 8(%ebp), %eax - movl %eax, (%esp) - call _in_page - testb %al, %al - je L31 - movl $0, 4(%esp) - movl $LC8, (%esp) - call _critical_error - jmp L16 -L31: - movl $0, 12(%esp) - movl $0, 8(%esp) - movl _extra_roots_region, %eax - movl 8(%eax), %eax - movl %eax, 4(%esp) - movl 8(%ebp), %eax - movl %eax, (%esp) - call _in_page - testb %al, %al - je L33 - movl $0, 4(%esp) - movl $LC9, (%esp) - call _critical_error - jmp L16 -L33: - movl 8(%ebp), %eax - movl %eax, (%esp) - call _allot_cell - movl %eax, %edx - movl 12(%ebp), %eax - movl %eax, 12(%esp) - movl $7, 8(%esp) - movl %edx, 4(%esp) - movl $15, (%esp) - call _general_error -L16: - leave - ret - .def _allot_cell; .scl 3; .type 32; .endef -_allot_cell: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - cmpl $268435455, 8(%ebp) - jbe L36 - movl 8(%ebp), %eax - movl %eax, (%esp) - call _cell_to_bignum - movl %eax, (%esp) - call _tag_bignum - movl %eax, -4(%ebp) - jmp L35 -L36: - movl 8(%ebp), %eax - movl %eax, (%esp) - call _tag_fixnum - movl %eax, -4(%ebp) -L35: - movl -4(%ebp), %eax - leave - ret - .def _tag_bignum; .scl 3; .type 32; .endef -_tag_bignum: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - andl $-8, %eax - orl $1, %eax - popl %ebp - ret -.globl _signal_error - .def _signal_error; .scl 2; .type 32; .endef -_signal_error: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - movl 8(%ebp), %eax - movl %eax, (%esp) - call _tag_fixnum - movl %eax, %edx - movl 12(%ebp), %eax - movl %eax, 12(%esp) - movl $7, 8(%esp) - movl %edx, 4(%esp) - movl $5, (%esp) - call _general_error - leave - ret -.globl _divide_by_zero_error - .def _divide_by_zero_error; .scl 2; .type 32; .endef -_divide_by_zero_error: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - movl 8(%ebp), %eax - movl %eax, 12(%esp) - movl $7, 8(%esp) - movl $7, 4(%esp) - movl $4, (%esp) - call _general_error - leave - ret -.globl _memory_signal_handler_impl - .def _memory_signal_handler_impl; .scl 2; .type 32; .endef -_memory_signal_handler_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl _signal_callstack_top, %eax - movl %eax, 4(%esp) - movl _signal_fault_addr, %eax - movl %eax, (%esp) - call _memory_protection_error - leave - ret -.globl _divide_by_zero_signal_handler_impl - .def _divide_by_zero_signal_handler_impl; .scl 2; .type 32; .endef -_divide_by_zero_signal_handler_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl _signal_callstack_top, %eax - movl %eax, (%esp) - call _divide_by_zero_error - leave - ret -.globl _misc_signal_handler_impl - .def _misc_signal_handler_impl; .scl 2; .type 32; .endef -_misc_signal_handler_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl _signal_callstack_top, %eax - movl %eax, 4(%esp) - movl _signal_number, %eax - movl %eax, (%esp) - call _signal_error - leave - ret -.globl _primitive_throw - .def _primitive_throw; .scl 2; .type 32; .endef -_primitive_throw: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_throw_impl - leave - ret - .def _primitive_throw_impl; .scl 3; .type 32; .endef -_primitive_throw_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpop - call _dpop - movl %eax, %ecx - movl _stack_chain, %eax - movl (%eax), %edx - movl %ecx, %eax - call _throw_impl - leave - ret - .def _dpop; .scl 3; .type 32; .endef -_dpop: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %esi, (%esp) - call _get - movl %eax, -4(%ebp) - subl $4, %esi - movl -4(%ebp), %eax - leave - ret - .def _get; .scl 3; .type 32; .endef -_get: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - movl (%eax), %eax - popl %ebp - ret -.globl _primitive_call_clear - .def _primitive_call_clear; .scl 2; .type 32; .endef -_primitive_call_clear: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_call_clear_impl - leave - ret - .def _primitive_call_clear_impl; .scl 3; .type 32; .endef -_primitive_call_clear_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpop - movl _stack_chain, %edx - movl 4(%edx), %edx - call _throw_impl - leave - ret -.globl _primitive_unimplemented2 - .def _primitive_unimplemented2; .scl 2; .type 32; .endef -_primitive_unimplemented2: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - call _not_implemented_error - leave - ret -.globl _primitive_unimplemented - .def _primitive_unimplemented; .scl 2; .type 32; .endef -_primitive_unimplemented: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_unimplemented_impl - leave - ret - .def _primitive_unimplemented_impl; .scl 3; .type 32; .endef -_primitive_unimplemented_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _not_implemented_error - leave - ret - .comm _console_open, 16 # 1 - .comm _userenv, 256 # 256 - .comm _T, 16 # 4 - .comm _stack_chain, 16 # 4 - .comm _ds_size, 16 # 4 - .comm _rs_size, 16 # 4 - .comm _stage2, 16 # 1 - .comm _profiling_p, 16 # 1 - .comm _signal_number, 16 # 4 - .comm _signal_fault_addr, 16 # 4 - .comm _signal_callstack_top, 16 # 4 - .comm _secure_gc, 16 # 1 - .comm _data_heap, 16 # 4 - .comm _cards_offset, 16 # 4 - .comm _newspace, 16 # 4 - .comm _nursery, 16 # 4 - .comm _gc_time, 16 # 8 - .comm _nursery_collections, 16 # 4 - .comm _aging_collections, 16 # 4 - .comm _cards_scanned, 16 # 4 - .comm _performing_gc, 16 # 1 - .comm _collecting_gen, 16 # 4 - .comm _collecting_aging_again, 16 # 1 - .comm _last_code_heap_scan, 16 # 4 - .comm _growing_data_heap, 16 # 1 - .comm _old_data_heap, 16 # 4 - .comm _gc_jmp, 208 # 208 - .comm _heap_scan_ptr, 16 # 4 - .comm _gc_off, 16 # 1 - .comm _gc_locals_region, 16 # 4 - .comm _gc_locals, 16 # 4 - .comm _extra_roots_region, 16 # 4 - .comm _extra_roots, 16 # 4 - .comm _bignum_zero, 16 # 4 - .comm _bignum_pos_one, 16 # 4 - .comm _bignum_neg_one, 16 # 4 - .comm _code_heap, 16 # 8 - .comm _data_relocation_base, 16 # 4 - .comm _code_relocation_base, 16 # 4 - .comm _posix_argc, 16 # 4 - .comm _posix_argv, 16 # 4 - .def _save_callstack_top; .scl 3; .type 32; .endef - .def _getpagesize; .scl 3; .type 32; .endef - .def _allot_array_4; .scl 3; .type 32; .endef - .def _print_obj; .scl 3; .type 32; .endef - .def _throw_impl; .scl 3; .type 32; .endef - .def _fix_callstack_top; .scl 3; .type 32; .endef - .def _fix_stacks; .scl 3; .type 32; .endef - .def _factorbug; .scl 3; .type 32; .endef - .def _exit; .scl 3; .type 32; .endef - .def ___getreent; .scl 3; .type 32; .endef - .def _fprintf; .scl 3; .type 32; .endef - .def _critical_error; .scl 3; .type 32; .endef - .def _type_error; .scl 3; .type 32; .endef - .section .drectve - - .ascii " -export:nursery,data" - .ascii " -export:cards_offset,data" - .ascii " -export:stack_chain,data" - .ascii " -export:userenv,data" diff --git a/vm/run.s b/vm/run.s deleted file mode 100644 index 78b2adac84..0000000000 --- a/vm/run.s +++ /dev/null @@ -1,1511 +0,0 @@ - .file "run.c" - .text -.globl _reset_datastack - .def _reset_datastack; .scl 2; .type 32; .endef -_reset_datastack: - pushl %ebp - movl %esp, %ebp - movl _stack_chain, %eax - movl 24(%eax), %eax - movl (%eax), %esi - subl $4, %esi - popl %ebp - ret -.globl _reset_retainstack - .def _reset_retainstack; .scl 2; .type 32; .endef -_reset_retainstack: - pushl %ebp - movl %esp, %ebp - movl _stack_chain, %eax - movl 28(%eax), %eax - movl (%eax), %edi - subl $4, %edi - popl %ebp - ret -.globl _fix_stacks - .def _fix_stacks; .scl 2; .type 32; .endef -_fix_stacks: - pushl %ebp - movl %esp, %ebp - leal 4(%esi), %eax - movl _stack_chain, %edx - movl 24(%edx), %edx - cmpl (%edx), %eax - jb L5 - leal 256(%esi), %eax - movl _stack_chain, %edx - movl 24(%edx), %edx - cmpl 8(%edx), %eax - jae L5 - jmp L4 -L5: - call _reset_datastack -L4: - leal 4(%edi), %eax - movl _stack_chain, %edx - movl 28(%edx), %edx - cmpl (%edx), %eax - jb L7 - leal 256(%edi), %eax - movl _stack_chain, %edx - movl 28(%edx), %edx - cmpl 8(%edx), %eax - jae L7 - jmp L3 -L7: - call _reset_retainstack -L3: - popl %ebp - ret -.globl _save_stacks - .def _save_stacks; .scl 2; .type 32; .endef -_save_stacks: - pushl %ebp - movl %esp, %ebp - cmpl $0, _stack_chain - je L8 - movl _stack_chain, %eax - movl %esi, 8(%eax) - movl _stack_chain, %eax - movl %edi, 12(%eax) -L8: - popl %ebp - ret -.globl _nest_stacks - .def _nest_stacks; .scl 2; .type 32; .endef -_nest_stacks: - pushl %ebp - movl %esp, %ebp - pushl %ebx - subl $20, %esp - movl $44, (%esp) - call _safe_malloc - movl %eax, -8(%ebp) - movl -8(%ebp), %eax - movl $-1, 4(%eax) - movl -8(%ebp), %eax - movl $-1, (%eax) - movl -8(%ebp), %eax - movl %esi, 16(%eax) - movl -8(%ebp), %eax - movl %edi, 20(%eax) - movl -8(%ebp), %edx - movl _userenv+8, %eax - movl %eax, 36(%edx) - movl -8(%ebp), %edx - movl _userenv+4, %eax - movl %eax, 32(%edx) - movl -8(%ebp), %ebx - movl _ds_size, %eax - movl %eax, (%esp) - call _alloc_segment - movl %eax, 24(%ebx) - movl -8(%ebp), %ebx - movl _rs_size, %eax - movl %eax, (%esp) - call _alloc_segment - movl %eax, 28(%ebx) - movl -8(%ebp), %edx - movl _stack_chain, %eax - movl %eax, 40(%edx) - movl -8(%ebp), %eax - movl %eax, _stack_chain - call _reset_datastack - call _reset_retainstack - addl $20, %esp - popl %ebx - popl %ebp - ret -.globl _unnest_stacks - .def _unnest_stacks; .scl 2; .type 32; .endef -_unnest_stacks: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl _stack_chain, %eax - movl 24(%eax), %eax - movl %eax, (%esp) - call _dealloc_segment - movl _stack_chain, %eax - movl 28(%eax), %eax - movl %eax, (%esp) - call _dealloc_segment - movl _stack_chain, %eax - movl 16(%eax), %esi - movl _stack_chain, %eax - movl 20(%eax), %edi - movl _stack_chain, %eax - movl 36(%eax), %eax - movl %eax, _userenv+8 - movl _stack_chain, %eax - movl 32(%eax), %eax - movl %eax, _userenv+4 - movl _stack_chain, %eax - movl %eax, -4(%ebp) - movl -4(%ebp), %eax - movl 40(%eax), %eax - movl %eax, _stack_chain - movl -4(%ebp), %eax - movl %eax, (%esp) - call _free - leave - ret -.globl _init_stacks - .def _init_stacks; .scl 2; .type 32; .endef -_init_stacks: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - movl %eax, _ds_size - movl 12(%ebp), %eax - movl %eax, _rs_size - movl $0, _stack_chain - popl %ebp - ret -.globl _primitive_drop - .def _primitive_drop; .scl 2; .type 32; .endef -_primitive_drop: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_drop_impl - leave - ret - .def _primitive_drop_impl; .scl 3; .type 32; .endef -_primitive_drop_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpop - leave - ret - .def _dpop; .scl 3; .type 32; .endef -_dpop: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %esi, (%esp) - call _get - movl %eax, -4(%ebp) - subl $4, %esi - movl -4(%ebp), %eax - leave - ret - .def _get; .scl 3; .type 32; .endef -_get: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - movl (%eax), %eax - popl %ebp - ret -.globl _primitive_2drop - .def _primitive_2drop; .scl 2; .type 32; .endef -_primitive_2drop: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_2drop_impl - leave - ret - .def _primitive_2drop_impl; .scl 3; .type 32; .endef -_primitive_2drop_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esi - popl %ebp - ret -.globl _primitive_3drop - .def _primitive_3drop; .scl 2; .type 32; .endef -_primitive_3drop: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_3drop_impl - leave - ret - .def _primitive_3drop_impl; .scl 3; .type 32; .endef -_primitive_3drop_impl: - pushl %ebp - movl %esp, %ebp - subl $12, %esi - popl %ebp - ret -.globl _primitive_dup - .def _primitive_dup; .scl 2; .type 32; .endef -_primitive_dup: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_dup_impl - leave - ret - .def _primitive_dup_impl; .scl 3; .type 32; .endef -_primitive_dup_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpeek - movl %eax, (%esp) - call _dpush - leave - ret - .def _dpush; .scl 3; .type 32; .endef -_dpush: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - addl $4, %esi - movl 8(%ebp), %eax - movl %eax, 4(%esp) - movl %esi, (%esp) - call _put - leave - ret - .def _put; .scl 3; .type 32; .endef -_put: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %edx - movl 12(%ebp), %eax - movl %eax, (%edx) - popl %ebp - ret - .def _dpeek; .scl 3; .type 32; .endef -_dpeek: - pushl %ebp - movl %esp, %ebp - subl $4, %esp - movl %esi, (%esp) - call _get - leave - ret -.globl _primitive_2dup - .def _primitive_2dup; .scl 2; .type 32; .endef -_primitive_2dup: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_2dup_impl - leave - ret - .def _primitive_2dup_impl; .scl 3; .type 32; .endef -_primitive_2dup_impl: - pushl %ebp - movl %esp, %ebp - subl $16, %esp - call _dpeek - movl %eax, -4(%ebp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -8(%ebp) - addl $8, %esi - movl -8(%ebp), %eax - movl %eax, 4(%esp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _put - movl -4(%ebp), %eax - movl %eax, 4(%esp) - movl %esi, (%esp) - call _put - leave - ret -.globl _primitive_3dup - .def _primitive_3dup; .scl 2; .type 32; .endef -_primitive_3dup: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_3dup_impl - leave - ret - .def _primitive_3dup_impl; .scl 3; .type 32; .endef -_primitive_3dup_impl: - pushl %ebp - movl %esp, %ebp - subl $20, %esp - call _dpeek - movl %eax, -4(%ebp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -8(%ebp) - leal -8(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -12(%ebp) - addl $12, %esi - movl -4(%ebp), %eax - movl %eax, 4(%esp) - movl %esi, (%esp) - call _put - movl -8(%ebp), %eax - movl %eax, 4(%esp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _put - movl -12(%ebp), %eax - movl %eax, 4(%esp) - leal -8(%esi), %eax - movl %eax, (%esp) - call _put - leave - ret -.globl _primitive_rot - .def _primitive_rot; .scl 2; .type 32; .endef -_primitive_rot: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_rot_impl - leave - ret - .def _primitive_rot_impl; .scl 3; .type 32; .endef -_primitive_rot_impl: - pushl %ebp - movl %esp, %ebp - subl $20, %esp - call _dpeek - movl %eax, -4(%ebp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -8(%ebp) - leal -8(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -12(%ebp) - movl -12(%ebp), %eax - movl %eax, 4(%esp) - movl %esi, (%esp) - call _put - movl -4(%ebp), %eax - movl %eax, 4(%esp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _put - movl -8(%ebp), %eax - movl %eax, 4(%esp) - leal -8(%esi), %eax - movl %eax, (%esp) - call _put - leave - ret -.globl _primitive__rot - .def _primitive__rot; .scl 2; .type 32; .endef -_primitive__rot: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive__rot_impl - leave - ret - .def _primitive__rot_impl; .scl 3; .type 32; .endef -_primitive__rot_impl: - pushl %ebp - movl %esp, %ebp - subl $20, %esp - call _dpeek - movl %eax, -4(%ebp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -8(%ebp) - leal -8(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -12(%ebp) - movl -8(%ebp), %eax - movl %eax, 4(%esp) - movl %esi, (%esp) - call _put - movl -12(%ebp), %eax - movl %eax, 4(%esp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _put - movl -4(%ebp), %eax - movl %eax, 4(%esp) - leal -8(%esi), %eax - movl %eax, (%esp) - call _put - leave - ret -.globl _primitive_dupd - .def _primitive_dupd; .scl 2; .type 32; .endef -_primitive_dupd: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_dupd_impl - leave - ret - .def _primitive_dupd_impl; .scl 3; .type 32; .endef -_primitive_dupd_impl: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - call _dpeek - movl %eax, -4(%ebp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -8(%ebp) - movl -8(%ebp), %eax - movl %eax, 4(%esp) - movl %esi, (%esp) - call _put - movl -8(%ebp), %eax - movl %eax, 4(%esp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _put - movl -4(%ebp), %eax - movl %eax, (%esp) - call _dpush - leave - ret -.globl _primitive_swapd - .def _primitive_swapd; .scl 2; .type 32; .endef -_primitive_swapd: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_swapd_impl - leave - ret - .def _primitive_swapd_impl; .scl 3; .type 32; .endef -_primitive_swapd_impl: - pushl %ebp - movl %esp, %ebp - subl $16, %esp - leal -4(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -4(%ebp) - leal -8(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -8(%ebp) - movl -8(%ebp), %eax - movl %eax, 4(%esp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _put - movl -4(%ebp), %eax - movl %eax, 4(%esp) - leal -8(%esi), %eax - movl %eax, (%esp) - call _put - leave - ret -.globl _primitive_nip - .def _primitive_nip; .scl 2; .type 32; .endef -_primitive_nip: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_nip_impl - leave - ret - .def _primitive_nip_impl; .scl 3; .type 32; .endef -_primitive_nip_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpop - movl %eax, -4(%ebp) - movl -4(%ebp), %eax - movl %eax, (%esp) - call _drepl - leave - ret - .def _drepl; .scl 3; .type 32; .endef -_drepl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl 8(%ebp), %eax - movl %eax, 4(%esp) - movl %esi, (%esp) - call _put - leave - ret -.globl _primitive_2nip - .def _primitive_2nip; .scl 2; .type 32; .endef -_primitive_2nip: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_2nip_impl - leave - ret - .def _primitive_2nip_impl; .scl 3; .type 32; .endef -_primitive_2nip_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpeek - movl %eax, -4(%ebp) - subl $8, %esi - movl -4(%ebp), %eax - movl %eax, (%esp) - call _drepl - leave - ret -.globl _primitive_tuck - .def _primitive_tuck; .scl 2; .type 32; .endef -_primitive_tuck: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_tuck_impl - leave - ret - .def _primitive_tuck_impl; .scl 3; .type 32; .endef -_primitive_tuck_impl: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - call _dpeek - movl %eax, -4(%ebp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -8(%ebp) - movl -8(%ebp), %eax - movl %eax, 4(%esp) - movl %esi, (%esp) - call _put - movl -4(%ebp), %eax - movl %eax, 4(%esp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _put - movl -4(%ebp), %eax - movl %eax, (%esp) - call _dpush - leave - ret -.globl _primitive_over - .def _primitive_over; .scl 2; .type 32; .endef -_primitive_over: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_over_impl - leave - ret - .def _primitive_over_impl; .scl 3; .type 32; .endef -_primitive_over_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - leal -4(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, (%esp) - call _dpush - leave - ret -.globl _primitive_pick - .def _primitive_pick; .scl 2; .type 32; .endef -_primitive_pick: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_pick_impl - leave - ret - .def _primitive_pick_impl; .scl 3; .type 32; .endef -_primitive_pick_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - leal -8(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, (%esp) - call _dpush - leave - ret -.globl _primitive_swap - .def _primitive_swap; .scl 2; .type 32; .endef -_primitive_swap: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_swap_impl - leave - ret - .def _primitive_swap_impl; .scl 3; .type 32; .endef -_primitive_swap_impl: - pushl %ebp - movl %esp, %ebp - subl $16, %esp - call _dpeek - movl %eax, -4(%ebp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _get - movl %eax, -8(%ebp) - movl -8(%ebp), %eax - movl %eax, 4(%esp) - movl %esi, (%esp) - call _put - movl -4(%ebp), %eax - movl %eax, 4(%esp) - leal -4(%esi), %eax - movl %eax, (%esp) - call _put - leave - ret -.globl _primitive_to_r - .def _primitive_to_r; .scl 2; .type 32; .endef -_primitive_to_r: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_to_r_impl - leave - ret - .def _primitive_to_r_impl; .scl 3; .type 32; .endef -_primitive_to_r_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpop - movl %eax, (%esp) - call _rpush - leave - ret - .def _rpush; .scl 3; .type 32; .endef -_rpush: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - addl $4, %edi - movl 8(%ebp), %eax - movl %eax, 4(%esp) - movl %edi, (%esp) - call _put - leave - ret -.globl _primitive_from_r - .def _primitive_from_r; .scl 2; .type 32; .endef -_primitive_from_r: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_from_r_impl - leave - ret - .def _primitive_from_r_impl; .scl 3; .type 32; .endef -_primitive_from_r_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _rpop - movl %eax, (%esp) - call _dpush - leave - ret - .def _rpop; .scl 3; .type 32; .endef -_rpop: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %edi, (%esp) - call _get - movl %eax, -4(%ebp) - subl $4, %edi - movl -4(%ebp), %eax - leave - ret -.globl _stack_to_array - .def _stack_to_array; .scl 2; .type 32; .endef -_stack_to_array: - pushl %ebp - movl %esp, %ebp - subl $40, %esp - movl 8(%ebp), %edx - movl 12(%ebp), %eax - subl %edx, %eax - addl $4, %eax - movl %eax, -4(%ebp) - cmpl $0, -4(%ebp) - jns L58 - movl $0, -12(%ebp) - jmp L57 -L58: - movl -4(%ebp), %eax - movl %eax, -16(%ebp) - cmpl $0, -16(%ebp) - jns L60 - addl $3, -16(%ebp) -L60: - movl -16(%ebp), %eax - sarl $2, %eax - movl %eax, 4(%esp) - movl $8, (%esp) - call _allot_array_internal - movl %eax, -8(%ebp) - movl -4(%ebp), %eax - movl %eax, 8(%esp) - movl 8(%ebp), %eax - movl %eax, 4(%esp) - movl -8(%ebp), %eax - addl $8, %eax - movl %eax, (%esp) - call _memcpy - movl -8(%ebp), %eax - movl %eax, (%esp) - call _tag_object - movl %eax, (%esp) - call _dpush - movl $1, -12(%ebp) -L57: - movl -12(%ebp), %eax - leave - ret - .def _tag_object; .scl 3; .type 32; .endef -_tag_object: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - andl $-8, %eax - orl $3, %eax - popl %ebp - ret -.globl _primitive_datastack - .def _primitive_datastack; .scl 2; .type 32; .endef -_primitive_datastack: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_datastack_impl - leave - ret - .def _primitive_datastack_impl; .scl 3; .type 32; .endef -_primitive_datastack_impl: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - movl %esi, 4(%esp) - movl _stack_chain, %eax - movl 24(%eax), %eax - movl (%eax), %eax - movl %eax, (%esp) - call _stack_to_array - testb %al, %al - jne L63 - movl $0, 12(%esp) - movl $7, 8(%esp) - movl $7, 4(%esp) - movl $11, (%esp) - call _general_error -L63: - leave - ret -.globl _primitive_retainstack - .def _primitive_retainstack; .scl 2; .type 32; .endef -_primitive_retainstack: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_retainstack_impl - leave - ret - .def _primitive_retainstack_impl; .scl 3; .type 32; .endef -_primitive_retainstack_impl: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - movl %edi, 4(%esp) - movl _stack_chain, %eax - movl 28(%eax), %eax - movl (%eax), %eax - movl %eax, (%esp) - call _stack_to_array - testb %al, %al - jne L66 - movl $0, 12(%esp) - movl $7, 8(%esp) - movl $7, 4(%esp) - movl $13, (%esp) - call _general_error -L66: - leave - ret -.globl _array_to_stack - .def _array_to_stack; .scl 2; .type 32; .endef -_array_to_stack: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - movl 8(%ebp), %eax - movl %eax, (%esp) - call _array_capacity - sall $2, %eax - movl %eax, -4(%ebp) - movl -4(%ebp), %eax - movl %eax, 8(%esp) - movl 8(%ebp), %eax - addl $8, %eax - movl %eax, 4(%esp) - movl 12(%ebp), %eax - movl %eax, (%esp) - call _memcpy - movl -4(%ebp), %eax - addl 12(%ebp), %eax - subl $4, %eax - leave - ret - .def _array_capacity; .scl 3; .type 32; .endef -_array_capacity: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - movl 4(%eax), %eax - shrl $3, %eax - popl %ebp - ret -.globl _primitive_set_datastack - .def _primitive_set_datastack; .scl 2; .type 32; .endef -_primitive_set_datastack: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_set_datastack_impl - leave - ret - .def _primitive_set_datastack_impl; .scl 3; .type 32; .endef -_primitive_set_datastack_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpop - movl %eax, (%esp) - call _untag_array - movl %eax, %edx - movl _stack_chain, %eax - movl 24(%eax), %eax - movl (%eax), %eax - movl %eax, 4(%esp) - movl %edx, (%esp) - call _array_to_stack - movl %eax, %esi - leave - ret - .def _untag_array; .scl 3; .type 32; .endef -_untag_array: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl 8(%ebp), %eax - movl %eax, 4(%esp) - movl $8, (%esp) - call _type_check - movl 8(%ebp), %eax - movl %eax, (%esp) - call _untag_object - leave - ret - .def _untag_object; .scl 3; .type 32; .endef -_untag_object: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - andl $-8, %eax - popl %ebp - ret - .def _type_check; .scl 3; .type 32; .endef -_type_check: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl 12(%ebp), %eax - movl %eax, (%esp) - call _type_of - cmpl 8(%ebp), %eax - je L74 - movl 12(%ebp), %eax - movl %eax, 4(%esp) - movl 8(%ebp), %eax - movl %eax, (%esp) - call _type_error -L74: - leave - ret - .def _type_of; .scl 3; .type 32; .endef -_type_of: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - movl 8(%ebp), %eax - andl $7, %eax - movl %eax, -4(%ebp) - cmpl $3, -4(%ebp) - jne L77 - movl 8(%ebp), %eax - movl %eax, (%esp) - call _object_type - movl %eax, -8(%ebp) - jmp L76 -L77: - movl -4(%ebp), %eax - movl %eax, -8(%ebp) -L76: - movl -8(%ebp), %eax - leave - ret - .def _object_type; .scl 3; .type 32; .endef -_object_type: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl 8(%ebp), %eax - andl $-8, %eax - movl %eax, (%esp) - call _get - movl %eax, (%esp) - call _untag_header - leave - ret - .def _untag_header; .scl 3; .type 32; .endef -_untag_header: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - shrl $3, %eax - popl %ebp - ret -.globl _primitive_set_retainstack - .def _primitive_set_retainstack; .scl 2; .type 32; .endef -_primitive_set_retainstack: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_set_retainstack_impl - leave - ret - .def _primitive_set_retainstack_impl; .scl 3; .type 32; .endef -_primitive_set_retainstack_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpop - movl %eax, (%esp) - call _untag_array - movl %eax, %edx - movl _stack_chain, %eax - movl 28(%eax), %eax - movl (%eax), %eax - movl %eax, 4(%esp) - movl %edx, (%esp) - call _array_to_stack - movl %eax, %edi - leave - ret -.globl _primitive_getenv - .def _primitive_getenv; .scl 2; .type 32; .endef -_primitive_getenv: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_getenv_impl - leave - ret - .def _primitive_getenv_impl; .scl 3; .type 32; .endef -_primitive_getenv_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpeek - movl %eax, (%esp) - call _untag_fixnum_fast - movl %eax, -4(%ebp) - movl -4(%ebp), %eax - movl _userenv(,%eax,4), %eax - movl %eax, (%esp) - call _drepl - leave - ret - .def _untag_fixnum_fast; .scl 3; .type 32; .endef -_untag_fixnum_fast: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - sarl $3, %eax - popl %ebp - ret -.globl _primitive_setenv - .def _primitive_setenv; .scl 2; .type 32; .endef -_primitive_setenv: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_setenv_impl - leave - ret - .def _primitive_setenv_impl; .scl 3; .type 32; .endef -_primitive_setenv_impl: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - call _dpop - movl %eax, (%esp) - call _untag_fixnum_fast - movl %eax, -4(%ebp) - call _dpop - movl %eax, -8(%ebp) - movl -4(%ebp), %edx - movl -8(%ebp), %eax - movl %eax, _userenv(,%edx,4) - leave - ret -.globl _primitive_exit - .def _primitive_exit; .scl 2; .type 32; .endef -_primitive_exit: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_exit_impl - leave - ret - .def _primitive_exit_impl; .scl 3; .type 32; .endef -_primitive_exit_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpop - movl %eax, (%esp) - call _to_fixnum - movl %eax, (%esp) - call _exit -.globl _primitive_os_env - .def _primitive_os_env; .scl 2; .type 32; .endef -_primitive_os_env: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_os_env_impl - leave - ret - .def _primitive_os_env_impl; .scl 3; .type 32; .endef -_primitive_os_env_impl: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - call _unbox_char_string - movl %eax, -4(%ebp) - movl -4(%ebp), %eax - movl %eax, (%esp) - call _getenv - movl %eax, -8(%ebp) - cmpl $0, -8(%ebp) - jne L92 - movl $7, (%esp) - call _dpush - jmp L91 -L92: - movl -8(%ebp), %eax - movl %eax, (%esp) - call _box_char_string -L91: - leave - ret -.globl _primitive_eq - .def _primitive_eq; .scl 2; .type 32; .endef -_primitive_eq: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_eq_impl - leave - ret - .def _primitive_eq_impl; .scl 3; .type 32; .endef -_primitive_eq_impl: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - call _dpop - movl %eax, -4(%ebp) - call _dpeek - movl %eax, -8(%ebp) - movl -4(%ebp), %eax - cmpl -8(%ebp), %eax - jne L96 - movl _T, %eax - movl %eax, -12(%ebp) - jmp L97 -L96: - movl $7, -12(%ebp) -L97: - movl -12(%ebp), %eax - movl %eax, (%esp) - call _drepl - leave - ret -.globl _primitive_millis - .def _primitive_millis; .scl 2; .type 32; .endef -_primitive_millis: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_millis_impl - leave - ret - .def _primitive_millis_impl; .scl 3; .type 32; .endef -_primitive_millis_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _current_millis - movl %eax, (%esp) - movl %edx, 4(%esp) - call _box_unsigned_8 - leave - ret -.globl _primitive_sleep - .def _primitive_sleep; .scl 2; .type 32; .endef -_primitive_sleep: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_sleep_impl - leave - ret - .def _primitive_sleep_impl; .scl 3; .type 32; .endef -_primitive_sleep_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpop - movl %eax, (%esp) - call _to_cell - movl %eax, (%esp) - call _sleep_millis - leave - ret -.globl _primitive_tag - .def _primitive_tag; .scl 2; .type 32; .endef -_primitive_tag: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_tag_impl - leave - ret - .def _primitive_tag_impl; .scl 3; .type 32; .endef -_primitive_tag_impl: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - call _dpeek - andl $7, %eax - movl %eax, (%esp) - call _tag_fixnum - movl %eax, (%esp) - call _drepl - leave - ret - .def _tag_fixnum; .scl 3; .type 32; .endef -_tag_fixnum: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - sall $3, %eax - andl $-8, %eax - popl %ebp - ret -.globl _primitive_slot - .def _primitive_slot; .scl 2; .type 32; .endef -_primitive_slot: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_slot_impl - leave - ret - .def _primitive_slot_impl; .scl 3; .type 32; .endef -_primitive_slot_impl: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - call _dpop - movl %eax, (%esp) - call _untag_fixnum_fast - movl %eax, -4(%ebp) - call _dpop - movl %eax, -8(%ebp) - movl -8(%ebp), %edx - andl $-8, %edx - movl -4(%ebp), %eax - sall $2, %eax - leal (%edx,%eax), %eax - movl %eax, (%esp) - call _get - movl %eax, (%esp) - call _dpush - leave - ret -.globl _primitive_set_slot - .def _primitive_set_slot; .scl 2; .type 32; .endef -_primitive_set_slot: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl %eax, -4(%ebp) - movl %edx, -8(%ebp) - movl -8(%ebp), %eax - call _save_callstack_top - call _primitive_set_slot_impl - leave - ret - .def _primitive_set_slot_impl; .scl 3; .type 32; .endef -_primitive_set_slot_impl: - pushl %ebp - movl %esp, %ebp - subl $24, %esp - call _dpop - movl %eax, (%esp) - call _untag_fixnum_fast - movl %eax, -4(%ebp) - call _dpop - movl %eax, -8(%ebp) - call _dpop - movl %eax, -12(%ebp) - movl -12(%ebp), %eax - movl %eax, 8(%esp) - movl -4(%ebp), %eax - movl %eax, 4(%esp) - movl -8(%ebp), %eax - movl %eax, (%esp) - call _set_slot - leave - ret - .def _set_slot; .scl 3; .type 32; .endef -_set_slot: - pushl %ebp - movl %esp, %ebp - subl $8, %esp - movl 16(%ebp), %eax - movl %eax, 4(%esp) - movl 8(%ebp), %edx - andl $-8, %edx - movl 12(%ebp), %eax - sall $2, %eax - leal (%edx,%eax), %eax - movl %eax, (%esp) - call _put - movl 8(%ebp), %eax - movl %eax, (%esp) - call _write_barrier - leave - ret - .def _write_barrier; .scl 3; .type 32; .endef -_write_barrier: - pushl %ebp - movl %esp, %ebp - subl $4, %esp - movl 8(%ebp), %eax - shrl $6, %eax - addl _cards_offset, %eax - movl %eax, -4(%ebp) - movl -4(%ebp), %edx - movl -4(%ebp), %eax - movzbl (%eax), %eax - orb $-64, %al - movb %al, (%edx) - leave - ret - .comm _console_open, 16 # 1 - .comm _userenv, 256 # 256 - .comm _T, 16 # 4 - .comm _stack_chain, 16 # 4 - .comm _ds_size, 16 # 4 - .comm _rs_size, 16 # 4 - .comm _stage2, 16 # 1 - .comm _profiling_p, 16 # 1 - .comm _signal_number, 16 # 4 - .comm _signal_fault_addr, 16 # 4 - .comm _signal_callstack_top, 16 # 4 - .comm _secure_gc, 16 # 1 - .comm _data_heap, 16 # 4 - .comm _cards_offset, 16 # 4 - .comm _newspace, 16 # 4 - .comm _nursery, 16 # 4 - .comm _gc_time, 16 # 8 - .comm _nursery_collections, 16 # 4 - .comm _aging_collections, 16 # 4 - .comm _cards_scanned, 16 # 4 - .comm _performing_gc, 16 # 1 - .comm _collecting_gen, 16 # 4 - .comm _collecting_aging_again, 16 # 1 - .comm _last_code_heap_scan, 16 # 4 - .comm _growing_data_heap, 16 # 1 - .comm _old_data_heap, 16 # 4 - .comm _gc_jmp, 208 # 208 - .comm _heap_scan_ptr, 16 # 4 - .comm _gc_off, 16 # 1 - .comm _gc_locals_region, 16 # 4 - .comm _gc_locals, 16 # 4 - .comm _extra_roots_region, 16 # 4 - .comm _extra_roots, 16 # 4 - .comm _bignum_zero, 16 # 4 - .comm _bignum_pos_one, 16 # 4 - .comm _bignum_neg_one, 16 # 4 - .comm _code_heap, 16 # 8 - .comm _data_relocation_base, 16 # 4 - .comm _code_relocation_base, 16 # 4 - .comm _posix_argc, 16 # 4 - .comm _posix_argv, 16 # 4 - .def _sleep_millis; .scl 3; .type 32; .endef - .def _current_millis; .scl 3; .type 32; .endef - .def _getenv; .scl 3; .type 32; .endef - .def _exit; .scl 3; .type 32; .endef - .def _general_error; .scl 3; .type 32; .endef - .def _memcpy; .scl 3; .type 32; .endef - .def _allot_array_internal; .scl 3; .type 32; .endef - .def _save_callstack_top; .scl 3; .type 32; .endef - .def _free; .scl 3; .type 32; .endef - .def _dealloc_segment; .scl 3; .type 32; .endef - .def _alloc_segment; .scl 3; .type 32; .endef - .def _safe_malloc; .scl 3; .type 32; .endef - .def _type_error; .scl 3; .type 32; .endef - .section .drectve - - .ascii " -export:nursery,data" - .ascii " -export:cards_offset,data" - .ascii " -export:stack_chain,data" - .ascii " -export:userenv,data" - .ascii " -export:unnest_stacks" - .ascii " -export:nest_stacks" - .ascii " -export:save_stacks"