X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcompiler%2Fgeneric%2Fvm-tran.lisp;h=651658770ded2ce19e89a17756e19324fca1d2c9;hb=95a6db7329b91dd90d165dd4057b9b5098d34aa2;hp=ea381c42b2614ec0952cafef86b0064b89e44b0d;hpb=19198944c81507369ae46522c13b30df628cb442;p=sbcl.git diff --git a/src/compiler/generic/vm-tran.lisp b/src/compiler/generic/vm-tran.lisp index ea381c4..6516587 100644 --- a/src/compiler/generic/vm-tran.lisp +++ b/src/compiler/generic/vm-tran.lisp @@ -18,9 +18,9 @@ (defconstant vector-data-bit-offset (* sb!vm:vector-data-offset sb!vm:word-bits)) -;;; We need to define these predicates, since the TYPEP source transform picks -;;; whichever predicate was defined last when there are multiple predicates for -;;; equivalent types. +;;; We need to define these predicates, since the TYPEP source +;;; transform picks whichever predicate was defined last when there +;;; are multiple predicates for equivalent types. (def-source-transform short-float-p (x) `(single-float-p ,x)) #!-long-float (def-source-transform long-float-p (x) `(double-float-p ,x)) @@ -78,22 +78,26 @@ (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))) (unless (array-type-p array-type) (give-up-ir1-transform)) (let ((dims (array-type-dimensions array-type))) - (when (or (atom dims) (= (length dims) 1)) + (when (and (consp dims) (= (length dims) 1)) (give-up-ir1-transform)) - (let ((el-type (array-type-element-type array-type)) - (total-size (if (member '* dims) + (let* ((el-type (array-type-element-type array-type)) + (total-size (if (or (atom dims) (member '* dims)) '* - (reduce #'* dims)))) - `(data-vector-ref (truly-the (simple-array ,(type-specifier el-type) - (,total-size)) - (%array-data-vector array)) - index))))) + (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))))))) (deftransform hairy-data-vector-set ((array index new-value) (array t t) @@ -126,23 +130,26 @@ index new-value))))) +;;; MNA: open-coded-simple-array patch (deftransform data-vector-set ((array index new-value) (simple-array t t)) (let ((array-type (continuation-type array))) (unless (array-type-p array-type) (give-up-ir1-transform)) (let ((dims (array-type-dimensions array-type))) - (when (or (atom dims) (= (length dims) 1)) + (when (and (consp dims) (= (length dims) 1)) (give-up-ir1-transform)) - (let ((el-type (array-type-element-type array-type)) - (total-size (if (member '* dims) + (let* ((el-type (array-type-element-type array-type)) + (total-size (if (or (atom dims) (member '* dims)) '* - (reduce #'* dims)))) - `(data-vector-set (truly-the (simple-array ,(type-specifier el-type) - (,total-size)) - (%array-data-vector array)) - index - new-value))))) + (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))))))) ;;; transforms for getting at simple arrays of (UNSIGNED-BYTE N) when (< N 8) ;;; @@ -281,3 +288,4 @@ (deftransform eql ((x y) (double-float double-float)) '(and (= (double-float-low-bits x) (double-float-low-bits y)) (= (double-float-high-bits x) (double-float-high-bits y)))) +