Changeset 11634 for trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
- Timestamp:
- 02/06/09 21:00:45 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r11633 r11634 6741 6741 (defknown p2-min/max (t t t) t) 6742 6742 (defun p2-min/max (form target representation) 6743 (cond ((= (length form) 3) 6744 (let* ((op (%car form)) 6745 (args (%cdr form)) 6746 (arg1 (%car args)) 6747 (arg2 (%cadr args))) 6748 (when (null target) 6749 (compile-forms-and-maybe-emit-clear-values arg1 nil nil 6750 arg2 nil nil) 6751 (return-from p2-min/max)) 6752 (when (notinline-p op) 6753 (compile-function-call form target representation) 6754 (return-from p2-min/max)) 6755 (let ((type1 (derive-compiler-type arg1)) 6756 (type2 (derive-compiler-type arg2))) 6757 (cond ((and (fixnum-type-p type1) (fixnum-type-p type2)) 6758 (compile-form arg1 'stack :int) 6759 (emit 'dup) 6760 (compile-form arg2 'stack :int) 6761 (emit 'dup_x1) 6762 (let ((LABEL1 (gensym))) 6763 (emit (if (eq op 'max) 'if_icmpge 'if_icmple) LABEL1) 6764 (emit 'swap) ;; The lower stack value is greater-or-equal 6765 (label LABEL1) 6766 (emit 'pop)) ;; Throw away the lower stack value 6767 (convert-representation :int representation) 6768 (emit-move-from-stack target representation)) 6769 ((and (java-long-type-p type1) (java-long-type-p type2)) 6770 (compile-form arg1 'stack :long) 6771 (emit 'dup2) 6772 (compile-form arg2 'stack :long) 6773 (emit 'dup2_x2) 6774 (emit 'lcmp) 6775 (let ((LABEL1 (gensym))) 6776 (emit (if (eq op 'max) 'ifge 'ifle) LABEL1) 6777 (emit 'dup2_x2) ;; pour-mans swap2 6778 (emit 'pop2) 6779 (label LABEL1) 6780 (emit 'pop2)) 6781 (convert-representation :long representation) 6782 (emit-move-from-stack target representation)) 6783 (t 6784 (compile-form arg1 'stack nil) 6785 (emit 'dup) 6786 (compile-form arg2 'stack nil) 6787 (emit 'dup_x1) 6788 (emit-invokevirtual +lisp-object-class+ 6789 (if (eq op 'max) 6790 "isLessThanOrEqualTo" 6791 "isGreaterThanOrEqualTo") 6792 (lisp-object-arg-types 1) "Z") 6793 (let ((LABEL1 (gensym))) 6794 (emit 'ifeq LABEL1) 6795 (emit 'swap) 6796 (label LABEL1) 6797 (emit 'pop)) 6798 (fix-boxing representation nil) 6799 (emit-move-from-stack target representation)))))) 6800 (t 6801 (compile-function-call form target representation)))) 6743 (case (length form) 6744 (1 (error 'program-error "Wrong number of arguments for ~A." (car form))) 6745 (2 (compile-form (cadr form) target representation)) 6746 (3 (let* ((op (%car form)) 6747 (args (%cdr form)) 6748 (arg1 (%car args)) 6749 (arg2 (%cadr args))) 6750 (when (null target) 6751 (compile-forms-and-maybe-emit-clear-values arg1 nil nil 6752 arg2 nil nil) 6753 (return-from p2-min/max)) 6754 (when (notinline-p op) 6755 (compile-function-call form target representation) 6756 (return-from p2-min/max)) 6757 (let ((type1 (derive-compiler-type arg1)) 6758 (type2 (derive-compiler-type arg2))) 6759 (cond ((and (fixnum-type-p type1) (fixnum-type-p type2)) 6760 (compile-form arg1 'stack :int) 6761 (emit 'dup) 6762 (compile-form arg2 'stack :int) 6763 (emit 'dup_x1) 6764 (let ((LABEL1 (gensym))) 6765 (emit (if (eq op 'max) 'if_icmpge 'if_icmple) LABEL1) 6766 (emit 'swap) ;; The lower stack value is greater-or-equal 6767 (label LABEL1) 6768 (emit 'pop)) ;; Throw away the lower stack value 6769 (convert-representation :int representation) 6770 (emit-move-from-stack target representation)) 6771 ((and (java-long-type-p type1) (java-long-type-p type2)) 6772 (compile-form arg1 'stack :long) 6773 (emit 'dup2) 6774 (compile-form arg2 'stack :long) 6775 (emit 'dup2_x2) 6776 (emit 'lcmp) 6777 (let ((LABEL1 (gensym))) 6778 (emit (if (eq op 'max) 'ifge 'ifle) LABEL1) 6779 (emit 'dup2_x2) ;; pour-mans swap2 6780 (emit 'pop2) 6781 (label LABEL1) 6782 (emit 'pop2)) 6783 (convert-representation :long representation) 6784 (emit-move-from-stack target representation)) 6785 (t 6786 (compile-form arg1 'stack nil) 6787 (emit 'dup) 6788 (compile-form arg2 'stack nil) 6789 (emit 'dup_x1) 6790 (emit-invokevirtual +lisp-object-class+ 6791 (if (eq op 'max) 6792 "isLessThanOrEqualTo" 6793 "isGreaterThanOrEqualTo") 6794 (lisp-object-arg-types 1) "Z") 6795 (let ((LABEL1 (gensym))) 6796 (emit 'ifeq LABEL1) 6797 (emit 'swap) 6798 (label LABEL1) 6799 (emit 'pop)) 6800 (fix-boxing representation nil) 6801 (emit-move-from-stack target representation)))))) 6802 (t 6803 (p2-min/max `(,(car form) (,(car form) (second form) (third form)) 6804 ,@(nthcdr 3 form)) target representation)))) 6802 6805 6803 6806 (defun p2-plus (form target representation)
Note: See TracChangeset
for help on using the changeset viewer.