Fix 18-year-old constant-folding bug on (get-lisp-obj-address fixnum)

Wrong ever since 6fa968aaa8 apparently
This commit is contained in:
Douglas Katzman 2025-12-29 21:43:16 -05:00
parent 58b8222523
commit 7635130348
2 changed files with 9 additions and 1 deletions

View file

@ -787,7 +787,8 @@
;;; VOP can't handle them.
(deftransform sb-vm::get-lisp-obj-address ((obj) ((constant-arg fixnum)))
(ash (lvar-value obj) sb-vm:n-fixnum-tag-bits))
(logand (ash (lvar-value obj) sb-vm:n-fixnum-tag-bits)
sb-ext:most-positive-word))
(deftransform sb-vm::get-lisp-obj-address ((obj) ((constant-arg character)))
(logior sb-vm:character-widetag

7
tests/lispobj.pure.lisp Normal file
View file

@ -0,0 +1,7 @@
(defun transformed () (sb-kernel:get-lisp-obj-address -1))
(defun not-transformed ()
(declare (notinline sb-kernel:get-lisp-obj-address))
(sb-kernel:get-lisp-obj-address -1))
(compile 'transformed)
(with-test (:name transform-get-lisp-obj-addresss)
(assert (eql (transformed) (not-transformed))))