From 3850be836ec7223c895901dd21f2a4e429314b94 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 17 Nov 2019 18:39:22 +0100 Subject: [PATCH] make compilation too robust against advices --- src/comp.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/comp.c b/src/comp.c index 33c39b53467..ad669a5dafb 100644 --- a/src/comp.c +++ b/src/comp.c @@ -224,6 +224,20 @@ bcall0 (Lisp_Object f) Ffuncall (1, &f); } +static Lisp_Object +symbol_subr (Lisp_Object symbol) +{ + Lisp_Object subr = Fsymbol_function (symbol); + + if (SUBRP (subr)) + return subr; + + if (!NILP (CALL1I (ad-has-any-advice, symbol))) + subr = CALL1I (ad-get-orig-definition, symbol); + + return SUBRP (subr) ? subr : Qnil; +} + static gcc_jit_field * type_to_cast_field (gcc_jit_type *type) { @@ -1800,7 +1814,7 @@ emit_ctxt_code (void) FOR_EACH_TAIL (f_subr) { Lisp_Object subr_sym = XCAR (f_subr); - Lisp_Object subr = Fsymbol_function (subr_sym); + Lisp_Object subr = symbol_subr (subr_sym); /* Ignore inliners. This are not real functions to be imported. */ if (SUBRP (subr)) { @@ -3225,11 +3239,8 @@ load_comp_unit (dynlib_handle_ptr handle, char *file_name) Lisp_Object subr = Fsymbol_function (f_sym); if (!NILP (subr)) { - if (!SUBRP (subr) - /* If is not a subr try to recover the original one assuming was - advised. */ - && !(!NILP (CALL1I (ad-has-any-advice, f_sym)) - && SUBRP (subr = CALL1I (ad-get-orig-definition, f_sym)))) + subr = symbol_subr (f_sym); + if (NILP (subr)) { /* FIXME: This is not robust in case of primitive redefinition. */ -- 2.39.5