aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorStefan Monnier2011-03-05 23:48:17 -0500
committerStefan Monnier2011-03-05 23:48:17 -0500
commite2abe5a13dffb08d6371b6a611bc39c3a9ac2bc6 (patch)
treeb9fb87041279f75ba8b6b304e0765bf412377af6 /src/bytecode.c
parentd032d5e7dfabfae60f3304da02c97cd1e189b9a2 (diff)
downloademacs-e2abe5a13dffb08d6371b6a611bc39c3a9ac2bc6.tar.gz
emacs-e2abe5a13dffb08d6371b6a611bc39c3a9ac2bc6.zip
Fix pcase memoizing; change lexbound byte-code marker.
* src/bytecode.c (exec_byte_code): Remove old lexical binding slot handling and replace it with the a integer args-desc handling. * eval.c (funcall_lambda): Adjust arglist test accordingly. * lisp/emacs-lisp/bytecomp.el (byte-compile-arglist-signature): Handle integer arglist descriptor. (byte-compile-make-args-desc): Make integer arglist descriptor. (byte-compile-lambda): Use integer arglist descriptor to mark lexical byte-coded functions instead of an extra slot. * lisp/help-fns.el (help-add-fundoc-usage): Don't add a dummy doc. (help-split-fundoc): Return a nil doc if there was no actual doc. (help-function-arglist): Generate an arglist from an integer arg-desc. * lisp/emacs-lisp/pcase.el (pcase--memoize): Rename from pcase-memoize; Make only the key weak. (pcase): Change the key used in the memoization table, so it does not always get GC'd away. * lisp/emacs-lisp/macroexp.el (macroexpand-all-1): Slight change to the pcase pattern to generate slightly better code.
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c71
1 files changed, 42 insertions, 29 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 9693a5a9196..dbab02886e2 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -502,37 +502,50 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
502 stacke = stack.bottom - 1 + XFASTINT (maxdepth); 502 stacke = stack.bottom - 1 + XFASTINT (maxdepth);
503#endif 503#endif
504 504
505 if (! NILP (args_template)) 505 if (INTEGERP (args_template))
506 /* We should push some arguments on the stack. */
507 { 506 {
508 Lisp_Object at; 507 int at = XINT (args_template);
509 int pushed = 0, optional = 0; 508 int rest = at & 128;
510 509 int mandatory = at & 127;
511 for (at = args_template; CONSP (at); at = XCDR (at)) 510 int nonrest = at >> 8;
512 if (EQ (XCAR (at), Qand_optional)) 511 eassert (mandatory <= nonrest);
513 optional = 1; 512 if (nargs <= nonrest)
514 else if (EQ (XCAR (at), Qand_rest)) 513 {
515 { 514 int i;
516 PUSH (pushed < nargs 515 for (i = 0 ; i < nargs; i++, args++)
517 ? Flist (nargs - pushed, args) 516 PUSH (*args);
518 : Qnil); 517 if (nargs < mandatory)
519 pushed = nargs; 518 /* Too few arguments. */
520 at = Qnil; 519 Fsignal (Qwrong_number_of_arguments,
521 break; 520 Fcons (Fcons (make_number (mandatory),
522 } 521 rest ? Qand_rest : make_number (nonrest)),
523 else if (pushed < nargs) 522 Fcons (make_number (nargs), Qnil)));
524 { 523 else
525 PUSH (*args++); 524 {
526 pushed++; 525 for (; i < nonrest; i++)
527 } 526 PUSH (Qnil);
528 else if (optional) 527 if (rest)
529 PUSH (Qnil); 528 PUSH (Qnil);
530 else 529 }
531 break; 530 }
532 531 else if (rest)
533 if (pushed != nargs || !NILP (at)) 532 {
533 int i;
534 for (i = 0 ; i < nonrest; i++, args++)
535 PUSH (*args);
536 PUSH (Flist (nargs - nonrest, args));
537 }
538 else
539 /* Too many arguments. */
534 Fsignal (Qwrong_number_of_arguments, 540 Fsignal (Qwrong_number_of_arguments,
535 Fcons (args_template, Fcons (make_number (nargs), Qnil))); 541 Fcons (Fcons (make_number (mandatory),
542 make_number (nonrest)),
543 Fcons (make_number (nargs), Qnil)));
544 }
545 else if (! NILP (args_template))
546 /* We should push some arguments on the stack. */
547 {
548 error ("Unknown args template!");
536 } 549 }
537 550
538 while (1) 551 while (1)