]> gitweb.factorcode.org Git - factor.git/commitdiff
Fixing some more bugs
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 22 Aug 2008 08:12:15 +0000 (03:12 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 22 Aug 2008 08:12:15 +0000 (03:12 -0500)
26 files changed:
basis/bootstrap/compiler/compiler.factor
basis/cocoa/messages/messages.factor
basis/columns/columns-docs.factor
basis/compiler/compiler.factor
basis/compiler/generator/fixup/fixup-docs.factor
basis/compiler/generator/generator-docs.factor
basis/compiler/generator/generator.factor
basis/compiler/generator/registers/registers.factor
basis/compiler/tree/checker/checker.factor
basis/compiler/tree/cleanup/cleanup-tests.factor
basis/compiler/tree/dead-code/dead-code-tests.factor
basis/compiler/tree/dead-code/recursive/recursive.factor
basis/compiler/tree/dead-code/simple/simple.factor
basis/compiler/tree/normalization/normalization-tests.factor
basis/compiler/tree/optimizer/optimizer.factor
basis/compiler/tree/propagation/propagation-tests.factor
basis/compiler/tree/propagation/simple/simple.factor
basis/compiler/tree/tree.factor
basis/compiler/tree/tuple-unboxing/tuple-unboxing.factor
basis/cpu/architecture/architecture.factor
basis/cpu/x86/architecture/architecture.factor
basis/help/cookbook/cookbook.factor
core/bootstrap/primitives.factor
core/classes/tuple/tuple.factor
core/continuations/continuations.factor
core/lexer/lexer.factor

index b6c2f64efb4f9d1729d4d6d7af003b59aa19d4e7..0b44761f5c83786724f577a8996a7a3fc9503b34 100755 (executable)
@@ -5,8 +5,9 @@ sequences namespaces parser kernel kernel.private classes
 classes.private arrays hashtables vectors classes.tuple sbufs
 hashtables.private sequences.private math classes.tuple.private
 growable namespaces.private assocs words command-line vocabs io
-io.encodings.string prettyprint libc compiler.units math.order
-compiler.tree.builder compiler.tree.optimizer ;
+io.encodings.string prettyprint libc splitting math.parser
+compiler.units math.order compiler.tree.builder
+compiler.tree.optimizer ;
 IN: bootstrap.compiler
 
 ! Don't bring this in when deploying, since it will store a
@@ -71,13 +72,21 @@ nl
 "." write flush
 
 {
-    . lines
+    memq? split harvest sift cut cut-slice start index clone
+    set-at reverse push-all class number>string string>number
 } compile-uncompiled
 
 "." write flush
 
 {
-    malloc calloc free memcpy
+    lines prefix suffix unclip new-assoc update
+    word-prop set-word-prop 1array 2array 3array ?nth
+} compile-uncompiled
+
+"." write flush
+
+{
+    . malloc calloc free memcpy
 } compile-uncompiled
 
 { build-tree } compile-uncompiled
index 5cc2b727df37a17f4da67194f4342c59b35694ed..94c5f05887d3f8f810da7945e81b9427439a1246 100755 (executable)
@@ -4,7 +4,7 @@ USING: alien alien.c-types alien.strings
 arrays assocs combinators compiler kernel
 math namespaces parser prettyprint prettyprint.sections
 quotations sequences strings words cocoa.runtime io macros
-memoize debugger io.encodings.ascii effects ;
+memoize debugger io.encodings.ascii effects compiler.generator ;
 IN: cocoa.messages
 
 : make-sender ( method function -- quot )
index e0d4e4a2e02346c97c97e58637788bcc7ab8a6fb..818ce2f75283b6366315f9c93f5b292bb18aeade 100644 (file)
@@ -6,7 +6,7 @@ ARTICLE: "columns" "Column sequences"
 { $subsection column }
 { $subsection <column> }
 "A utility word:"
-{ $subsection flipped } ;
+{ $subsection <flipped> } ;
 
 HELP: column
 { $class-description "A virtual sequence which presents a fixed column of a matrix represented as a sequence of rows. New instances can be created by calling " { $link <column> } "." } ;
index 2a274ef45700885f66537d0f9752fc7956abdeb0..7480c13339160d6e81b5c98767f97eec32e3aea4 100755 (executable)
@@ -46,7 +46,6 @@ SYMBOL: +failed+
     ] tri ;
 
 : (compile) ( word -- )
