diff options
author | Andrea Corallo <akrl@sdf.org> | 2023-03-20 17:24:48 +0100 |
---|---|---|
committer | Andrea Corallo <akrl@sdf.org> | 2023-03-20 19:01:26 +0100 |
commit | 263d6c38539691c954f4c3057cbe8d5468499b91 (patch) | |
tree | 39277706b61b8450a79b0476537ba4791355a7eb /lisp/emacs-lisp | |
parent | 6bf441ff11540f2c49cb4f9d506597217cdc73d6 (diff) | |
download | emacs-263d6c38539691c954f4c3057cbe8d5468499b91.tar.gz |
Comp fix calls to redefined primtives with op-bytecode (bug#61917)
* lisp/emacs-lisp/comp.el (comp-emit-set-call-subr): Fix compilation
of calls to redefined primtives with dedicated op-bytecode.
* test/src/comp-tests.el (61917-1): New test.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/comp.el | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 283c00103b5..febca8df19c 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -1773,17 +1773,25 @@ SP-DELTA is the stack adjustment." (maxarg (cdr arity))) (when (eq maxarg 'unevalled) (signal 'native-ice (list "subr contains unevalled args" subr-name))) - (if (eq maxarg 'many) - ;; callref case. - (comp-emit-set-call (comp-callref subr-name nargs (comp-sp))) - ;; Normal call. - (unless (and (>= maxarg nargs) (<= minarg nargs)) - (signal 'native-ice - (list "incoherent stack adjustment" nargs maxarg minarg))) - (let* ((subr-name subr-name) - (slots (cl-loop for i from 0 below maxarg - collect (comp-slot-n (+ i (comp-sp)))))) - (comp-emit-set-call (apply #'comp-call (cons subr-name slots)))))))) + (if (not (subrp subr-name)) + ;; The primitive got redefined before the compiler is + ;; invoked! (bug#61917) + (comp-emit-set-call `(callref funcall + ,(make-comp-mvar :constant subr-name) + ,@(cl-loop repeat nargs + for sp from (comp-sp) + collect (comp-slot-n sp)))) + (if (eq maxarg 'many) + ;; callref case. + (comp-emit-set-call (comp-callref subr-name nargs (comp-sp))) + ;; Normal call. + (unless (and (>= maxarg nargs) (<= minarg nargs)) + (signal 'native-ice + (list "incoherent stack adjustment" nargs maxarg minarg))) + (let* ((subr-name subr-name) + (slots (cl-loop for i from 0 below maxarg + collect (comp-slot-n (+ i (comp-sp)))))) + (comp-emit-set-call (apply #'comp-call (cons subr-name slots))))))))) (eval-when-compile (defun comp-op-to-fun (x) |