From: Federico Tedin <federicotedin@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Patch to remove a bit of duplicated code in eval.c
Date: Fri, 17 Sep 2021 22:08:34 +0200 [thread overview]
Message-ID: <8735q3x8vx.fsf@gmail.com> (raw)
In-Reply-To: <83k0jf8xsw.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 17 Sep 2021 10:29:35 +0300")
>> My concerns now are:
>> 1) Could I have broken anything without realizing it, since this is such
>> a central function in Lisp code evaluation? Everything seems to be
>> compiling fine (without warnings) and so far I haven't had any crashes.
>
> I tried to compare the old and the new code, and their differences are
> not trivial to audit. For example, you remove this part:
>
>> - else if (XSUBR (fun)->max_args == UNEVALLED)
>> - val = (XSUBR (fun)->function.aUNEVALLED) (args_left);
>
> but I don't immediately see how you have something equivalent and at
> the right opportunity in the new code.
This part in particular is handled by the else-case in
'apply_subr'. Functionally it should be the same because I'm just taking
the value of 'args_left' and passing it to 'funcall_subr' (through the
'arg_vector' array of Lisp_Objects, with fixed size 1). Then
'funcall_subr' just calls 'aUNEVALLED' with that single Lisp_Object,
which corresponds to the section you pointed out.
> I'm not saying I already see something you have broken, I'm saying
> these changes are not easy to audit for correctness, at least not for
> me. They are not a mechanical move of code from one place to another,
> they really change the flow of control and processing.
>
> So I think we'd like to have tests for each of the cases supported by
> the code to make sure nothing is broken. Is it feasible to write such
> tests?
On this I am not very sure. There are some tests for this file on
eval-tests.el, however they don't seem to cover subroutines
stuff. However it seems like some stuff could be tested; for example, I
have realized that my patch evaluates all arguments before doing an
arguments length check, which is already different to the current
implementation (but would be easy to fix also). I will look into adding
relevant tests to other parts I feel I might have affected as well.
>> 2) I removed a comment that made reference to Bug#21245, but it seems
>> like it makes sense since the variable it refers to is no longer needed.
>
> If the reason for the comment is gone, no need to keep the comment.
>
>> 3) Have I maybe made Emacs slower by always using SAFE_ALLOCA_LISP for
>> the subroutine arguments (instead of only for 'max_args=MANY')?
>
> This should be measured.
Sounds good. I also thought about it again and realized that if
max_args!=MANY, then I can use simply use a Lisp_Object argvals[8]...
like in the code I removed. So in that case the behavior should be
exactly the same as before, and the change was a mistake on my side.
> In any case, let's delay installing this patch until after the
> emacs-28 release branch is cut, so as not to destabilize Emacs 28
> unnecessarily.
Yes good point! I will re-visit this patch on the following days to see
how I can improve it, alongside with Stefan's feedback.
Thanks for your feedback!
next prev parent reply other threads:[~2021-09-17 20:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 21:49 Patch to remove a bit of duplicated code in eval.c Federico Tedin
2021-09-17 7:29 ` Eli Zaretskii
2021-09-17 20:08 ` Federico Tedin [this message]
2021-09-17 17:11 ` Stefan Monnier
2021-09-17 20:27 ` Federico Tedin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8735q3x8vx.fsf@gmail.com \
--to=federicotedin@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).