From: Andrea Corallo Date: Thu, 18 Feb 2021 21:10:20 +0000 (+0100) Subject: * Add a bunch of assertions for fixnums coming from Lisp later used as int X-Git-Tag: emacs-28.0.90~2727^2~143 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b1bab6e07396fb30a7a2ba8cb4fd42f44020f513;p=emacs.git * Add a bunch of assertions for fixnums coming from Lisp later used as int * src/comp.c (emit_limple_insn, declare_lex_function) (compile_function, Fcomp__compile_ctxt_to_file): Add some assertion. --- diff --git a/src/comp.c b/src/comp.c index f3a3e5556f2..3b1f3be2682 100644 --- a/src/comp.c +++ b/src/comp.c @@ -2057,6 +2057,7 @@ emit_limple_insn (Lisp_Object insn) */ gcc_jit_lvalue *nargs = gcc_jit_param_as_lvalue (gcc_jit_function_get_param (comp.func, 0)); + eassert (XFIXNUM (arg[0]) < INT_MAX); gcc_jit_rvalue *n = gcc_jit_context_new_rvalue_from_int (comp.ctxt, comp.ptrdiff_type, @@ -2200,6 +2201,7 @@ emit_limple_insn (Lisp_Object insn) { /* Ex: (set-par-to-local #s(comp-mvar 0 3 nil nil nil nil) 0). */ EMACS_INT param_n = XFIXNUM (arg[1]); + eassert (param_n < INT_MAX); gcc_jit_rvalue *param = gcc_jit_param_as_rvalue (gcc_jit_function_get_param (comp.func, param_n)); @@ -2228,6 +2230,7 @@ emit_limple_insn (Lisp_Object insn) */ EMACS_INT slot_n = XFIXNUM (CALL1I (comp-mvar-slot, arg[0])); + eassert (slot_n < INT_MAX); gcc_jit_rvalue *n = gcc_jit_context_new_rvalue_from_int (comp.ctxt, comp.ptrdiff_type, @@ -3805,6 +3808,7 @@ declare_lex_function (Lisp_Object func) if (!nargs) { EMACS_INT max_args = XFIXNUM (CALL1I (comp-args-max, args)); + eassert (max_args < INT_MAX); gcc_jit_type **type = SAFE_ALLOCA (max_args * sizeof (*type)); for (ptrdiff_t i = 0; i < max_args; i++) type[i] = comp.lisp_obj_type; @@ -3869,6 +3873,7 @@ compile_function (Lisp_Object func) { USE_SAFE_ALLOCA; comp.frame_size = XFIXNUM (CALL1I (comp-func-frame-size, func)); + eassert (comp.frame_size < INT_MAX); comp.func = xmint_pointer (Fgethash (CALL1I (comp-func-c-name, func), comp.exported_funcs_h, Qnil)); @@ -4353,7 +4358,9 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file, comp.func_relocs_local = NULL; comp.speed = XFIXNUM (CALL1I (comp-ctxt-speed, Vcomp_ctxt)); + eassert (comp.speed < INT_MAX); comp.debug = XFIXNUM (CALL1I (comp-ctxt-debug, Vcomp_ctxt)); + eassert (comp.debug < INT_MAX); if (comp.debug) gcc_jit_context_set_bool_option (comp.ctxt,