X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fgeneric%2Fvm-tran.lisp;h=672b1a20b856a9e05a1d32eb4f5b711b12cfd73b;hb=b19093fa94d6e1785abee99c35c9a610e8777671;hp=8ee4ef33d310024c0bcdb9567654a1d7ce40dc1b;hpb=9266ac18b62c73bff89a0f45165cf740b3c87ca1;p=sbcl.git diff --git a/src/compiler/generic/vm-tran.lisp b/src/compiler/generic/vm-tran.lisp index 8ee4ef3..672b1a2 100644 --- a/src/compiler/generic/vm-tran.lisp +++ b/src/compiler/generic/vm-tran.lisp @@ -78,28 +78,22 @@ (declare (type (simple-array ,element-type-specifier 1) array)) (data-vector-ref array index))))) -;;; MNA: open-coded-simple-array patch (deftransform data-vector-ref ((array index) (simple-array t)) (let ((array-type (continuation-type array))) - ;; FIXME: How could this happen? Doesn't the limitation to arg - ;; type SIMPLE-ARRAY guarantee that ARRAY-TYPE is an ARRAY-TYPE? (unless (array-type-p array-type) (give-up-ir1-transform)) (let ((dims (array-type-dimensions array-type))) - (when (and (consp dims) (= (length dims) 1)) + (when (or (atom dims) (= (length dims) 1)) (give-up-ir1-transform)) - (let* ((el-type (array-type-element-type array-type)) - (total-size (if (or (atom dims) (member '* dims)) - '* - (reduce #'* dims))) - (type-sp `(simple-array ,(type-specifier el-type) - (,total-size)))) - (if (atom dims) - `(let ((a (truly-the ,type-sp (%array-simp array)))) - (data-vector-ref a index)) - `(let ((a (truly-the ,type-sp (%array-data-vector array)))) - (data-vector-ref a index))))))) + (let ((el-type (array-type-element-type array-type)) + (total-size (if (member '* dims) + '* + (reduce #'* dims)))) + `(data-vector-ref (truly-the (simple-array ,(type-specifier el-type) + (,total-size)) + (%array-data-vector array)) + index))))) (deftransform hairy-data-vector-set ((array index new-value) (array t t) @@ -132,28 +126,23 @@ index new-value))))) -;;; MNA: open-coded-simple-array patch (deftransform data-vector-set ((array index new-value) - (simple-array t t)) + (simple-array t t)) (let ((array-type (continuation-type array))) - ;; FIXME: How could this happen? Doesn't the limitation to arg - ;; type SIMPLE-ARRAY guarantee that ARRAY-TYPE is an ARRAY-TYPE? (unless (array-type-p array-type) (give-up-ir1-transform)) (let ((dims (array-type-dimensions array-type))) - (when (and (consp dims) (= (length dims) 1)) - (give-up-ir1-transform)) - (let* ((el-type (array-type-element-type array-type)) - (total-size (if (or (atom dims) (member '* dims)) - '* - (reduce #'* dims))) - (type-sp `(simple-array ,(type-specifier el-type) - (,total-size)))) - (if (atom dims) - `(let ((a (truly-the ,type-sp (%array-simp array)))) - (data-vector-set a index new-value)) - `(let ((a (truly-the ,type-sp (%array-data-vector array)))) - (data-vector-set a index new-value))))))) + (when (or (atom dims) (= (length dims) 1)) + (give-up-ir1-transform)) + (let ((el-type (array-type-element-type array-type)) + (total-size (if (member '* dims) + '* + (reduce #'* dims)))) + `(data-vector-set (truly-the (simple-array ,(type-specifier el-type) + (,total-size)) + (%array-data-vector array)) + index + new-value))))) ;;; transforms for getting at simple arrays of (UNSIGNED-BYTE N) when (< N 8) ;;; @@ -258,31 +247,26 @@ ;;;; primitive translator for BYTE-BLT (def-primitive-translator byte-blt (src src-start dst dst-start dst-end) - `(let ((src ,src) - (src-start (* ,src-start sb!vm:byte-bits)) - (dst ,dst) - (dst-start (* ,dst-start sb!vm:byte-bits)) - (dst-end (* ,dst-end sb!vm:byte-bits))) - (let ((length (- dst-end dst-start))) - (etypecase src - (system-area-pointer - (etypecase dst - (system-area-pointer - (system-area-copy src src-start dst dst-start length)) - ((simple-unboxed-array (*)) - (copy-from-system-area src src-start - dst (+ dst-start ,vector-data-bit-offset) - length)))) - ((simple-unboxed-array (*)) - (etypecase dst - (system-area-pointer - (copy-to-system-area src (+ src-start ,vector-data-bit-offset) - dst dst-start - length)) - ((simple-unboxed-array (*)) - (bit-bash-copy src (+ src-start ,vector-data-bit-offset) - dst (+ dst-start ,vector-data-bit-offset) - length)))))))) + + ;; new version + ;; + ;; FIXME: CMU CL had a hairier implementation of this. It had the + ;; small problem that it didn't work for large (>16M) values of + ;; SRC-START or DST-START. However, it might have been more + ;; efficient. In particular, I haven't checked how much the foreign + ;; function call costs us here. My guess is that if the overhead is + ;; acceptable for SQRT and COS, it's acceptable here, but this + ;; should probably be checked. -- WHN + (once-only ((dst-start dst-start)) + `(flet ((sap (thing) + (etypecase thing + (system-area-pointer thing) + ((simple-unboxed-array (*)) (vector-sap thing))))) + (declare (inline sap)) + (without-gcing + (memmove (sap+ (sap ,dst) ,dst-start) + (sap+ (sap ,src) ,src-start) + (- ,dst-end ,dst-start)))))) ;;;; transforms for EQL of floating point values