Changeset 11637


Ignore:
Timestamp:
02/06/09 23:22:51 (12 years ago)
Author:
ehuelsmann
Message:

Extend EMIT-DUP to be able to duplicate past the top-most stack value.

File:
1 edited

Legend:

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

    r11636 r11637  
    413413
    414414(defknown emit-dup (symbol) t)
    415 (defun emit-dup (representation)
    416   (ecase (representation-size representation)
    417     (1 (emit 'dup))
    418     (2 (emit 'dup2))))
     415(defun emit-dup (representation &key (past nil past-supplied-p))
     416  "Emits the 'dup' instruction required to duplicate `representation'.
     417
     418If `past' is specified, the newly duplicated value is inserted on the
     419stack past the top-most value, which is assumed to be of the representation
     420passed in `past'."
     421  (emit
     422   (nth (if past-supplied-p
     423            (representation-size past) 0)
     424        (ecase (representation-size representation)
     425          (1 '(dup  dup_x1  dup_x2))
     426          (2 '(dup2 dup2_x1 dup2_x2))))))
    419427
    420428(defknown emit-swap (symbol symbol) t)
     
    49654973    (compile-form (%cadr args) 'stack nil)
    49664974    (when target
    4967       (emit 'dup_x1))
     4975      (emit-dup nil :past nil))
    49684976    (emit-invokevirtual +lisp-object-class+
    49694977                        (if (eq op 'sys:set-car) "setCar" "setCdr")
     
    56315639                  position-arg 'stack :int
    56325640                  arg3 'stack nil)
    5633            (emit 'dup_x2)
     5641           (emit 'dup_x2) ;; use not supported by emit-dup: 3 values involved
    56345642           (emit 'pop)
    56355643           (emit-invokevirtual +lisp-object-class+ "LDB" '("I" "I") +lisp-object+)
     
    67686776                    (emit-dup common-rep)
    67696777                    (compile-form arg2 'stack common-rep)
    6770                     (emit (if (eq common-rep :long)
    6771                               'dup2_x2 'dup_x1))
     6778                    (emit-dup common-rep :past common-rep)
    67726779                    (emit-numeric-comparison (if (eq op 'max) '<= '>=)
    67736780                                             common-rep LABEL1)
     
    67796786                 (t
    67806787                  (compile-form arg1 'stack nil)
    6781                   (emit 'dup)
     6788                  (emit-dup nil)
    67826789                  (compile-form arg2 'stack nil)
    6783                   (emit 'dup_x1)
     6790                  (emit-dup nil :past nil)
    67846791                  (emit-invokevirtual +lisp-object-class+
    67856792                                      (if (eq op 'max)
Note: See TracChangeset for help on using the changeset viewer.