From e2a78b0d6d844f29acaaddd775c7b1cd6dec7af8 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 8 Jul 2018 09:36:37 -0600 Subject: [PATCH] Bignum fixes for byte-compiler and bytecode interpreter * lisp/emacs-lisp/byte-opt.el: Mark bignump and fixnump as side-effect-and-error-free-fns. * src/bytecode.c (exec_byte_code): Handle bignums. --- lisp/emacs-lisp/byte-opt.el | 4 ++-- src/bytecode.c | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 5c0b5e340bb..1920503b8c4 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -1195,14 +1195,14 @@ window-width zerop)) (side-effect-and-error-free-fns '(arrayp atom - bobp bolp bool-vector-p + bignump bobp bolp bool-vector-p buffer-end buffer-list buffer-size buffer-string bufferp car-safe case-table-p cdr-safe char-or-string-p characterp charsetp commandp cons consp current-buffer current-global-map current-indentation current-local-map current-minor-mode-maps current-time eobp eolp eq equal eventp - floatp following-char framep + fixnump floatp following-char framep get-largest-window get-lru-window hash-table-p identity ignore integerp integer-or-marker-p interactive-p diff --git a/src/bytecode.c b/src/bytecode.c index 282754d22b6..f87983a59c0 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -972,11 +972,15 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, NEXT; CASE (Bsub1): - TOP = FIXNUMP (TOP) ? make_fixnum (XINT (TOP) - 1) : Fsub1 (TOP); + TOP = (FIXNUMP (TOP) && XINT (TOP) != MOST_NEGATIVE_FIXNUM + ? make_fixnum (XINT (TOP) - 1) + : Fsub1 (TOP)); NEXT; CASE (Badd1): - TOP = FIXNUMP (TOP) ? make_fixnum (XINT (TOP) + 1) : Fadd1 (TOP); + TOP = (FIXNUMP (TOP) && XINT (TOP) != MOST_POSITIVE_FIXNUM + ? make_fixnum (XINT (TOP) + 1) + : Fadd1 (TOP)); NEXT; CASE (Beqlsign): @@ -1027,7 +1031,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, NEXT; CASE (Bnegate): - TOP = FIXNUMP (TOP) ? make_fixnum (- XINT (TOP)) : Fminus (1, &TOP); + TOP = (FIXNUMP (TOP) && XINT (TOP) != MOST_NEGATIVE_FIXNUM + ? make_fixnum (- XINT (TOP)) + : Fminus (1, &TOP)); NEXT; CASE (Bplus): @@ -1324,11 +1330,11 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, NEXT; CASE (Bnumberp): - TOP = FIXED_OR_FLOATP (TOP) ? Qt : Qnil; + TOP = NUMBERP (TOP) ? Qt : Qnil; NEXT; CASE (Bintegerp): - TOP = FIXNUMP (TOP) ? Qt : Qnil; + TOP = INTEGERP (TOP) ? Qt : Qnil; NEXT; #if BYTE_CODE_SAFE -- 2.39.2