1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-04 22:50:59 -08:00

Clarify internal_catch etc.

The recent change to internal_catch and friends relied on some
confusion I introduced to the code in 2013.  Attempt to fix
the confusion by clarifying the code instead.  This saves an
instruction and a load dependency in the typical case.
* src/eval.c (internal_catch, internal_condition_case)
(internal_condition_case_1, internal_condition_case_2)
(internal_condition_case_n): Undo the previous change.  Instead,
use use ‘c’ rather than ‘handlerlist’ in the typical case.
Also, use ‘eassert’ rather than ‘clobbered_eassert’ when possible.
This commit is contained in:
Paul Eggert 2016-12-31 13:10:38 -08:00
parent a60d77b840
commit 535ef18ed5

View file

@ -1085,19 +1085,22 @@ internal_catch (Lisp_Object tag,
{
/* This structure is made part of the chain `catchlist'. */
struct handler *c = push_handler (tag, CATCHER);
Lisp_Object val;
/* Call FUNC. */
if (! sys_setjmp (c->jmp))
val = func (arg);
else
{
/* Throw works by a longjmp that comes right here. */
val = handlerlist->val;
Lisp_Object val = func (arg);
eassert (handlerlist == c);
handlerlist = c->next;
return val;
}
else
{ /* Throw works by a longjmp that comes right here. */
Lisp_Object val = handlerlist->val;
clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return val;
}
clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return val;
}
/* Unwind the specbind, catch, and handler stacks back to CATCH, and
@ -1311,22 +1314,20 @@ internal_condition_case (Lisp_Object (*bfun) (void), Lisp_Object handlers,
Lisp_Object (*hfun) (Lisp_Object))
{
struct handler *c = push_handler (handlers, CONDITION_CASE);
Lisp_Object val;
bool call_hfun;
if (sys_setjmp (c->jmp))
{
val = handlerlist->val;
call_hfun = true;
Lisp_Object val = handlerlist->val;
clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return hfun (val);
}
else
{
val = bfun ();
call_hfun = false;
Lisp_Object val = bfun ();
eassert (handlerlist == c);
handlerlist = c->next;
return val;
}
clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return call_hfun ? hfun (val) : val;
}
/* Like internal_condition_case but call BFUN with ARG as its argument. */
@ -1337,22 +1338,20 @@ internal_condition_case_1 (Lisp_Object (*bfun) (Lisp_Object), Lisp_Object arg,
Lisp_Object (*hfun) (Lisp_Object))
{
struct handler *c = push_handler (handlers, CONDITION_CASE);
Lisp_Object val;
bool call_hfun;
if (sys_setjmp (c->jmp))
{
val = handlerlist->val;
call_hfun = true;
Lisp_Object val = handlerlist->val;
clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return hfun (val);
}
else
{
val = bfun (arg);
call_hfun = false;
Lisp_Object val = bfun (arg);
eassert (handlerlist == c);
handlerlist = c->next;
return val;
}
clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return call_hfun ? hfun (val) : val;
}
/* Like internal_condition_case_1 but call BFUN with ARG1 and ARG2 as
@ -1366,22 +1365,20 @@ internal_condition_case_2 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object),
Lisp_Object (*hfun) (Lisp_Object))
{
struct handler *c = push_handler (handlers, CONDITION_CASE);
Lisp_Object val;
bool call_hfun;
if (sys_setjmp (c->jmp))
{
val = handlerlist->val;
call_hfun = true;
Lisp_Object val = handlerlist->val;
clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return hfun (val);
}
else
{
val = bfun (arg1, arg2);
call_hfun = false;
Lisp_Object val = bfun (arg1, arg2);
eassert (handlerlist == c);
handlerlist = c->next;
return val;
}
clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return call_hfun ? hfun (val) : val;
}
/* Like internal_condition_case but call BFUN with NARGS as first,
@ -1397,22 +1394,20 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *),
Lisp_Object *args))
{
struct handler *c = push_handler (handlers, CONDITION_CASE);
Lisp_Object val;
bool call_hfun;
if (sys_setjmp (c->jmp))
{
val = handlerlist->val;
call_hfun = true;
Lisp_Object val = handlerlist->val;
clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return hfun (val, nargs, args);
}
else
{
val = bfun (nargs, args);
call_hfun = false;
Lisp_Object val = bfun (nargs, args);
eassert (handlerlist == c);
handlerlist = c->next;
return val;
}
clobbered_eassert (handlerlist == c);
handlerlist = handlerlist->next;
return call_hfun ? hfun (val, nargs, args) : val;
}
struct handler *