From: Paul Eggert Date: Thu, 27 Jun 2019 19:31:27 +0000 (-0700) Subject: Improve XFIXNUM cleanup a bit X-Git-Tag: emacs-27.0.90~2178 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f59a3f3d61c7da8a22ddb13185ae2271865ae155;p=emacs.git Improve XFIXNUM cleanup a bit Based on Pip Cet’s review (Bug#36370#13). * src/ccl.c (Fccl_execute_on_string): Use clearer indexing. * src/dosfns.c (Fint86, Fdos_memput): Avoid runtime checks for negative fixnums when debugging. This restores the earlier machine code. * src/lisp.h (XFIXNUM, XUFIXNUM): Use eassert, not eassume. (XFIXNAT): At the start, merely eassert FIXNUMP rather than eassuming FIXNATP. At the end, eassume that the result is nonnegative. This restores help to the compiler that the previous patch mistakenly removed. --- diff --git a/src/ccl.c b/src/ccl.c index f1d4c28df1c..ff42c6f25fc 100644 --- a/src/ccl.c +++ b/src/ccl.c @@ -2062,9 +2062,9 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY if (TYPE_RANGED_FIXNUMP (int, AREF (status, i))) ccl.reg[i] = XFIXNUM (AREF (status, i)); } - if (FIXNUMP (AREF (status, i))) + if (FIXNUMP (AREF (status, 8))) { - EMACS_INT ic = XFIXNUM (AREF (status, i)); + EMACS_INT ic = XFIXNUM (AREF (status, 8)); if (ccl.ic < ic && ic < ccl.size) ccl.ic = ic; } diff --git a/src/dosfns.c b/src/dosfns.c index fb5bcc9ad3f..635f29bd656 100644 --- a/src/dosfns.c +++ b/src/dosfns.c @@ -72,16 +72,16 @@ REGISTERS should be a vector produced by `make-register' and if (no < 0 || no > 0xff || ASIZE (registers) != 8) return Qnil; for (i = 0; i < 8; i++) - CHECK_FIXNAT (AREF (registers, i)); + CHECK_FIXNUM (AREF (registers, i)); - inregs.x.ax = (unsigned long) XFIXNAT (AREF (registers, 0)); - inregs.x.bx = (unsigned long) XFIXNAT (AREF (registers, 1)); - inregs.x.cx = (unsigned long) XFIXNAT (AREF (registers, 2)); - inregs.x.dx = (unsigned long) XFIXNAT (AREF (registers, 3)); - inregs.x.si = (unsigned long) XFIXNAT (AREF (registers, 4)); - inregs.x.di = (unsigned long) XFIXNAT (AREF (registers, 5)); - inregs.x.cflag = (unsigned long) XFIXNAT (AREF (registers, 6)); - inregs.x.flags = (unsigned long) XFIXNAT (AREF (registers, 7)); + inregs.x.ax = (unsigned long) XFIXNUM (AREF (registers, 0)); + inregs.x.bx = (unsigned long) XFIXNUM (AREF (registers, 1)); + inregs.x.cx = (unsigned long) XFIXNUM (AREF (registers, 2)); + inregs.x.dx = (unsigned long) XFIXNUM (AREF (registers, 3)); + inregs.x.si = (unsigned long) XFIXNUM (AREF (registers, 4)); + inregs.x.di = (unsigned long) XFIXNUM (AREF (registers, 5)); + inregs.x.cflag = (unsigned long) XFIXNUM (AREF (registers, 6)); + inregs.x.flags = (unsigned long) XFIXNUM (AREF (registers, 7)); int86 (no, &inregs, &outregs); @@ -139,8 +139,8 @@ DEFUN ("msdos-memput", Fdos_memput, Sdos_memput, 2, 2, 0, for (i = 0; i < len; i++) { - CHECK_FIXNAT (AREF (vector, i)); - buf[i] = (unsigned char) XFIXNAT (AREF (vector, i)) & 0xFF; + CHECK_FIXNUM (AREF (vector, i)); + buf[i] = (unsigned char) XFIXNUM (AREF (vector, i)) & 0xFF; } dosmemput (buf, len, offs); diff --git a/src/lisp.h b/src/lisp.h index 077d2360654..a0619e64f20 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -1195,7 +1195,7 @@ INLINE bool INLINE EMACS_INT XFIXNUM (Lisp_Object a) { - eassume (FIXNUMP (a)); + eassert (FIXNUMP (a)); return XFIXNUM_RAW (a); } @@ -1209,7 +1209,7 @@ XUFIXNUM_RAW (Lisp_Object a) INLINE EMACS_UINT XUFIXNUM (Lisp_Object a) { - eassume (FIXNUMP (a)); + eassert (FIXNUMP (a)); return XUFIXNUM_RAW (a); } @@ -2828,9 +2828,11 @@ FIXNATP (Lisp_Object x) INLINE EMACS_INT XFIXNAT (Lisp_Object a) { - eassume (FIXNATP (a)); + eassert (FIXNUMP (a)); EMACS_INT int0 = Lisp_Int0; - return USE_LSB_TAG ? XFIXNUM (a) : XLI (a) - (int0 << VALBITS); + EMACS_INT result = USE_LSB_TAG ? XFIXNUM (a) : XLI (a) - (int0 << VALBITS); + eassume (0 <= result); + return result; } INLINE bool