-    USE: prettyprint dup .
     '[
         H{ } clone dependencies set
 
index a4ff549e8e390512ae5e3a3a06a715f6fec06d32..a119d153e6ab9c3c0f90805016ed95e57d0d759d 100644 (file)
@@ -1,5 +1,5 @@
 USING: help.syntax help.markup math kernel
-words strings alien ;
+words strings alien compiler.generator ;
 IN: compiler.generator.fixup
 
 HELP: frame-required
@@ -14,3 +14,6 @@ HELP: rel-dlsym
 { $values { "name" string } { "dll" "a " { $link dll } " or " { $link f } } { "class" "a relocation class" } }
 { $description "Records that the most recently assembled instruction contains a reference to the " { $snippet "name" } " symbol from " { $snippet "dll" } ". The correct " { $snippet "class" } " to use depends on instruction formats."
 } ;
+
+HELP: literal-table
+{ $var-description "Holds a vector of literal objects referenced from the currently compiling word. If " { $link compiled-stack-traces? } " is on, " { $link begin-compiling } " ensures that the first entry is the word being compiled." } ;
index e00b8d5b28f318a9578ee56921ac8a68ae9b17dc..53bc031ad0842f8f10c1256c5aa34460ac6eedb2 100755 (executable)
@@ -1,6 +1,6 @@
-USING: help.markup help.syntax words debugger generator.fixup
-generator.registers quotations kernel vectors arrays effects
-sequences ;
+USING: help.markup help.syntax words debugger
+compiler.generator.fixup compiler.generator.registers quotations
+kernel vectors arrays effects sequences ;
 IN: compiler.generator
 
 ARTICLE: "generator" "Compiled code generator"
@@ -31,9 +31,6 @@ HELP: compiled-stack-traces?
 { $values { "?" "a boolean" } }
 { $description "Iftrue, compiled code blocks will retain what word they were compiled from. This information is used by " { $link :c } " to display call stack traces after an error is thrown from compiled code. This is on by default; the deployment tool switches it off to save some space in the deployed image." } ;
 
-HELP: literal-table
-{ $var-description "Holds a vector of literal objects referenced from the currently compiling word. If " { $link compiled-stack-traces? } " is on, " { $link begin-compiling } " ensures that the first entry is the word being compiled." } ;
-
 HELP: begin-compiling
 { $values { "word" word } { "label" word } }
 { $description "Prepares to generate machine code for a word." } ;
index 4d826c40d2a35f43f7d06d684e8b5907667d0b7e..0897424472099d8b517ba7f4303397d41627b366 100755 (executable)
@@ -92,7 +92,7 @@ M: node generate-node drop iterate-next ;
     %jump-label ;
 
 : generate-call ( label -- next )
