diff options
Diffstat (limited to 'src/bytecode.c')
| -rw-r--r-- | src/bytecode.c | 242 |
1 files changed, 203 insertions, 39 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index fd2680e4054..58b26c79b84 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -76,17 +76,14 @@ Lisp_Object Qbyte_code_meter; | |||
| 76 | } \ | 76 | } \ |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | #else /* no BYTE_CODE_METER */ | 79 | #endif /* BYTE_CODE_METER */ |
| 80 | |||
| 81 | #define METER_CODE(last_code, this_code) | ||
| 82 | |||
| 83 | #endif /* no BYTE_CODE_METER */ | ||
| 84 | 80 | ||
| 85 | 81 | ||
| 86 | Lisp_Object Qbytecode; | 82 | Lisp_Object Qbytecode; |
| 87 | 83 | ||
| 88 | /* Byte codes: */ | 84 | /* Byte codes: */ |
| 89 | 85 | ||
| 86 | #define Bstack_ref 0 /* Actually, Bstack_ref+0 is not implemented: use dup. */ | ||
| 90 | #define Bvarref 010 | 87 | #define Bvarref 010 |
| 91 | #define Bvarset 020 | 88 | #define Bvarset 020 |
| 92 | #define Bvarbind 030 | 89 | #define Bvarbind 030 |
| @@ -136,7 +133,7 @@ Lisp_Object Qbytecode; | |||
| 136 | 133 | ||
| 137 | #define Bpoint 0140 | 134 | #define Bpoint 0140 |
| 138 | /* Was Bmark in v17. */ | 135 | /* Was Bmark in v17. */ |
| 139 | #define Bsave_current_buffer 0141 | 136 | #define Bsave_current_buffer 0141 /* Obsolete. */ |
| 140 | #define Bgoto_char 0142 | 137 | #define Bgoto_char 0142 |
| 141 | #define Binsert 0143 | 138 | #define Binsert 0143 |
| 142 | #define Bpoint_max 0144 | 139 | #define Bpoint_max 0144 |
| @@ -146,7 +143,9 @@ Lisp_Object Qbytecode; | |||
| 146 | #define Bpreceding_char 0150 | 143 | #define Bpreceding_char 0150 |
| 147 | #define Bcurrent_column 0151 | 144 | #define Bcurrent_column 0151 |
| 148 | #define Bindent_to 0152 | 145 | #define Bindent_to 0152 |
| 149 | #define Bscan_buffer 0153 /* No longer generated as of v18 */ | 146 | #ifdef BYTE_CODE_SAFE |
| 147 | #define Bscan_buffer 0153 /* No longer generated as of v18. */ | ||
| 148 | #endif | ||
| 150 | #define Beolp 0154 | 149 | #define Beolp 0154 |
| 151 | #define Beobp 0155 | 150 | #define Beobp 0155 |
| 152 | #define Bbolp 0156 | 151 | #define Bbolp 0156 |
| @@ -154,9 +153,13 @@ Lisp_Object Qbytecode; | |||
| 154 | #define Bcurrent_buffer 0160 | 153 | #define Bcurrent_buffer 0160 |
| 155 | #define Bset_buffer 0161 | 154 | #define Bset_buffer 0161 |
| 156 | #define Bsave_current_buffer_1 0162 /* Replacing Bsave_current_buffer. */ | 155 | #define Bsave_current_buffer_1 0162 /* Replacing Bsave_current_buffer. */ |
| 156 | #if 0 | ||
| 157 | #define Bread_char 0162 /* No longer generated as of v19 */ | 157 | #define Bread_char 0162 /* No longer generated as of v19 */ |
| 158 | #endif | ||
| 159 | #ifdef BYTE_CODE_SAFE | ||
| 158 | #define Bset_mark 0163 /* this loser is no longer generated as of v18 */ | 160 | #define Bset_mark 0163 /* this loser is no longer generated as of v18 */ |
| 159 | #define Binteractive_p 0164 /* Needed since interactive-p takes unevalled args */ | 161 | #endif |
| 162 | #define Binteractive_p 0164 /* Obsolete since Emacs-24.1. */ | ||
| 160 | 163 | ||
| 161 | #define Bforward_char 0165 | 164 | #define Bforward_char 0165 |
| 162 | #define Bforward_word 0166 | 165 | #define Bforward_word 0166 |
| @@ -181,16 +184,16 @@ Lisp_Object Qbytecode; | |||
| 181 | #define Bdup 0211 | 184 | #define Bdup 0211 |
| 182 | 185 | ||
| 183 | #define Bsave_excursion 0212 | 186 | #define Bsave_excursion 0212 |
| 184 | #define Bsave_window_excursion 0213 | 187 | #define Bsave_window_excursion 0213 /* Obsolete since Emacs-24.1. */ |
| 185 | #define Bsave_restriction 0214 | 188 | #define Bsave_restriction 0214 |
| 186 | #define Bcatch 0215 | 189 | #define Bcatch 0215 |
| 187 | 190 | ||
| 188 | #define Bunwind_protect 0216 | 191 | #define Bunwind_protect 0216 |
| 189 | #define Bcondition_case 0217 | 192 | #define Bcondition_case 0217 |
| 190 | #define Btemp_output_buffer_setup 0220 | 193 | #define Btemp_output_buffer_setup 0220 /* Obsolete since Emacs-24.1. */ |
| 191 | #define Btemp_output_buffer_show 0221 | 194 | #define Btemp_output_buffer_show 0221 /* Obsolete since Emacs-24.1. */ |
| 192 | 195 | ||
| 193 | #define Bunbind_all 0222 | 196 | #define Bunbind_all 0222 /* Obsolete. Never used. */ |
| 194 | 197 | ||
| 195 | #define Bset_marker 0223 | 198 | #define Bset_marker 0223 |
| 196 | #define Bmatch_beginning 0224 | 199 | #define Bmatch_beginning 0224 |
| @@ -226,9 +229,15 @@ Lisp_Object Qbytecode; | |||
| 226 | #define BconcatN 0260 | 229 | #define BconcatN 0260 |
| 227 | #define BinsertN 0261 | 230 | #define BinsertN 0261 |
| 228 | 231 | ||
| 232 | /* Bstack_ref is code 0. */ | ||
| 233 | #define Bstack_set 0262 | ||
| 234 | #define Bstack_set2 0263 | ||
| 235 | #define BdiscardN 0266 | ||
| 236 | |||
| 229 | #define Bconstant 0300 | 237 | #define Bconstant 0300 |
| 230 | #define CONSTANTLIM 0100 | ||
| 231 | 238 | ||
| 239 | /* Whether to maintain a `top' and `bottom' field in the stack frame. */ | ||
| 240 | #define BYTE_MAINTAIN_TOP (BYTE_CODE_SAFE || BYTE_MARK_STACK) | ||
| 232 | 241 | ||
| 233 | /* Structure describing a value stack used during byte-code execution | 242 | /* Structure describing a value stack used during byte-code execution |
| 234 | in Fbyte_code. */ | 243 | in Fbyte_code. */ |
| @@ -241,7 +250,9 @@ struct byte_stack | |||
| 241 | 250 | ||
| 242 | /* Top and bottom of stack. The bottom points to an area of memory | 251 | /* Top and bottom of stack. The bottom points to an area of memory |
| 243 | allocated with alloca in Fbyte_code. */ | 252 | allocated with alloca in Fbyte_code. */ |
| 253 | #if BYTE_MAINTAIN_TOP | ||
| 244 | Lisp_Object *top, *bottom; | 254 | Lisp_Object *top, *bottom; |
| 255 | #endif | ||
| 245 | 256 | ||
| 246 | /* The string containing the byte-code, and its current address. | 257 | /* The string containing the byte-code, and its current address. |
| 247 | Storing this here protects it from GC because mark_byte_stack | 258 | Storing this here protects it from GC because mark_byte_stack |
| @@ -268,6 +279,7 @@ struct byte_stack *byte_stack_list; | |||
| 268 | 279 | ||
| 269 | /* Mark objects on byte_stack_list. Called during GC. */ | 280 | /* Mark objects on byte_stack_list. Called during GC. */ |
| 270 | 281 | ||
| 282 | #if BYTE_MARK_STACK | ||
| 271 | void | 283 | void |
| 272 | mark_byte_stack (void) | 284 | mark_byte_stack (void) |
| 273 | { | 285 | { |
| @@ -292,7 +304,7 @@ mark_byte_stack (void) | |||
| 292 | mark_object (stack->constants); | 304 | mark_object (stack->constants); |
| 293 | } | 305 | } |
| 294 | } | 306 | } |
| 295 | 307 | #endif | |
| 296 | 308 | ||
| 297 | /* Unmark objects in the stacks on byte_stack_list. Relocate program | 309 | /* Unmark objects in the stacks on byte_stack_list. Relocate program |
| 298 | counters. Called when GC has completed. */ | 310 | counters. Called when GC has completed. */ |
| @@ -346,13 +358,19 @@ unmark_byte_stack (void) | |||
| 346 | /* Actions that must be performed before and after calling a function | 358 | /* Actions that must be performed before and after calling a function |
| 347 | that might GC. */ | 359 | that might GC. */ |
| 348 | 360 | ||
| 361 | #if !BYTE_MAINTAIN_TOP | ||
| 362 | #define BEFORE_POTENTIAL_GC() ((void)0) | ||
| 363 | #define AFTER_POTENTIAL_GC() ((void)0) | ||
| 364 | #else | ||
| 349 | #define BEFORE_POTENTIAL_GC() stack.top = top | 365 | #define BEFORE_POTENTIAL_GC() stack.top = top |
| 350 | #define AFTER_POTENTIAL_GC() stack.top = NULL | 366 | #define AFTER_POTENTIAL_GC() stack.top = NULL |
| 367 | #endif | ||
| 351 | 368 | ||
| 352 | /* Garbage collect if we have consed enough since the last time. | 369 | /* Garbage collect if we have consed enough since the last time. |
| 353 | We do this at every branch, to avoid loops that never GC. */ | 370 | We do this at every branch, to avoid loops that never GC. */ |
| 354 | 371 | ||
| 355 | #define MAYBE_GC() \ | 372 | #define MAYBE_GC() \ |
| 373 | do { \ | ||
| 356 | if (consing_since_gc > gc_cons_threshold \ | 374 | if (consing_since_gc > gc_cons_threshold \ |
| 357 | && consing_since_gc > gc_relative_threshold) \ | 375 | && consing_since_gc > gc_relative_threshold) \ |
| 358 | { \ | 376 | { \ |
| @@ -360,7 +378,7 @@ unmark_byte_stack (void) | |||
| 360 | Fgarbage_collect (); \ | 378 | Fgarbage_collect (); \ |
| 361 | AFTER_POTENTIAL_GC (); \ | 379 | AFTER_POTENTIAL_GC (); \ |
| 362 | } \ | 380 | } \ |
| 363 | else | 381 | } while (0) |
| 364 | 382 | ||
| 365 | /* Check for jumping out of range. */ | 383 | /* Check for jumping out of range. */ |
| 366 | 384 | ||
| @@ -402,6 +420,21 @@ the third, MAXDEPTH, the maximum stack depth used in this function. | |||
| 402 | If the third argument is incorrect, Emacs may crash. */) | 420 | If the third argument is incorrect, Emacs may crash. */) |
| 403 | (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth) | 421 | (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth) |
| 404 | { | 422 | { |
| 423 | return exec_byte_code (bytestr, vector, maxdepth, Qnil, 0, NULL); | ||
| 424 | } | ||
| 425 | |||
| 426 | /* Execute the byte-code in BYTESTR. VECTOR is the constant vector, and | ||
| 427 | MAXDEPTH is the maximum stack depth used (if MAXDEPTH is incorrect, | ||
| 428 | emacs may crash!). If ARGS_TEMPLATE is non-nil, it should be a lisp | ||
| 429 | argument list (including &rest, &optional, etc.), and ARGS, of size | ||
| 430 | NARGS, should be a vector of the actual arguments. The arguments in | ||
| 431 | ARGS are pushed on the stack according to ARGS_TEMPLATE before | ||
| 432 | executing BYTESTR. */ | ||
| 433 | |||
| 434 | Lisp_Object | ||
| 435 | exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | ||
| 436 | Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) | ||
| 437 | { | ||
| 405 | int count = SPECPDL_INDEX (); | 438 | int count = SPECPDL_INDEX (); |
| 406 | #ifdef BYTE_CODE_METER | 439 | #ifdef BYTE_CODE_METER |
| 407 | int this_op = 0; | 440 | int this_op = 0; |
| @@ -411,10 +444,10 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 411 | /* Lisp_Object v1, v2; */ | 444 | /* Lisp_Object v1, v2; */ |
| 412 | Lisp_Object *vectorp; | 445 | Lisp_Object *vectorp; |
| 413 | #ifdef BYTE_CODE_SAFE | 446 | #ifdef BYTE_CODE_SAFE |
| 414 | int const_length = XVECTOR (vector)->size; | 447 | ptrdiff_t const_length; |
| 415 | Lisp_Object *stacke; | 448 | Lisp_Object *stacke; |
| 416 | #endif | ||
| 417 | int bytestr_length; | 449 | int bytestr_length; |
| 450 | #endif | ||
| 418 | struct byte_stack stack; | 451 | struct byte_stack stack; |
| 419 | Lisp_Object *top; | 452 | Lisp_Object *top; |
| 420 | Lisp_Object result; | 453 | Lisp_Object result; |
| @@ -431,7 +464,11 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 431 | 464 | ||
| 432 | CHECK_STRING (bytestr); | 465 | CHECK_STRING (bytestr); |
| 433 | CHECK_VECTOR (vector); | 466 | CHECK_VECTOR (vector); |
| 434 | CHECK_NUMBER (maxdepth); | 467 | CHECK_NATNUM (maxdepth); |
| 468 | |||
| 469 | #ifdef BYTE_CODE_SAFE | ||
| 470 | const_length = ASIZE (vector); | ||
| 471 | #endif | ||
| 435 | 472 | ||
| 436 | if (STRING_MULTIBYTE (bytestr)) | 473 | if (STRING_MULTIBYTE (bytestr)) |
| 437 | /* BYTESTR must have been produced by Emacs 20.2 or the earlier | 474 | /* BYTESTR must have been produced by Emacs 20.2 or the earlier |
| @@ -441,16 +478,23 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 441 | convert them back to the originally intended unibyte form. */ | 478 | convert them back to the originally intended unibyte form. */ |
| 442 | bytestr = Fstring_as_unibyte (bytestr); | 479 | bytestr = Fstring_as_unibyte (bytestr); |
| 443 | 480 | ||
| 481 | #ifdef BYTE_CODE_SAFE | ||
| 444 | bytestr_length = SBYTES (bytestr); | 482 | bytestr_length = SBYTES (bytestr); |
| 483 | #endif | ||
| 445 | vectorp = XVECTOR (vector)->contents; | 484 | vectorp = XVECTOR (vector)->contents; |
| 446 | 485 | ||
| 447 | stack.byte_string = bytestr; | 486 | stack.byte_string = bytestr; |
| 448 | stack.pc = stack.byte_string_start = SDATA (bytestr); | 487 | stack.pc = stack.byte_string_start = SDATA (bytestr); |
| 449 | stack.constants = vector; | 488 | stack.constants = vector; |
| 450 | stack.bottom = (Lisp_Object *) alloca (XFASTINT (maxdepth) | 489 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object) < XFASTINT (maxdepth)) |
| 490 | memory_full (SIZE_MAX); | ||
| 491 | top = (Lisp_Object *) alloca (XFASTINT (maxdepth) | ||
| 451 | * sizeof (Lisp_Object)); | 492 | * sizeof (Lisp_Object)); |
| 452 | top = stack.bottom - 1; | 493 | #if BYTE_MAINTAIN_TOP |
| 494 | stack.bottom = top; | ||
| 453 | stack.top = NULL; | 495 | stack.top = NULL; |
| 496 | #endif | ||
| 497 | top -= 1; | ||
| 454 | stack.next = byte_stack_list; | 498 | stack.next = byte_stack_list; |
| 455 | byte_stack_list = &stack; | 499 | byte_stack_list = &stack; |
| 456 | 500 | ||
| @@ -458,6 +502,52 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 458 | stacke = stack.bottom - 1 + XFASTINT (maxdepth); | 502 | stacke = stack.bottom - 1 + XFASTINT (maxdepth); |
| 459 | #endif | 503 | #endif |
| 460 | 504 | ||
| 505 | if (INTEGERP (args_template)) | ||
| 506 | { | ||
| 507 | ptrdiff_t at = XINT (args_template); | ||
| 508 | int rest = at & 128; | ||
| 509 | int mandatory = at & 127; | ||
| 510 | ptrdiff_t nonrest = at >> 8; | ||
| 511 | eassert (mandatory <= nonrest); | ||
| 512 | if (nargs <= nonrest) | ||
| 513 | { | ||
| 514 | ptrdiff_t i; | ||
| 515 | for (i = 0 ; i < nargs; i++, args++) | ||
| 516 | PUSH (*args); | ||
| 517 | if (nargs < mandatory) | ||
| 518 | /* Too few arguments. */ | ||
| 519 | Fsignal (Qwrong_number_of_arguments, | ||
| 520 | Fcons (Fcons (make_number (mandatory), | ||
| 521 | rest ? Qand_rest : make_number (nonrest)), | ||
| 522 | Fcons (make_number (nargs), Qnil))); | ||
| 523 | else | ||
| 524 | { | ||
| 525 | for (; i < nonrest; i++) | ||
| 526 | PUSH (Qnil); | ||
| 527 | if (rest) | ||
| 528 | PUSH (Qnil); | ||
| 529 | } | ||
| 530 | } | ||
| 531 | else if (rest) | ||
| 532 | { | ||
| 533 | ptrdiff_t 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. */ | ||
| 540 | Fsignal (Qwrong_number_of_arguments, | ||
| 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!"); | ||
| 549 | } | ||
| 550 | |||
| 461 | while (1) | 551 | while (1) |
| 462 | { | 552 | { |
| 463 | #ifdef BYTE_CODE_SAFE | 553 | #ifdef BYTE_CODE_SAFE |
| @@ -539,7 +629,16 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 539 | { | 629 | { |
| 540 | Lisp_Object v1; | 630 | Lisp_Object v1; |
| 541 | v1 = TOP; | 631 | v1 = TOP; |
| 542 | TOP = CAR (v1); | 632 | if (CONSP (v1)) |
| 633 | TOP = XCAR (v1); | ||
| 634 | else if (NILP (v1)) | ||
| 635 | TOP = Qnil; | ||
| 636 | else | ||
| 637 | { | ||
| 638 | BEFORE_POTENTIAL_GC (); | ||
| 639 | wrong_type_argument (Qlistp, v1); | ||
| 640 | AFTER_POTENTIAL_GC (); | ||
| 641 | } | ||
| 543 | break; | 642 | break; |
| 544 | } | 643 | } |
| 545 | 644 | ||
| @@ -565,7 +664,17 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 565 | { | 664 | { |
| 566 | Lisp_Object v1; | 665 | Lisp_Object v1; |
| 567 | v1 = TOP; | 666 | v1 = TOP; |
| 568 | TOP = CDR (v1); | 667 | if (CONSP (v1)) |
| 668 | TOP = XCDR (v1); | ||
| 669 | else if (NILP (v1)) | ||
| 670 | TOP = Qnil; | ||
| 671 | else | ||
| 672 | { | ||
| 673 | BEFORE_POTENTIAL_GC (); | ||
| 674 | wrong_type_argument (Qlistp, v1); | ||
| 675 | AFTER_POTENTIAL_GC (); | ||
| 676 | } | ||
| 677 | break; | ||
| 569 | break; | 678 | break; |
| 570 | } | 679 | } |
| 571 | 680 | ||
| @@ -699,7 +808,7 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 699 | AFTER_POTENTIAL_GC (); | 808 | AFTER_POTENTIAL_GC (); |
| 700 | break; | 809 | break; |
| 701 | 810 | ||
| 702 | case Bunbind_all: | 811 | case Bunbind_all: /* Obsolete. Never used. */ |
| 703 | /* To unbind back to the beginning of this frame. Not used yet, | 812 | /* To unbind back to the beginning of this frame. Not used yet, |
| 704 | but will be needed for tail-recursion elimination. */ | 813 | but will be needed for tail-recursion elimination. */ |
| 705 | BEFORE_POTENTIAL_GC (); | 814 | BEFORE_POTENTIAL_GC (); |
| @@ -827,37 +936,43 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 827 | save_excursion_save ()); | 936 | save_excursion_save ()); |
| 828 | break; | 937 | break; |
| 829 | 938 | ||
| 830 | case Bsave_current_buffer: | 939 | case Bsave_current_buffer: /* Obsolete since ??. */ |
| 831 | case Bsave_current_buffer_1: | 940 | case Bsave_current_buffer_1: |
| 832 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); | 941 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); |
| 833 | break; | 942 | break; |
| 834 | 943 | ||
| 835 | case Bsave_window_excursion: | 944 | case Bsave_window_excursion: /* Obsolete since 24.1. */ |
| 836 | BEFORE_POTENTIAL_GC (); | 945 | { |
| 837 | TOP = Fsave_window_excursion (TOP); | 946 | register int count1 = SPECPDL_INDEX (); |
| 838 | AFTER_POTENTIAL_GC (); | 947 | record_unwind_protect (Fset_window_configuration, |
| 839 | break; | 948 | Fcurrent_window_configuration (Qnil)); |
| 949 | BEFORE_POTENTIAL_GC (); | ||
| 950 | TOP = Fprogn (TOP); | ||
| 951 | unbind_to (count1, TOP); | ||
| 952 | AFTER_POTENTIAL_GC (); | ||
| 953 | break; | ||
| 954 | } | ||
| 840 | 955 | ||
| 841 | case Bsave_restriction: | 956 | case Bsave_restriction: |
| 842 | record_unwind_protect (save_restriction_restore, | 957 | record_unwind_protect (save_restriction_restore, |
| 843 | save_restriction_save ()); | 958 | save_restriction_save ()); |
| 844 | break; | 959 | break; |
| 845 | 960 | ||
| 846 | case Bcatch: | 961 | case Bcatch: /* FIXME: ill-suited for lexbind. */ |
| 847 | { | 962 | { |
| 848 | Lisp_Object v1; | 963 | Lisp_Object v1; |
| 849 | BEFORE_POTENTIAL_GC (); | 964 | BEFORE_POTENTIAL_GC (); |
| 850 | v1 = POP; | 965 | v1 = POP; |
| 851 | TOP = internal_catch (TOP, Feval, v1); | 966 | TOP = internal_catch (TOP, eval_sub, v1); |
| 852 | AFTER_POTENTIAL_GC (); | 967 | AFTER_POTENTIAL_GC (); |
| 853 | break; | 968 | break; |
| 854 | } | 969 | } |
| 855 | 970 | ||
| 856 | case Bunwind_protect: | 971 | case Bunwind_protect: /* FIXME: avoid closure for lexbind. */ |
| 857 | record_unwind_protect (Fprogn, POP); | 972 | record_unwind_protect (Fprogn, POP); |
| 858 | break; | 973 | break; |
| 859 | 974 | ||
| 860 | case Bcondition_case: | 975 | case Bcondition_case: /* FIXME: ill-suited for lexbind. */ |
| 861 | { | 976 | { |
| 862 | Lisp_Object handlers, body; | 977 | Lisp_Object handlers, body; |
| 863 | handlers = POP; | 978 | handlers = POP; |
| @@ -868,7 +983,7 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 868 | break; | 983 | break; |
| 869 | } | 984 | } |
| 870 | 985 | ||
| 871 | case Btemp_output_buffer_setup: | 986 | case Btemp_output_buffer_setup: /* Obsolete since 24.1. */ |
| 872 | BEFORE_POTENTIAL_GC (); | 987 | BEFORE_POTENTIAL_GC (); |
| 873 | CHECK_STRING (TOP); | 988 | CHECK_STRING (TOP); |
| 874 | temp_output_buffer_setup (SSDATA (TOP)); | 989 | temp_output_buffer_setup (SSDATA (TOP)); |
| @@ -876,7 +991,7 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 876 | TOP = Vstandard_output; | 991 | TOP = Vstandard_output; |
| 877 | break; | 992 | break; |
| 878 | 993 | ||
| 879 | case Btemp_output_buffer_show: | 994 | case Btemp_output_buffer_show: /* Obsolete since 24.1. */ |
| 880 | { | 995 | { |
| 881 | Lisp_Object v1; | 996 | Lisp_Object v1; |
| 882 | BEFORE_POTENTIAL_GC (); | 997 | BEFORE_POTENTIAL_GC (); |
| @@ -896,13 +1011,13 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 896 | v1 = POP; | 1011 | v1 = POP; |
| 897 | v2 = TOP; | 1012 | v2 = TOP; |
| 898 | CHECK_NUMBER (v2); | 1013 | CHECK_NUMBER (v2); |
| 899 | AFTER_POTENTIAL_GC (); | ||
| 900 | op = XINT (v2); | 1014 | op = XINT (v2); |
| 901 | immediate_quit = 1; | 1015 | immediate_quit = 1; |
| 902 | while (--op >= 0 && CONSP (v1)) | 1016 | while (--op >= 0 && CONSP (v1)) |
| 903 | v1 = XCDR (v1); | 1017 | v1 = XCDR (v1); |
| 904 | immediate_quit = 0; | 1018 | immediate_quit = 0; |
| 905 | TOP = CAR (v1); | 1019 | TOP = CAR (v1); |
| 1020 | AFTER_POTENTIAL_GC (); | ||
| 906 | break; | 1021 | break; |
| 907 | } | 1022 | } |
| 908 | 1023 | ||
| @@ -1310,7 +1425,7 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 1310 | { | 1425 | { |
| 1311 | Lisp_Object v1; | 1426 | Lisp_Object v1; |
| 1312 | BEFORE_POTENTIAL_GC (); | 1427 | BEFORE_POTENTIAL_GC (); |
| 1313 | XSETFASTINT (v1, (int) current_column ()); /* iftc */ | 1428 | XSETFASTINT (v1, current_column ()); |
| 1314 | AFTER_POTENTIAL_GC (); | 1429 | AFTER_POTENTIAL_GC (); |
| 1315 | PUSH (v1); | 1430 | PUSH (v1); |
| 1316 | break; | 1431 | break; |
| @@ -1348,7 +1463,7 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 1348 | AFTER_POTENTIAL_GC (); | 1463 | AFTER_POTENTIAL_GC (); |
| 1349 | break; | 1464 | break; |
| 1350 | 1465 | ||
| 1351 | case Binteractive_p: | 1466 | case Binteractive_p: /* Obsolete since 24.1. */ |
| 1352 | PUSH (Finteractive_p ()); | 1467 | PUSH (Finteractive_p ()); |
| 1353 | break; | 1468 | break; |
| 1354 | 1469 | ||
| @@ -1398,7 +1513,7 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 1398 | CHECK_CHARACTER (TOP); | 1513 | CHECK_CHARACTER (TOP); |
| 1399 | AFTER_POTENTIAL_GC (); | 1514 | AFTER_POTENTIAL_GC (); |
| 1400 | c = XFASTINT (TOP); | 1515 | c = XFASTINT (TOP); |
| 1401 | if (NILP (current_buffer->enable_multibyte_characters)) | 1516 | if (NILP (BVAR (current_buffer, enable_multibyte_characters))) |
| 1402 | MAKE_CHAR_MULTIBYTE (c); | 1517 | MAKE_CHAR_MULTIBYTE (c); |
| 1403 | XSETFASTINT (TOP, syntax_code_spec[(int) SYNTAX (c)]); | 1518 | XSETFASTINT (TOP, syntax_code_spec[(int) SYNTAX (c)]); |
| 1404 | } | 1519 | } |
| @@ -1638,8 +1753,57 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 1638 | #endif | 1753 | #endif |
| 1639 | 1754 | ||
| 1640 | case 0: | 1755 | case 0: |
| 1756 | /* Actually this is Bstack_ref with offset 0, but we use Bdup | ||
| 1757 | for that instead. */ | ||
| 1758 | /* case Bstack_ref: */ | ||
| 1641 | abort (); | 1759 | abort (); |
| 1642 | 1760 | ||
| 1761 | /* Handy byte-codes for lexical binding. */ | ||
| 1762 | case Bstack_ref+1: | ||
| 1763 | case Bstack_ref+2: | ||
| 1764 | case Bstack_ref+3: | ||
| 1765 | case Bstack_ref+4: | ||
| 1766 | case Bstack_ref+5: | ||
| 1767 | { | ||
| 1768 | Lisp_Object *ptr = top - (op - Bstack_ref); | ||
| 1769 | PUSH (*ptr); | ||
| 1770 | break; | ||
| 1771 | } | ||
| 1772 | case Bstack_ref+6: | ||
| 1773 | { | ||
| 1774 | Lisp_Object *ptr = top - (FETCH); | ||
| 1775 | PUSH (*ptr); | ||
| 1776 | break; | ||
| 1777 | } | ||
| 1778 | case Bstack_ref+7: | ||
| 1779 | { | ||
| 1780 | Lisp_Object *ptr = top - (FETCH2); | ||
| 1781 | PUSH (*ptr); | ||
| 1782 | break; | ||
| 1783 | } | ||
| 1784 | case Bstack_set: | ||
| 1785 | /* stack-set-0 = discard; stack-set-1 = discard-1-preserve-tos. */ | ||
| 1786 | { | ||
| 1787 | Lisp_Object *ptr = top - (FETCH); | ||
| 1788 | *ptr = POP; | ||
| 1789 | break; | ||
| 1790 | } | ||
| 1791 | case Bstack_set2: | ||
| 1792 | { | ||
| 1793 | Lisp_Object *ptr = top - (FETCH2); | ||
| 1794 | *ptr = POP; | ||
| 1795 | break; | ||
| 1796 | } | ||
| 1797 | case BdiscardN: | ||
| 1798 | op = FETCH; | ||
| 1799 | if (op & 0x80) | ||
| 1800 | { | ||
| 1801 | op &= 0x7F; | ||
| 1802 | top[-op] = TOP; | ||
| 1803 | } | ||
| 1804 | DISCARD (op); | ||
| 1805 | break; | ||
| 1806 | |||
| 1643 | case 255: | 1807 | case 255: |
| 1644 | default: | 1808 | default: |
| 1645 | #ifdef BYTE_CODE_SAFE | 1809 | #ifdef BYTE_CODE_SAFE |