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 | |
| 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')
| -rw-r--r-- | src/bytecode.c | 47 | ||||
| -rw-r--r-- | src/eval.c | 10 |
2 files changed, 17 insertions, 40 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) |
diff --git a/src/eval.c b/src/eval.c index d182f7f693d..7b7bdd8df7b 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -2863,14 +2863,14 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, | |||
| 2863 | xsignal1 (Qinvalid_function, fun); | 2863 | xsignal1 (Qinvalid_function, fun); |
| 2864 | syms_left = AREF (fun, COMPILED_ARGLIST); | 2864 | syms_left = AREF (fun, COMPILED_ARGLIST); |
| 2865 | if (INTEGERP (syms_left)) | 2865 | if (INTEGERP (syms_left)) |
| 2866 | /* A byte-code object with a non-nil `push args' slot means we | 2866 | /* A byte-code object with an integer args template means we |
| 2867 | shouldn't bind any arguments, instead just call the byte-code | 2867 | shouldn't bind any arguments, instead just call the byte-code |
| 2868 | interpreter directly; it will push arguments as necessary. | 2868 | interpreter directly; it will push arguments as necessary. |
| 2869 | 2869 | ||
| 2870 | Byte-code objects with either a non-existent, or a nil value for | 2870 | Byte-code objects with a nil args template (the default) |
| 2871 | the `push args' slot (the default), have dynamically-bound | 2871 | have dynamically-bound arguments, and use the |
| 2872 | arguments, and use the argument-binding code below instead (as do | 2872 | argument-binding code below instead (as do all interpreted |
| 2873 | all interpreted functions, even lexically bound ones). */ | 2873 | functions, even lexically bound ones). */ |
| 2874 | { | 2874 | { |
| 2875 | /* If we have not actually read the bytecode string | 2875 | /* If we have not actually read the bytecode string |
| 2876 | and constants vector yet, fetch them from the file. */ | 2876 | and constants vector yet, fetch them from the file. */ |