diff options
| author | Paul Eggert | 2016-12-31 13:10:38 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-12-31 13:26:52 -0800 |
| commit | 535ef18ed523862db405d22ec4bea0bbfd4172ce (patch) | |
| tree | d6e74aa3749787a4244e4df44a167860147c883e /src/eval.c | |
| parent | a60d77b8400edc130a1f48802e9257592234095a (diff) | |
| download | emacs-535ef18ed523862db405d22ec4bea0bbfd4172ce.tar.gz emacs-535ef18ed523862db405d22ec4bea0bbfd4172ce.zip | |
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.
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 91 |
1 files changed, 43 insertions, 48 deletions
diff --git a/src/eval.c b/src/eval.c index 01ae3a178d8..b1747387471 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -1085,19 +1085,22 @@ internal_catch (Lisp_Object tag, | |||
| 1085 | { | 1085 | { |
| 1086 | /* This structure is made part of the chain `catchlist'. */ | 1086 | /* This structure is made part of the chain `catchlist'. */ |
| 1087 | struct handler *c = push_handler (tag, CATCHER); | 1087 | struct handler *c = push_handler (tag, CATCHER); |
| 1088 | Lisp_Object val; | ||
| 1089 | 1088 | ||
| 1090 | /* Call FUNC. */ | 1089 | /* Call FUNC. */ |
| 1091 | if (! sys_setjmp (c->jmp)) | 1090 | if (! sys_setjmp (c->jmp)) |
| 1092 | val = func (arg); | ||
| 1093 | else | ||
| 1094 | { | 1091 | { |
| 1095 | /* Throw works by a longjmp that comes right here. */ | 1092 | Lisp_Object val = func (arg); |
| 1096 | val = handlerlist->val; | 1093 | eassert (handlerlist == c); |
| 1094 | handlerlist = c->next; | ||
| 1095 | return val; | ||
| 1096 | } | ||
| 1097 | else | ||
| 1098 | { /* Throw works by a longjmp that comes right here. */ | ||
| 1099 | Lisp_Object val = handlerlist->val; | ||
| 1100 | clobbered_eassert (handlerlist == c); | ||
| 1101 | handlerlist = handlerlist->next; | ||
| 1102 | return val; | ||
| 1097 | } | 1103 | } |
| 1098 | clobbered_eassert (handlerlist == c); | ||
| 1099 | handlerlist = handlerlist->next; | ||
| 1100 | return val; | ||
| 1101 | } | 1104 | } |
| 1102 | 1105 | ||
| 1103 | /* Unwind the specbind, catch, and handler stacks back to CATCH, and | 1106 | /* 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, | |||
| 1311 | Lisp_Object (*hfun) (Lisp_Object)) | 1314 | Lisp_Object (*hfun) (Lisp_Object)) |
| 1312 | { | 1315 | { |
| 1313 | struct handler *c = push_handler (handlers, CONDITION_CASE); | 1316 | struct handler *c = push_handler (handlers, CONDITION_CASE); |
| 1314 | Lisp_Object val; | ||
| 1315 | bool call_hfun; | ||
| 1316 | |||
| 1317 | if (sys_setjmp (c->jmp)) | 1317 | if (sys_setjmp (c->jmp)) |
| 1318 | { | 1318 | { |
| 1319 | val = handlerlist->val; | 1319 | Lisp_Object val = handlerlist->val; |
| 1320 | call_hfun = true; | 1320 | clobbered_eassert (handlerlist == c); |
| 1321 | handlerlist = handlerlist->next; | ||
| 1322 | return hfun (val); | ||
| 1321 | } | 1323 | } |
| 1322 | else | 1324 | else |
| 1323 | { | 1325 | { |
| 1324 | val = bfun (); | 1326 | Lisp_Object val = bfun (); |
| 1325 | call_hfun = false; | 1327 | eassert (handlerlist == c); |
| 1328 | handlerlist = c->next; | ||
| 1329 | return val; | ||
| 1326 | } | 1330 | } |
| 1327 | clobbered_eassert (handlerlist == c); | ||
| 1328 | handlerlist = handlerlist->next; | ||
| 1329 | return call_hfun ? hfun (val) : val; | ||
| 1330 | } | 1331 | } |
| 1331 | 1332 | ||
| 1332 | /* Like internal_condition_case but call BFUN with ARG as its argument. */ | 1333 | /* 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, | |||
| 1337 | Lisp_Object (*hfun) (Lisp_Object)) | 1338 | Lisp_Object (*hfun) (Lisp_Object)) |
| 1338 | { | 1339 | { |
| 1339 | struct handler *c = push_handler (handlers, CONDITION_CASE); | 1340 | struct handler *c = push_handler (handlers, CONDITION_CASE); |
| 1340 | Lisp_Object val; | ||
| 1341 | bool call_hfun; | ||
| 1342 | |||
| 1343 | if (sys_setjmp (c->jmp)) | 1341 | if (sys_setjmp (c->jmp)) |
| 1344 | { | 1342 | { |
| 1345 | val = handlerlist->val; | 1343 | Lisp_Object val = handlerlist->val; |
| 1346 | call_hfun = true; | 1344 | clobbered_eassert (handlerlist == c); |
| 1345 | handlerlist = handlerlist->next; | ||
| 1346 | return hfun (val); | ||
| 1347 | } | 1347 | } |
| 1348 | else | 1348 | else |
| 1349 | { | 1349 | { |
| 1350 | val = bfun (arg); | 1350 | Lisp_Object val = bfun (arg); |
| 1351 | call_hfun = false; | 1351 | eassert (handlerlist == c); |
| 1352 | handlerlist = c->next; | ||
| 1353 | return val; | ||
| 1352 | } | 1354 | } |
| 1353 | clobbered_eassert (handlerlist == c); | ||
| 1354 | handlerlist = handlerlist->next; | ||
| 1355 | return call_hfun ? hfun (val) : val; | ||
| 1356 | } | 1355 | } |
| 1357 | 1356 | ||
| 1358 | /* Like internal_condition_case_1 but call BFUN with ARG1 and ARG2 as | 1357 | /* 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), | |||
| 1366 | Lisp_Object (*hfun) (Lisp_Object)) | 1365 | Lisp_Object (*hfun) (Lisp_Object)) |
| 1367 | { | 1366 | { |
| 1368 | struct handler *c = push_handler (handlers, CONDITION_CASE); | 1367 | struct handler *c = push_handler (handlers, CONDITION_CASE); |
| 1369 | Lisp_Object val; | ||
| 1370 | bool call_hfun; | ||
| 1371 | |||
| 1372 | if (sys_setjmp (c->jmp)) | 1368 | if (sys_setjmp (c->jmp)) |
| 1373 | { | 1369 | { |
| 1374 | val = handlerlist->val; | 1370 | Lisp_Object val = handlerlist->val; |
| 1375 | call_hfun = true; | 1371 | clobbered_eassert (handlerlist == c); |
| 1372 | handlerlist = handlerlist->next; | ||
| 1373 | return hfun (val); | ||
| 1376 | } | 1374 | } |
| 1377 | else | 1375 | else |
| 1378 | { | 1376 | { |
| 1379 | val = bfun (arg1, arg2); | 1377 | Lisp_Object val = bfun (arg1, arg2); |
| 1380 | call_hfun = false; | 1378 | eassert (handlerlist == c); |
| 1379 | handlerlist = c->next; | ||
| 1380 | return val; | ||
| 1381 | } | 1381 | } |
| 1382 | clobbered_eassert (handlerlist == c); | ||
| 1383 | handlerlist = handlerlist->next; | ||
| 1384 | return call_hfun ? hfun (val) : val; | ||
| 1385 | } | 1382 | } |
| 1386 | 1383 | ||
| 1387 | /* Like internal_condition_case but call BFUN with NARGS as first, | 1384 | /* 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 *), | |||
| 1397 | Lisp_Object *args)) | 1394 | Lisp_Object *args)) |
| 1398 | { | 1395 | { |
| 1399 | struct handler *c = push_handler (handlers, CONDITION_CASE); | 1396 | struct handler *c = push_handler (handlers, CONDITION_CASE); |
| 1400 | Lisp_Object val; | ||
| 1401 | bool call_hfun; | ||
| 1402 | |||
| 1403 | if (sys_setjmp (c->jmp)) | 1397 | if (sys_setjmp (c->jmp)) |
| 1404 | { | 1398 | { |
| 1405 | val = handlerlist->val; | 1399 | Lisp_Object val = handlerlist->val; |
| 1406 | call_hfun = true; | 1400 | clobbered_eassert (handlerlist == c); |
| 1401 | handlerlist = handlerlist->next; | ||
| 1402 | return hfun (val, nargs, args); | ||
| 1407 | } | 1403 | } |
| 1408 | else | 1404 | else |
| 1409 | { | 1405 | { |
| 1410 | val = bfun (nargs, args); | 1406 | Lisp_Object val = bfun (nargs, args); |
| 1411 | call_hfun = false; | 1407 | eassert (handlerlist == c); |
| 1408 | handlerlist = c->next; | ||
| 1409 | return val; | ||
| 1412 | } | 1410 | } |
| 1413 | clobbered_eassert (handlerlist == c); | ||
| 1414 | handlerlist = handlerlist->next; | ||
| 1415 | return call_hfun ? hfun (val, nargs, args) : val; | ||
| 1416 | } | 1411 | } |
| 1417 | 1412 | ||
| 1418 | struct handler * | 1413 | struct handler * |