Changeset 11611


Ignore:
Timestamp:
01/31/09 20:28:09 (13 years ago)
Author:
ehuelsmann
Message:

Clean up COMPILE-CONSTANT: there's no reason to cast from one type to another at runtime if you can do it compile time.

File:
1 edited

Legend:

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

    r11610 r11611  
    23672367    (:int
    23682368     (cond ((fixnump form)
    2369             (emit-push-constant-int form)
    2370             (emit-move-from-stack target representation)
    2371             (return-from compile-constant))
     2369            (emit-push-constant-int form))
    23722370           ((integerp form)
    23732371            (emit 'getstatic *this-class* (declare-bignum form) +lisp-bignum+)
    2374             (emit-invokevirtual +lisp-object-class+ "intValue" nil "I")
    2375             (emit-move-from-stack target representation)
    2376             (return-from compile-constant))
     2372            (emit-invokevirtual +lisp-object-class+ "intValue" nil "I"))
    23772373           (t
    23782374            (sys::%format t "compile-constant int representation~%")
    2379             (assert nil))))
     2375            (assert nil)))
     2376     (emit-move-from-stack target representation)
     2377     (return-from compile-constant))
    23802378    (:long
    2381      (cond ((fixnump form)
    2382             (case form
    2383               (0
    2384                (emit 'lconst_0))
    2385               (1
    2386                (emit 'lconst_1))
    2387               (t
    2388                (emit-push-constant-int form)
    2389                (emit 'i2l)))
    2390             (emit-move-from-stack target representation)
    2391             (return-from compile-constant))
    2392            ((<= most-negative-java-long form most-positive-java-long)
    2393             (emit 'ldc2_w (pool-long form))
    2394             (return-from compile-constant))
     2379     (cond ((<= most-negative-java-long form most-positive-java-long)
     2380            (emit-push-constant-long form))
    23952381           ((integerp form)
    23962382            (emit 'getstatic *this-class* (declare-bignum form) +lisp-bignum+)
    2397             (emit-invokevirtual +lisp-object-class+ "longValue" nil "J")
    2398             (emit-move-from-stack target representation)
    2399             (return-from compile-constant))
     2383            (emit-invokevirtual +lisp-object-class+ "longValue" nil "J"))
    24002384           (t
    24012385            (sys::%format t "compile-constant long representation~%")
    2402             (assert nil))))
     2386            (assert nil)))
     2387     (emit-move-from-stack target representation)
     2388     (return-from compile-constant))
    24032389    (:char
    24042390     (cond ((characterp form)
     
    24142400     (return-from compile-constant))
    24152401    (:float
    2416      (cond ((fixnump form)
    2417             (compile-constant form 'stack :int)
    2418             (emit 'i2f))
    2419            ((and (integerp form)
    2420                  (<= most-negative-java-long form most-positive-java-long))
    2421             (compile-constant form 'stack :long)
    2422             (emit 'l2f))
    2423            ((integerp form)
    2424             (emit 'getfield *this-class* (declare-bignum form)
    2425                   +lisp-bignum+)
    2426             (emit-invokevirtual +lisp-bignum-class+ "floatValue" nil "F"))
     2402     (cond ((integerp form)
     2403            (emit-push-constant-float (coerce form 'single-float)))
    24272404           ((typep form 'single-float)
    24282405            (emit-push-constant-float form))
     
    24362413     (return-from compile-constant))
    24372414    (:double
    2438      (cond ((fixnump form)
    2439             (compile-constant form 'stack :int)
    2440             (emit 'i2d))
    2441            ((and (integerp form)
    2442                  (<= most-negative-java-long form most-positive-java-long))
    2443             (compile-constant form 'stack :long)
    2444             (emit 'l2d))
    2445            ((integerp form)
    2446             (emit 'getfield *this-class* (declare-bignum form)
    2447                   +lisp-bignum+)
    2448             (emit-invokevirtual +lisp-bignum-class+ "doubleValue" nil "D"))
    2449            ((typep form 'single-float)
    2450             (emit-push-constant-float form)
    2451             (emit 'f2d))
     2415     (cond ((or (integerp form)
     2416                (typep form 'single-float))
     2417            (emit-push-constant-double (coerce form 'double-float)))
    24522418           ((typep form 'double-float)
    24532419            (emit-push-constant-double form))
     
    69296895             (t
    69306896              (compile-binary-operation "add" args target representation)))))
    6931     (4
     6897    (t
    69326898     ;; (+ a b c) => (+ (+ a b) c)
    6933      (let ((new-form `(+ (+ ,(second form) ,(third form)) ,(fourth form))))
    6934        (p2-plus new-form target representation)))
    6935     (t
    6936      (compile-function-call form target representation))))
     6899     (let ((new-form `(+ (+ ,(second form) ,(third form)) ,@(nthcdr 3 form))))
     6900       (p2-plus new-form target representation)))))
    69376901
    69386902(defun p2-minus (form target representation)
Note: See TracChangeset for help on using the changeset viewer.