diff options
| author | Jim Blandy | 1992-08-12 13:30:54 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-08-12 13:30:54 +0000 |
| commit | 63639d4409f53b229b9f0a397e42f3515c6d2023 (patch) | |
| tree | 11781c3738fe4eb70f7ba62dbba97bf756cea235 /src/bytecode.c | |
| parent | 9e2b097b2608f55d27df1e3521575be8dd670a0c (diff) | |
| download | emacs-63639d4409f53b229b9f0a397e42f3515c6d2023.tar.gz emacs-63639d4409f53b229b9f0a397e42f3515c6d2023.zip | |
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
sure the count on the symbol's `byte-code-meter' property does not
overflow.
* bytecode.c (syms_of_bytecode): Add a docstring for
byte-metering-on.
Diffstat (limited to 'src/bytecode.c')
| -rw-r--r-- | src/bytecode.c | 263 |
1 files changed, 185 insertions, 78 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index 7604dd82655..33383ce7c11 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -5,7 +5,7 @@ This file is part of GNU Emacs. | |||
| 5 | 5 | ||
| 6 | GNU Emacs is free software; you can redistribute it and/or modify | 6 | GNU Emacs is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 1, or (at your option) | 8 | the Free Software Foundation; either version 2, or (at your option) |
| 9 | any later version. | 9 | any later version. |
| 10 | 10 | ||
| 11 | GNU Emacs is distributed in the hope that it will be useful, | 11 | GNU Emacs is distributed in the hope that it will be useful, |
| @@ -17,14 +17,12 @@ You should have received a copy of the GNU General Public License | |||
| 17 | along with GNU Emacs; see the file COPYING. If not, write to | 17 | along with GNU Emacs; see the file COPYING. If not, write to |
| 18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | 19 | ||
| 20 | hacked on by jwz 17-jun-91 | 20 | hacked on by jwz@lucid.com 17-jun-91 |
| 21 | o added a compile-time switch to turn on simple sanity checking; | 21 | o added a compile-time switch to turn on simple sanity checking; |
| 22 | o put back the obsolete byte-codes for error-detection; | 22 | o put back the obsolete byte-codes for error-detection; |
| 23 | o put back fset, symbol-function, and read-char because I don't | ||
| 24 | see any reason for them to have been removed; | ||
| 25 | o added a new instruction, unbind_all, which I will use for | 23 | o added a new instruction, unbind_all, which I will use for |
| 26 | tail-recursion elimination; | 24 | tail-recursion elimination; |
| 27 | o made temp_output_buffer_show() be called with the right number | 25 | o made temp_output_buffer_show be called with the right number |
| 28 | of args; | 26 | of args; |
| 29 | o made the new bytecodes be called with args in the right order; | 27 | o made the new bytecodes be called with args in the right order; |
| 30 | o added metering support. | 28 | o added metering support. |
| @@ -34,48 +32,49 @@ by Hallvard: | |||
| 34 | o all conditionals now only do QUIT if they jump. | 32 | o all conditionals now only do QUIT if they jump. |
| 35 | */ | 33 | */ |
| 36 | 34 | ||
| 37 | |||
| 38 | #include "config.h" | 35 | #include "config.h" |
| 39 | #include "lisp.h" | 36 | #include "lisp.h" |
| 40 | #include "buffer.h" | 37 | #include "buffer.h" |
| 41 | #include "syntax.h" | 38 | #include "syntax.h" |
| 42 | 39 | ||
| 43 | /* Define this to enable some minor sanity checking | 40 | /* |
| 44 | (useful for debugging the byte compiler...) | 41 | * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for |
| 45 | */ | 42 | * debugging the byte compiler...) |
| 46 | #define BYTE_CODE_SAFE | 43 | * |
| 47 | 44 | * define BYTE_CODE_METER to enable generation of a byte-op usage histogram. | |
| 48 | /* Define this to enable generation of a histogram of byte-op usage. | ||
| 49 | */ | 45 | */ |
| 50 | #define BYTE_CODE_METER | 46 | /* #define BYTE_CODE_SAFE */ |
| 47 | /* #define BYTE_CODE_METER */ | ||
| 51 | 48 | ||
| 52 | 49 | ||
| 53 | #ifdef BYTE_CODE_METER | 50 | #ifdef BYTE_CODE_METER |
| 54 | 51 | ||
| 55 | Lisp_Object Vbyte_code_meter; | 52 | Lisp_Object Vbyte_code_meter, Qbyte_code_meter; |
| 56 | int byte_metering_on; | 53 | int byte_metering_on; |
| 57 | 54 | ||
| 58 | # define METER_2(code1,code2) \ | 55 | #define METER_2(code1, code2) \ |
| 59 | XFASTINT (XVECTOR (XVECTOR (Vbyte_code_meter)->contents[(code1)]) \ | 56 | XFASTINT (XVECTOR (XVECTOR (Vbyte_code_meter)->contents[(code1)]) \ |
| 60 | ->contents[(code2)]) | 57 | ->contents[(code2)]) |
| 61 | 58 | ||
| 62 | # define METER_1(code) METER_2 (0,(code)) | 59 | #define METER_1(code) METER_2 (0, (code)) |
| 63 | 60 | ||
| 64 | # define METER_CODE(last_code, this_code) { \ | 61 | #define METER_CODE(last_code, this_code) \ |
| 65 | if (byte_metering_on) { \ | 62 | { \ |
| 66 | if (METER_1 (this_code) != ((1<<VALBITS)-1)) \ | 63 | if (byte_metering_on) \ |
| 67 | METER_1 (this_code) ++; \ | 64 | { \ |
| 68 | if (last_code && \ | 65 | if (METER_1 (this_code) != ((1<<VALBITS)-1)) \ |
| 69 | METER_2 (last_code,this_code) != ((1<<VALBITS)-1)) \ | 66 | METER_1 (this_code)++; \ |
| 70 | METER_2 (last_code,this_code) ++; \ | 67 | if (last_code \ |
| 71 | } \ | 68 | && METER_2 (last_code, this_code) != ((1<<VALBITS)-1))\ |
| 72 | } | 69 | METER_2 (last_code, this_code)++; \ |
| 70 | } \ | ||
| 71 | } | ||
| 73 | 72 | ||
| 74 | #else /* ! BYTE_CODE_METER */ | 73 | #else /* no BYTE_CODE_METER */ |
| 75 | 74 | ||
| 76 | # define meter_code(last_code, this_code) | 75 | #define METER_CODE(last_code, this_code) |
| 77 | 76 | ||
| 78 | #endif | 77 | #endif /* no BYTE_CODE_METER */ |
| 79 | 78 | ||
| 80 | 79 | ||
| 81 | Lisp_Object Qbytecode; | 80 | Lisp_Object Qbytecode; |
| @@ -107,9 +106,9 @@ Lisp_Object Qbytecode; | |||
| 107 | #define Baref 0110 | 106 | #define Baref 0110 |
| 108 | #define Baset 0111 | 107 | #define Baset 0111 |
| 109 | #define Bsymbol_value 0112 | 108 | #define Bsymbol_value 0112 |
| 110 | #define Bsymbol_function 0113 /* no longer generated as of v19 */ | 109 | #define Bsymbol_function 0113 |
| 111 | #define Bset 0114 | 110 | #define Bset 0114 |
| 112 | #define Bfset 0115 /* no longer generated as of v19 */ | 111 | #define Bfset 0115 |
| 113 | #define Bget 0116 | 112 | #define Bget 0116 |
| 114 | #define Bsubstring 0117 | 113 | #define Bsubstring 0117 |
| 115 | #define Bconcat2 0120 | 114 | #define Bconcat2 0120 |
| @@ -147,7 +146,7 @@ Lisp_Object Qbytecode; | |||
| 147 | #define Bbobp 0157 | 146 | #define Bbobp 0157 |
| 148 | #define Bcurrent_buffer 0160 | 147 | #define Bcurrent_buffer 0160 |
| 149 | #define Bset_buffer 0161 | 148 | #define Bset_buffer 0161 |
| 150 | #define Bread_char 0162 | 149 | #define Bread_char 0162 /* No longer generated as of v19 */ |
| 151 | #define Bset_mark 0163 /* this loser is no longer generated as of v18 */ | 150 | #define Bset_mark 0163 /* this loser is no longer generated as of v18 */ |
| 152 | #define Binteractive_p 0164 /* Needed since interactive-p takes unevalled args */ | 151 | #define Binteractive_p 0164 /* Needed since interactive-p takes unevalled args */ |
| 153 | 152 | ||
| @@ -161,6 +160,7 @@ Lisp_Object Qbytecode; | |||
| 161 | #define Bdelete_region 0174 | 160 | #define Bdelete_region 0174 |
| 162 | #define Bnarrow_to_region 0175 | 161 | #define Bnarrow_to_region 0175 |
| 163 | #define Bwiden 0176 | 162 | #define Bwiden 0176 |
| 163 | #define Bend_of_line 0177 | ||
| 164 | 164 | ||
| 165 | #define Bconstant2 0201 | 165 | #define Bconstant2 0201 |
| 166 | #define Bgoto 0202 | 166 | #define Bgoto 0202 |
| @@ -184,6 +184,12 @@ Lisp_Object Qbytecode; | |||
| 184 | 184 | ||
| 185 | #define Bunbind_all 0222 | 185 | #define Bunbind_all 0222 |
| 186 | 186 | ||
| 187 | #define Bset_marker 0223 | ||
| 188 | #define Bmatch_beginning 0224 | ||
| 189 | #define Bmatch_end 0225 | ||
| 190 | #define Bupcase 0226 | ||
| 191 | #define Bdowncase 0227 | ||
| 192 | |||
| 187 | #define Bstringeqlsign 0230 | 193 | #define Bstringeqlsign 0230 |
| 188 | #define Bstringlss 0231 | 194 | #define Bstringlss 0231 |
| 189 | #define Bequal 0232 | 195 | #define Bequal 0232 |
| @@ -202,6 +208,16 @@ Lisp_Object Qbytecode; | |||
| 202 | #define Bnumberp 0247 | 208 | #define Bnumberp 0247 |
| 203 | #define Bintegerp 0250 | 209 | #define Bintegerp 0250 |
| 204 | 210 | ||
| 211 | #define BRgoto 0252 | ||
| 212 | #define BRgotoifnil 0253 | ||
| 213 | #define BRgotoifnonnil 0254 | ||
| 214 | #define BRgotoifnilelsepop 0255 | ||
| 215 | #define BRgotoifnonnilelsepop 0256 | ||
| 216 | |||
| 217 | #define BlistN 0257 | ||
| 218 | #define BconcatN 0260 | ||
| 219 | #define BinsertN 0261 | ||
| 220 | |||
| 205 | #define Bconstant 0300 | 221 | #define Bconstant 0300 |
| 206 | #define CONSTANTLIM 0100 | 222 | #define CONSTANTLIM 0100 |
| 207 | 223 | ||
| @@ -285,11 +301,10 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 285 | { | 301 | { |
| 286 | #ifdef BYTE_CODE_SAFE | 302 | #ifdef BYTE_CODE_SAFE |
| 287 | if (stackp > stacke) | 303 | if (stackp > stacke) |
| 288 | error ( | 304 | error ("Byte code stack overflow (byte compiler bug), pc %d, depth %d", |
| 289 | "Stack overflow in byte code (byte compiler bug), pc = %d, depth = %d", | ||
| 290 | pc - XSTRING (string_saved)->data, stacke - stackp); | 305 | pc - XSTRING (string_saved)->data, stacke - stackp); |
| 291 | if (stackp < stack) | 306 | if (stackp < stack) |
| 292 | error ("Stack underflow in byte code (byte compiler bug), pc = %d", | 307 | error ("Byte code stack underflow (byte compiler bug), pc %d", |
| 293 | pc - XSTRING (string_saved)->data); | 308 | pc - XSTRING (string_saved)->data); |
| 294 | #endif | 309 | #endif |
| 295 | 310 | ||
| @@ -390,7 +405,20 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 390 | case Bcall+4: case Bcall+5: | 405 | case Bcall+4: case Bcall+5: |
| 391 | op -= Bcall; | 406 | op -= Bcall; |
| 392 | docall: | 407 | docall: |
| 393 | DISCARD(op); | 408 | DISCARD (op); |
| 409 | #ifdef BYTE_CODE_METER | ||
| 410 | if (byte_metering_on && XTYPE (TOP) == Lisp_Symbol) | ||
| 411 | { | ||
| 412 | v1 = TOP; | ||
| 413 | v2 = Fget (v1, Qbyte_code_meter); | ||
| 414 | if (XTYPE (v2) == Lisp_Int | ||
| 415 | && XINT (v2) != ((1<<VALBITS)-1)) | ||
| 416 | { | ||
| 417 | XSETINT (v2, XINT (v2) + 1); | ||
| 418 | Fput (v1, Qbyte_code_meter, v2); | ||
| 419 | } | ||
| 420 | } | ||
| 421 | #endif | ||
| 394 | TOP = Ffuncall (op + 1, &TOP); | 422 | TOP = Ffuncall (op + 1, &TOP); |
| 395 | break; | 423 | break; |
| 396 | 424 | ||
| @@ -411,8 +439,7 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 411 | 439 | ||
| 412 | case Bunbind_all: | 440 | case Bunbind_all: |
| 413 | /* To unbind back to the beginning of this frame. Not used yet, | 441 | /* To unbind back to the beginning of this frame. Not used yet, |
| 414 | but wil be needed for tail-recursion elimination. | 442 | but will be needed for tail-recursion elimination. */ |
| 415 | */ | ||
| 416 | unbind_to (count, Qnil); | 443 | unbind_to (count, Qnil); |
| 417 | break; | 444 | break; |
| 418 | 445 | ||
| @@ -447,7 +474,7 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 447 | QUIT; | 474 | QUIT; |
| 448 | pc = XSTRING (string_saved)->data + op; | 475 | pc = XSTRING (string_saved)->data + op; |
| 449 | } | 476 | } |
| 450 | else DISCARD(1); | 477 | else DISCARD (1); |
| 451 | break; | 478 | break; |
| 452 | 479 | ||
| 453 | case Bgotoifnonnilelsepop: | 480 | case Bgotoifnonnilelsepop: |
| @@ -457,7 +484,50 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 457 | QUIT; | 484 | QUIT; |
| 458 | pc = XSTRING (string_saved)->data + op; | 485 | pc = XSTRING (string_saved)->data + op; |
| 459 | } | 486 | } |
| 460 | else DISCARD(1); | 487 | else DISCARD (1); |
| 488 | break; | ||
| 489 | |||
| 490 | case BRgoto: | ||
| 491 | QUIT; | ||
| 492 | pc += *pc - 127; | ||
| 493 | break; | ||
| 494 | |||
| 495 | case BRgotoifnil: | ||
| 496 | if (NILP (POP)) | ||
| 497 | { | ||
| 498 | QUIT; | ||
| 499 | pc += *pc - 128; | ||
| 500 | } | ||
| 501 | pc++; | ||
| 502 | break; | ||
| 503 | |||
| 504 | case BRgotoifnonnil: | ||
| 505 | if (!NILP (POP)) | ||
| 506 | { | ||
| 507 | QUIT; | ||
| 508 | pc += *pc - 128; | ||
| 509 | } | ||
| 510 | pc++; | ||
| 511 | break; | ||
| 512 | |||
| 513 | case BRgotoifnilelsepop: | ||
| 514 | op = *pc++; | ||
| 515 | if (NILP (TOP)) | ||
| 516 | { | ||
| 517 | QUIT; | ||
| 518 | pc += op - 128; | ||
| 519 | } | ||
| 520 | else DISCARD (1); | ||
| 521 | break; | ||
| 522 | |||
| 523 | case BRgotoifnonnilelsepop: | ||
| 524 | op = *pc++; | ||
| 525 | if (!NILP (TOP)) | ||
| 526 | { | ||
| 527 | QUIT; | ||
| 528 | pc += op - 128; | ||
| 529 | } | ||
| 530 | else DISCARD (1); | ||
| 461 | break; | 531 | break; |
| 462 | 532 | ||
| 463 | case Breturn: | 533 | case Breturn: |
| @@ -465,7 +535,7 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 465 | goto exit; | 535 | goto exit; |
| 466 | 536 | ||
| 467 | case Bdiscard: | 537 | case Bdiscard: |
| 468 | DISCARD(1); | 538 | DISCARD (1); |
| 469 | break; | 539 | break; |
| 470 | 540 | ||
| 471 | case Bdup: | 541 | case Bdup: |
| @@ -600,15 +670,21 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 600 | break; | 670 | break; |
| 601 | 671 | ||
| 602 | case Blist3: | 672 | case Blist3: |
| 603 | DISCARD(2); | 673 | DISCARD (2); |
| 604 | TOP = Flist (3, &TOP); | 674 | TOP = Flist (3, &TOP); |
| 605 | break; | 675 | break; |
| 606 | 676 | ||
| 607 | case Blist4: | 677 | case Blist4: |
| 608 | DISCARD(3); | 678 | DISCARD (3); |
| 609 | TOP = Flist (4, &TOP); | 679 | TOP = Flist (4, &TOP); |
| 610 | break; | 680 | break; |
| 611 | 681 | ||
| 682 | case BlistN: | ||
| 683 | op = FETCH; | ||
| 684 | DISCARD (op - 1); | ||
| 685 | TOP = Flist (op, &TOP); | ||
| 686 | break; | ||
| 687 | |||
| 612 | case Blength: | 688 | case Blength: |
| 613 | TOP = Flength (TOP); | 689 | TOP = Flength (TOP); |
| 614 | break; | 690 | break; |
| @@ -652,20 +728,26 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 652 | break; | 728 | break; |
| 653 | 729 | ||
| 654 | case Bconcat2: | 730 | case Bconcat2: |
| 655 | DISCARD(1); | 731 | DISCARD (1); |
| 656 | TOP = Fconcat (2, &TOP); | 732 | TOP = Fconcat (2, &TOP); |
| 657 | break; | 733 | break; |
| 658 | 734 | ||
| 659 | case Bconcat3: | 735 | case Bconcat3: |
| 660 | DISCARD(2); | 736 | DISCARD (2); |
| 661 | TOP = Fconcat (3, &TOP); | 737 | TOP = Fconcat (3, &TOP); |
| 662 | break; | 738 | break; |
| 663 | 739 | ||
| 664 | case Bconcat4: | 740 | case Bconcat4: |
| 665 | DISCARD(3); | 741 | DISCARD (3); |
| 666 | TOP = Fconcat (4, &TOP); | 742 | TOP = Fconcat (4, &TOP); |
| 667 | break; | 743 | break; |
| 668 | 744 | ||
| 745 | case BconcatN: | ||
| 746 | op = FETCH; | ||
| 747 | DISCARD (op - 1); | ||
| 748 | TOP = Fconcat (op, &TOP); | ||
| 749 | break; | ||
| 750 | |||
| 669 | case Bsub1: | 751 | case Bsub1: |
| 670 | v1 = TOP; | 752 | v1 = TOP; |
| 671 | if (XTYPE (v1) == Lisp_Int) | 753 | if (XTYPE (v1) == Lisp_Int) |
| @@ -716,7 +798,7 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 716 | break; | 798 | break; |
| 717 | 799 | ||
| 718 | case Bdiff: | 800 | case Bdiff: |
| 719 | DISCARD(1); | 801 | DISCARD (1); |
| 720 | TOP = Fminus (2, &TOP); | 802 | TOP = Fminus (2, &TOP); |
| 721 | break; | 803 | break; |
| 722 | 804 | ||
| @@ -732,33 +814,32 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 732 | break; | 814 | break; |
| 733 | 815 | ||
| 734 | case Bplus: | 816 | case Bplus: |
| 735 | DISCARD(1); | 817 | DISCARD (1); |
| 736 | TOP = Fplus (2, &TOP); | 818 | TOP = Fplus (2, &TOP); |
| 737 | break; | 819 | break; |
| 738 | 820 | ||
| 739 | case Bmax: | 821 | case Bmax: |
| 740 | DISCARD(1); | 822 | DISCARD (1); |
| 741 | TOP = Fmax (2, &TOP); | 823 | TOP = Fmax (2, &TOP); |
| 742 | break; | 824 | break; |
| 743 | 825 | ||
| 744 | case Bmin: | 826 | case Bmin: |
| 745 | DISCARD(1); | 827 | DISCARD (1); |
| 746 | TOP = Fmin (2, &TOP); | 828 | TOP = Fmin (2, &TOP); |
| 747 | break; | 829 | break; |
| 748 | 830 | ||
| 749 | case Bmult: | 831 | case Bmult: |
| 750 | DISCARD(1); | 832 | DISCARD (1); |
| 751 | TOP = Ftimes (2, &TOP); | 833 | TOP = Ftimes (2, &TOP); |
| 752 | break; | 834 | break; |
| 753 | 835 | ||
| 754 | case Bquo: | 836 | case Bquo: |
| 755 | DISCARD(1); | 837 | DISCARD (1); |
| 756 | TOP = Fquo (2, &TOP); | 838 | TOP = Fquo (2, &TOP); |
| 757 | break; | 839 | break; |
| 758 | 840 | ||
| 759 | case Brem: | 841 | case Brem: |
| 760 | v1 = POP; | 842 | v1 = POP; |
| 761 | /* This had args in the wrong order. -- jwz */ | ||
| 762 | TOP = Frem (TOP, v1); | 843 | TOP = Frem (TOP, v1); |
| 763 | break; | 844 | break; |
| 764 | 845 | ||
| @@ -775,6 +856,12 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 775 | TOP = Finsert (1, &TOP); | 856 | TOP = Finsert (1, &TOP); |
| 776 | break; | 857 | break; |
| 777 | 858 | ||
| 859 | case BinsertN: | ||
| 860 | op = FETCH; | ||
| 861 | DISCARD (op - 1); | ||
| 862 | TOP = Finsert (op, &TOP); | ||
| 863 | break; | ||
| 864 | |||
| 778 | case Bpoint_max: | 865 | case Bpoint_max: |
| 779 | XFASTINT (v1) = ZV; | 866 | XFASTINT (v1) = ZV; |
| 780 | PUSH (v1); | 867 | PUSH (v1); |
| @@ -842,29 +929,24 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 842 | break; | 929 | break; |
| 843 | 930 | ||
| 844 | case Bforward_char: | 931 | case Bforward_char: |
| 845 | /* This was wrong! --jwz */ | ||
| 846 | TOP = Fforward_char (TOP); | 932 | TOP = Fforward_char (TOP); |
| 847 | break; | 933 | break; |
| 848 | 934 | ||
| 849 | case Bforward_word: | 935 | case Bforward_word: |
| 850 | /* This was wrong! --jwz */ | ||
| 851 | TOP = Fforward_word (TOP); | 936 | TOP = Fforward_word (TOP); |
| 852 | break; | 937 | break; |
| 853 | 938 | ||
| 854 | case Bskip_chars_forward: | 939 | case Bskip_chars_forward: |
| 855 | /* This was wrong! --jwz */ | ||
| 856 | v1 = POP; | 940 | v1 = POP; |
| 857 | TOP = Fskip_chars_forward (TOP, v1); | 941 | TOP = Fskip_chars_forward (TOP, v1); |
| 858 | break; | 942 | break; |
| 859 | 943 | ||
| 860 | case Bskip_chars_backward: | 944 | case Bskip_chars_backward: |
| 861 | /* This was wrong! --jwz */ | ||
| 862 | v1 = POP; | 945 | v1 = POP; |
| 863 | TOP = Fskip_chars_backward (TOP, v1); | 946 | TOP = Fskip_chars_backward (TOP, v1); |
| 864 | break; | 947 | break; |
| 865 | 948 | ||
| 866 | case Bforward_line: | 949 | case Bforward_line: |
| 867 | /* This was wrong! --jwz */ | ||
| 868 | TOP = Fforward_line (TOP); | 950 | TOP = Fforward_line (TOP); |
| 869 | break; | 951 | break; |
| 870 | 952 | ||
| @@ -880,13 +962,11 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 880 | 962 | ||
| 881 | case Bdelete_region: | 963 | case Bdelete_region: |
| 882 | v1 = POP; | 964 | v1 = POP; |
| 883 | /* This had args in the wrong order. -- jwz */ | ||
| 884 | TOP = Fdelete_region (TOP, v1); | 965 | TOP = Fdelete_region (TOP, v1); |
| 885 | break; | 966 | break; |
| 886 | 967 | ||
| 887 | case Bnarrow_to_region: | 968 | case Bnarrow_to_region: |
| 888 | v1 = POP; | 969 | v1 = POP; |
| 889 | /* This had args in the wrong order. -- jwz */ | ||
| 890 | TOP = Fnarrow_to_region (TOP, v1); | 970 | TOP = Fnarrow_to_region (TOP, v1); |
| 891 | break; | 971 | break; |
| 892 | 972 | ||
| @@ -894,27 +974,49 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 894 | PUSH (Fwiden ()); | 974 | PUSH (Fwiden ()); |
| 895 | break; | 975 | break; |
| 896 | 976 | ||
| 977 | case Bend_of_line: | ||
| 978 | TOP = Fend_of_line (TOP); | ||
| 979 | break; | ||
| 980 | |||
| 981 | case Bset_marker: | ||
| 982 | v1 = POP; | ||
| 983 | v2 = POP; | ||
| 984 | TOP = Fset_marker (TOP, v2, v1); | ||
| 985 | break; | ||
| 986 | |||
| 987 | case Bmatch_beginning: | ||
| 988 | TOP = Fmatch_beginning (TOP); | ||
| 989 | break; | ||
| 990 | |||
| 991 | case Bmatch_end: | ||
| 992 | TOP = Fmatch_end (TOP); | ||
| 993 | break; | ||
| 994 | |||
| 995 | case Bupcase: | ||
| 996 | TOP = Fupcase (TOP); | ||
| 997 | break; | ||
| 998 | |||
| 999 | case Bdowncase: | ||
| 1000 | TOP = Fdowncase (TOP); | ||
| 1001 | break; | ||
| 1002 | |||
| 897 | case Bstringeqlsign: | 1003 | case Bstringeqlsign: |
| 898 | v1 = POP; | 1004 | v1 = POP; |
| 899 | /* This had args in the wrong order. -- jwz */ | ||
| 900 | TOP = Fstring_equal (TOP, v1); | 1005 | TOP = Fstring_equal (TOP, v1); |
| 901 | break; | 1006 | break; |
| 902 | 1007 | ||
| 903 | case Bstringlss: | 1008 | case Bstringlss: |
| 904 | v1 = POP; | 1009 | v1 = POP; |
| 905 | /* This had args in the wrong order. -- jwz */ | ||
| 906 | TOP = Fstring_lessp (TOP, v1); | 1010 | TOP = Fstring_lessp (TOP, v1); |
| 907 | break; | 1011 | break; |
| 908 | 1012 | ||
| 909 | case Bequal: | 1013 | case Bequal: |
| 910 | v1 = POP; | 1014 | v1 = POP; |
| 911 | /* This had args in the wrong order. -- jwz */ | ||
| 912 | TOP = Fequal (TOP, v1); | 1015 | TOP = Fequal (TOP, v1); |
| 913 | break; | 1016 | break; |
| 914 | 1017 | ||
| 915 | case Bnthcdr: | 1018 | case Bnthcdr: |
| 916 | v1 = POP; | 1019 | v1 = POP; |
| 917 | /* This had args in the wrong order. -- jwz */ | ||
| 918 | TOP = Fnthcdr (TOP, v1); | 1020 | TOP = Fnthcdr (TOP, v1); |
| 919 | break; | 1021 | break; |
| 920 | 1022 | ||
| @@ -932,13 +1034,11 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 932 | 1034 | ||
| 933 | case Bmember: | 1035 | case Bmember: |
| 934 | v1 = POP; | 1036 | v1 = POP; |
| 935 | /* This had args in the wrong order. -- jwz */ | ||
| 936 | TOP = Fmember (TOP, v1); | 1037 | TOP = Fmember (TOP, v1); |
| 937 | break; | 1038 | break; |
| 938 | 1039 | ||
| 939 | case Bassq: | 1040 | case Bassq: |
| 940 | v1 = POP; | 1041 | v1 = POP; |
| 941 | /* This had args in the wrong order. -- jwz */ | ||
| 942 | TOP = Fassq (TOP, v1); | 1042 | TOP = Fassq (TOP, v1); |
| 943 | break; | 1043 | break; |
| 944 | 1044 | ||
| @@ -948,13 +1048,11 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 948 | 1048 | ||
| 949 | case Bsetcar: | 1049 | case Bsetcar: |
| 950 | v1 = POP; | 1050 | v1 = POP; |
| 951 | /* This had args in the wrong order. -- jwz */ | ||
| 952 | TOP = Fsetcar (TOP, v1); | 1051 | TOP = Fsetcar (TOP, v1); |
| 953 | break; | 1052 | break; |
| 954 | 1053 | ||
| 955 | case Bsetcdr: | 1054 | case Bsetcdr: |
| 956 | v1 = POP; | 1055 | v1 = POP; |
| 957 | /* This had args in the wrong order. -- jwz */ | ||
| 958 | TOP = Fsetcdr (TOP, v1); | 1056 | TOP = Fsetcdr (TOP, v1); |
| 959 | break; | 1057 | break; |
| 960 | 1058 | ||
| @@ -975,13 +1073,12 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 975 | break; | 1073 | break; |
| 976 | 1074 | ||
| 977 | case Bnconc: | 1075 | case Bnconc: |
| 978 | DISCARD(1); | 1076 | DISCARD (1); |
| 979 | TOP = Fnconc (2, &TOP); | 1077 | TOP = Fnconc (2, &TOP); |
| 980 | break; | 1078 | break; |
| 981 | 1079 | ||
| 982 | case Bnumberp: | 1080 | case Bnumberp: |
| 983 | TOP = (XTYPE (TOP) == Lisp_Int || XTYPE (TOP) == Lisp_Float | 1081 | TOP = (NUMBERP (TOP) ? Qt : Qnil); |
| 984 | ? Qt : Qnil); | ||
| 985 | break; | 1082 | break; |
| 986 | 1083 | ||
| 987 | case Bintegerp: | 1084 | case Bintegerp: |
| @@ -996,7 +1093,7 @@ If the third argument is incorrect, Emacs may crash.") | |||
| 996 | error ("scan-buffer is an obsolete bytecode"); | 1093 | error ("scan-buffer is an obsolete bytecode"); |
| 997 | break; | 1094 | break; |
| 998 | case Bmark: | 1095 | case Bmark: |
| 999 | error("mark is an obsolete bytecode"); | 1096 | error ("mark is an obsolete bytecode"); |
| 1000 | break; | 1097 | break; |
| 1001 | #endif | 1098 | #endif |
| 1002 | 1099 | ||
| @@ -1035,17 +1132,27 @@ syms_of_bytecode () | |||
| 1035 | #ifdef BYTE_CODE_METER | 1132 | #ifdef BYTE_CODE_METER |
| 1036 | 1133 | ||
| 1037 | DEFVAR_LISP ("byte-code-meter", &Vbyte_code_meter, | 1134 | DEFVAR_LISP ("byte-code-meter", &Vbyte_code_meter, |
| 1038 | "a vector of vectors which holds a histogram of byte-code usage."); | 1135 | "A vector of vectors which holds a histogram of byte-code usage.\n\ |
| 1039 | DEFVAR_BOOL ("byte-metering-on", &byte_metering_on, ""); | 1136 | (aref (aref byte-code-meter 0) CODE) indicates how many times the byte\n\ |
| 1137 | opcode CODE has been executed.\n\ | ||
| 1138 | (aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,\n\ | ||
| 1139 | indicates how many times the byte opcodes CODE1 and CODE2 have been\n\ | ||
| 1140 | executed in succession."); | ||
| 1141 | DEFVAR_BOOL ("byte-metering-on", &byte_metering_on, | ||
| 1142 | "If non-nil, keep profiling information on byte code usage.\n\ | ||
| 1143 | The variable byte-code-meter indicates how often each byte opcode is used.\n\ | ||
| 1144 | If a symbol has a property named `byte-code-meter' whose value is an\n\ | ||
| 1145 | integer, it is incremented each time that symbol's function is called."); | ||
| 1040 | 1146 | ||
| 1041 | byte_metering_on = 0; | 1147 | byte_metering_on = 0; |
| 1042 | Vbyte_code_meter = Fmake_vector(make_number(256), make_number(0)); | 1148 | Vbyte_code_meter = Fmake_vector (make_number (256), make_number (0)); |
| 1043 | 1149 | Qbyte_code_meter = intern ("byte-code-meter"); | |
| 1150 | staticpro (&Qbyte_code_meter); | ||
| 1044 | { | 1151 | { |
| 1045 | int i = 256; | 1152 | int i = 256; |
| 1046 | while (i--) | 1153 | while (i--) |
| 1047 | XVECTOR(Vbyte_code_meter)->contents[i] = | 1154 | XVECTOR (Vbyte_code_meter)->contents[i] = |
| 1048 | Fmake_vector(make_number(256), make_number(0)); | 1155 | Fmake_vector (make_number (256), make_number (0)); |
| 1049 | } | 1156 | } |
| 1050 | #endif | 1157 | #endif |
| 1051 | } | 1158 | } |