...
 
Commits (2)
  • Andrea Corallo's avatar
    Fix lambda-list relocation class · 4681f330
    Andrea Corallo authored
    Lambda-lists must stay in the same relocation class of the object
    referenced by code to respect uninterned symbols.
    
    	* lisp/emacs-lisp/comp.el (comp-prepare-args-for-top-level): Break
    	the original function in a generic specializing for
    	dynamic/lexical functions.  When allocating the lambda-list for
    	dynamic functions do that in the default relocation class.
    	(comp-emit-for-top-level): Make use of the new
    	`comp-prepare-args-for-top-level'.
    	(comp-emit-lambda-for-top-level): Likewise.
    4681f330
  • Andrea Corallo's avatar
    Add a test for lambda list containing uninterned symbols · 0f964db3
    Andrea Corallo authored
    	* test/src/comp-test-funcs-dyn.el
    	(comp-tests-cl-uninterned-arg-parse-f): New function.
    
    	* test/src/comp-tests.el (comp-tests-cl-uninterned-arg-parse-f):
    	New test.
    0f964db3
......@@ -1365,16 +1365,25 @@ the annotation emission."
(comp-log-func func 2)
func)
(defun comp-prepare-args-for-top-level (function)
"Given FUNCTION return the two args arguments for comp--register-..."
(if (comp-func-l-p function)
(let ((args (comp-func-l-args function)))
(cons (comp-args-base-min args)
(if (comp-args-p args)
(comp-args-max args)
'many)))
(cons (func-arity (comp-func-byte-func function))
(comp-func-d-lambda-list function))))
(cl-defgeneric comp-prepare-args-for-top-level (function)
"Given FUNCTION return the two args arguments for comp--register-...")
(cl-defmethod comp-prepare-args-for-top-level ((function comp-func-l))
"Lexical scoped FUNCTION."
(let ((args (comp-func-l-args function)))
(cons (make-comp-mvar :constant (comp-args-base-min args))
(make-comp-mvar :constant (if (comp-args-p args)
(comp-args-max args)
'many)))))
(cl-defmethod comp-prepare-args-for-top-level ((function comp-func-d))
"Dynamic scoped FUNCTION."
(cons (make-comp-mvar :constant (func-arity (comp-func-byte-func function)))
(let ((comp-curr-allocation-class 'd-default))
;; Lambda-lists must stay in the same relocation class of
;; the object referenced by code to respect uninterned
;; symbols.
(make-comp-mvar :constant (comp-func-d-lambda-list function)))))
(cl-defgeneric comp-emit-for-top-level (form for-late-load)
"Emit the limple code for top level FORM.")
......@@ -1390,8 +1399,8 @@ the annotation emission."
'comp--late-register-subr
'comp--register-subr)
(make-comp-mvar :constant name)
(make-comp-mvar :constant (car args))
(make-comp-mvar :constant (cdr args))
(car args)
(cdr args)
(make-comp-mvar :constant c-name)
(make-comp-mvar
:constant
......@@ -1431,8 +1440,8 @@ These are stored in the reloc data array."
(puthash (comp-func-byte-func func)
(make-comp-mvar :constant nil)
(comp-ctxt-lambda-fixups-h comp-ctxt)))
(make-comp-mvar :constant (car args))
(make-comp-mvar :constant (cdr args))
(car args)
(cdr args)
(make-comp-mvar :constant (comp-func-c-name func))
(make-comp-mvar
:constant (let* ((h (comp-ctxt-function-docs comp-ctxt))
......
......@@ -42,6 +42,9 @@
for yyy = xxx
collect xxx))
(cl-defun comp-tests-cl-uninterned-arg-parse-f (a &optional b &aux)
(list a b))
(provide 'comp-test-dyn-funcs)
;;; comp-test-funcs-dyn.el ends here
......@@ -578,4 +578,9 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html."
"Verify CL macro expansion (bug#42088)."
(should (equal (comp-tests-cl-macro-exp-f) '(a b))))
(ert-deftest comp-tests-cl-uninterned-arg-parse-f ()
"Verify the parsing of a lambda list with uninterned symbols (bug#42120)."
(should (equal (comp-tests-cl-uninterned-arg-parse-f 1 2)
'(1 2))))
;;; comp-tests.el ends here