Opened 4 years ago

Last modified 3 years ago

#1322 new defect

hairy-equal failures

Reported by: rme Owned by:
Priority: major Milestone:
Component: ANSI CL Compliance Version: trunk
Keywords: Cc:

Description

(copied from mail into a ticket, for tracking purposes)

(defun junk ()
 (let ((s (make-array '(10) :element-type 'character
		       :initial-contents "0123456789" :fill-pointer 3)))
   (values (equal s "012") (equal "012" s))))

On a trunk x8632 lisp, this returns (values nil nil).

I compared the disassembly, and it appears to me that something goes wrong at the places I marked with ***.

In the first snippet (from a ccl-1.11 dx86cl), we load the subtag of the array's data vector into arg_z, and then branch and push it. In the second segment (from a trunk version), we do the same kind of work, but extract the subtag into temp1. We then branch and push arg_z anyway, which doesn't contain what we just computed.

;;; (= x-type target::subtag-vectorH)
L203
   (movl (@ -12 (% ebp)) (% arg_z))        ;   [205]
   (cmpl ($ #x3C8) (% arg_z))              ;   [208] are we subtag-vectorh?
   (jne L238)                              ;   [214]

;;; (%svref x target::arrayH.flags-cell)
   (movl (@ -4 (% ebp)) (% temp1))         ;   [216] we are, so get flags word
   (movl (@ 14 (% temp1)) (% temp1))       ;   [219] from array header

;;; (ldb target::arrayH.flags-cell-subtag-byte (the fixnum (%svref x target::arrayH.flags-cell)))
   (movl (% temp1) (% imm0))               ;   [222] extract subtag of data vector
   (sarl ($ 8) (% imm0))                   ;   [224] from flags word (byte 8 8)
   (andb ($ #xFC) (% imm0.b))              ;   [227]
   (movl (% imm0) (% arg_z))               ;   [230] ***
   (andl ($ #x3FC) (% arg_z))              ;   [232] ***
   (jmp L241)                              ;   [238]

;;; (if (= x-type target::subtag-vectorH) (ldb target::arrayH.flags-cell-subtag-byte (the fixnum (%svref
L238
   (movl (@ -12 (% ebp)) (% arg_z))        ;   [240]

;;; (let* ((x-simple (if (= x-type target::subtag-vectorH) (ldb target::arrayH.flags-cell-subtag-byte (t
L241
   (pushl (% arg_z))                       ;   [243] *** push subtag

And from a trunk x8632 lisp:

;;; (= x-type target::subtag-vectorH)
L209
   (movl (@ -12 (% ebp)) (% arg_z))        ;   [211]
   (cmpl ($ #x3C8) (% arg_z))              ;   [214] are we subtag-vectorh?
   (jne L244)                              ;   [220]

;;; (%svref x target::arrayH.flags-cell)
   (movl (@ -4 (% ebp)) (% temp1))         ;   [222] we are, so grab flags word
   (movl (@ 14 (% temp1)) (% temp1))       ;   [225] from array header

;;; (ldb target::arrayH.flags-cell-subtag-byte (the fixnum (%svref x target::arrayH.flags-cell)))
   (movl (% temp1) (% imm0))               ;   [228]
   (sarl ($ 8) (% imm0))                   ;   [230]
   (andb ($ #xFC) (% imm0.b))              ;   [233]
   (movl (% imm0) (% temp1))               ;   [236] ***
   (andl ($ #x3FC) (% temp1))              ;   [238] ***
   (jmp L247)                              ;   [244]

;;; (if (= x-type target::subtag-vectorH) (ldb target::arrayH.flags-cell-subtag-byte (the fixnum (%svref
L244
   (movl (@ -12 (% ebp)) (% arg_z))        ;   [246]

;;; (let* ((x-simple (if (= x-type target::subtag-vectorH) (ldb target::arrayH.flags-cell-subtag-byte (t
L247
   (pushl (% arg_z))                       ;   [249] ***

Change History (2)

comment:1 Changed 4 years ago by rme

Simpler test case:

(defparameter *a* (make-array 10 :element-type 'character
			      :initial-contents "0123456789" :fill-pointer 3))

(defun foo (x)
  (let* ((x-type (typecode x))
	 (x-simple (if (= x-type target::subtag-vectorH)
		     (ldb target::arrayH.flags-cell-subtag-byte
			  (the fixnum (%svref x target::arrayH.flags-cell)))
		     x-type)))
    (values x-type x-simple)))
? (foo *a*)
242
242
;; should be 242 (subtag-vectorH), 191 (subtag-simple-base-string)

comment:2 Changed 3 years ago by rme

  • Priority changed from normal to major
Note: See TracTickets for help on using tickets.