Commit e9a598e5 authored by Raymond Toy's avatar Raymond Toy

Complex array accessors are not foldable

Fixes #61 and #62.

declared inline and the compiler tries to constant-fold these inlined
functions operating on simple arrays.

Thus don't allow the compiler to constant-fold calls to
`%ARRAY-FILL-POINTER-P`.  This is normally protected by a call to
`ARRAY-HEADER-P`, but when it's inlined, the compiler tries to
constant-fold `%ARRAY-FILL-POINTER-P` on an array without such a slot.

`%ARRAY-DATA-VECTOR`, and `%ARRAY-DISPLACEMENT`, and the calls are
protected by `ARRAY-HEADER-P`. So don't constant-fold these either.

Maybe we could also make CONSTANT-FOLD-CALL be smarter about this?

* src/compiler/generic/objdef.lisp
  * Remove flushable from these ref-trans methods.
* src/general-info/
  * Update
* tests/issues.lisp
  * Add tests from the bug reports.
parent 771fd903
Pipeline #290 passed with stage
in 9 minutes and 16 seconds
......@@ -252,29 +252,32 @@
:ref-known (flushable foldable)
:set-trans (setf %array-fill-pointer)
:set-known (unsafe))
;; Don't let these ref-trans to be constant-folded because these
;; might get called on arrays that don't have these slots. (Because
;; the lisp functions might be inlined.)
(fill-pointer-p :type (member t nil)
:ref-trans %array-fill-pointer-p
:ref-known (flushable foldable)
:ref-known (flushable)
:set-trans (setf %array-fill-pointer-p)
:set-known (unsafe))
(elements :type index
:ref-trans %array-available-elements
:ref-known (flushable foldable)
:ref-known (flushable)
:set-trans (setf %array-available-elements)
:set-known (unsafe))
(data :type array
:ref-trans %array-data-vector
:ref-known (flushable foldable)
:ref-known (flushable)
:set-trans (setf %array-data-vector)
:set-known (unsafe))
(displacement :type (or index null)
:ref-trans %array-displacement
:ref-known (flushable foldable)
:ref-known (flushable)
:set-trans (setf %array-displacement)
:set-known (unsafe))
(displaced-p :type (member t nil)
:ref-trans %array-displaced-p
:ref-known (flushable foldable)
:ref-known (flushable)
:set-trans (setf %array-displaced-p)
:set-known (unsafe))
(dimensions :rest-p t))
......@@ -35,6 +35,8 @@ public domain.
* ~~#59~~ Incorrect type-derivation for `decode-float`
* ~~#60~~ The function `C::%UNARY-FROUND` is undefined
* ~~#58~~ Bogus type error in comparison of complex number with `THE` form
* ~~#61~~ Segfault when compiling call to `ARRAY-HAS-FILL-POINTER-P` on bit vector constant
* ~~#62~~ Segfault when compiling `ARRAY-DISPLACEMENT` on a string constant
* Other changes:
* Improvements to the PCL implementation of CLOS:
* Changes to building procedure:
......@@ -521,3 +521,17 @@
(let ((c9 (compile nil #'(lambda (x)
(= (the (eql 1.0d0) x) #c(1/2 1/2))))))
(assert-false (funcall c9 1.d0))))
(define-test issue.61
(:tag :issues)
;; Verifies that the compiler doesn't segfault and that we return
;; the correct value.
(funcall (compile nil '(lambda () (array-has-fill-pointer-p #*10))))))
(define-test issue.62
(:tag :issues)
;; Verifies that the compiler doesn't segfault and that we return
;; the correct value.
(funcall (compile nil '(lambda () (array-displacement "aaaaaaaa"))))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment