From 50e15ebb6f96c020d06f6e8b08f8116e5416ebeb Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Tue, 9 Dec 2008 19:38:45 -0600
Subject: [PATCH 1/8] show mount point

---
 basis/tools/files/files.factor | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/basis/tools/files/files.factor b/basis/tools/files/files.factor
index ab9ce01c3e..b4295af205 100755
--- a/basis/tools/files/files.factor
+++ b/basis/tools/files/files.factor
@@ -63,7 +63,7 @@ percent-used percent-free ;
     [ [ unparse ] map ] bi prefix simple-table. ;
 
 : file-systems. ( -- )
-    { device-name free-space used-space total-space percent-used }
+    { device-name free-space used-space total-space percent-used mount-point }
     print-file-systems ;
 
 {

From a4fc4046a0d8c30a6e435a2a7fb14fdd4aaa1aee Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Tue, 9 Dec 2008 20:01:23 -0600
Subject: [PATCH 2/8] Updating epoll code

---
 basis/io/unix/epoll/epoll.factor    | 71 +++++++++++++++--------------
 basis/unix/linux/epoll/epoll.factor | 23 +++++-----
 2 files changed, 48 insertions(+), 46 deletions(-)

diff --git a/basis/io/unix/epoll/epoll.factor b/basis/io/unix/epoll/epoll.factor
index 05a9bcfa8d..237985742b 100644
--- a/basis/io/unix/epoll/epoll.factor
+++ b/basis/io/unix/epoll/epoll.factor
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types kernel io.ports io.unix.backend
-bit-arrays sequences assocs unix unix.linux.epoll math
-namespaces unix.time ;
+USING: accessors alien.c-types kernel io.ports io.unix.backend
+bit-arrays sequences assocs struct-arrays unix unix.linux.epoll
+math namespaces locals unix.time ;
 IN: io.unix.epoll
 
 TUPLE: epoll-mx < mx events ;
@@ -14,47 +14,48 @@ TUPLE: epoll-mx < mx events ;
 
 : <epoll-mx> ( -- mx )
     epoll-mx new-mx
-    max-events epoll_create dup io-error over set-mx-fd
-    max-events "epoll-event" <c-array> over set-epoll-mx-events ;
+        max-events epoll_create dup io-error >>fd
+        max-events "epoll-event" <struct-array> >>events ;
 
-GENERIC: io-task-events ( task -- n )
-
-M: input-task io-task-events drop EPOLLIN ;
-
-M: output-task io-task-events drop EPOLLOUT ;
-
-: make-event ( task -- event )
+: make-event ( fd events -- event )
     "epoll-event" <c-object>
-    over io-task-events over set-epoll-event-events
-    swap io-task-fd over set-epoll-event-fd ;
+    [ set-epoll-event-events ] keep
+    [ set-epoll-event-fd ] keep ;
 
-: do-epoll-ctl ( task mx what -- )
-    >r mx-fd r> rot dup io-task-fd swap make-event
-    epoll_ctl io-error ;
+:: do-epoll-ctl ( fd mx what events -- )
+    mx fd>> what fd events make-event what epoll_ctl io-error ;
 
-M: epoll-mx register-io-task ( task mx -- )
-    [ EPOLL_CTL_ADD do-epoll-ctl ] [ call-next-method ] 2bi ;
+: do-epoll-add ( fd mx events -- )
+    EPOLL_CTL_ADD swap EPOLLONESHOT bitor do-epoll-ctl ;
 
-M: epoll-mx unregister-io-task ( task mx -- )
-    [ call-next-method ] [ EPOLL_CTL_DEL do-epoll-ctl ] 2bi ;
+: do-epoll-del ( fd mx events -- )
+    EPOLL_CTL_DEL swap do-epoll-ctl ;
 
-: wait-event ( mx timeout -- n )
-    >r { mx-fd epoll-mx-events } get-slots max-events
-    r> epoll_wait dup multiplexer-error ;
+M: epoll-mx add-input-callback ( thread fd mx -- )
+    [ EPOLLIN do-epoll-add ] [ call-next-method ] 2bi ;
 
-: epoll-read-task ( mx fd -- )
-    over mx-reads at* [ perform-io-task ] [ 2drop ] if ;
+M: epoll-mx add-output-callback ( thread fd mx -- )
+    [ EPOLLOUT do-epoll-add ] [ call-next-method ] 2bi ;
 
-: epoll-write-task ( mx fd -- )
-    over mx-writes at* [ perform-io-task ] [ 2drop ] if ;
+M: epoll-mx remove-input-callbacks ( fd mx -- seq )
+    2dup reads>> key? [
+        [ call-next-method ] [ EPOLLIN do-epoll-del ] 2bi
+    ] [ 2drop f ] if ;
 
-: handle-event ( mx kevent -- )
-    epoll-event-fd 2dup epoll-read-task epoll-write-task ;
+M: epoll-mx remove-output-callbacks ( fd mx -- seq )
+    2dup writes>> key? [
+        [ EPOLLOUT do-epoll-del ] [ call-next-method ] 2bi
+    ] [ 2drop f ] if ;
+
+: wait-event ( mx us -- n )
+    [ [ fd>> ] [ events>> ] bi max-events ] [ 1000 /i ] bi*
+    epoll_wait dup multiplexer-error ;
+
+: handle-event ( mx event -- )
+    epoll-event-fd [ input-available ] [ output-available ] 2bi ;
 
 : handle-events ( mx n -- )
-    [
-        over epoll-mx-events epoll-event-nth handle-event
-    ] with each ;
+    [ dup events>> ] dip head-slice [ handle-event ] with each ;
 
-M: epoll-mx wait-for-events ( ms mx -- )
-    dup rot wait-event handle-events ;
+M: epoll-mx wait-for-events ( us mx -- )
+    swap 60000 or dupd wait-event handle-events ;
diff --git a/basis/unix/linux/epoll/epoll.factor b/basis/unix/linux/epoll/epoll.factor
index c18fa2ee6c..72935807c3 100644
--- a/basis/unix/linux/epoll/epoll.factor
+++ b/basis/unix/linux/epoll/epoll.factor
@@ -18,14 +18,15 @@ FUNCTION: int epoll_wait ( int epfd, epoll_event* events, int maxevents, int tim
 : EPOLL_CTL_DEL 2 ; inline ! Remove a file decriptor from the interface.
 : EPOLL_CTL_MOD 3 ; inline ! Change file decriptor epoll_event structure.
 
-: EPOLLIN     HEX: 001 ; inline
-: EPOLLPRI    HEX: 002 ; inline
-: EPOLLOUT    HEX: 004 ; inline
-: EPOLLRDNORM HEX: 040 ; inline
-: EPOLLRDBAND HEX: 080 ; inline
-: EPOLLWRNORM HEX: 100 ; inline
-: EPOLLWRBAND HEX: 200 ; inline
-: EPOLLMSG    HEX: 400 ; inline
-: EPOLLERR    HEX: 008 ; inline
-: EPOLLHUP    HEX: 010 ; inline
-: EPOLLET     31 2^    ; inline
+: EPOLLIN      HEX: 001 ; inline
+: EPOLLPRI     HEX: 002 ; inline
+: EPOLLOUT     HEX: 004 ; inline
+: EPOLLRDNORM  HEX: 040 ; inline
+: EPOLLRDBAND  HEX: 080 ; inline
+: EPOLLWRNORM  HEX: 100 ; inline
+: EPOLLWRBAND  HEX: 200 ; inline
+: EPOLLMSG     HEX: 400 ; inline
+: EPOLLERR     HEX: 008 ; inline
+: EPOLLHUP     HEX: 010 ; inline
+: EPOLLONESHOT 30 2^    ; inline
+: EPOLLET      31 2^    ; inline

From e42de00371a771ddeb9b5e58283c81046a307870 Mon Sep 17 00:00:00 2001
From: slava <slava@slava-laptop.(none)>
Date: Tue, 9 Dec 2008 20:55:42 -0600
Subject: [PATCH 3/8] Fix some bugs in epoll, and use it on Linux

---
 basis/io/unix/epoll/epoll.factor | 18 ++++++++++--------
 basis/io/unix/linux/linux.factor |  4 ++--
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/basis/io/unix/epoll/epoll.factor b/basis/io/unix/epoll/epoll.factor
index 237985742b..e8d33787f3 100644
--- a/basis/io/unix/epoll/epoll.factor
+++ b/basis/io/unix/epoll/epoll.factor
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types kernel io.ports io.unix.backend
-bit-arrays sequences assocs struct-arrays unix unix.linux.epoll
-math namespaces locals unix.time ;
+bit-arrays sequences assocs struct-arrays math namespaces locals
+fry unix unix.linux.epoll unix.time ;
 IN: io.unix.epoll
 
 TUPLE: epoll-mx < mx events ;
@@ -23,7 +23,7 @@ TUPLE: epoll-mx < mx events ;
     [ set-epoll-event-fd ] keep ;
 
 :: do-epoll-ctl ( fd mx what events -- )
-    mx fd>> what fd events make-event what epoll_ctl io-error ;
+    mx fd>> what fd fd events make-event epoll_ctl io-error ;
 
 : do-epoll-add ( fd mx events -- )
     EPOLL_CTL_ADD swap EPOLLONESHOT bitor do-epoll-ctl ;
@@ -48,14 +48,16 @@ M: epoll-mx remove-output-callbacks ( fd mx -- seq )
     ] [ 2drop f ] if ;
 
 : wait-event ( mx us -- n )
-    [ [ fd>> ] [ events>> ] bi max-events ] [ 1000 /i ] bi*
+    [ [ fd>> ] [ events>> ] bi [ underlying>> ] [ length ] bi ] [ 1000 /i ] bi*
     epoll_wait dup multiplexer-error ;
 
-: handle-event ( mx event -- )
-    epoll-event-fd [ input-available ] [ output-available ] 2bi ;
+: handle-event ( event mx -- )
+    [ epoll-event-fd ] dip
+    [ EPOLLIN EPOLLOUT bitor do-epoll-del ]
+    [ input-available ] [ output-available ] 2tri ;
 
 : handle-events ( mx n -- )
-    [ dup events>> ] dip head-slice [ handle-event ] with each ;
+    [ dup events>> ] dip head-slice swap '[ _ handle-event ] each ;
 
 M: epoll-mx wait-for-events ( us mx -- )
-    swap 60000 or dupd wait-event handle-events ;
+    swap 60000000 or dupd wait-event handle-events ;
diff --git a/basis/io/unix/linux/linux.factor b/basis/io/unix/linux/linux.factor
index e75f4c5f6b..be5b83f1b0 100644
--- a/basis/io/unix/linux/linux.factor
+++ b/basis/io/unix/linux/linux.factor
@@ -1,10 +1,10 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel io.backend io.monitors io.unix.backend
-io.unix.select io.unix.linux.monitors system namespaces ;
+io.unix.epoll io.unix.linux.monitors system namespaces ;
 IN: io.unix.linux
 
 M: linux init-io ( -- )
-    <select-mx> mx set-global ;
+    <epoll-mx> mx set-global ;
 
 linux set-io-backend

From 7ad6d342122cff0ffe3ef9738cbcd259cdd490fc Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Tue, 9 Dec 2008 21:07:28 -0600
Subject: [PATCH 4/8] Fix byte-arrays tests

---
 core/byte-arrays/byte-arrays-tests.factor | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/core/byte-arrays/byte-arrays-tests.factor b/core/byte-arrays/byte-arrays-tests.factor
index 07b82f6111..edaea108a1 100644
--- a/core/byte-arrays/byte-arrays-tests.factor
+++ b/core/byte-arrays/byte-arrays-tests.factor
@@ -1,7 +1,10 @@
 IN: byte-arrays.tests
-USING: tools.test byte-arrays ;
+USING: tools.test byte-arrays sequences kernel ;
 
-[ B{ 1 2 3 0 0 0 } ] [ 6 B{ 1 2 3 } resize-byte-array ] unit-test
+[ 6 B{ 1 2 3 } ] [
+    6 B{ 1 2 3 } resize-byte-array
+    [ length ] [ 3 head ] bi
+] unit-test
 
 [ B{ 1 2 } ] [ 2 B{ 1 2 3 4 5 6 7 8 9 } resize-byte-array ] unit-test
 

From f3acfcd355fc7e17e0395552dddef240873b170e Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Tue, 9 Dec 2008 21:30:11 -0600
Subject: [PATCH 5/8] replace f with a "" for file-systems.

---
 basis/tools/files/files.factor | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/basis/tools/files/files.factor b/basis/tools/files/files.factor
index b4295af205..7968639d47 100755
--- a/basis/tools/files/files.factor
+++ b/basis/tools/files/files.factor
@@ -41,9 +41,9 @@ percent-used percent-free ;
 
 : file-system-spec ( file-system-info obj -- str )
     {
-        { device-name [ device-name>> ] }
-        { mount-point [ mount-point>> ] }
-        { type [ type>> ] }
+        { device-name [ device-name>> [ "" ] unless* ] }
+        { mount-point [ mount-point>> [ "" ] unless* ] }
+        { type [ type>> [ "" ] unless* ] }
         { available-space [ available-space>> [ 0 ] unless* ] }
         { free-space [ free-space>> [ 0 ] unless* ] }
         { used-space [ used-space>> [ 0 ] unless* ] }

From 2a3db4cd23bec207cd404a8b3ed1bdeedbcea2e5 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Tue, 9 Dec 2008 21:50:31 -0600
Subject: [PATCH 6/8] Minor optimization to flip

---
 core/sequences/sequences.factor | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor
index 8c9eff94f5..e364359928 100644
--- a/core/sequences/sequences.factor
+++ b/core/sequences/sequences.factor
@@ -845,9 +845,10 @@ PRIVATE>
 USE: arrays
 
 : array-length ( array -- len )
-    { array } declare length>> ;
+    { array } declare length>> ; inline
 
 : array-flip ( matrix -- newmatrix )
+    { array } declare
     [ dup first array-length [ array-length min ] reduce ] keep
     [ [ array-nth ] with { } map-as ] curry { } map-as ;
 

From eb654e948e44b34dcc3de93c329f7a35d603a410 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Wed, 10 Dec 2008 01:12:08 -0600
Subject: [PATCH 7/8] Print messages as benchmarks are run

---
 extra/benchmark/benchmark.factor | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/extra/benchmark/benchmark.factor b/extra/benchmark/benchmark.factor
index a1e892229a..9afd211876 100755
--- a/extra/benchmark/benchmark.factor
+++ b/extra/benchmark/benchmark.factor
@@ -6,8 +6,10 @@ continuations debugger math ;
 IN: benchmark
 
 : run-benchmark ( vocab -- result )
-    [ [ require ] [ [ run ] benchmark ] bi ] curry
-    [ error. f ] recover ;
+    [ "=== " write vocab-name print flush ] [
+        [ [ require ] [ [ run ] benchmark ] bi ] curry
+        [ error. f ] recover
+    ] bi ;
 
 : run-benchmarks ( -- assoc )
     "benchmark" all-child-vocabs-seq

From d821cd72815400a31924bb7d8760649029a511e1 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Wed, 10 Dec 2008 01:19:22 -0600
Subject: [PATCH 8/8] Fix win64 bootstrap

---
 basis/cpu/x86/32/bootstrap.factor       | 1 +
 basis/cpu/x86/64/unix/bootstrap.factor  | 1 +
 basis/cpu/x86/64/winnt/bootstrap.factor | 1 +
 basis/cpu/x86/bootstrap.factor          | 4 ++--
 4 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/basis/cpu/x86/32/bootstrap.factor b/basis/cpu/x86/32/bootstrap.factor
index 698c3a1766..f29dec128c 100644
--- a/basis/cpu/x86/32/bootstrap.factor
+++ b/basis/cpu/x86/32/bootstrap.factor
@@ -10,6 +10,7 @@ IN: bootstrap.x86
 : shift-arg ( -- reg ) ECX ;
 : div-arg ( -- reg ) EAX ;
 : mod-arg ( -- reg ) EDX ;
+: arg ( -- reg ) EAX ;
 : temp0 ( -- reg ) EAX ;
 : temp1 ( -- reg ) EDX ;
 : temp2 ( -- reg ) ECX ;
diff --git a/basis/cpu/x86/64/unix/bootstrap.factor b/basis/cpu/x86/64/unix/bootstrap.factor
index a21c4534d2..20a953b6d5 100644
--- a/basis/cpu/x86/64/unix/bootstrap.factor
+++ b/basis/cpu/x86/64/unix/bootstrap.factor
@@ -5,6 +5,7 @@ cpu.x86.assembler layouts vocabs parser ;
 IN: bootstrap.x86
 
 : stack-frame-size ( -- n ) 4 bootstrap-cells ;
+: arg ( -- reg ) RDI ;
 
 << "resource:basis/cpu/x86/64/bootstrap.factor" parse-file parsed >>
 call
diff --git a/basis/cpu/x86/64/winnt/bootstrap.factor b/basis/cpu/x86/64/winnt/bootstrap.factor
index 709f138463..3accca400f 100644
--- a/basis/cpu/x86/64/winnt/bootstrap.factor
+++ b/basis/cpu/x86/64/winnt/bootstrap.factor
@@ -5,6 +5,7 @@ cpu.x86.assembler layouts vocabs parser ;
 IN: bootstrap.x86
 
 : stack-frame-size ( -- n ) 8 bootstrap-cells ;
+: arg ( -- reg ) RCX ;
 
 << "resource:basis/cpu/x86/64/bootstrap.factor" parse-file parsed >>
 call
diff --git a/basis/cpu/x86/bootstrap.factor b/basis/cpu/x86/bootstrap.factor
index 3451da78e1..42fcfaa6a2 100644
--- a/basis/cpu/x86/bootstrap.factor
+++ b/basis/cpu/x86/bootstrap.factor
@@ -162,11 +162,11 @@ big-endian off
 ! Quotations and words
 [
     ! load from stack
-    temp0 ds-reg [] MOV
+    arg ds-reg [] MOV
     ! pop stack
     ds-reg bootstrap-cell SUB
     ! call quotation
-    temp0 quot-xt-offset [+] JMP
+    arg quot-xt-offset [+] JMP
 ] f f f \ (call) define-sub-primitive
 
 [