From: Andrea Corallo Date: Sun, 11 Aug 2019 12:54:13 +0000 (+0200) Subject: rework args structures X-Git-Tag: emacs-28.0.90~2727^2~1293 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b6e7df0926b1a569a582b0d3ff0da0c27ad368bd;p=emacs.git rework args structures --- diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 9bf60d1f3cb..a35fbd0fec5 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -76,15 +76,20 @@ finally return h) "Hash table lap-op -> stack adjustment.")) -(cl-defstruct comp-args +(cl-defstruct comp-args-gen (min nil :type number - :documentation "Minimum number of arguments allowed.") - (max nil + :documentation "Minimum number of arguments allowed.")) + +(cl-defstruct (comp-args (:include comp-args-gen)) + (max nil :type number :documentation "Maximum number of arguments allowed. -To be used when ncall-conv is nil.") - (ncall-conv nil :type boolean - :documentation "If t the signature is: -(ptrdiff_t nargs, Lisp_Object *args).")) +To be used when ncall-conv is nil.")) + +(cl-defstruct (comp-nargs (:include comp-args-gen)) + "Describe args when the functin signature is of kind: +(ptrdiff_t nargs, Lisp_Object *args)." + (nonrest nil :type number + :documentation "Number of non rest arguments.")) (cl-defstruct (comp-block (:copier nil)) "A basic block." @@ -109,7 +114,7 @@ into it.") :documentation "Byte compiled version.") (lap () :type list :documentation "Lap assembly representation.") - (args nil :type 'comp-args) + (args nil :type 'comp-args-gen) (frame-size nil :type 'number) (blocks (make-hash-table) :type 'hash-table :documentation "Key is the basic block symbol value is a comp-block @@ -203,8 +208,8 @@ BODY is evaluate only if `comp-debug' is non nil." (< nonrest 9)) ;; SUBR_MAX_ARGS (make-comp-args :min mandatory :max nonrest) - (make-comp-args :min mandatory - :ncall-conv t)))) + (make-comp-nargs :min mandatory + :nonrest nonrest)))) (defun comp-spill-lap (func) "Byte compile and spill the LAP rapresentation for FUNC." @@ -703,13 +708,13 @@ the annotation emission." (comp-pass (make-comp-limplify :sp -1 :frame (comp-new-frame frame-size))) - (args-min (comp-args-min (comp-func-args func))) + (args-min (comp-args-gen-min (comp-func-args func))) (comp-block ())) ;; Prologue (comp-emit-block 'entry) (comp-emit-annotation (concat "Lisp function: " (symbol-name (comp-func-symbol-name func)))) - (if (not (comp-args-ncall-conv (comp-func-args func))) + (if (comp-args-p (comp-func-args func)) (cl-loop for i below (comp-args-max (comp-func-args func)) do (cl-incf (comp-sp)) do (comp-emit `(setpar ,(comp-slot) ,i))) diff --git a/src/comp.c b/src/comp.c index a4793a36ada..881a78b3d75 100644 --- a/src/comp.c +++ b/src/comp.c @@ -2247,8 +2247,7 @@ DEFUN ("comp-add-func-to-ctxt", Fcomp_add_func_to_ctxt, Scomp_add_func_to_ctxt, char *c_name = (char *) SDATA (FUNCALL1 (comp-func-c-func-name, func)); Lisp_Object args = FUNCALL1 (comp-func-args, func); EMACS_INT frame_size = XFIXNUM (FUNCALL1 (comp-func-frame-size, func)); - /* EMACS_INT min_args = XFIXNUM (FUNCALL1 (comp-args-min, args)); */ - bool ncall = !NILP (FUNCALL1 (comp-args-ncall-conv, args)); + bool ncall = (FUNCALL1 (comp-nargs-p, args)); if (!ncall) { @@ -2373,8 +2372,8 @@ DEFUN ("comp-compile-and-load-ctxt", Fcomp_compile_and_load_ctxt, x->s.header.size = PVEC_SUBR << PSEUDOVECTOR_AREA_BITS; x->s.function.a0 = gcc_jit_result_get_code(gcc_res, c_name); eassert (x->s.function.a0); - x->s.min_args = XFIXNUM (FUNCALL1 (comp-args-min, args)); - if (NILP (FUNCALL1 (comp-args-ncall-conv, args))) + x->s.min_args = XFIXNUM (FUNCALL1 (comp-args-gen-min, args)); + if (FUNCALL1 (comp-args-p, args)) x->s.max_args = XFIXNUM (FUNCALL1 (comp-args-max, args)); else x->s.max_args = MANY;