Revert "Comp fix calls to redefined primtives with op-bytecode (bug#61917)"

This reverts commit 263d6c3853.

These patch series caused a number of regression and more analysis is
required.
This commit is contained in:
Andrea Corallo 2023-03-28 14:56:47 +02:00
parent 8b66d8abd0
commit a8c9283e17
2 changed files with 11 additions and 32 deletions

View file

@ -1773,25 +1773,17 @@ SP-DELTA is the stack adjustment."
(maxarg (cdr arity))) (maxarg (cdr arity)))
(when (eq maxarg 'unevalled) (when (eq maxarg 'unevalled)
(signal 'native-ice (list "subr contains unevalled args" subr-name))) (signal 'native-ice (list "subr contains unevalled args" subr-name)))
(if (not (subrp subr-name)) (if (eq maxarg 'many)
;; The primitive got redefined before the compiler is ;; callref case.
;; invoked! (bug#61917) (comp-emit-set-call (comp-callref subr-name nargs (comp-sp)))
(comp-emit-set-call `(callref funcall ;; Normal call.
,(make-comp-mvar :constant subr-name) (unless (and (>= maxarg nargs) (<= minarg nargs))
,@(cl-loop repeat nargs (signal 'native-ice
for sp from (comp-sp) (list "incoherent stack adjustment" nargs maxarg minarg)))
collect (comp-slot-n sp)))) (let* ((subr-name subr-name)
(if (eq maxarg 'many) (slots (cl-loop for i from 0 below maxarg
;; callref case. collect (comp-slot-n (+ i (comp-sp))))))
(comp-emit-set-call (comp-callref subr-name nargs (comp-sp))) (comp-emit-set-call (apply #'comp-call (cons subr-name slots))))))))
;; 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 (eval-when-compile
(defun comp-op-to-fun (x) (defun comp-op-to-fun (x)

View file

@ -532,19 +532,6 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html."
(should (subr-native-elisp-p (should (subr-native-elisp-p
(symbol-function 'comp-test-48029-nonascii-žžž-f)))) (symbol-function 'comp-test-48029-nonascii-žžž-f))))
(comp-deftest 61917-1 ()
"Verify we can compile calls to redefined primitives with
dedicated byte-op code."
(let ((f (lambda (fn &rest args)
(apply fn args))))
(advice-add #'delete-region :around f)
(unwind-protect
(should (subr-native-elisp-p
(native-compile
'(lambda ()
(delete-region (point-min) (point-max))))))
(advice-remove #'delete-region f))))
;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;
;; Tromey's tests. ;; ;; Tromey's tests. ;;