| [13075] | 1 | ;;; Copyright 2009 Clozure Associates
|
|---|
| 2 | ;;; This file is part of Clozure CL.
|
|---|
| 3 | ;;;
|
|---|
| 4 | ;;; Clozure CL is licensed under the terms of the Lisp Lesser GNU
|
|---|
| 5 | ;;; Public License , known as the LLGPL and distributed with Clozure
|
|---|
| 6 | ;;; CL as the file "LICENSE". The LLGPL consists of a preamble and
|
|---|
| 7 | ;;; the LGPL, which is distributed with Clozure CL as the file "LGPL".
|
|---|
| 8 | ;;; Where these conflict, the preamble takes precedence.
|
|---|
| 9 | ;;;
|
|---|
| 10 | ;;; Clozure CL is referenced in the preamble as the "LIBRARY."
|
|---|
| 11 | ;;;
|
|---|
| 12 | ;;; The LLGPL is also available online at
|
|---|
| 13 | ;;; http://opensource.franz.com/preamble.html
|
|---|
| 14 |
|
|---|
| [7999] | 15 | (in-package "CCL")
|
|---|
| 16 |
|
|---|
| 17 | (eval-when (:compile-toplevel :execute)
|
|---|
| 18 | (require "X86-LAPMACROS"))
|
|---|
| 19 |
|
|---|
| 20 | (defx8632lapfunction eql ((x arg_y) (y arg_z))
|
|---|
| 21 | "Return T if OBJ1 and OBJ2 represent either the same object or
|
|---|
| 22 | numbers with the same type and value."
|
|---|
| 23 | (check-nargs 2)
|
|---|
| 24 | @top
|
|---|
| 25 | @tail
|
|---|
| 26 | (cmpl (% x) (% y))
|
|---|
| 27 | (je @win)
|
|---|
| [8905] | 28 | (movl (% x) (% imm0))
|
|---|
| 29 | (andb ($ x8632::fulltagmask) (% al))
|
|---|
| 30 | (movb (% arg_z.b) (% ah))
|
|---|
| 31 | (andb ($ x8632::fulltagmask) (% ah))
|
|---|
| [7999] | 32 | (cmpb (% al) (% ah))
|
|---|
| 33 | (jnz @lose)
|
|---|
| 34 | (cmpb ($ x8632::fulltag-misc) (% al))
|
|---|
| 35 | (jnz @lose)
|
|---|
| [8905] | 36 | (cmpb ($ x8632::fulltag-misc) (% ah))
|
|---|
| 37 | (jnz @lose)
|
|---|
| [7999] | 38 | ;; Objects are both of tag-misc. Headers must match exactly;
|
|---|
| 39 | ;; dispatch on subtag.
|
|---|
| 40 | (getvheader x imm0)
|
|---|
| 41 | ;;(getvheader y imm1)
|
|---|
| 42 | (cmpb ($ x8632::subtag-macptr) (% imm0.b))
|
|---|
| 43 | (je @macptr) ; will need to check subtag of %y
|
|---|
| 44 | (cmp (% imm0) (@ x8632::misc-header-offset (% y)))
|
|---|
| 45 | (jne @lose)
|
|---|
| 46 | (cmpb ($ x8632::subtag-bignum) (% imm0.b))
|
|---|
| 47 | (je @bignum)
|
|---|
| 48 | (cmpb ($ x8632::subtag-single-float) (% imm0.b))
|
|---|
| 49 | (je @one-unboxed-word)
|
|---|
| 50 | (cmpb ($ x8632::subtag-double-float) (% imm0.b))
|
|---|
| 51 | (je @double-float)
|
|---|
| [9538] | 52 | (cmpb ($ x8632::subtag-complex) (% imm0.b))
|
|---|
| [7999] | 53 | (je @complex)
|
|---|
| [9538] | 54 | (cmpb ($ x8632::subtag-ratio) (% imm0.b))
|
|---|
| [7999] | 55 | (je @ratio)
|
|---|
| 56 | @lose
|
|---|
| [10959] | 57 | (movl ($ (target-nil-value)) (% arg_z))
|
|---|
| [7999] | 58 | (single-value-return)
|
|---|
| 59 | @double-float
|
|---|
| [9562] | 60 | ;; use UCOMISD here, maybe?
|
|---|
| [7999] | 61 | (movl (@ x8632::double-float.val-high (% x)) (% imm0))
|
|---|
| [9562] | 62 | (cmpl (% imm0) (@ x8632::double-float.val-high (% y)))
|
|---|
| [7999] | 63 | (jne @lose)
|
|---|
| 64 | (movl (@ x8632::double-float.value (% x)) (% imm0))
|
|---|
| [9562] | 65 | (cmpl (% imm0) (@ x8632::double-float.value (% y)))
|
|---|
| [7999] | 66 | (jne @lose)
|
|---|
| [10959] | 67 | (movl ($ (target-t-value)) (% arg_z))
|
|---|
| [7999] | 68 | (single-value-return)
|
|---|
| 69 | @macptr
|
|---|
| 70 | (cmpb ($ x8632::subtag-macptr) (@ x8632::misc-subtag-offset (% y)))
|
|---|
| 71 | (jne @lose)
|
|---|
| 72 | @one-unboxed-word
|
|---|
| 73 | (movl (@ x8632::misc-data-offset (% x)) (% imm0))
|
|---|
| 74 | @test
|
|---|
| 75 | (cmpl (% imm0) (@ x8632::misc-data-offset (% y)))
|
|---|
| [10959] | 76 | (movl ($ (target-t-value)) (%l imm0))
|
|---|
| [9538] | 77 | (lea (@ (- x8632::t-offset) (% imm0)) (% arg_z))
|
|---|
| [7999] | 78 | (cmovel (%l imm0) (%l arg_z))
|
|---|
| 79 | (single-value-return)
|
|---|
| 80 | @win
|
|---|
| [10959] | 81 | (movl ($ (target-t-value)) (% arg_z))
|
|---|
| [7999] | 82 | (single-value-return)
|
|---|
| 83 | @ratio
|
|---|
| 84 | @complex
|
|---|
| 85 | ;; Have either a ratio or a complex. In either case, corresponding
|
|---|
| 86 | ;; elements of both objects must be EQL. Recurse on the first
|
|---|
| 87 | ;; elements. If true, tail-call on the second, else fail.
|
|---|
| 88 | (save-simple-frame)
|
|---|
| 89 | (pushl (@ x8632::ratio.denom (% x))) ; aka complex.imagpart
|
|---|
| 90 | (pushl (@ x8632::ratio.denom (% y)))
|
|---|
| 91 | (movl (@ x8632::ratio.numer (% x)) (% x)) ; aka complex.realpart
|
|---|
| 92 | (movl (@ x8632::ratio.numer (% y)) (% y)) ; aka complex.realpart
|
|---|
| 93 | (:talign 5)
|
|---|
| 94 | (call @top)
|
|---|
| 95 | (recover-fn)
|
|---|
| 96 | (cmp-reg-to-nil arg_z)
|
|---|
| 97 | (pop (% y))
|
|---|
| 98 | (pop (% x))
|
|---|
| 99 | (restore-simple-frame)
|
|---|
| 100 | (jnz @tail)
|
|---|
| 101 | ;; lose, again
|
|---|
| [10959] | 102 | (movl ($ (target-nil-value)) (% arg_z))
|
|---|
| [7999] | 103 | (single-value-return)
|
|---|
| 104 | @bignum
|
|---|
| 105 | ;; Way back when, we got x's header into imm0. We know that y's
|
|---|
| 106 | ;; header is identical. Use the element-count from imm0 to control
|
|---|
| 107 | ;; the loop. There's no such thing as a 0-element bignum, so the
|
|---|
| 108 | ;; loop must always execute at least once.
|
|---|
| 109 | (header-length imm0 temp0)
|
|---|
| 110 | (xor (% temp1) (% temp1))
|
|---|
| 111 | @bignum-next
|
|---|
| 112 | (movl (@ x8632::misc-data-offset (% x) (% temp1)) (% imm0))
|
|---|
| 113 | (cmpl (@ x8632::misc-data-offset (% y) (% temp1)) (% imm0))
|
|---|
| 114 | (jne @lose)
|
|---|
| 115 | (addl ($ '1) (% temp1))
|
|---|
| 116 | (sub ($ '1) (% temp0))
|
|---|
| 117 | (jnz @bignum-next)
|
|---|
| [10959] | 118 | (movl ($ (target-t-value)) (% arg_z))
|
|---|
| [7999] | 119 | (single-value-return))
|
|---|
| 120 |
|
|---|
| 121 | (defx8632lapfunction equal ((x arg_y) (y arg_z))
|
|---|
| 122 | "Return T if X and Y are EQL or if they are structured components
|
|---|
| 123 | whose elements are EQUAL. Strings and bit-vectors are EQUAL if they
|
|---|
| 124 | are the same length and have identical components. Other arrays must be
|
|---|
| 125 | EQ to be EQUAL. Pathnames are EQUAL if their components are."
|
|---|
| 126 | (check-nargs 2)
|
|---|
| 127 | @top
|
|---|
| 128 | @tail
|
|---|
| 129 | (cmp (% x) (% y))
|
|---|
| 130 | (je @win)
|
|---|
| [8905] | 131 | (movl (% x) (% imm0))
|
|---|
| 132 | (andb ($ x8632::fulltagmask) (% al))
|
|---|
| 133 | (movb (% arg_z.b) (% ah))
|
|---|
| 134 | (andb ($ x8632::fulltagmask) (% ah))
|
|---|
| [7999] | 135 | (cmpb (% al) (% ah))
|
|---|
| [8905] | 136 | (jnz @lose)
|
|---|
| [7999] | 137 | (cmpb ($ x8632::fulltag-cons) (% imm0.b))
|
|---|
| 138 | (je @cons)
|
|---|
| 139 | (cmpb ($ x8632::fulltag-misc) (% imm0.b))
|
|---|
| 140 | (je @misc)
|
|---|
| 141 | @lose
|
|---|
| [10959] | 142 | (movl ($ (target-nil-value)) (% arg_z))
|
|---|
| [7999] | 143 | (single-value-return)
|
|---|
| 144 | @win
|
|---|
| [10959] | 145 | (movl ($ (target-t-value)) (% arg_z))
|
|---|
| [7999] | 146 | (single-value-return)
|
|---|
| 147 | @cons
|
|---|
| [11353] | 148 | ;; If either X or Y is NIL, lose.
|
|---|
| 149 | (cmp-reg-to-nil x)
|
|---|
| 150 | (je @lose)
|
|---|
| 151 | (cmp-reg-to-nil y)
|
|---|
| 152 | (je @lose)
|
|---|
| [7999] | 153 | ;; Check to see if the CARs are EQ. If so, we can avoid saving
|
|---|
| 154 | ;; context, and can just tail call ourselves on the CDRs.
|
|---|
| 155 | (%car x temp0)
|
|---|
| 156 | (%car y temp1)
|
|---|
| 157 | (cmpl (% temp0) (% temp1))
|
|---|
| 158 | (jne @recurse)
|
|---|
| 159 | (%cdr x x)
|
|---|
| 160 | (%cdr y y)
|
|---|
| 161 | (jmp @tail)
|
|---|
| 162 | @recurse
|
|---|
| 163 | (save-simple-frame)
|
|---|
| 164 | (pushl (@ x8632::cons.cdr (% x)))
|
|---|
| 165 | (pushl (@ x8632::cons.cdr (% y)))
|
|---|
| 166 | (movl (% temp0) (% x))
|
|---|
| 167 | (movl (% temp1) (% y))
|
|---|
| 168 | (:talign 5)
|
|---|
| 169 | (call @top)
|
|---|
| 170 | (recover-fn)
|
|---|
| 171 | (cmp-reg-to-nil arg_z)
|
|---|
| 172 | (pop (% y))
|
|---|
| 173 | (pop (% x))
|
|---|
| 174 | (restore-simple-frame)
|
|---|
| 175 | (jnz @top)
|
|---|
| [10959] | 176 | (movl ($ (target-nil-value)) (% arg_z))
|
|---|
| [7999] | 177 | (single-value-return)
|
|---|
| 178 | @misc
|
|---|
| 179 | ;; Both objects are uvectors of some sort. Try EQL; if that fails,
|
|---|
| 180 | ;; call HAIRY-EQUAL.
|
|---|
| 181 | (save-simple-frame)
|
|---|
| 182 | (pushl (% x))
|
|---|
| 183 | (pushl (% y))
|
|---|
| 184 | (call-symbol eql 2)
|
|---|
| 185 | (cmp-reg-to-nil arg_z)
|
|---|
| 186 | (jne @won-with-eql)
|
|---|
| 187 | (popl (% y))
|
|---|
| 188 | (popl (% x))
|
|---|
| 189 | (restore-simple-frame)
|
|---|
| 190 | (jump-symbol hairy-equal 2)
|
|---|
| 191 | @won-with-eql
|
|---|
| 192 | (restore-simple-frame) ; discards pushed args
|
|---|
| [10959] | 193 | (movl ($ (target-t-value)) (% arg_z))
|
|---|
| [7999] | 194 | (single-value-return))
|
|---|
| 195 |
|
|---|
| 196 | (defx8632lapfunction %lisp-lowbyte-ref ((thing arg_z))
|
|---|
| 197 | (box-fixnum thing arg_z)
|
|---|
| 198 | (andl ($ '#xff) (%l arg_z))
|
|---|
| 199 | (single-value-return))
|
|---|