-    dup maybe-compile
+    dup maybe-compile
     end-basic-block
     dup compiling-loops get at [
         %jump-label f
@@ -255,13 +255,13 @@ M: #shuffle generate-node
     shuffle-effect phantom-shuffle iterate-next ;
 
 M: #>r generate-node
-    in-d>> length
-    phantom->r
+    [ in-d>> length ] [ out-r>> empty? ] bi
+    [ phantom-drop ] [ phantom->r ] if
     iterate-next ;
 
 M: #r> generate-node
-    out-d>> length
-    phantom-r>
+    [ in-r>> length ] [ out-d>> empty? ] bi
+    [ phantom-rdrop ] [ phantom-r> ] if
     iterate-next ;
 
 ! #return
index 064f0275314a739c672a87168f859c07a7b497f2..41753433de4b5ec3cfbfd09d6a67bb9e1248b838 100755 (executable)
@@ -658,3 +658,9 @@ UNION: immediate fixnum POSTPONE: f ;
 : phantom-r> ( n -- )
     phantom-retainstack get phantom-input
     phantom-datastack get phantom-append ;
+
+: phantom-drop ( n -- )
+    phantom-datastack get phantom-input drop ;
+
+: phantom-rdrop ( n -- )
+    phantom-retainstack get phantom-input drop ;
index 58e31a8cf55f0889bf7987cb3c723373f6449a7a..632412a6af0e6bfb0dec0d7a52ae01306423ad98 100644 (file)
@@ -31,9 +31,12 @@ M: #shuffle check-node*
 
 M: #copy check-node* inputs/outputs 2array check-lengths ;
 
-M: #>r check-node* inputs/outputs 2array check-lengths ;
+: check->r/r> ( node -- )
+    inputs/outputs dup empty? [ 2drop ] [ 2array check-lengths ] if ;
 
-M: #r> check-node* inputs/outputs 2array check-lengths ;
+M: #>r check-node* check->r/r> ;
+
+M: #r> check-node* check->r/r> ;
 
 M: #return-recursive check-node* inputs/outputs 2array check-lengths ;
 
@@ -43,9 +46,10 @@ M: #phi check-node*
     bi ;
 
 M: #enter-recursive check-node*
+    [ [ label>> enter-out>> ] [ out-d>> ] bi assert= ]
     [ [ in-d>> ] [ out-d>> ] bi 2array check-lengths ]
     [ recursive-phi-in check-lengths ]
-    bi ;
+    tri ;
 
 M: #push check-node*
     out-d>> length 1 = [ "Bad #push" throw ] unless ;
@@ -72,7 +76,7 @@ SYMBOL: terminated?
 GENERIC: check-stack-flow* ( node -- )
 
 : (check-stack-flow) ( nodes -- )
-    [ check-stack-flow* ] each ;
+    [ check-stack-flow* terminated? get not ] all? drop ;
 
 : init-stack-flow ( -- )
     V{ } clone datastack set
@@ -164,31 +168,27 @@ M: #branch check-stack-flow*
 
 : check-phi-in ( #phi -- )
     phi-in-d>> branch-out get [
-        over [ +bottom+ eq? ] all? [
-            2drop
-        ] [
+        dup [
             over length tail* sequence= [
                 "Branch outputs don't match phi inputs"
                 throw
             ] unless
+        ] [
+            2drop
         ] if
     ] 2each ;
 
 : set-phi-datastack ( #phi -- )
     phi-in-d>> first length
-    branch-out get [ ] find nip
-    dup [ swap head* >vector ] [ 2drop V{ } clone ] if datastack set ;
+    branch-out get [ ] find nip swap head* >vector datastack set ;
 
 M: #phi check-stack-flow*
-    [ check-phi-in ] [ set-phi-datastack ] [ check-out-d ] tri ;
+    branch-out get [ ] contains? [
+        [ check-phi-in ] [ set-phi-datastack ] [ check-out-d ] tri
+    ] [ drop terminated? on ] if ;
 
 M: #recursive check-stack-flow*
-    [
-        init-stack-flow
-        child>> (check-stack-flow)
-        datastack get
-    ] with-scope
-    datastack set ;
+    [ check-in-d ] [ child>> (check-stack-flow) ] bi ;
 
 M: #copy check-stack-flow* [ check-in-d ] [ check-out-d ] bi ;
 
index 9a40d3a4f62534f620fd6adcd21879d68b6def4b..e969d098c7727b9a3195ff6701943b97dd07d293 100644 (file)
@@ -443,3 +443,11 @@ cell-bits 32 = [
 [ ] [
     [ { merge } declare accum>> 0 >>length ] cleaned-up-tree drop
 ] unit-test
+
+[ ] [
+    [
+        [ "X" throw ]
+        [ dupd dup -1 < [ 0 >= [ ] [ "X" throw ] if ] [ drop ] if ]
+        if
+    ] cleaned-up-tree drop
+] unit-test
index 5e2eb2c38d3ed989a418a94d24c7520757dc5a3c..670634e752be03bea9d8f05980f30dce81431f8e 100644 (file)
@@ -5,7 +5,7 @@ compiler.tree.cleanup compiler.tree.escape-analysis
 compiler.tree.tuple-unboxing compiler.tree.debugger
 compiler.tree.normalization compiler.tree.checker tools.test
 kernel math stack-checker.state accessors combinators io
-prettyprint ;
+prettyprint words sequences.deep sequences.private ;
 IN: compiler.tree.dead-code.tests
 
 \ remove-dead-code must-infer
@@ -106,3 +106,70 @@ IN: compiler.tree.dead-code.tests
 : boo ( a b -- c ) 2drop f ;
 
 [ [ dup 4 eq? [ nip ] [ boo ] if ] ] [ [ dup dup 4 eq? [ drop nip ] [ drop boo ] if ] optimize-quot ] unit-test
+
+: squish ( quot -- quot' )
+    [
+        {
+            { [ dup word? ] [ dup vocabulary>> [ drop "REC" ] unless ] }
+            { [ dup wrapper? ] [ dup wrapped>> vocabulary>> [ drop "WRAP" ] unless ] }
+            [ ]
+        } cond
+    ] deep-map ;
+
+: call-recursive-dce-1 ( a -- b )
+    [ call-recursive-dce-1 drop ] [ call-recursive-dce-1 ] bi ; inline recursive
+
+[ [ "WRAP" [ dup >r "REC" drop r> "REC" ] label ] ] [
+    [ call-recursive-dce-1 ] optimize-quot squish
+] unit-test
+
+: produce-a-value ( -- a ) f ;
+
+: call-recursive-dce-2 ( a -- b )
+    drop
+    produce-a-value dup . call-recursive-dce-2 ; inline recursive
+
+[ [ "WRAP" [ produce-a-value . "REC" ] label ] ] [
+    [ f call-recursive-dce-2 drop ] optimize-quot squish
+] unit-test
+
+[ [ "WRAP" [ produce-a-value dup . drop "REC" ] label ] ] [
+    [ f call-recursive-dce-2 ] optimize-quot squish
+] unit-test
+
+: call-recursive-dce-3 ( a -- )
+    call-recursive-dce-3 ; inline recursive
+
+[ [ [ drop "WRAP" [ "REC" ] label ] [ . ] if ] ] [
+    [ [ call-recursive-dce-3 ] [ . ] if ] optimize-quot squish
+] unit-test
+
+[ [ drop "WRAP" [ "REC" ] label ] ] [
+    [ call-recursive-dce-3 ] optimize-quot squish
+] unit-test
+
+: call-recursive-dce-4 ( a -- b )
+    call-recursive-dce-4 ; inline recursive
+
+[ [ "WRAP" [ "REC" ] label ] ] [
+    [ call-recursive-dce-4 ] optimize-quot squish
+] unit-test
+
+[ [ drop "WRAP" [ "REC" ] label ] ] [
+    [ call-recursive-dce-4 drop ] optimize-quot squish
+] unit-test
+
+[ ] [ [ f call-recursive-dce-3 swap ] optimize-quot drop ] unit-test
+
+: call-recursive-dce-5 ( -- ) call-recursive-dce-5 ; inline recursive
+
+[ ] [ [ call-recursive-dce-5 swap ] optimize-quot drop ] unit-test
+
+[ ] [ [ [ 0 -rot set-nth-unsafe ] curry (each-integer) ] optimize-quot drop ] unit-test
+
+: call-recursive-dce-6 ( i quot: ( i -- ? ) -- i )
+    dup call [ drop ] [ call-recursive-dce-6 ] if ; inline recursive
+
+[ ] [ [ [ ] curry [ ] swap compose call-recursive-dce-6 ] optimize-quot drop ] unit-test
+
+[ ] [ [ [ ] rot [ . ] curry pick [ roll 2drop call ] [ 2nip call ] if ] optimize-quot drop ] unit-test
index 28c65969e3d0bb9cc92b0635daaf721db232fff1..022912ff4e73dcbeead212c6822f51051136d4ee 100644 (file)
@@ -1,12 +1,16 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors sequences kernel
-compiler.tree compiler.tree.dead-code.branches
+USING: accessors arrays assocs sequences kernel locals fry
+combinators stack-checker.backend
+compiler.tree
+compiler.tree.dead-code.branches
 compiler.tree.dead-code.liveness
 compiler.tree.dead-code.simple ;
 IN: compiler.tree.dead-code.recursive
 
 M: #enter-recursive compute-live-values*
+    #! If the output of an #enter-recursive is live, then the
+    #! corresponding inputs to the #call-recursive are live also.
     [ out-d>> ] [ recursive-phi-in ] bi look-at-phi ;
 
 : return-recursive-phi-in ( #return-recursive -- phi-in )
@@ -16,22 +20,60 @@ M: #return-recursive compute-live-values*
     [ out-d>> ] [ return-recursive-phi-in ] bi look-at-phi ;
 
 M: #call-recursive compute-live-values*
-    #! If the output of a copy is live, then the corresponding
-    #! inputs to #return nodes are live also.
+    #! If the output of a #call-recursive is live, then the
+    #! corresponding inputs to #return nodes are live also.
     [ out-d>> ] [ label>> return>> in-d>> ] bi look-at-mapping ;
 
-M: #recursive remove-dead-code*
-    [ filter-live ] change-in-d
-    [ (remove-dead-code) ] change-child ;
+:: drop-dead-inputs ( inputs outputs -- #shuffle )
+    [let* | new-inputs [ inputs make-values ]
+            live-inputs [ outputs inputs filter-corresponding ]
+            new-live-inputs [ outputs new-inputs filter-corresponding ]
+            mapping [ new-live-inputs live-inputs zip ] |
+        inputs filter-live
+        new-live-inputs
+        mapping
+        #shuffle
+    ] ;
 
-M: #call-recursive remove-dead-code*
-    [ filter-live ] change-in-d
-    [ filter-live ] change-out-d ;
+M: #recursive remove-dead-code* ( node -- nodes )
+    dup [ in-d>> ] [ label>> enter-out>> ] bi drop-dead-inputs
+    {
+        [ [ dup label>> enter-recursive>> ] [ out-d>> ] bi* '[ , >>in-d drop ] bi@ ]
+        [ drop [ (remove-dead-code) ] change-child drop ]
+        [ drop label>> [ filter-live ] change-enter-out drop ]
+        [ swap 2array ]
+    } 2cleave ;
 
 M: #enter-recursive remove-dead-code*
-    [ filter-live ] change-in-d
     [ filter-live ] change-out-d ;
 
-M: #return-recursive remove-dead-code*
-    [ filter-live ] change-in-d
-    [ filter-live ] change-out-d ;
+: drop-call-recursive-inputs ( node -- #shuffle )
+    dup [ in-d>> ] [ label>> enter-out>> ] bi drop-dead-inputs
+    [ out-d>> >>in-d drop ]
+    [ nip ]
+    2bi ;
+
+:: drop-call-recursive-outputs ( node -- #shuffle )
+    [let* | node-out [ node out-d>> ]
+            return-in [ node label>> return>> in-d>> ]
+            node-out-live [ return-in node-out filter-corresponding ]
+            new-node-out-live [ node-out-live make-values ]
+            node-out-dropped [ node-out filter-live ]
+            new-node-out-dropped [ node-out-dropped new-node-out-live filter-corresponding ]
+            mapping [ node-out-dropped new-node-out-dropped zip ] |
+        node new-node-out-live >>out-d drop
+        new-node-out-live node-out-dropped mapping #shuffle
+    ] ;
+
+M: #call-recursive remove-dead-code*
+    [ drop-call-recursive-inputs ]
+    [ ]
+    [ drop-call-recursive-outputs ]
+    tri 3array ;
+
+M: #return-recursive remove-dead-code* ( node -- nodes )
+    dup [ in-d>> ] [ out-d>> ] bi drop-dead-inputs
+    [ drop [ filter-live ] change-out-d drop ]
+    [ out-d>> >>in-d drop ]
+    [ swap 2array ]
+    2tri ;
index a3695dc81585b114865b80687312ecd245cf0369..880ae94a1f3490874d85de03a4049296543ffdb3 100644 (file)
@@ -41,12 +41,17 @@ M: #alien-indirect compute-live-values* nip look-at-inputs ;
 : filter-mapping ( assoc -- assoc' )
     live-values get '[ drop , key? ] assoc-filter ;
 
-: filter-corresponding ( new old -- new' )
+: filter-corresponding ( new old -- old' )
+    #! Remove elements from 'old' if the element with the same
+    #! index in 'new' is dead.
     zip filter-mapping values ;
 
 : filter-live ( values -- values' )
     [ live-value? ] filter ;
 
+: drop-dead-values ( in out -- #shuffle )
+    [ make-values dup ] keep zip #shuffle ;
+
 :: drop-dead-outputs ( node -- nodes )
     [let* | old-outputs [ node out-d>> ]
             new-outputs [ old-outputs make-values ]
index 0c2fbf255c845d07576f64d7c95c80f10fef27d0..1b4f728adc24810ad6dc9b6019df71e1c23b2970 100644 (file)
@@ -1,6 +1,7 @@
 IN: compiler.tree.normalization.tests
 USING: compiler.tree.builder compiler.tree.normalization
-compiler.tree sequences accessors tools.test kernel math ;
+compiler.tree compiler.tree.checker
+sequences accessors tools.test kernel math ;
 
 \ count-introductions must-infer
 \ normalize must-infer
@@ -24,20 +25,24 @@ compiler.tree sequences accessors tools.test kernel math ;
     [ normalize recursive-inputs ] bi
 ] unit-test
 
-[ ] [ [ [ 1 ] [ 2 ] if + * ] build-tree normalize drop ] unit-test
+[ ] [ [ [ 1 ] [ 2 ] if + * ] build-tree normalize check-nodes ] unit-test
 
 DEFER: bbb
 : aaa ( x -- ) dup [ dup >r bbb r> aaa ] [ drop ] if ; inline recursive
 : bbb ( x -- ) >r drop 0 r> aaa ; inline recursive
 
-[ ] [ [ bbb ] build-tree normalize drop ] unit-test
+[ ] [ [ bbb ] build-tree normalize check-nodes ] unit-test
 
 : ccc ( -- ) ccc drop 1 ; inline recursive
 
-[ ] [ [ ccc ] build-tree normalize drop ] unit-test
+[ ] [ [ ccc ] build-tree normalize check-nodes ] unit-test
 
 DEFER: eee
 : ddd ( -- ) eee ; inline recursive
 : eee ( -- ) swap ddd ; inline recursive
 
-[ ] [ [ eee ] build-tree normalize drop ] unit-test
+[ ] [ [ eee ] build-tree normalize check-nodes ] unit-test
+
+: call-recursive-5 ( -- ) call-recursive-5 ; inline recursive
+
+[ ] [ [ call-recursive-5 swap ] build-tree normalize check-nodes ] unit-test
index 6e191157b01114595c67f2d64ae574e7286bb0be..d42dff774701e927aa3ab7a4231495431979dd81 100644 (file)
@@ -26,5 +26,4 @@ IN: compiler.tree.optimizer
     compute-def-use
     remove-dead-code
     ! strength-reduce
-    compute-def-use USE: kernel
-    dup check-nodes ;
+    ;
index e0b5c1a676e81c1b6ae52fa247cc1bb3018cc009..c3b1b7a5fd687cc2b741a93a90df54d93f801901 100644 (file)
@@ -567,3 +567,7 @@ M: integer infinite-loop infinite-loop ;
 [ ] [ [ instance? ] final-classes drop ] unit-test
 
 [ f ] [ [ V{ } clone ] final-info first literal?>> ] unit-test
+
+: fold-throw-test ( a -- b ) "A" throw ; foldable
+
+[ ] [ [ 0 fold-throw-test ] final-info drop ] unit-test
index 73da76c525edfcc85aedabefd310d62419083bdb..b39ecef6e4836763e9b8e2f1fa7fbded5f9d178c 100644 (file)
@@ -62,10 +62,10 @@ M: #declare propagate-before
     [ in-d>> [ value-info literal?>> ] all? ] [ drop f ] if ;
 
 : fold-call ( #call word -- infos )
-    [ in-d>> [ value-info literal>> ] map ]
-    [ [ execute ] curry ]
-    bi* with-datastack
-    [ <literal-info> ] map ;
+    [ [ out-d>> ] [ in-d>> [ value-info literal>> ] map ] bi ] [ '[ , execute ] ] bi*
+    '[ , , with-datastack [ <literal-info> ] map nip ]
+    [ drop [ object-info ] replicate ]
+    recover ;
 
 : predicate-output-infos ( info class -- info )
     [ class>> ] dip {
index 40a35e66d4f69cfdfcd86c5193d3303e6cd3f2a6..f7d0adbf92fea6adbbbfcdb7f53e374a8573f60b 100755 (executable)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry arrays generic assocs kernel math namespaces parser
 sequences words vectors math.intervals effects classes
-accessors combinators stack-checker.state stack-checker.visitor ;
+accessors combinators stack-checker.state stack-checker.visitor
+stack-checker.inlining ;
 IN: compiler.tree
 
 ! High-level tree SSA form.
index ac2c2bc22937e4865c17cb01a02a03f3ab3773c0..3f92d99597f4cb6db4a3e30ad225b1b6d91f7de8 100644 (file)
@@ -103,7 +103,9 @@ M: #phi unbox-tuples*
     [ flatten-values ] change-out-d ;
 
 M: #recursive unbox-tuples*
-    [ flatten-values ] change-in-d ;
+    [ label>> [ flatten-values ] change-enter-out drop ]
+    [ [ flatten-values ] change-in-d ]
+    bi ;
 
 M: #enter-recursive unbox-tuples*
     [ flatten-values ] change-in-d
index 56b4630962b4c6e5aa66d3ca5846d68ea8a55221..d15c5a30ab1fd2aef0111f0af4c55d788a23bd11 100755 (executable)
@@ -163,8 +163,8 @@ PREDICATE: small-slot < integer cells small-enough? ;
 PREDICATE: small-tagged < integer v>operand small-enough? ;
 
 : if-small-struct ( n size true false -- ? )
-    >r >r over not over struct-small-enough? and
-    [ nip r> call r> drop ] [ r> drop r> call ] if ;
+    [ over not over struct-small-enough? and ] 2dip
+    [ [ nip ] prepose ] dip if ;
     inline
 
 : %unbox-struct ( n size -- )
index 3aa9b22695c534efa8e69fd2f8e694261ddd38f6..52ad68baf12a59010ee48c9cb454b004696d846c 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types arrays cpu.x86.assembler
 cpu.x86.assembler.private cpu.architecture kernel kernel.private
-math memory namespaces sequences words generator
+math memory namespaces sequences words compiler.generator
 compiler.generator.registers compiler.generator.fixup system
 layouts combinators compiler.constants math.order ;
 IN: cpu.x86.architecture
index 922866649108727df62f2ab35af71e8e39dd3929..1539a07d68cb184586d23d753d29e3f5f45522c5 100755 (executable)
@@ -1,5 +1,5 @@
 USING: help.markup help.syntax io kernel math namespaces parser
-prettyprint sequences vocabs.loader namespaces inference ;
+prettyprint sequences vocabs.loader namespaces stack-checker ;
 IN: help.cookbook
 
 ARTICLE: "cookbook-syntax" "Basic syntax cookbook"
index 5d7d5e0d2cb39670cc92ceed8a121f8a82660aab..b9191ac6125250b9e33e6b26ad46be387dc97ce4 100755 (executable)
@@ -72,7 +72,6 @@ bootstrapping? on
     "classes.predicate"
     "compiler.units"
     "continuations.private"
-    "generator"
     "growable"
     "hashtables"
     "hashtables.private"
index 94d3a64c45be36eda587f1e38553e8d2c9ea2409..585bb6ece70ebff047ead211f1338c6f2a1215e5 100755 (executable)
@@ -164,8 +164,8 @@ ERROR: bad-superclass class ;
 
 : update-slot ( old-values n class initial -- value )
     pick [
-        >r >r swap nth dup r> instance?
-        [ r> drop ] [ drop r> ] if
+        >r >r swap nth dup r> instance? r> swap
+        [ drop ] [ nip ] if
     ] [ >r 3drop r> ] if ;
 
 : apply-slot-permutation ( old-values triples -- new-values )
index 11162be4d36042880b736584c14af2c78e70a7a2..1d3c061a42a9f94bb7be9b2c17f9bd4b585a6a91 100755 (executable)
@@ -19,12 +19,9 @@ SYMBOL: restarts
 
 : c> ( -- continuation ) catchstack* pop ;
 
-: dummy ( -- obj )
-    #! Optimizing compiler assumes stack won't be messed with
-    #! in-transit. To ensure that a value is actually reified
-    #! on the stack, we put it in a non-inline word together
-    #! with a declaration.
-    f { object } declare ;
+! We have to defeat some optimizations to make continuations work
+: dummy-1 ( -- obj ) f ;
+: dummy-2 ( obj -- obj ) dup drop ;
 
 : init-catchstack ( -- ) V{ } clone 1 setenv ;
 
@@ -68,7 +65,7 @@ C: <continuation> continuation
     #! ( value f r:capture r:restore )
     #! Execution begins right after the call to 'continuation'.
     #! The 'restore' branch is taken.
-    >r >r dummy continuation r> r> ?if ; inline
+    >r >r dummy-1 continuation r> r> [ dummy-2 ] prepose ?if ; inline
 
 : callcc0 ( quot -- ) [ drop ] ifcc ; inline
 
index 397aef8e076566dd27eee8ca6632cd29af9e9141..eb6442bbb95eda4b4b0b20b5e7b8a38d469e7daa 100644 (file)
@@ -23,9 +23,9 @@ TUPLE: lexer text line line-text line-length column ;
     lexer new-lexer ;
 
 : skip ( i seq ? -- n )
-    over >r
+    >r tuck r>
     [ swap CHAR: \s eq? xor ] curry find-from drop
-    [ r> drop ] [ r> length ] if* ;
+    [ ] [ length ] ?if ;
 
 : change-lexer-column ( lexer quot -- )
     swap