all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Sergey Vinokurov <serg.foo@gmail.com>
To: 69953@debbugs.gnu.org
Subject: bug#69953: [PATCH] Remove duplicated asserts and checks
Date: Sat, 23 Mar 2024 03:27:34 +0000	[thread overview]
Message-ID: <9378099f-76e1-45b4-8e4d-0f077cb28307@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1089 bytes --]

Hello,

I noticed that emacs-module.c contains duplicate 
module_non_local_exit_check() checks and 
module_assert_thread/module_assert_env asserts, mostly performed at the 
same point in program sequentially.

The module_non_local_exit_check() checks happen in 
MODULE_HANDLE_NONLOCAL_EXIT and MODULE_FUNCTION_BEGIN_NO_CATCH macros. 
The MODULE_HANDLE_NONLOCAL_EXIT is never used by itself, only as part of 
MODULE_FUNCTION_BEGIN which starts with MODULE_FUNCTION_BEGIN_NO_CATCH 
that performs the check.

In addition, there're 6 "Implementation of runtime and environment 
functions" rules outlined where MODULE_HANDLE_NONLOCAL_EXIT should be 
called at step 4 but module_non_local_exit_check() is supposed to have 
already happened at step 3 so documentation does not seem to intend for 
the check to be repeated in MODULE_HANDLE_NONLOCAL_EXIT.

Regarding asserts my observation is that module_non_local_exit_check() 
already contains module_assert_thread and module_assert_env so there's 
no need to do asserts if first thing we do is call 
module_non_local_exit_check.

Regards,
Sergey

[-- Attachment #2: 0001-Remove-duplicated-asserts-and-checks.patch --]
[-- Type: text/x-patch, Size: 2592 bytes --]

From 8c8516ee4869690d0d9418b26d4fae90520c9860 Mon Sep 17 00:00:00 2001
From: Sergey Vinokurov <serg.foo@gmail.com>
Date: Sat, 23 Mar 2024 02:15:06 +0000
Subject: [PATCH] Remove duplicated asserts and checks

* src/emacs-module.c (MODULE_HANDLE_NONLOCAL_EXIT): Remove redundant check
* src/emacs-module.c (MODULE_FUNCTION_BEGIN_NO_CATCH): Remove redundant assert
* src/emacs-module.c (module_non_local_exit_signal): Remove redundant assert
* src/emacs-module.c (module_non_local_exit_throw): Remove redundant assert
---
 src/emacs-module.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/src/emacs-module.c b/src/emacs-module.c
index 08db39b0b0d..fbeeb146a68 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -264,8 +264,6 @@ module_decode_utf_8 (const char *str, ptrdiff_t len)
 /* TODO: Make backtraces work if this macro is used.  */
 
 #define MODULE_HANDLE_NONLOCAL_EXIT(retval)                             \
-  if (module_non_local_exit_check (env) != emacs_funcall_exit_return)	\
-    return retval;							\
   struct handler *internal_handler =                                    \
     push_handler_nosignal (Qt, CATCHER_ALL);                            \
   if (!internal_handler)                                                \
@@ -332,8 +330,6 @@ #define MODULE_INTERNAL_CLEANUP()		\
 
 #define MODULE_FUNCTION_BEGIN_NO_CATCH(error_retval)                    \
   do {                                                                  \
-    module_assert_thread ();                                            \
-    module_assert_env (env);                                            \
     if (module_non_local_exit_check (env) != emacs_funcall_exit_return) \
       return error_retval;                                              \
   } while (false)
@@ -523,8 +519,6 @@ module_non_local_exit_get (emacs_env *env,
 module_non_local_exit_signal (emacs_env *env,
                               emacs_value symbol, emacs_value data)
 {
-  module_assert_thread ();
-  module_assert_env (env);
   if (module_non_local_exit_check (env) == emacs_funcall_exit_return)
     module_non_local_exit_signal_1 (env, value_to_lisp (symbol),
 				    value_to_lisp (data));
@@ -533,8 +527,6 @@ module_non_local_exit_signal (emacs_env *env,
 static void
 module_non_local_exit_throw (emacs_env *env, emacs_value tag, emacs_value value)
 {
-  module_assert_thread ();
-  module_assert_env (env);
   if (module_non_local_exit_check (env) == emacs_funcall_exit_return)
     module_non_local_exit_throw_1 (env, value_to_lisp (tag),
 				   value_to_lisp (value));
-- 
2.43.1


             reply	other threads:[~2024-03-23  3:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-23  3:27 Sergey Vinokurov [this message]
2024-03-23  7:15 ` bug#69953: [PATCH] Remove duplicated asserts and checks Eli Zaretskii
2024-03-23 12:38   ` Sergey Vinokurov
2024-04-13  7:42   ` Eli Zaretskii
2024-04-27  8:27     ` Eli Zaretskii
2024-05-09  7:24       ` Eli Zaretskii
2024-05-09 14:16         ` Sergey Vinokurov
2024-05-11 10:02           ` Eli Zaretskii
2024-05-11 12:12             ` Sergey Vinokurov
2024-05-11 12:18               ` Eli Zaretskii
2024-05-11 12:57                 ` Sergey Vinokurov
2024-05-11 13:05                   ` Eli Zaretskii
2024-05-11 13:11           ` Daniel Colascione

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9378099f-76e1-45b4-8e4d-0f077cb28307@gmail.com \
    --to=serg.foo@gmail.com \
    --cc=69953@debbugs.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.