]> gitweb.factorcode.org Git - factor.git/commitdiff
more dataflow work
authorSlava Pestov <slava@factorcode.org>
Sun, 28 Nov 2004 04:09:32 +0000 (04:09 +0000)
committerSlava Pestov <slava@factorcode.org>
Sun, 28 Nov 2004 04:09:32 +0000 (04:09 +0000)
library/inference/branches.factor
library/inference/dataflow.factor
library/inference/stack.factor
library/inference/words.factor
native/port.c

index 0ebe3f288de2a4ba9f6c12100d47f4f188253169..b6322b52bc98cab5ed054b3acfcc16199df85788 100644 (file)
@@ -98,11 +98,11 @@ DEFER: (infer)
         [ drop f ] when
     ] catch ;
 
-: infer-branches ( consume instruction branchlist -- )
+: infer-branches ( branchlist consume instruction -- )
     #! Recursive stack effect inference is done here. If one of
     #! the branches has an undecidable stack effect, we set the
     #! base case to this stack effect and try again.
-    f over [ recursive-branch or ] each [
+    rot f over [ recursive-branch or ] each [
         [ [ car infer-branch , ] map ] make-list swap
         >r dataflow, r> unify
     ] [
@@ -111,8 +111,10 @@ DEFER: (infer)
 
 : infer-ifte ( -- )
     #! Infer effects for both branches, unify.
-    3 IFTE
-    pop-d pop-d 2list
+    3 ensure-d
+    \ drop dataflow-word, pop-d
+    \ drop dataflow-word, pop-d 2list
+    1 inputs IFTE
     pop-d drop ( condition )
     infer-branches ;
 
@@ -126,15 +128,17 @@ DEFER: (infer)
 
 : infer-generic ( -- )
     #! Infer effects for all branches, unify.
-    2 GENERIC
-    pop-d vtable>list
+    2 ensure-d
+    \ drop dataflow-word, pop-d vtable>list
+    1 inputs GENERIC
     peek-d drop ( dispatch )
     infer-branches ;
 
 : infer-2generic ( -- )
     #! Infer effects for all branches, unify.
-    3 2GENERIC
-    pop-d vtable>list
+    3 ensure-d
+    \ drop dataflow-word, pop-d vtable>list
+    2 inputs 2GENERIC
     peek-d drop ( dispatch )
     peek-d drop ( dispatch )
     infer-branches ;
index 9ca33761e5240db5021eb03b301558d575cb11c2..266f1f6d55f211cf8961fff3cd8837dc725e460a 100644 (file)
@@ -49,19 +49,19 @@ SYMBOL: 2GENERIC
 : get-dataflow ( -- IR )
     dataflow-graph get reverse ;
 
+: inputs ( count -- vector )
+    meta-d get [ vector-length swap - ] keep vector-tail ;
+
 : dataflow, ( consume instruction parameters -- )
     #! Add a node to the dataflow IR. Each node is a list of
     #! three elements:
-    #! - list of elements consumed from stack
+    #! - vector of elements consumed from stack
     #! - a symbol CALL, JUMP or PUSH
     #! - parameter(s) to insn
     unit cons cons  dataflow-graph cons@ ;
 
 : dataflow-literal, ( lit -- )
-    >r f PUSH r> dataflow, ;
-
-: inputs ( count -- vector )
-    meta-d get [ vector-length swap - ] keep vector-tail ;
+    >r 0 inputs PUSH r> dataflow, ;
 
 : dataflow-word, ( word -- )
     [
index 78492920b635b5e18a3746d98a0d1455194d299b..73a9c036d46d218b29a9a2d3b0e8712ab5891064 100644 (file)
@@ -33,10 +33,16 @@ USE: lists
 
 : meta-infer ( word -- )
     #! Mark a word as being partially evaluated.
-    dup unit [ car host-word ] cons  "infer" set-word-property ;
+    dup unit [
+        car dup dataflow-word, host-word
+    ] cons  "infer" set-word-property ;
 
-\ >r [ pop-d push-r ] "infer" set-word-property
-\ r> [ pop-r push-d ] "infer" set-word-property
+\ >r [
+    \ >r dataflow-word, pop-d push-r
+] "infer" set-word-property
+\ r> [
+    \ r> dataflow-word, pop-r push-d
+] "infer" set-word-property
 
 \ drop meta-infer
 \ 2drop meta-infer 
index 12cc514f9ac5d46b72f871e7c596de0f23ce3051..905205ecd1a3452d3a990f549b8fb07efcc5838d 100644 (file)
@@ -45,11 +45,11 @@ USE: hashtables
     #! either execute the word in the meta interpreter (if it is
     #! side-effect-free and all parameters are literal), or
     #! simply apply its stack effect to the meta-interpreter.
-    dup car ensure-d  over dataflow-word,
-    swap "infer" word-property dup [
-        nip call
+    dup car ensure-d 
+    over "infer" word-property dup [
+        nip nip call
     ] [
-        drop consume/produce
+        drop swap dataflow-word, consume/produce
     ] ifte ;
 
 : no-effect ( word -- )
@@ -118,6 +118,7 @@ USE: hashtables
     ] ifte ;
 
 : infer-call ( [ rstate | quot ] -- )
+    \ drop dataflow-word,
     [
         dataflow-graph off
         pop-d uncons recursive-state set (infer)
index 0b4b99e1e25b8bdb25de5a1b01a7aee9c040bbed..59e72d5f25ea732643af275dd185e69bcaf789fc 100644 (file)
@@ -19,7 +19,6 @@ PORT* port(PORT_MODE type, CELL fd)
        port->type = type;
        port->closed = false;
        port->fd = fd;
-       port->line = F;
        port->client_host = F;
        port->client_port = F;
        port->client_socket = F;