diff options
| author | Paul Eggert | 2016-08-07 09:58:09 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-08-07 10:02:03 -0700 |
| commit | 7961dee1827c7d30a238e7eec3ae0ba26dd6fd30 (patch) | |
| tree | b079e4dff6a292aabdfabfc68a447bc84d567f4e /src/bytecode.c | |
| parent | 7fb75680b38fe0805c2ff7e9cca3bec8121ba984 (diff) | |
| download | emacs-7961dee1827c7d30a238e7eec3ae0ba26dd6fd30.tar.gz emacs-7961dee1827c7d30a238e7eec3ae0ba26dd6fd30.zip | |
Tune interpretation of integer arglist descriptor
* src/bytecode.c (exec_byte_code):
Simplify and tune when INTEGERP (args_template).
Diffstat (limited to 'src/bytecode.c')
| -rw-r--r-- | src/bytecode.c | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index ee1b79f1826..6ccad469efa 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -476,49 +476,26 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 476 | stacke = stack.bottom - 1 + XFASTINT (maxdepth); | 476 | stacke = stack.bottom - 1 + XFASTINT (maxdepth); |
| 477 | #endif | 477 | #endif |
| 478 | 478 | ||
| 479 | if (INTEGERP (args_template)) | 479 | if (!NILP (args_template)) |
| 480 | { | 480 | { |
| 481 | eassert (INTEGERP (args_template)); | ||
| 481 | ptrdiff_t at = XINT (args_template); | 482 | ptrdiff_t at = XINT (args_template); |
| 482 | bool rest = (at & 128) != 0; | 483 | bool rest = (at & 128) != 0; |
| 483 | int mandatory = at & 127; | 484 | int mandatory = at & 127; |
| 484 | ptrdiff_t nonrest = at >> 8; | 485 | ptrdiff_t nonrest = at >> 8; |
| 485 | eassert (mandatory <= nonrest); | 486 | ptrdiff_t maxargs = rest ? PTRDIFF_MAX : nonrest; |
| 486 | if (nargs <= nonrest) | 487 | if (! (mandatory <= nargs && nargs <= maxargs)) |
| 487 | { | ||
| 488 | ptrdiff_t i; | ||
| 489 | for (i = 0 ; i < nargs; i++, args++) | ||
| 490 | PUSH (*args); | ||
| 491 | if (nargs < mandatory) | ||
| 492 | /* Too few arguments. */ | ||
| 493 | Fsignal (Qwrong_number_of_arguments, | ||
| 494 | list2 (Fcons (make_number (mandatory), | ||
| 495 | rest ? Qand_rest : make_number (nonrest)), | ||
| 496 | make_number (nargs))); | ||
| 497 | else | ||
| 498 | { | ||
| 499 | for (; i < nonrest; i++) | ||
| 500 | PUSH (Qnil); | ||
| 501 | if (rest) | ||
| 502 | PUSH (Qnil); | ||
| 503 | } | ||
| 504 | } | ||
| 505 | else if (rest) | ||
| 506 | { | ||
| 507 | ptrdiff_t i; | ||
| 508 | for (i = 0 ; i < nonrest; i++, args++) | ||
| 509 | PUSH (*args); | ||
| 510 | PUSH (Flist (nargs - nonrest, args)); | ||
| 511 | } | ||
| 512 | else | ||
| 513 | /* Too many arguments. */ | ||
| 514 | Fsignal (Qwrong_number_of_arguments, | 488 | Fsignal (Qwrong_number_of_arguments, |
| 515 | list2 (Fcons (make_number (mandatory), make_number (nonrest)), | 489 | list2 (Fcons (make_number (mandatory), make_number (nonrest)), |
| 516 | make_number (nargs))); | 490 | make_number (nargs))); |
| 517 | } | 491 | ptrdiff_t pushedargs = min (nonrest, nargs); |
| 518 | else if (! NILP (args_template)) | 492 | for (ptrdiff_t i = 0; i < pushedargs; i++, args++) |
| 519 | /* We should push some arguments on the stack. */ | 493 | PUSH (*args); |
| 520 | { | 494 | if (nonrest < nargs) |
| 521 | error ("Unknown args template!"); | 495 | PUSH (Flist (nargs - nonrest, args)); |
| 496 | else | ||
| 497 | for (ptrdiff_t i = nargs - rest; i < nonrest; i++) | ||
| 498 | PUSH (Qnil); | ||
| 522 | } | 499 | } |
| 523 | 500 | ||
| 524 | while (1) | 501 | while (1) |