diff --git a/Makefile b/Makefile index dd2e83985e..f9eb353a34 100755 --- a/Makefile +++ b/Makefile @@ -31,6 +31,7 @@ ifdef CONFIG endif DLL_OBJS = $(PLAF_DLL_OBJS) \ + vm/aging_collector.o \ vm/alien.o \ vm/arrays.o \ vm/bignum.o \ @@ -40,29 +41,31 @@ DLL_OBJS = $(PLAF_DLL_OBJS) \ vm/code_block.o \ vm/code_heap.o \ vm/contexts.o \ - vm/data_gc.o \ vm/data_heap.o \ vm/debug.o \ vm/dispatch.o \ vm/errors.o \ vm/factor.o \ + vm/full_collector.o \ + vm/gc.o \ vm/heap.o \ vm/image.o \ vm/inline_cache.o \ vm/io.o \ vm/jit.o \ - vm/local_roots.o \ vm/math.o \ + vm/nursery_collector.o \ + vm/old_space.o \ vm/primitives.o \ vm/profiler.o \ vm/quotations.o \ vm/run.o \ vm/strings.o \ + vm/to_tenured_collector.o \ vm/tuples.o \ vm/utilities.o \ vm/vm.o \ - vm/words.o \ - vm/write_barrier.o + vm/words.o EXE_OBJS = $(PLAF_EXE_OBJS) diff --git a/README.txt b/README.txt deleted file mode 100755 index 016d60e68c..0000000000 --- a/README.txt +++ /dev/null @@ -1,154 +0,0 @@ -The Factor programming language -------------------------------- - -This file covers installation and basic usage of the Factor -implementation. It is not an introduction to the language itself. - -* Contents - -- Compiling the Factor VM -- Libraries needed for compilation -- Bootstrapping the Factor image -- Running Factor on Unix with X11 -- Running Factor on Mac OS X - Cocoa UI -- Running Factor on Mac OS X - X11 UI -- Running Factor on Windows -- Command line usage -- The Factor FAQ -- Source organization -- Community - -* Compiling the Factor VM - -Factor supports various platforms. For an up-to-date list, see -. - -The Factor VM is written in C++ and uses GNU extensions. When compiling -with GCC 3.x, boost::unordered_map must be installed. On GCC 4.x, Factor -uses std::tr1::unordered_map which is shipped as part of GCC. - -Run 'make' ('gmake' on *BSD) with no parameters to build the Factor VM. - -* Bootstrapping the Factor image - -Once you have compiled the Factor VM, you must bootstrap the Factor -system using the image that corresponds to your CPU architecture. - -Boot images can be obtained from . - -Once you download the right image, bootstrap Factor with the -following command line: - -./factor -i=boot..image - -Bootstrap can take a while, depending on your system. When the process -completes, a 'factor.image' file will be generated. Note that this image -is both CPU and OS-specific, so in general cannot be shared between -machines. - -* Running Factor on Unix with X11 - -On Unix, Factor can either run a graphical user interface using X11, or -a terminal listener. - -For X11 support, you need recent development libraries for libc, -Pango, X11, and OpenGL. On a Debian-derived Linux distribution -(like Ubuntu), you can use the following line to grab everything: - - sudo apt-get install libc6-dev libpango1.0-dev libx11-dev libgl1-mesa-dev - -Note that if you are using a proprietary OpenGL driver, you should -probably leave out the last package in the list. - -If your DISPLAY environment variable is set, the UI will start -automatically when you run Factor: - - ./factor - -To run an interactive terminal listener: - - ./factor -run=listener - -* Running Factor on Mac OS X - Cocoa UI - -On Mac OS X, a Cocoa UI is available in addition to the terminal -listener. - -The 'factor' executable runs the terminal listener: - - ./factor - -The 'Factor.app' bundle runs the Cocoa UI. Note that this is not a -self-contained bundle, it must be run from the same directory which -contains factor.image and the library sources. - -* Running Factor on Mac OS X - X11 UI - -The X11 UI is also available on Mac OS X, however its use is not -recommended since it does not integrate with the host OS. - -When compiling Factor, pass the X11=1 parameter: - - make X11=1 - -Then bootstrap with the following switches: - - ./factor -i=boot..image -ui-backend=x11 - -Now if $DISPLAY is set, running ./factor will start the UI. - -* Running Factor on Windows XP/Vista - -The Factor runtime is compiled into two binaries: - - factor.com - a Windows console application - factor.exe - a Windows native application, without a console - -If you did not download the binary package, you can bootstrap Factor in -the command prompt using the console application: - - factor.com -i=boot..image - -Once bootstrapped, double-clicking factor.exe or factor.com starts -the Factor UI. - -To run the listener in the command prompt: - - factor.com -run=listener - -* The Factor FAQ - -The Factor FAQ is available at the following location: - - - -* Command line usage - -Factor supports a number of command line switches. To read command line -usage documentation, enter the following in the UI listener: - - "command-line" about - -* Source organization - -The Factor source tree is organized as follows: - - build-support/ - scripts used for compiling Factor - vm/ - Factor VM - core/ - Factor core library - basis/ - Factor basis library, compiler, tools - extra/ - more libraries and applications - misc/ - editor modes, icons, etc - unmaintained/ - unmaintained contributions, please help! - -* Community - -The Factor homepage is located at . - -Factor developers meet in the #concatenative channel on the -irc.freenode.net server. Drop by if you want to discuss anything related -to Factor or language design in general. - -Have fun! - -:tabSize=2:indentSize=2:noTabs=true: diff --git a/basis/alien/libraries/libraries-docs.factor b/basis/alien/libraries/libraries-docs.factor index 55537890b8..bface7f45a 100755 --- a/basis/alien/libraries/libraries-docs.factor +++ b/basis/alien/libraries/libraries-docs.factor @@ -45,10 +45,12 @@ HELP: load-library HELP: add-library { $values { "name" string } { "path" string } { "abi" "one of " { $snippet "\"cdecl\"" } " or " { $snippet "\"stdcall\"" } } } -{ $description "Defines a new logical library named " { $snippet "name" } " located in the file system at " { $snippet "path" } "and the specified ABI." } -{ $notes "Because the entire source file is parsed before top-level forms are executed, " { $link add-library } " cannot be used in the same file as " { $link POSTPONE: FUNCTION: } " definitions from that library. The " { $link add-library } " call will happen too late, after compilation, and the alien calls will not work." +{ $description "Defines a new logical library named " { $snippet "name" } " located in the file system at " { $snippet "path" } " and the specified ABI. The logical library name can then be used by a " { $link POSTPONE: LIBRARY: } " form to specify the logical library for subsequent " { $link POSTPONE: FUNCTION: } " definitions." } +{ $notes "Because the entire source file is parsed before top-level forms are executed, " { $link add-library } " must be placed within a " { $snippet "<< ... >>" } " parse-time evaluation block." $nl -"Instead, " { $link add-library } " calls must either be placed in different source files from those that use that library, or alternatively, " { $link "syntax-immediate" } " can be used to load the library before compilation." } +"This ensures that if the logical library is later used in the same file, for example by a " { $link POSTPONE: FUNCTION: } " definition. Otherwise, the " { $link add-library } " call will happen too late, after compilation, and the C function calls will not refer to the correct library." +$nl +"For details about parse-time evaluation, see " { $link "syntax-immediate" } "." } { $examples "Here is a typical usage of " { $link add-library } ":" { $code "<< \"freetype\" {" diff --git a/basis/alien/parser/parser-tests.factor b/basis/alien/parser/parser-tests.factor index 195cbb78a2..061deb84c5 100644 --- a/basis/alien/parser/parser-tests.factor +++ b/basis/alien/parser/parser-tests.factor @@ -1,6 +1,7 @@ ! (c)2009 Joe Groff bsd license USING: accessors alien.c-types alien.parser alien.syntax -tools.test vocabs.parser parser ; +tools.test vocabs.parser parser eval vocabs.parser debugger +continuations ; IN: alien.parser.tests TYPEDEF: char char2 @@ -28,4 +29,15 @@ SYMBOL: not-c-type [ "not-c-type" parse-c-type ] [ no-c-type? ] must-fail-with [ "not-word" parse-c-type ] [ error>> no-word-error? ] must-fail-with -] with-file-vocabs \ No newline at end of file +] with-file-vocabs + +! Reported by mnestic +TYPEDEF: int alien-parser-test-int ! reasonably unique name... + +[ "OK!" ] [ + [ + "USE: specialized-arrays SPECIALIZED-ARRAY: alien-parser-test-int" eval( -- ) + ! after restart, we end up here + "OK!" + ] [ :1 ] recover +] unit-test \ No newline at end of file diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index 67f1d4e5fd..e4ff5789d2 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -8,7 +8,7 @@ namespaces summary math vocabs.parser ; IN: alien.parser : parse-c-type-name ( name -- word ) - dup search [ nip ] [ no-word ] if* ; + dup search [ ] [ no-word ] ?if ; : parse-c-type ( string -- type ) { @@ -17,7 +17,7 @@ IN: alien.parser { [ dup search c-type-word? ] [ parse-c-type-name ] } { [ "**" ?tail ] [ drop void* ] } { [ "*" ?tail ] [ parse-c-type-name resolve-pointer-type ] } - [ parse-c-type-name no-c-type ] + [ dup search [ no-c-type ] [ no-word ] ?if ] } cond ; : scan-c-type ( -- c-type ) diff --git a/basis/alien/syntax/syntax-docs.factor b/basis/alien/syntax/syntax-docs.factor index 0021c2cdee..a8d3048b82 100644 --- a/basis/alien/syntax/syntax-docs.factor +++ b/basis/alien/syntax/syntax-docs.factor @@ -1,5 +1,6 @@ IN: alien.syntax -USING: alien alien.c-types alien.parser classes.struct help.markup help.syntax see ; +USING: alien alien.c-types alien.parser alien.libraries +classes.struct help.markup help.syntax see ; HELP: DLL" { $syntax "DLL\" path\"" } @@ -21,7 +22,8 @@ ARTICLE: "syntax-aliens" "Alien object literal syntax" HELP: LIBRARY: { $syntax "LIBRARY: name" } { $values { "name" "a logical library name" } } -{ $description "Sets the logical library for consequent " { $link POSTPONE: FUNCTION: } " definitions that follow." } ; +{ $description "Sets the logical library for consequent " { $link POSTPONE: FUNCTION: } ", " { $link POSTPONE: C-GLOBAL: } " and " { $link POSTPONE: CALLBACK: } " definitions, as well as " { $link POSTPONE: &: } " forms." } +{ $notes "Logical library names are defined with the " { $link add-library } " word." } ; HELP: FUNCTION: { $syntax "FUNCTION: return name ( parameters )" } @@ -96,21 +98,26 @@ HELP: CALLBACK: HELP: &: { $syntax "&: symbol" } -{ $values { "symbol" "A C library symbol name" } } +{ $values { "symbol" "A C global variable name" } } { $description "Pushes the address of a symbol named " { $snippet "symbol" } " from the current library, set with " { $link POSTPONE: LIBRARY: } "." } ; HELP: typedef -{ $values { "old" "a string" } { "new" "a string" } } +{ $values { "old" "a C type" } { "new" "a C type" } } { $description "Aliases the C type " { $snippet "old" } " under the name " { $snippet "new" } "." } { $notes "Using this word in the same source file which defines C bindings can cause problems, because words are compiled before top-level forms are run. Use the " { $link POSTPONE: TYPEDEF: } " word instead." } ; { POSTPONE: TYPEDEF: typedef } related-words HELP: c-struct? -{ $values { "c-type" "a C type name" } { "?" "a boolean" } } +{ $values { "c-type" "a C type" } { "?" "a boolean" } } { $description "Tests if a C type is a structure defined by " { $link POSTPONE: STRUCT: } "." } ; HELP: define-function { $values { "return" "a C return type" } { "library" "a logical library name" } { "function" "a C function name" } { "parameters" "a sequence of C parameter types" } } { $description "Defines a word named " { $snippet "function" } " in the current vocabulary (see " { $link "vocabularies" } "). The word calls " { $link alien-invoke } " with the specified parameters." } { $notes "This word is used to implement the " { $link POSTPONE: FUNCTION: } " parsing word." } ; + +HELP: C-GLOBAL: +{ $syntax "C-GLOBAL: type name" } +{ $values { "type" "a C type" } { "name" "a C global variable name" } } +{ $description "Defines a new word named " { $snippet "name" } " which accesses a global variable in the current library, set with " { $link POSTPONE: LIBRARY: } "." } ; diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor index 303a3914cb..7adf837841 100644 --- a/basis/alien/syntax/syntax.factor +++ b/basis/alien/syntax/syntax.factor @@ -38,3 +38,12 @@ ERROR: no-such-symbol name library ; SYNTAX: &: scan "c-library" get '[ _ _ address-of ] over push-all ; + +: global-quot ( type word -- quot ) + name>> "c-library" get '[ _ _ address-of 0 ] + swap c-type-getter-boxer append ; + +: define-global ( type word -- ) + [ nip ] [ global-quot ] 2bi (( -- value )) define-declared ; + +SYNTAX: C-GLOBAL: scan-c-type CREATE-WORD define-global ; diff --git a/basis/classes/struct/bit-accessors/bit-accessors-tests.factor b/basis/classes/struct/bit-accessors/bit-accessors-tests.factor new file mode 100644 index 0000000000..e2ff6dbd9c --- /dev/null +++ b/basis/classes/struct/bit-accessors/bit-accessors-tests.factor @@ -0,0 +1,7 @@ +! Copyright (C) 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: classes.struct.bit-accessors tools.test effects kernel random stack-checker ; +IN: classes.struct.bit-accessors.test + +[ t ] [ 20 random 20 random bit-reader infer (( alien -- n )) effect= ] unit-test +[ t ] [ 20 random 20 random bit-writer infer (( n alien -- )) effect= ] unit-test diff --git a/basis/classes/struct/bit-accessors/bit-accessors.factor b/basis/classes/struct/bit-accessors/bit-accessors.factor new file mode 100644 index 0000000000..c535e52c0a --- /dev/null +++ b/basis/classes/struct/bit-accessors/bit-accessors.factor @@ -0,0 +1,46 @@ +! Copyright (C) 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: kernel sequences math fry locals math.order alien.accessors ; +IN: classes.struct.bit-accessors + +! Bitfield accessors are little-endian on all platforms +! Why not? It's unspecified in C + +: ones-between ( start end -- n ) + [ 2^ 1 - ] bi@ swap bitnot bitand ; + +:: manipulate-bits ( offset bits step-quot -- quot shift-amount offset' bits' ) + offset 8 /mod :> start-bit :> i + start-bit bits + 8 min :> end-bit + start-bit end-bit ones-between :> mask + end-bit start-bit - :> used-bits + + i mask start-bit step-quot call( i mask start-bit -- quot ) + used-bits + i 1 + 8 * + bits used-bits - ; inline + +:: bit-manipulator ( offset bits + step-quot: ( i mask start-bit -- quot ) + combine-quot: ( prev-quot shift-amount next-quot -- quot ) + -- quot ) + offset bits step-quot manipulate-bits + dup zero? [ 3drop ] [ + step-quot combine-quot bit-manipulator + combine-quot call( prev shift next -- quot ) + ] if ; inline recursive + +: bit-reader ( offset bits -- quot: ( alien -- n ) ) + [ neg '[ _ alien-unsigned-1 _ bitand _ shift ] ] + [ swap '[ _ _ bi _ shift bitor ] ] + bit-manipulator ; + +:: write-bits ( n alien i mask start-bit -- ) + n start-bit shift mask bitand + alien i alien-unsigned-1 mask bitnot bitand + bitor alien i set-alien-unsigned-1 ; inline + +: bit-writer ( offset bits -- quot: ( n alien -- ) ) + [ '[ _ _ _ write-bits ] ] + [ '[ _ [ [ _ neg shift ] dip @ ] 2bi ] ] + bit-manipulator ; diff --git a/basis/classes/struct/prettyprint/prettyprint.factor b/basis/classes/struct/prettyprint/prettyprint.factor index 43d24e5716..b7b51432dd 100644 --- a/basis/classes/struct/prettyprint/prettyprint.factor +++ b/basis/classes/struct/prettyprint/prettyprint.factor @@ -23,6 +23,11 @@ IN: classes.struct.prettyprint [ type>> pprint-c-type ] [ read-only>> [ \ read-only pprint-word ] when ] [ initial>> [ \ initial: pprint-word pprint* ] when* ] + [ + dup struct-bit-slot-spec? + [ \ bits: pprint-word bits>> pprint* ] + [ drop ] if + ] } cleave block> \ } pprint-word block> ; diff --git a/basis/classes/struct/struct-tests.factor b/basis/classes/struct/struct-tests.factor index a026417171..58ab2df80b 100755 --- a/basis/classes/struct/struct-tests.factor +++ b/basis/classes/struct/struct-tests.factor @@ -352,3 +352,16 @@ STRUCT: struct-that's-a-word { x int } ; ] unit-test [ f ] [ "a-struct" c-types get key? ] unit-test + +STRUCT: bit-field-test + { a uint bits: 12 } + { b int bits: 2 } + { c char } ; + +[ S{ bit-field-test f 0 0 0 } ] [ bit-field-test ] unit-test +[ S{ bit-field-test f 1 -2 3 } ] [ bit-field-test 1 >>a 2 >>b 3 >>c ] unit-test +[ 4095 ] [ bit-field-test 8191 >>a a>> ] unit-test +[ 1 ] [ bit-field-test 1 >>b b>> ] unit-test +[ -2 ] [ bit-field-test 2 >>b b>> ] unit-test +[ 1 ] [ bit-field-test 257 >>c c>> ] unit-test +[ 3 ] [ bit-field-test heap-size ] unit-test diff --git a/basis/classes/struct/struct.factor b/basis/classes/struct/struct.factor index beddf07dd5..af23834383 100755 --- a/basis/classes/struct/struct.factor +++ b/basis/classes/struct/struct.factor @@ -1,4 +1,4 @@ -! (c)Joe Groff bsd license +! (c)Joe Groff, Daniel Ehrenberg bsd license USING: accessors alien alien.c-types alien.data alien.parser arrays byte-arrays classes classes.parser classes.tuple classes.tuple.parser classes.tuple.private combinators combinators.short-circuit @@ -6,7 +6,9 @@ combinators.smart cpu.architecture definitions functors.backend fry generalizations generic.parser kernel kernel.private lexer libc locals macros make math math.order parser quotations sequences slots slots.private specialized-arrays vectors words -summary namespaces assocs vocabs.parser ; +summary namespaces assocs vocabs.parser math.functions +classes.struct.bit-accessors bit-arrays ; +QUALIFIED: math IN: classes.struct SPECIALIZED-ARRAY: uchar @@ -22,6 +24,10 @@ TUPLE: struct TUPLE: struct-slot-spec < slot-spec type ; +! For a struct-bit-slot-spec, offset is in bits, not bytes +TUPLE: struct-bit-slot-spec < struct-slot-spec + bits signed? ; + PREDICATE: struct-class < tuple-class superclass \ struct eq? ; @@ -84,14 +90,36 @@ MACRO: ( class -- quot: ( ... -- struct ) ) : pad-struct-slots ( values class -- values' class ) [ struct-slots [ initial>> ] map over length tail append ] keep ; -: (reader-quot) ( slot -- quot ) +: sign-extend ( n bits -- n' ) + ! formula from: + ! http://guru.multimedia.cx/fast-sign-extension/ + 1 - -1 swap shift [ + ] keep bitxor ; inline + +: sign-extender ( signed? bits -- quot ) + '[ _ [ _ sign-extend ] when ] ; + +GENERIC: (reader-quot) ( slot -- quot ) + +M: struct-slot-spec (reader-quot) [ type>> c-type-getter-boxer ] [ offset>> [ >c-ptr ] swap suffix ] bi prepend ; -: (writer-quot) ( slot -- quot ) +M: struct-bit-slot-spec (reader-quot) + [ [ offset>> ] [ bits>> ] bi bit-reader ] + [ [ signed?>> ] [ bits>> ] bi sign-extender ] + bi compose + [ >c-ptr ] prepose ; + +GENERIC: (writer-quot) ( slot -- quot ) + +M: struct-slot-spec (writer-quot) [ type>> c-setter ] [ offset>> [ >c-ptr ] swap suffix ] bi prepend ; +M: struct-bit-slot-spec (writer-quot) + [ offset>> ] [ bits>> ] bi bit-writer + [ >c-ptr ] prepose ; + : (boxer-quot) ( class -- quot ) '[ _ memory>struct ] ; @@ -186,20 +214,24 @@ M: struct-c-type c-struct? drop t ; class (unboxer-quot) >>unboxer-quot class (boxer-quot) >>boxer-quot ; -: align-offset ( offset class -- offset' ) - c-type-align align ; +GENERIC: align-offset ( offset class -- offset' ) + +M: struct-slot-spec align-offset + [ type>> c-type-align 8 * align ] keep + [ [ 8 /i ] dip (>>offset) ] [ type>> heap-size 8 * + ] 2bi ; + +M: struct-bit-slot-spec align-offset + [ (>>offset) ] [ bits>> + ] 2bi ; : struct-offsets ( slots -- size ) - 0 [ - [ type>> align-offset ] keep - [ (>>offset) ] [ type>> heap-size + ] 2bi - ] reduce ; + 0 [ align-offset ] reduce 8 align 8 /i ; : union-struct-offsets ( slots -- size ) - [ 0 >>offset type>> heap-size ] [ max ] map-reduce ; + 1 [ 0 >>offset type>> heap-size max ] reduce ; : struct-align ( slots -- align ) - [ type>> c-type-align ] [ max ] map-reduce ; + [ struct-bit-slot-spec? not ] filter + 1 [ type>> c-type-align max ] reduce ; PRIVATE> M: struct byte-length class "struct-size" word-prop ; foldable @@ -273,11 +305,43 @@ ERROR: invalid-struct-slot token ; c-type c-type-boxed-class dup \ byte-array = [ drop \ c-ptr ] when ; +SYMBOL: bits: + +>bits + slot-spec type>> { + { int [ t ] } + { uint [ f ] } + [ bad-type-for-bits ] + } case >>signed? + slot-spec name>> >>name + slot-spec class>> >>class + slot-spec type>> >>type + slot-spec read-only>> >>read-only + slot-spec initial>> >>initial ; + +: peel-off-struct-attributes ( slot-spec array -- slot-spec array ) + dup empty? [ + unclip { + { initial: [ [ first >>initial ] [ rest ] bi ] } + { read-only [ [ t >>read-only ] dip ] } + { bits: [ [ first set-bits ] [ rest ] bi ] } + [ bad-slot-attribute ] + } case + ] unless ; + +PRIVATE> + : ( name c-type attributes -- slot-spec ) [ struct-slot-spec new ] 3dip [ >>name ] [ [ >>type ] [ struct-slot-class >>class ] bi ] - [ [ dup empty? ] [ peel-off-attributes ] until drop ] tri* ; + [ [ dup empty? ] [ peel-off-struct-attributes ] until drop ] tri* ; > vreg>constant ] [ src2>> ] [ ] tri constant-fold* ] bi \ ##load-immediate new-insn ; inline +: unary-constant-fold? ( insn -- ? ) + src>> vreg>expr constant-expr? ; inline + +GENERIC: unary-constant-fold* ( x insn -- y ) + +M: ##not unary-constant-fold* drop bitnot ; +M: ##neg unary-constant-fold* drop neg ; + +: unary-constant-fold ( insn -- insn' ) + [ dst>> ] + [ [ src>> vreg>constant ] [ ] bi unary-constant-fold* ] bi + \ ##load-immediate new-insn ; inline + +: maybe-unary-constant-fold ( insn -- insn' ) + dup unary-constant-fold? [ unary-constant-fold ] [ drop f ] if ; + +M: ##neg rewrite + maybe-unary-constant-fold ; + +M: ##not rewrite + maybe-unary-constant-fold ; + : reassociate ( insn op -- insn ) [ { diff --git a/basis/compiler/cfg/value-numbering/value-numbering-tests.factor b/basis/compiler/cfg/value-numbering/value-numbering-tests.factor index 5f8eda2c08..f98824cb95 100644 --- a/basis/compiler/cfg/value-numbering/value-numbering-tests.factor +++ b/basis/compiler/cfg/value-numbering/value-numbering-tests.factor @@ -983,6 +983,34 @@ cell 8 = [ ] unit-test ] when +[ + { + T{ ##peek f 0 D 0 } + T{ ##load-immediate f 1 1 } + T{ ##load-immediate f 2 -1 } + } +] [ + { + T{ ##peek f 0 D 0 } + T{ ##load-immediate f 1 1 } + T{ ##neg f 2 1 } + } value-numbering-step +] unit-test + +[ + { + T{ ##peek f 0 D 0 } + T{ ##load-immediate f 1 1 } + T{ ##load-immediate f 2 -2 } + } +] [ + { + T{ ##peek f 0 D 0 } + T{ ##load-immediate f 1 1 } + T{ ##not f 2 1 } + } value-numbering-step +] unit-test + ! Displaced alien optimizations 3 vreg-counter set-global diff --git a/basis/compiler/codegen/codegen-tests.factor b/basis/compiler/codegen/codegen-tests.factor index 225577d0b9..43473ebcbb 100644 --- a/basis/compiler/codegen/codegen-tests.factor +++ b/basis/compiler/codegen/codegen-tests.factor @@ -1,14 +1,14 @@ USING: compiler.codegen.fixup tools.test cpu.architecture math kernel make -compiler.constants ; +compiler.constants words ; IN: compiler.codegen.tests -[ ] [ [ ] with-fixup drop ] unit-test -[ ] [ [ \ + %call ] with-fixup drop ] unit-test +[ ] [ gensym [ ] with-fixup drop ] unit-test +[ ] [ gensym [ \ + %call ] with-fixup drop ] unit-test -[ ] [ [