Changeset 11622


Ignore:
Timestamp:
02/04/09 21:07:44 (13 years ago)
Author:
ehuelsmann
Message:

Eliminate NEW-FIXNUM and EMIT-FIXNUM-INIT in favor of CONVERT-REPRESENTATION.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11621 r11622  
    21612161     (setf (gethash local-function ht) g))))
    21622162
    2163 (defun new-fixnum (&optional (test-val t))
    2164   (when test-val
    2165     (emit 'new +lisp-fixnum-class+)
    2166     (emit 'dup)))
    2167 
    21682163(defknown declare-fixnum (fixnum) string)
    21692164(defun declare-fixnum (n)
     
    21812176      (emit 'aaload))
    21822177     (t
    2183       (new-fixnum)
    21842178      (emit-push-constant-int n)
    2185       (emit-invokespecial-init +lisp-fixnum-class+ '("I"))))
     2179            (convert-representation :int nil)))
    21862180     (emit 'putstatic *this-class* g +lisp-fixnum+)
    21872181     (setf *static-code* *code*)
     
    52325226           (compiler-unsupported "p2-function: unsupported case: ~S" form)))))
    52335227
    5234 (defun emit-fixnum-init (representation)
    5235   (case representation
    5236     (:int)
    5237     (:long
    5238      (emit 'i2l))
    5239     (t
    5240      (emit-invokespecial-init +lisp-fixnum-class+ '("I")))))
    5241 
    52425228(defknown p2-ash (t t t) t)
    52435229(define-inlined-function p2-ash (form target representation)
     
    52635249                (fixnum-type-p type1)
    52645250                (fixnum-type-p result-type))
    5265      (new-fixnum (null representation))
    52665251           (compile-form arg1 'stack :int)
    52675252           (cond ((plusp constant-shift)
     
    52795264                 ((zerop constant-shift)
    52805265                  (compile-form arg2 nil nil))) ; for effect
    5281      (emit-fixnum-init representation)
     5266           (convert-representation :int representation)
    52825267           (emit-move-from-stack target representation))
    52835268          ((and constant-shift
     
    53055290          ((and (fixnum-type-p type1)
    53065291                low2 high2 (<= -31 low2 high2 0)) ; Negative shift.
    5307      (new-fixnum (null representation))
    53085292     (compile-forms-and-maybe-emit-clear-values arg1 'stack :int
    53095293                  arg2 'stack :int)
    53105294           (emit 'ineg)
    53115295           (emit 'ishr)
    5312      (emit-fixnum-init representation)
     5296           (convert-representation :int representation)
    53135297           (emit-move-from-stack target representation))
    53145298          ((fixnum-type-p type2)
     
    53755359                ;;                     (format t "p2-logand fixnum case~%")
    53765360                ;; Both arguments are fixnums.
    5377     (new-fixnum (null representation))
    53785361    (compile-forms-and-maybe-emit-clear-values arg1 'stack :int
    53795362                 arg2 'stack :int)
    53805363                (emit 'iand)
    5381     (emit-fixnum-init representation)
     5364                (convert-representation :int representation)
    53825365                (emit-move-from-stack target representation))
    53835366               ((or (and (fixnum-type-p type1)
     
    53865369                         (compiler-subtypep type2 'unsigned-byte)))
    53875370                ;; One of the arguments is a positive fixnum.
    5388     (new-fixnum (null representation))
    53895371    (compile-forms-and-maybe-emit-clear-values arg1 'stack :int
    53905372                 arg2 'stack :int)
    53915373                (emit 'iand)
    5392     (emit-fixnum-init representation)
     5374                (convert-representation :int representation)
    53935375                (emit-move-from-stack target representation))
    53945376               ((and (java-long-type-p type1) (java-long-type-p type2))
     
    54665448                                  target representation))
    54675449               ((and (fixnum-type-p type1) (fixnum-type-p type2))
    5468     (new-fixnum (null representation))
    54695450    (compile-forms-and-maybe-emit-clear-values arg1 'stack :int
    54705451                 arg2 'stack :int)
    54715452                (emit 'ior)
    5472     (emit-fixnum-init representation)
     5453                (convert-representation :int representation)
    54735454                (emit-move-from-stack target representation))
    54745455               ((and (eql (fixnum-constant-value type1) 0) (< *safety* 3))
     
    55415522               ((and (fixnum-type-p type1) (fixnum-type-p type2))
    55425523;;                 (format t "p2-logxor case 2~%")
    5543     (new-fixnum (null representation))
    55445524    (compile-forms-and-maybe-emit-clear-values arg1 'stack :int
    55455525                 arg2 'stack :int)
    55465526                (emit 'ixor)
    5547     (emit-fixnum-init representation))
     5527                (convert-representation :int representation))
    55485528               ((and (java-long-type-p type1) (java-long-type-p type2))
    55495529    (compile-forms-and-maybe-emit-clear-values arg1 'stack :long
     
    55735553  (cond ((and (fixnum-type-p (derive-compiler-type form)))
    55745554         (let ((arg (%cadr form)))
    5575      (new-fixnum (null representation))
    55765555     (compile-forms-and-maybe-emit-clear-values arg 'stack :int)
    55775556           (emit 'iconst_m1)
    55785557           (emit 'ixor)
    5579      (emit-fixnum-init representation)
     5558           (convert-representation :int representation)
    55805559           (emit-move-from-stack target representation)))
    55815560        (t
     
    56085587          ((and size position)
    56095588           (cond ((<= (+ position size) 31)
    5610       (new-fixnum (null representation))
    56115589      (compile-forms-and-maybe-emit-clear-values size-arg nil nil
    56125590                   position-arg nil nil
     
    56175595                  (emit-push-constant-int (1- (expt 2 size))) ; mask
    56185596                  (emit 'iand)
    5619       (emit-fixnum-init representation)
     5597                  (convert-representation :int representation)
    56205598                  (emit-move-from-stack target representation))
    56215599                 ((<= (+ position size) 63)
    5622       (new-fixnum (and (null representation) (<= size 31)))
    56235600      (compile-forms-and-maybe-emit-clear-values size-arg nil nil
    56245601                   position-arg nil nil
     
    56315608                         (emit-push-constant-int (1- (expt 2 size)))
    56325609                         (emit 'iand)
    5633        (emit-fixnum-init representation))
     5610                         (convert-representation :int representation))
    56345611                        (t
    56355612                         (emit-push-constant-long (1- (expt 2 size))) ; mask
     
    68266803                 (type2 (derive-compiler-type arg2)))
    68276804             (cond ((and (fixnum-type-p type1) (fixnum-type-p type2))
    6828           (new-fixnum (null representation))
    6829                       (compile-form arg1 'stack :int)
    6830                       (emit 'dup)
    6831                       (compile-form arg2 'stack :int)
     6805                    (compile-form arg1 'stack :int)
     6806                    (emit 'dup)
     6807                    (compile-form arg2 'stack :int)
    68326808                    (emit 'dup_x1)
    68336809                    (let ((LABEL1 (gensym)))
    68346810                      (emit (if (eq op 'max) 'if_icmpge 'if_icmple) LABEL1)
    68356811                      (emit 'swap)  ;; The lower stack value is greater-or-equal
    6836                         (label LABEL1)
     6812                      (label LABEL1)
    68376813                      (emit 'pop))  ;; Throw away the lower stack value
    6838         (emit-fixnum-init representation)
     6814                    (convert-representation :int representation)
    68396815                    (emit-move-from-stack target representation))
    68406816                   ((and (java-long-type-p type1) (java-long-type-p type2))
    6841                       (compile-form arg1 'stack :long)
    6842                       (emit 'dup2)
    6843                       (compile-form arg2 'stack :long)
     6817                    (compile-form arg1 'stack :long)
     6818                    (emit 'dup2)
     6819                    (compile-form arg2 'stack :long)
    68446820                    (emit 'dup2_x2)
    6845                       (emit 'lcmp)
     6821                    (emit 'lcmp)
    68466822                    (let ((LABEL1 (gensym)))
    68476823                      (emit (if (eq op 'max) 'ifge 'ifle) LABEL1)
    68486824                      (emit 'dup2_x2) ;; pour-mans swap2
    68496825                      (emit 'pop2)
    6850                         (label LABEL1)
     6826                      (label LABEL1)
    68516827                      (emit 'pop2))
    68526828                    (convert-representation :long representation)
     
    70917067             (emit-invokevirtual class "setCharAt" '("I" "C") nil)
    70927068             (when target
    7093          (new-fixnum (null representation))
    70947069               (emit 'iload value-register)
    7095                (case representation
    7096                  (:char)
    7097                  (t
    7098                   (emit-invokespecial-init +lisp-fixnum-class+ '("I"))))
     7070               (convert-representation :char representation)
    70997071               (emit-move-from-stack target representation))))
    71007072          (t
     
    72717243           (when value-register
    72727244             (cond ((fixnum-type-p type3)
    7273         (new-fixnum (null representation))
    72747245                    (emit 'iload value-register)
    7275         (emit-fixnum-init representation))
     7246                    (convert-representation :int representation))
    72767247                   (t
    72777248                    (aload value-register)
     
    77277698  (cond ((check-arg-count form 1)
    77287699         (let ((arg (%cadr form)))
    7729            (unless (eq representation :int)
    7730        (new-fixnum))
    77317700     (compile-forms-and-maybe-emit-clear-values arg 'stack nil)
    77327701           (emit-invokevirtual +lisp-object-class+ "sxhash" nil "I")
    7733            (unless (eq representation :int)
    7734              (emit-invokespecial-init +lisp-fixnum-class+ '("I"))
    7735              (fix-boxing representation 'fixnum))
     7702           (convert-representation :int representation)
    77367703           (emit-move-from-stack target representation)))
    77377704        (t
     
    78477814          ((and (< *safety* 3)
    78487815                (eq (derive-compiler-type arg) 'character))
    7849      (new-fixnum (null representation))
    78507816           (compile-form arg 'stack :char)
    7851      (emit-fixnum-init representation)
     7817           ;; we change the representation between the above and here
     7818           ;;  ON PURPOSE!
     7819     (convert-representation :int representation)
    78527820           (emit-move-from-stack target representation))
    78537821          (t
     
    83198287               (not (variable-used-non-locally-p variable))
    83208288               (zerop (compiland-children *current-compiland*)))
    8321       (emit-push-variable variable)
    8322       (derive-variable-representation variable nil) ;; nil == no block
    8323       (when (< 1 (representation-size (variable-representation variable)))
    8324         (allocate-variable-register variable))
    8325       (convert-representation nil (variable-representation variable))
    8326       (emit-move-to-variable variable)))
     8289      (when (memq (type-representation (variable-declared-type variable))
     8290                  '(:int :long))
     8291        (emit-push-variable variable)
     8292;;        (sys::%format t "declared type: ~S~%" (variable-declared-type variable))
     8293        (derive-variable-representation variable nil)
     8294;;        (sys::%format t "representation: ~S~%" (variable-representation variable))
     8295        (when (< 1 (representation-size (variable-representation variable)))
     8296          (allocate-variable-register variable))
     8297        (convert-representation nil (variable-representation variable))
     8298        (emit-move-to-variable variable))))
    83278299  t)
    83288300
Note: See TracChangeset for help on using the changeset viewer.