From ffjeld at common-lisp.net Thu Sep 1 22:53:14 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Fri, 2 Sep 2005 00:53:14 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/compiler.lisp Message-ID: <20050901225314.999D788552@common-lisp.net> Update of /project/movitz/cvsroot/movitz In directory common-lisp.net:/tmp/cvs-serv31293 Modified Files: compiler.lisp Log Message: Fixed bug in make-store-lexical that would produce bogus code when the source was a boolean expression. Date: Fri Sep 2 00:52:59 2005 Author: ffjeld Index: movitz/compiler.lisp diff -u movitz/compiler.lisp:1.162 movitz/compiler.lisp:1.163 --- movitz/compiler.lisp:1.162 Thu Sep 1 00:30:55 2005 +++ movitz/compiler.lisp Fri Sep 2 00:52:58 2005 @@ -8,7 +8,7 @@ ;;;; Created at: Wed Oct 25 12:30:49 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: compiler.lisp,v 1.162 2005/08/31 22:30:55 ffjeld Exp $ +;;;; $Id: compiler.lisp,v 1.163 2005/09/01 22:52:58 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -3833,11 +3833,37 @@ (t `((:movl ,source :eax) (,*compiler-global-segment-prefix* :call (:edi ,(global-constant-offset 'unbox-u32)))))))))) + ((eq source :boolean-cf=1) + (let ((tmp (chose-free-register protect-registers))) + `((:sbbl :ecx :ecx) + (,*compiler-local-segment-prefix* + :movl (:edi (:ecx 4) ,(global-constant-offset 'not-not-nil)) ,tmp) + ,@(make-store-lexical binding tmp shared-reference-p funobj frame-map + :protect-registers protect-registers)))) + ((eq source :boolean-cf=0) + (let ((tmp (chose-free-register protect-registers))) + `((:sbbl :ecx :ecx) + (,*compiler-local-segment-prefix* + :movl (:edi (:ecx 4) ,(global-constant-offset 'boolean-zero)) ,tmp) + ,@(make-store-lexical binding tmp shared-reference-p funobj frame-map + :protect-registers protect-registers)))) + ((and *compiler-use-cmov-p* + (member source +boolean-modes+)) + (let ((tmp (chose-free-register protect-registers))) + (append `((:movl :edi ,tmp)) + (list (cons *compiler-local-segment-prefix* + (make-cmov-on-boolean source + `(:edi ,(global-constant-offset 't-symbol)) + tmp))) + (make-store-lexical binding tmp shared-reference-p funobj frame-map + :protect-registers protect-registers)))) ((member source +boolean-modes+) (let ((tmp (chose-free-register protect-registers)) (label (gensym "store-lexical-bool-"))) (append `((:movl :edi ,tmp)) - (list (make-branch-on-boolean source label)) + (list (make-branch-on-boolean source label :invert t)) + `((,*compiler-local-segment-prefix* + :movl (:edi ,(global-constant-offset 't-symbol)) ,tmp)) (list label) (make-store-lexical binding tmp shared-reference-p funobj frame-map :protect-registers protect-registers)))) From ffjeld at common-lisp.net Thu Sep 1 22:53:54 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Fri, 2 Sep 2005 00:53:54 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/interrupt.lisp Message-ID: <20050901225354.1C444880E6@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv31319 Modified Files: interrupt.lisp Log Message: sync Date: Fri Sep 2 00:53:53 2005 Author: ffjeld Index: movitz/losp/muerte/interrupt.lisp diff -u movitz/losp/muerte/interrupt.lisp:1.48 movitz/losp/muerte/interrupt.lisp:1.49 --- movitz/losp/muerte/interrupt.lisp:1.48 Fri Aug 26 21:40:32 2005 +++ movitz/losp/muerte/interrupt.lisp Fri Sep 2 00:53:53 2005 @@ -10,7 +10,7 @@ ;;;; Author: Frode Vatvedt Fjeld ;;;; Created at: Wed Apr 7 01:50:03 2004 ;;;; -;;;; $Id: interrupt.lisp,v 1.48 2005/08/26 19:40:32 ffjeld Exp $ +;;;; $Id: interrupt.lisp,v 1.49 2005/09/01 22:53:53 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -348,7 +348,7 @@ (princ "Halting CPU due to stack exhaustion.") (halt-cpu)) ((<= stack-left 1024) - (backtrace :print-frames t) + #+ignore (backtrace :print-frames t) (halt-cpu) #+ignore (format *debug-io* @@ -363,6 +363,7 @@ (format *debug-io* "~&Stack-warning: Bumped stack-bottom by ~D to #x~X. Reset ES.~%" (- old-bottom new-bottom) new-bottom) + (backtrace :length 5 :spartan t) (break "Stack overload exception ~D at EIP=~@Z, ESP=~@Z, bottom=#x~X, ENV=#x~X." vector $eip (dit-frame-esp nil dit-frame) From ffjeld at common-lisp.net Tue Sep 6 22:00:19 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Wed, 7 Sep 2005 00:00:19 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/compiler.lisp Message-ID: <20050906220019.268388815C@common-lisp.net> Update of /project/movitz/cvsroot/movitz In directory common-lisp.net:/tmp/cvs-serv6951 Modified Files: compiler.lisp Log Message: Fixed bug in make-load-lexical: Loading a constant into :untagged-fixnum-ecx would load the boxed fixnum rather than the unboxed value. Date: Wed Sep 7 00:00:18 2005 Author: ffjeld Index: movitz/compiler.lisp diff -u movitz/compiler.lisp:1.163 movitz/compiler.lisp:1.164 --- movitz/compiler.lisp:1.163 Fri Sep 2 00:52:58 2005 +++ movitz/compiler.lisp Wed Sep 7 00:00:17 2005 @@ -8,7 +8,7 @@ ;;;; Created at: Wed Oct 25 12:30:49 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: compiler.lisp,v 1.163 2005/09/01 22:52:58 ffjeld Exp $ +;;;; $Id: compiler.lisp,v 1.164 2005/09/06 22:00:17 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -3546,7 +3546,7 @@ (type-specifier-singleton decoded-type)) #+ignore (warn "Immloadlex: ~S" (type-specifier-singleton decoded-type)) - (make-immediate-move (movitz-immediate-value + (make-immediate-move (movitz-fixnum-value (car (type-specifier-singleton decoded-type))) :ecx)) ((and binding-type From ffjeld at common-lisp.net Fri Sep 16 22:05:47 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sat, 17 Sep 2005 00:05:47 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/integers.lisp Message-ID: <20050916220547.1AD5188031@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv31870 Modified Files: integers.lisp Log Message: Fixed bug in ldb%byte that would erroneously return 0 for byte-positions above #x4000. Date: Sat Sep 17 00:05:46 2005 Author: ffjeld Index: movitz/losp/muerte/integers.lisp diff -u movitz/losp/muerte/integers.lisp:1.110 movitz/losp/muerte/integers.lisp:1.111 --- movitz/losp/muerte/integers.lisp:1.110 Thu Sep 1 00:34:14 2005 +++ movitz/losp/muerte/integers.lisp Sat Sep 17 00:05:46 2005 @@ -9,7 +9,7 @@ ;;;; Created at: Wed Nov 8 18:44:57 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: integers.lisp,v 1.110 2005/08/31 22:34:14 ffjeld Exp $ +;;;; $Id: integers.lisp,v 1.111 2005/09/16 22:05:46 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -1053,6 +1053,10 @@ (i 0 (+ i 29))) ((>= i length) (bignum-canonicalize r)) (bignum-set-zerof tmp) + (when (get 'foo 'foo) + (format t "~&i: ~D, y: #x~X ~S/~S~%" i (ldb (byte 29 i) y) + (integer-length x) + (integer-length y))) (bignum-addf r (bignum-shift-leftf (bignum-mulf (bignum-addf tmp x) (ldb (byte 29 i) y)) i))) @@ -1797,7 +1801,8 @@ (:sarl 5 :ecx) (:andl -4 :ecx) (:addl 4 :ecx) - (:cmpl #x4000 :ecx) + (:cmpl ,(* #x4000 movitz:+movitz-fixnum-factor+) + :ecx) (:jae 'position-outside-integer) (:cmpw :cx (:ebx (:offset movitz-bignum length))) (:jc '(:sub-program (position-outside-integer) @@ -2173,7 +2178,14 @@ (defun expt (base-number power-number) "Take base-number to the power-number." - (do ((i 0 (1+ i)) - (r 1 (* r base-number))) - ((>= i power-number) r))) + (etypecase power-number + (positive-fixnum + (do ((i 0 (1+ i)) + (r 1 (* r base-number))) + ((>= i power-number) r) + (declare (index i)))) + (positive-bignum + (do ((i 0 (1+ i)) + (r 1 (* r base-number))) + ((>= i power-number) r))))) From ffjeld at common-lisp.net Fri Sep 16 22:15:01 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sat, 17 Sep 2005 00:15:01 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/integers.lisp Message-ID: <20050916221501.75F5988537@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv32150 Modified Files: integers.lisp Log Message: Fixed bug in ldb%byte that would erroneously return 0 for byte-positions above #x4000. (same bug present at anoter spot.) Date: Sat Sep 17 00:14:59 2005 Author: ffjeld Index: movitz/losp/muerte/integers.lisp diff -u movitz/losp/muerte/integers.lisp:1.111 movitz/losp/muerte/integers.lisp:1.112 --- movitz/losp/muerte/integers.lisp:1.111 Sat Sep 17 00:05:46 2005 +++ movitz/losp/muerte/integers.lisp Sat Sep 17 00:14:59 2005 @@ -9,7 +9,7 @@ ;;;; Created at: Wed Nov 8 18:44:57 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: integers.lisp,v 1.111 2005/09/16 22:05:46 ffjeld Exp $ +;;;; $Id: integers.lisp,v 1.112 2005/09/16 22:14:59 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -1862,7 +1862,8 @@ (:compile-form (:result-mode :ebx) integer) (:compile-form (:result-mode :ecx) position) (:shrl 5 :ecx) ; compute fixnum bigit-number in ecx - (:cmpl #x4000 :ecx) + (:cmpl ,(* #x4000 movitz:+movitz-fixnum-factor+) + :ecx) (:jnc 'position-outside-integer) (:cmpw :cx (:ebx (:offset movitz-bignum length))) (:jbe '(:sub-program (position-outside-integer) From ffjeld at common-lisp.net Fri Sep 16 22:48:07 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sat, 17 Sep 2005 00:48:07 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/io-port.lisp Message-ID: <20050916224807.4FC748854A@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv2783 Modified Files: io-port.lisp Log Message: Added (io-port :location). Date: Sat Sep 17 00:48:06 2005 Author: ffjeld Index: movitz/losp/muerte/io-port.lisp diff -u movitz/losp/muerte/io-port.lisp:1.18 movitz/losp/muerte/io-port.lisp:1.19 --- movitz/losp/muerte/io-port.lisp:1.18 Sat Aug 20 22:27:19 2005 +++ movitz/losp/muerte/io-port.lisp Sat Sep 17 00:48:06 2005 @@ -10,7 +10,7 @@ ;;;; Author: Frode Vatvedt Fjeld ;;;; Created at: Wed Mar 21 22:14:08 2001 ;;;; -;;;; $Id: io-port.lisp,v 1.18 2005/08/20 20:27:19 ffjeld Exp $ +;;;; $Id: io-port.lisp,v 1.19 2005/09/16 22:48:06 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -79,6 +79,15 @@ (:movl :edi :eax) (:movl :edi :edx) (:cld))) + (:location + `(with-inline-assembly (:returns :eax :type fixnum) + (:compile-form (:result-mode :edx) ,port) + (:std) + (:shrl ,movitz::+movitz-fixnum-shift+ :edx) + (:inl :dx :eax) + (:andl -8 :eax) + (:movl :edi :edx) + (:cld))) (:character `(with-inline-assembly (:returns :eax) (:compile-form (:result-mode :edx) ,port) @@ -99,6 +108,8 @@ (io-port port :unsigned-byte16)) (:unsigned-byte32 (io-port port :unsigned-byte32)) + (:location + (io-port port :location)) (:character (io-port port :character)))) @@ -260,6 +271,20 @@ (:movl :edi :edx) (:movl :edi :eax) (:cld)))) + (:location + `(let ((,value-var ,value) + (,port-var ,port)) + (with-inline-assembly (:returns :nothing) + (:load-lexical (:lexical-binding ,port-var) :edx) + (:load-lexical (:lexical-binding ,value-var) :eax) + (:andl -8 :eax) + (:std) + (:shrl ,movitz::+movitz-fixnum-shift+ :edx) + (:outl :eax :dx) + (:movl :edi :edx) + (:movl :edi :eax) + (:cld)) + ,value-var)) (:character `(let ((,value-var ,value) (,port-var ,port)) @@ -284,6 +309,8 @@ (setf (io-port port :unsigned-byte16) value)) (:unsigned-byte32 (setf (io-port port :unsigned-byte32) value)) + (:location + (setf (io-port port :location) value)) (:character (setf (io-port port :character) value)))) @@ -309,7 +336,7 @@ that reads from plus some offset." (let ((io-var (gensym "io-base-"))) `(let ((,io-var (check-the (unsigned-byte 16) ,io-base-form))) - (symbol-macrolet ((,name ,io-var)) + (let ((,name ,io-var)) (macrolet ((,name (offset &optional (type :unsigned-byte8)) `(io-port (+ ,',io-var ,offset) ,type))) , at body))))) From ffjeld at common-lisp.net Fri Sep 16 22:49:35 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sat, 17 Sep 2005 00:49:35 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/eval.lisp Message-ID: <20050916224935.C8DD88854A@common-lisp.net> Update of /project/movitz/cvsroot/movitz In directory common-lisp.net:/tmp/cvs-serv2810 Modified Files: eval.lisp Log Message: Fix eval of coerce. Date: Sat Sep 17 00:49:35 2005 Author: ffjeld Index: movitz/eval.lisp diff -u movitz/eval.lisp:1.9 movitz/eval.lisp:1.10 --- movitz/eval.lisp:1.9 Thu Dec 9 14:27:28 2004 +++ movitz/eval.lisp Sat Sep 17 00:49:34 2005 @@ -1,6 +1,6 @@ ;;;;------------------------------------------------------------------ ;;;; -;;;; Copyright (C) 20012000, 2002-2004, +;;;; Copyright (C) 2000-2005, ;;;; Department of Computer Science, University of Tromso, Norway ;;;; ;;;; Filename: eval.lisp @@ -9,7 +9,7 @@ ;;;; Created at: Thu Nov 2 17:45:05 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: eval.lisp,v 1.9 2004/12/09 13:27:28 ffjeld Exp $ +;;;; $Id: eval.lisp,v 1.10 2005/09/16 22:49:34 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -149,7 +149,7 @@ (cdr form)))) ((member operator '(muerte.cl:coerce)) (apply #'coerce - (mapcar (lambda (arg) (movitz-eval arg env nil)) + (mapcar (lambda (arg) (translate-program (movitz-eval arg env nil) :muerte.cl :cl)) (cdr form)))) ((and compiler-macro-function (not (movitz-env-get (car form) 'notinline nil env)) From ffjeld at common-lisp.net Fri Sep 16 22:50:09 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sat, 17 Sep 2005 00:50:09 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/special-operators-cl.lisp Message-ID: <20050916225009.069228854A@common-lisp.net> Update of /project/movitz/cvsroot/movitz In directory common-lisp.net:/tmp/cvs-serv2828 Modified Files: special-operators-cl.lisp Log Message: minor edits. Date: Sat Sep 17 00:50:08 2005 Author: ffjeld Index: movitz/special-operators-cl.lisp diff -u movitz/special-operators-cl.lisp:1.48 movitz/special-operators-cl.lisp:1.49 --- movitz/special-operators-cl.lisp:1.48 Sun Aug 28 23:03:27 2005 +++ movitz/special-operators-cl.lisp Sat Sep 17 00:50:08 2005 @@ -9,7 +9,7 @@ ;;;; Created at: Fri Nov 24 16:31:11 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: special-operators-cl.lisp,v 1.48 2005/08/28 21:03:27 ffjeld Exp $ +;;;; $Id: special-operators-cl.lisp,v 1.49 2005/09/16 22:50:08 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -1319,7 +1319,7 @@ ,cleanup-entry ;; First, restore stack-frame in EBP (:movl (:esp) :ebp) - ;; Now (?), modify unwind-protect dyn-env-entry to be normal continuation + ;; Now, modify unwind-protect dyn-env-entry to be normal continuation (:locally (:movl (:edi (:edi-offset unbound-function)) :edx)) (:movl :edx (:esp 4)) ; not unwind-protect-tag (:movl ',continue-label (:esp 8)) ; new jumper index @@ -1341,25 +1341,10 @@ (:store-lexical ,next-continuation-step-binding :eax :type t)) , at cleanup-forms)) `((:locally (:popl (:edi (:edi-offset raw-scratch0)))) ; pop final continuation - -;;; ;; Now (?), modify unwind-protect dyn-env-entry to be normal continuation -;;; (:locally (:movl (:edi (:edi-offset unbound-value)) :edx)) -;;; (:movl :edx (:esp 4)) ; not unwind-protect-tag -;;; (:movl ',continue-label (:esp 8)) ; new jumper index - (:load-lexical ,next-continuation-step-binding :edx) (:locally (:movl :edx (:edi (:edi-offset dynamic-env)))) (:locally (:call (:edi (:edi-offset dynamic-jump-next)))) - -;;; (:locally (:movl :esi (:edi (:edi-offset scratch1)))) -;;; (:locally (:movl :edx (:edi (:edi-offset dynamic-env)))) -;;; (:movl :edx :esp) ; enter non-local jump stack mode (possibly). -;;; (:movl (:esp) :edx) ; target stack-frame EBP -;;; (:movl (:edx -4) :esi) ; get target funobj into EDX -;;; (:movl (:esp 8) :edx) ; target jumper number -;;; (:jmp (:esi :edx ,(slot-offset 'movitz-funobj 'constant0))) - ) - `(,continue + ,continue (:movl (:esp) :ebp) (:movl (:esp 12) :edx) (:locally (:movl :edx (:edi (:edi-offset dynamic-env)))) From ffjeld at common-lisp.net Fri Sep 16 22:55:15 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sat, 17 Sep 2005 00:55:15 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/integers.lisp Message-ID: <20050916225515.7BBFF88031@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv2947 Modified Files: integers.lisp Log Message: fast-compare-two-reals would fail for bignum comparison where a bignum of 8192 bigits (or 262144 bits) was involved. Date: Sat Sep 17 00:55:12 2005 Author: ffjeld Index: movitz/losp/muerte/integers.lisp diff -u movitz/losp/muerte/integers.lisp:1.112 movitz/losp/muerte/integers.lisp:1.113 --- movitz/losp/muerte/integers.lisp:1.112 Sat Sep 17 00:14:59 2005 +++ movitz/losp/muerte/integers.lisp Sat Sep 17 00:55:11 2005 @@ -9,7 +9,7 @@ ;;;; Created at: Wed Nov 8 18:44:57 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: integers.lisp,v 1.112 2005/09/16 22:14:59 ffjeld Exp $ +;;;; $Id: integers.lisp,v 1.113 2005/09/16 22:55:11 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -74,12 +74,14 @@ ;; Both n1 and n2 are positive bignums. (:shrl 16 :ecx) - (:cmpw :cx (:eax (:offset movitz-bignum length))) + (:movzxw (:eax (:offset movitz-bignum length)) :edx) + ;; (:cmpw :cx (:eax (:offset movitz-bignum length))) + (:cmpl :ecx :edx) (:jne '(:sub-program (positive-different-sizes) (:ret))) ;; Both n1 and n2 are positive bignums of the same size, namely ECX. - (:movl :ecx :edx) ; counter + ;; (:movl :ecx :edx) ; counter positive-compare-loop (:subl ,movitz:+movitz-fixnum-factor+ :edx) (:jz 'positive-compare-lsb) @@ -1053,10 +1055,6 @@ (i 0 (+ i 29))) ((>= i length) (bignum-canonicalize r)) (bignum-set-zerof tmp) - (when (get 'foo 'foo) - (format t "~&i: ~D, y: #x~X ~S/~S~%" i (ldb (byte 29 i) y) - (integer-length x) - (integer-length y))) (bignum-addf r (bignum-shift-leftf (bignum-mulf (bignum-addf tmp x) (ldb (byte 29 i) y)) i))) From ffjeld at common-lisp.net Fri Sep 16 23:02:20 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sat, 17 Sep 2005 01:02:20 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/integers.lisp Message-ID: <20050916230220.145878854A@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv3942 Modified Files: integers.lisp Log Message: Added expt with negative power-number. Date: Sat Sep 17 01:02:19 2005 Author: ffjeld Index: movitz/losp/muerte/integers.lisp diff -u movitz/losp/muerte/integers.lisp:1.113 movitz/losp/muerte/integers.lisp:1.114 --- movitz/losp/muerte/integers.lisp:1.113 Sat Sep 17 00:55:11 2005 +++ movitz/losp/muerte/integers.lisp Sat Sep 17 01:02:19 2005 @@ -9,7 +9,7 @@ ;;;; Created at: Wed Nov 8 18:44:57 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: integers.lisp,v 1.113 2005/09/16 22:55:11 ffjeld Exp $ +;;;; $Id: integers.lisp,v 1.114 2005/09/16 23:02:19 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -2186,5 +2186,7 @@ (positive-bignum (do ((i 0 (1+ i)) (r 1 (* r base-number))) - ((>= i power-number) r))))) - + ((>= i power-number) r))) + ((integer * -1) + (/ (expt base-number (- power-number)))))) + From ffjeld at common-lisp.net Sat Sep 17 01:44:30 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sat, 17 Sep 2005 03:44:30 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/integers.lisp Message-ID: <20050917014430.5BC3488031@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv14451 Modified Files: integers.lisp Log Message: Added rootn to implement sqrt and expt for ratio powers. Date: Sat Sep 17 03:44:29 2005 Author: ffjeld Index: movitz/losp/muerte/integers.lisp diff -u movitz/losp/muerte/integers.lisp:1.114 movitz/losp/muerte/integers.lisp:1.115 --- movitz/losp/muerte/integers.lisp:1.114 Sat Sep 17 01:02:19 2005 +++ movitz/losp/muerte/integers.lisp Sat Sep 17 03:44:29 2005 @@ -9,7 +9,7 @@ ;;;; Created at: Wed Nov 8 18:44:57 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: integers.lisp,v 1.114 2005/09/16 23:02:19 ffjeld Exp $ +;;;; $Id: integers.lisp,v 1.115 2005/09/17 01:44:29 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -2175,6 +2175,26 @@ r))) (setf r next-r))))) +(defun rootn (x root) + (check-type root (integer 2 *)) + (let ((root-1 (1- root)) + (r (/ x root))) + (dotimes (i 10 r) + (let ((m (min (integer-length (numerator r)) + (integer-length (denominator r))))) + (when (>= m 32) + (setf r (/ (ash (numerator r) (- 24 m)) + (ash (denominator r) (- 24 m)))))) + #+ignore (format t "~&~D: ~X~%~D: ~F [~D ~D]~%" i r i r + (integer-length (numerator r)) + (integer-length (denominator r))) + (setf r (/ (+ (* root-1 r) + (/ x (expt r root-1))) + root))))) + +(defun sqrt (x) + (rootn x 2)) + (defun expt (base-number power-number) "Take base-number to the power-number." (etypecase power-number @@ -2187,6 +2207,10 @@ (do ((i 0 (1+ i)) (r 1 (* r base-number))) ((>= i power-number) r))) - ((integer * -1) - (/ (expt base-number (- power-number)))))) + ((real * -1) + (/ (expt base-number (- power-number)))) + (ratio + (expt (rootn base-number (denominator power-number)) + (numerator power-number))))) + From ffjeld at common-lisp.net Sun Sep 18 14:23:46 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sun, 18 Sep 2005 16:23:46 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/integers.lisp Message-ID: <20050918142346.094B28854A@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv5553 Modified Files: integers.lisp Log Message: Added (deftype number). Date: Sun Sep 18 16:23:46 2005 Author: ffjeld Index: movitz/losp/muerte/integers.lisp diff -u movitz/losp/muerte/integers.lisp:1.115 movitz/losp/muerte/integers.lisp:1.116 --- movitz/losp/muerte/integers.lisp:1.115 Sat Sep 17 03:44:29 2005 +++ movitz/losp/muerte/integers.lisp Sun Sep 18 16:23:44 2005 @@ -9,7 +9,7 @@ ;;;; Created at: Wed Nov 8 18:44:57 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: integers.lisp,v 1.115 2005/09/17 01:44:29 ffjeld Exp $ +;;;; $Id: integers.lisp,v 1.116 2005/09/18 14:23:44 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -2207,7 +2207,7 @@ (do ((i 0 (1+ i)) (r 1 (* r base-number))) ((>= i power-number) r))) - ((real * -1) + ((number * -1) (/ (expt base-number (- power-number)))) (ratio (expt (rootn base-number (denominator power-number)) From ffjeld at common-lisp.net Sun Sep 18 14:24:06 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sun, 18 Sep 2005 16:24:06 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/arithmetic-macros.lisp Message-ID: <20050918142406.E947A8854E@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv5571 Modified Files: arithmetic-macros.lisp Log Message: Added (deftype number). Date: Sun Sep 18 16:24:01 2005 Author: ffjeld Index: movitz/losp/muerte/arithmetic-macros.lisp diff -u movitz/losp/muerte/arithmetic-macros.lisp:1.11 movitz/losp/muerte/arithmetic-macros.lisp:1.12 --- movitz/losp/muerte/arithmetic-macros.lisp:1.11 Wed Aug 24 09:31:34 2005 +++ movitz/losp/muerte/arithmetic-macros.lisp Sun Sep 18 16:23:48 2005 @@ -10,7 +10,7 @@ ;;;; Author: Frode Vatvedt Fjeld ;;;; Created at: Sat Jul 17 13:42:46 2004 ;;;; -;;;; $Id: arithmetic-macros.lisp,v 1.11 2005/08/24 07:31:34 ffjeld Exp $ +;;;; $Id: arithmetic-macros.lisp,v 1.12 2005/09/18 14:23:48 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -606,7 +606,9 @@ (deftype real (&optional (lower-limit '*) (upper-limit '*)) `(or (integer ,lower-limit ,upper-limit) (rational ,lower-limit ,upper-limit))) - + +(deftype number (&optional (lower-limit '*) (upper-limit '*)) + `(real ,lower-limit ,upper-limit)) (define-simple-typep (bit bitp) (x) (or (eq x 0) (eq x 1))) From ffjeld at common-lisp.net Sun Sep 18 14:42:22 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sun, 18 Sep 2005 16:42:22 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/integers.lisp Message-ID: <20050918144222.D092C88168@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv6822 Modified Files: integers.lisp Log Message: Added lcm. Date: Sun Sep 18 16:42:21 2005 Author: ffjeld Index: movitz/losp/muerte/integers.lisp diff -u movitz/losp/muerte/integers.lisp:1.116 movitz/losp/muerte/integers.lisp:1.117 --- movitz/losp/muerte/integers.lisp:1.116 Sun Sep 18 16:23:44 2005 +++ movitz/losp/muerte/integers.lisp Sun Sep 18 16:42:21 2005 @@ -9,7 +9,7 @@ ;;;; Created at: Wed Nov 8 18:44:57 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: integers.lisp,v 1.116 2005/09/18 14:23:44 ffjeld Exp $ +;;;; $Id: integers.lisp,v 1.117 2005/09/18 14:42:21 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -2137,6 +2137,18 @@ (gcd gcd (car rest))) (rest (cdr integers) (cdr rest))) ((null rest) gcd))))) + +(defun lcm (&rest numbers) + "Returns the least common multiple of one or more integers. LCM of no + arguments is defined to be 1." + (numargs-case + (1 (n) + (abs n)) + (2 (n m) + (abs (* (truncate (max n m) (gcd n m)) (min n m)))) + (t (&rest numbers) + (declare (dynamic-extent numbers)) + (reduce #'lcm numbers)))) (defun floor (n &optional (divisor 1)) "This is floor written in terms of truncate." From ffjeld at common-lisp.net Sun Sep 18 15:09:15 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sun, 18 Sep 2005 17:09:15 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/arithmetic-macros.lisp Message-ID: <20050918150915.CB1458854A@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv8862 Modified Files: arithmetic-macros.lisp Log Message: Changed representation of bytespecs to be cons-cells. Date: Sun Sep 18 17:09:15 2005 Author: ffjeld Index: movitz/losp/muerte/arithmetic-macros.lisp diff -u movitz/losp/muerte/arithmetic-macros.lisp:1.12 movitz/losp/muerte/arithmetic-macros.lisp:1.13 --- movitz/losp/muerte/arithmetic-macros.lisp:1.12 Sun Sep 18 16:23:48 2005 +++ movitz/losp/muerte/arithmetic-macros.lisp Sun Sep 18 17:09:15 2005 @@ -10,7 +10,7 @@ ;;;; Author: Frode Vatvedt Fjeld ;;;; Created at: Sat Jul 17 13:42:46 2004 ;;;; -;;;; $Id: arithmetic-macros.lisp,v 1.12 2005/09/18 14:23:48 ffjeld Exp $ +;;;; $Id: arithmetic-macros.lisp,v 1.13 2005/09/18 15:09:15 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -268,14 +268,14 @@ (t `(no-macro-call * ,factor1 ,factor2))))) (t `(* (* ,(first operands) ,(second operands)) ,@(cddr operands))))) -(define-compiler-macro byte (&whole form size position) + +(define-compiler-macro byte (&whole form size position &environment env) (cond - ((and (integerp size) - (integerp position)) - (+ (* size #x400) position)) - ((integerp size) - `(+ ,position ,(* size #x400))) - (t form))) + ((and (movitz:movitz-constantp size env) + (movitz:movitz-constantp position env)) + `(quote ,(cons (movitz:movitz-eval size env) + (movitz:movitz-eval position env)))) + (t `(cons ,size ,position)))) (define-compiler-macro logand (&whole form &rest integers &environment env) (let ((constant-folded-integers (loop for x in integers From ffjeld at common-lisp.net Sun Sep 18 15:09:26 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sun, 18 Sep 2005 17:09:26 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/integers.lisp Message-ID: <20050918150926.ED21588594@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv8880 Modified Files: integers.lisp Log Message: Changed representation of bytespecs to be cons-cells. Date: Sun Sep 18 17:09:22 2005 Author: ffjeld Index: movitz/losp/muerte/integers.lisp diff -u movitz/losp/muerte/integers.lisp:1.117 movitz/losp/muerte/integers.lisp:1.118 --- movitz/losp/muerte/integers.lisp:1.117 Sun Sep 18 16:42:21 2005 +++ movitz/losp/muerte/integers.lisp Sun Sep 18 17:09:22 2005 @@ -9,7 +9,7 @@ ;;;; Created at: Wed Nov 8 18:44:57 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: integers.lisp,v 1.117 2005/09/18 14:42:21 ffjeld Exp $ +;;;; $Id: integers.lisp,v 1.118 2005/09/18 15:09:22 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -1396,14 +1396,13 @@ ;;; bytes (defun byte (size position) - (check-type position (integer 0 #x3ff)) - (+ (* size #x400) position)) + (cons size position)) (defun byte-size (bytespec) - (values (truncate bytespec #x400))) + (car bytespec)) (defun byte-position (bytespec) - (rem bytespec #x400)) + (cdr bytespec)) (defun logbitp (index integer) (check-type index positive-fixnum) @@ -2082,7 +2081,6 @@ (:jnz 'count-loop))) (positive-bignum (bignum-logcount integer)))) - (defun dpb (newbyte bytespec integer) (logior (if (= 0 newbyte) From ffjeld at common-lisp.net Sun Sep 18 15:58:07 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sun, 18 Sep 2005 17:58:07 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/arithmetic-macros.lisp Message-ID: <20050918155807.B695F88168@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv11984 Modified Files: arithmetic-macros.lisp Log Message: Changed the bytespec representation back to integers. The longest bignum is (expt 2 20) bits, so that's what we use for the position. Most bytespec's sizes will fit in the 9 bits remaining in a fixnum. Date: Sun Sep 18 17:58:06 2005 Author: ffjeld Index: movitz/losp/muerte/arithmetic-macros.lisp diff -u movitz/losp/muerte/arithmetic-macros.lisp:1.13 movitz/losp/muerte/arithmetic-macros.lisp:1.14 --- movitz/losp/muerte/arithmetic-macros.lisp:1.13 Sun Sep 18 17:09:15 2005 +++ movitz/losp/muerte/arithmetic-macros.lisp Sun Sep 18 17:58:05 2005 @@ -10,7 +10,7 @@ ;;;; Author: Frode Vatvedt Fjeld ;;;; Created at: Sat Jul 17 13:42:46 2004 ;;;; -;;;; $Id: arithmetic-macros.lisp,v 1.13 2005/09/18 15:09:15 ffjeld Exp $ +;;;; $Id: arithmetic-macros.lisp,v 1.14 2005/09/18 15:58:05 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -273,9 +273,11 @@ (cond ((and (movitz:movitz-constantp size env) (movitz:movitz-constantp position env)) - `(quote ,(cons (movitz:movitz-eval size env) - (movitz:movitz-eval position env)))) - (t `(cons ,size ,position)))) + (let ((size (movitz:movitz-eval size env)) + (position (movitz:movitz-eval position env))) + (check-type position (unsigned-byte 20)) + (+ position (ash size 20)))) + (t form))) (define-compiler-macro logand (&whole form &rest integers &environment env) (let ((constant-folded-integers (loop for x in integers From ffjeld at common-lisp.net Sun Sep 18 15:58:11 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sun, 18 Sep 2005 17:58:11 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/integers.lisp Message-ID: <20050918155811.8B6D588569@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv12001 Modified Files: integers.lisp Log Message: Changed the bytespec representation back to integers. The longest bignum is (expt 2 20) bits, so that's what we use for the position. Most bytespec's sizes will fit in the 9 bits remaining in a fixnum. Date: Sun Sep 18 17:58:10 2005 Author: ffjeld Index: movitz/losp/muerte/integers.lisp diff -u movitz/losp/muerte/integers.lisp:1.118 movitz/losp/muerte/integers.lisp:1.119 --- movitz/losp/muerte/integers.lisp:1.118 Sun Sep 18 17:09:22 2005 +++ movitz/losp/muerte/integers.lisp Sun Sep 18 17:58:09 2005 @@ -9,7 +9,7 @@ ;;;; Created at: Wed Nov 8 18:44:57 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: integers.lisp,v 1.118 2005/09/18 15:09:22 ffjeld Exp $ +;;;; $Id: integers.lisp,v 1.119 2005/09/18 15:58:09 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -1396,13 +1396,15 @@ ;;; bytes (defun byte (size position) - (cons size position)) + (check-type size positive-fixnum) + (let ((position (check-the (unsigned-byte 20) position))) + (+ position (ash size 20)))) (defun byte-size (bytespec) - (car bytespec)) + (ash bytespec -20)) (defun byte-position (bytespec) - (cdr bytespec)) + (ldb (byte 20 0) bytespec)) (defun logbitp (index integer) (check-type index positive-fixnum) From ffjeld at common-lisp.net Sun Sep 18 16:20:10 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sun, 18 Sep 2005 18:20:10 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/arithmetic-macros.lisp Message-ID: <20050918162010.2F0168854E@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv14444 Modified Files: arithmetic-macros.lisp Log Message: Added proper inlining of logand when the mask is a constant (unsigned-byte 32). Date: Sun Sep 18 18:20:05 2005 Author: ffjeld Index: movitz/losp/muerte/arithmetic-macros.lisp diff -u movitz/losp/muerte/arithmetic-macros.lisp:1.14 movitz/losp/muerte/arithmetic-macros.lisp:1.15 --- movitz/losp/muerte/arithmetic-macros.lisp:1.14 Sun Sep 18 17:58:05 2005 +++ movitz/losp/muerte/arithmetic-macros.lisp Sun Sep 18 18:20:04 2005 @@ -10,7 +10,7 @@ ;;;; Author: Frode Vatvedt Fjeld ;;;; Created at: Sat Jul 17 13:42:46 2004 ;;;; -;;;; $Id: arithmetic-macros.lisp,v 1.14 2005/09/18 15:58:05 ffjeld Exp $ +;;;; $Id: arithmetic-macros.lisp,v 1.15 2005/09/18 16:20:04 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -293,7 +293,18 @@ (case (length constant-folded-integers) (0 0) (1 (first constant-folded-integers)) - (2 `(no-macro-call logand ,(first constant-folded-integers) ,(second constant-folded-integers))) + (2 (cond + ((typep (first constant-folded-integers) + '(unsigned-byte 32)) + (let ((x (first constant-folded-integers))) + `(with-inline-assembly (:returns :untagged-fixnum-ecx + :type (unsigned-byte ,(integer-length x))) + (:compile-form (:result-mode :untagged-fixnum-ecx) + ,(second constant-folded-integers)) + (:andl ,x :ecx)))) + (t `(no-macro-call logand + ,(first constant-folded-integers) + ,(second constant-folded-integers))))) (t `(logand (logand ,(first constant-folded-integers) ,(second constant-folded-integers)) ,@(cddr constant-folded-integers)))))) From ffjeld at common-lisp.net Sun Sep 18 16:20:36 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sun, 18 Sep 2005 18:20:36 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/compiler.lisp Message-ID: <20050918162036.7E4738854E@common-lisp.net> Update of /project/movitz/cvsroot/movitz In directory common-lisp.net:/tmp/cvs-serv14470 Modified Files: compiler.lisp Log Message: Teached the compiler to add a constant to :untagged-fixnum-ecx. Date: Sun Sep 18 18:20:35 2005 Author: ffjeld Index: movitz/compiler.lisp diff -u movitz/compiler.lisp:1.164 movitz/compiler.lisp:1.165 --- movitz/compiler.lisp:1.164 Wed Sep 7 00:00:17 2005 +++ movitz/compiler.lisp Sun Sep 18 18:20:35 2005 @@ -8,7 +8,7 @@ ;;;; Created at: Wed Oct 25 12:30:49 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: compiler.lisp,v 1.164 2005/09/06 22:00:17 ffjeld Exp $ +;;;; $Id: compiler.lisp,v 1.165 2005/09/18 16:20:35 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -7007,6 +7007,8 @@ ((eq :argument-stack (operator loc1)) `((:addl ,constant0 (:ebp ,(argument-stack-offset (binding-target term1)))))) + ((eq :untagged-fixnum-ecx (operator loc1)) + `((:addl ,(truncate constant0 +movitz-fixnum-factor+) :ecx))) (t (error "Don't know how to add this for loc1 ~S" loc1)))) ((and constant0 (integerp destination-location) From ffjeld at common-lisp.net Sun Sep 18 16:21:26 2005 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Sun, 18 Sep 2005 18:21:26 +0200 (CEST) Subject: [movitz-cvs] CVS update: movitz/losp/muerte/io-port.lisp Message-ID: <20050918162126.56AFB88537@common-lisp.net> Update of /project/movitz/cvsroot/movitz/losp/muerte In directory common-lisp.net:/tmp/cvs-serv14485 Modified Files: io-port.lisp Log Message: Added ignorable declarations for with-io-register-syntax. Date: Sun Sep 18 18:21:25 2005 Author: ffjeld Index: movitz/losp/muerte/io-port.lisp diff -u movitz/losp/muerte/io-port.lisp:1.19 movitz/losp/muerte/io-port.lisp:1.20 --- movitz/losp/muerte/io-port.lisp:1.19 Sat Sep 17 00:48:06 2005 +++ movitz/losp/muerte/io-port.lisp Sun Sep 18 18:21:25 2005 @@ -10,7 +10,7 @@ ;;;; Author: Frode Vatvedt Fjeld ;;;; Created at: Wed Mar 21 22:14:08 2001 ;;;; -;;;; $Id: io-port.lisp,v 1.19 2005/09/16 22:48:06 ffjeld Exp $ +;;;; $Id: io-port.lisp,v 1.20 2005/09/18 16:21:25 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -337,6 +337,7 @@ (let ((io-var (gensym "io-base-"))) `(let ((,io-var (check-the (unsigned-byte 16) ,io-base-form))) (let ((,name ,io-var)) + (declare (ignorable ,name)) (macrolet ((,name (offset &optional (type :unsigned-byte8)) `(io-port (+ ,',io-var ,offset) ,type))) , at body)))))