New basic block optimizer performs more aggressive dead load and store elimination.
Stack shuffles are compiled more efficiently.
Pushing literals on either side of a stack shuffle is now compiled more efficiently.
-
Tail-recursive inlined words are compiled in a new way, saving a few instructions.
-
Sequences:
+
Collections:
Faster map, 2each and 2map.
Arrays are now better supported and should be used instead of vectors where resizing is not desired.
+
Some new sequence words that do not bounds check: nth-unsafe and set-nth-unsafe. These should only be used in special circumstances, such as inner loops (each, map and so on use them).
+
Hashtables did not obey the rule that equal objects must have equal hashcodes, so using hashtables as hashtable keys did not work.
Everything else:
+
Easier exception handling. The cleanup ( try cleanup -- ) word encapsulates the following idiom:
+
+[ A ] [ B rethrow ] catch
+[ A ] [ B ] cleanup
+
+The recover ( try recover -- ) word encapsulates the following idiom:
+
+[ A ] [ [ B ] when* ] catch
+[ A ] [ B ] recover
+
+The catch ( try -- error/f ) word no longer takes a quotation that receives the error caught; rather, it just pushes the error that was caught on the stack. That is, the old way:
+
+[ A ] [ B ] catch
+
+Becomes:
+
+[ A ] catch B
+
+However, most uses of catch can be replaced by cleanup and recover.
The distinct t type is gone. Now, the t object is just a symbol.
-
Hashtables did not obey the rule that equal objects must have equal hashcodes, so using hashtables as hashtable keys did not work.
+
A new with-server ( port ident quot -- ) combinator takes care of listening on a network socket, logging client connections, spawning client handler threads, and error handling. The quotation is called for each client, in a new scope with the client socket as the default stream.
+
New 1+, 1- words are a bit faster than 1 + and 1 - since there is one less generic dispatch involved.
diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt
index d8d834de46..43f6ae8b2a 100644
--- a/TODO.FACTOR.txt
+++ b/TODO.FACTOR.txt
@@ -1,6 +1,21 @@
-- nodes: lazily create history, class/literal map hashes
- 5 car gives wrong error
- compile interruption checks
+- check that set-datastack and set-callstack compile correctly in the
+ face of optimization
+- [ 2cdr < ] sort -- sig11
+- slice: if sequence or seq start is changed, abstraction violation
+- array>tuple: check length and class
+- code walker & exceptions
+- floating point intrinsics
+- fix fixnum/mod overflow on PowerPC
+- intrinsic char-slot set-char-slot
+- split: return vectors
+- vectors: ensure its ok with bignum indices
+- nth-unsafe and set-nth-unsafe; ensure it works with bignum indices
+- set-path: iterative
+- parse-command-line: no unswons of cli args
+- investigate if rehashing on startup is really necessary
+- remove word transfer hack in bootstrap
+ ui:
@@ -35,7 +50,6 @@
http://clozure.com/cgi-bin/viewcvs.cgi/ccl/lisp-kernel/lisp-exceptions.c?rev=1.9&content-type=text/vnd.viewcvs-markup
- http keep alive, and range get
-- code walker & exceptions
+ ffi:
@@ -55,10 +69,7 @@
- [ ] [ throw ] ifte ==> should raise 'unbalanced branches' error
- declare slot types for built-ins
- remove dead code after a 'throw'
-- floating point intrinsics
- flushing optimization
-- fix fixnum/mod overflow on PowerPC
-- intrinsic char-slot set-char-slot
- [ [ dup call ] dup call ] infer hangs
- the invalid recursion form case needs to be fixed, for inlines too
- recursion is iffy; if the stack at the recursive call doesn't match
@@ -66,11 +77,8 @@
+ sequences:
-- split: return vectors
- specialized arrays
- instances: do not use make-list
-- vectors: ensure its ok with bignum indices
-- nth-unsafe and set-nth-unsafe; ensure it works with bignum indices
- >c/c>: vector stack
- search: slow
- vectorize >n, n>, (get)
@@ -91,10 +99,6 @@
- there is a problem with hashcodes of words and bootstrapping
- delegating generic words with a non-standard picker
- code gc
-- set-path: iterative
-- parse-command-line: no unswons of cli args
-- investigate if rehashing on startup is really necessary
-- remove word transfer hack in bootstrap
+ i/o:
diff --git a/library/compiler/basic-blocks.factor b/library/compiler/basic-blocks.factor
index 0dc6ccb48a..377fa18c02 100644
--- a/library/compiler/basic-blocks.factor
+++ b/library/compiler/basic-blocks.factor
@@ -30,19 +30,17 @@ M: %inc-d simplify-stack* ( vop -- ) d-height accum-height ;
M: %inc-r simplify-stack* ( vop -- ) r-height accum-height ;
-: update-ds ( vop -- )
+GENERIC: update-loc ( loc -- )
+
+M: ds-loc update-loc
dup ds-loc-n d-height get - swap set-ds-loc-n ;
-: update-cs ( vop -- )
+M: cs-loc update-loc
dup cs-loc-n r-height get - swap set-cs-loc-n ;
-M: %peek-d simplify-stack* ( vop -- ) 0 vop-in update-ds ;
+M: %peek simplify-stack* ( vop -- ) 0 vop-in update-loc ;
-M: %peek-r simplify-stack* ( vop -- ) 0 vop-in update-cs ;
-
-M: %replace-d simplify-stack* ( vop -- ) 0 vop-out update-ds ;
-
-M: %replace-r simplify-stack* ( vop -- ) 0 vop-out update-cs ;
+M: %replace simplify-stack* ( vop -- ) 0 vop-out update-loc ;
: simplify-stack ( block -- )
#! Combine all %inc-d/%inc-r into two final ones.
@@ -106,14 +104,10 @@ M: %inc-r trim-dead* ( tail vop -- ) simplify-inc drop ;
: redundant-peek? ( vop -- ? )
dup 0 vop-in swap 0 vop-out vreg-contents get hash = ;
-: ?dead-peek ( tail vop -- )
+M: %peek trim-dead* ( tail vop -- )
dup redundant-peek? >r tuck live-load? not r> or
[ dup remember-peek dup , ] unless drop ;
-M: %peek-d trim-dead* ( tail vop -- ) ?dead-peek ;
-
-M: %peek-r trim-dead* ( tail vop -- ) ?dead-peek ;
-
: redundant-replace? ( vop -- ? )
dup 0 vop-out swap 0 vop-in vreg-contents get hash = ;
@@ -128,14 +122,10 @@ M: %peek-r trim-dead* ( tail vop -- ) ?dead-peek ;
dup 0 vop-out forget-stack-loc
dup 0 vop-out swap 0 vop-in vreg-contents get set-hash ;
-: ?dead-replace ( tail vop -- )
+M: %replace trim-dead* ( tail vop -- )
dup redundant-replace? >r tuck live-load? not r> or
[ dup remember-replace dup , ] unless drop ;
-M: %replace-d trim-dead* ( tail vop -- ) ?dead-replace ;
-
-M: %replace-r trim-dead* ( tail vop -- ) ?dead-replace ;
-
: ?dead-literal dup forget-vregs tuck live-load? ?, ;
M: %immediate trim-dead* ( tail vop -- ) ?dead-literal ;
diff --git a/library/compiler/ppc/generator.factor b/library/compiler/ppc/generator.factor
index 63520fa213..2d53efeb3a 100644
--- a/library/compiler/ppc/generator.factor
+++ b/library/compiler/ppc/generator.factor
@@ -72,7 +72,7 @@ M: %untag generate-node ( vop -- )
M: %dispatch generate-node ( vop -- )
0 check-src
- 3 3 2 SLWI
+ 3 3 1 SRAWI
! The value 24 is a magic number. It is the length of the
! instruction sequence that follows to be generated.
0 1 rel-address compiled-offset 24 + 4 LOAD32
@@ -86,9 +86,11 @@ M: %type generate-node ( vop -- )