diff options
| author | Paul Eggert | 2016-08-09 00:37:39 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-08-09 01:31:21 -0700 |
| commit | d896f78973bce33da7b4629089122bb58103d75c (patch) | |
| tree | 8c9c094265e217ef5ba92f0476d77f81ecd0cd19 /src/bytecode.c | |
| parent | 4d07064a4374a2f74a256e64027ef80f355c7a7e (diff) | |
| download | emacs-d896f78973bce33da7b4629089122bb58103d75c.tar.gz emacs-d896f78973bce33da7b4629089122bb58103d75c.zip | |
Tune bytecode quitting
* src/bytecode.c (BYTE_CODE_QUIT): Check for GC, too. Do the
check only once every 256 times. This should be good enough, and
improves performance significantly on x86-64 as branch-prediction
typically assumes checking will not be done so the instruction
pipeline stays fuller.
(exec_byte_code): Set up the quit counter. Don’t call maybe_gc
directly, as BYTE_CODE_QUIT does that now.
Diffstat (limited to 'src/bytecode.c')
| -rw-r--r-- | src/bytecode.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index 6be17e3fd3e..52f827f282a 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -368,6 +368,9 @@ relocate_byte_stack (void) | |||
| 368 | 368 | ||
| 369 | #define BYTE_CODE_QUIT \ | 369 | #define BYTE_CODE_QUIT \ |
| 370 | do { \ | 370 | do { \ |
| 371 | if (quitcounter++) \ | ||
| 372 | break; \ | ||
| 373 | maybe_gc (); \ | ||
| 371 | if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ | 374 | if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ |
| 372 | { \ | 375 | { \ |
| 373 | Lisp_Object flag = Vquit_flag; \ | 376 | Lisp_Object flag = Vquit_flag; \ |
| @@ -446,6 +449,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 446 | stack.pc = stack.byte_string_start = SDATA (bytestr); | 449 | stack.pc = stack.byte_string_start = SDATA (bytestr); |
| 447 | if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth)) | 450 | if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth)) |
| 448 | memory_full (SIZE_MAX); | 451 | memory_full (SIZE_MAX); |
| 452 | unsigned char quitcounter = 0; | ||
| 449 | int stack_items = XFASTINT (maxdepth) + 1; | 453 | int stack_items = XFASTINT (maxdepth) + 1; |
| 450 | Lisp_Object *stack_base = alloca (stack_items * sizeof *top); | 454 | Lisp_Object *stack_base = alloca (stack_items * sizeof *top); |
| 451 | Lisp_Object *stack_lim = stack_base + stack_items; | 455 | Lisp_Object *stack_lim = stack_base + stack_items; |
| @@ -601,7 +605,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 601 | CASE (Bgotoifnil): | 605 | CASE (Bgotoifnil): |
| 602 | { | 606 | { |
| 603 | Lisp_Object v1; | 607 | Lisp_Object v1; |
| 604 | maybe_gc (); | ||
| 605 | op = FETCH2; | 608 | op = FETCH2; |
| 606 | v1 = POP; | 609 | v1 = POP; |
| 607 | if (NILP (v1)) | 610 | if (NILP (v1)) |
| @@ -788,7 +791,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 788 | NEXT; | 791 | NEXT; |
| 789 | 792 | ||
| 790 | CASE (Bgoto): | 793 | CASE (Bgoto): |
| 791 | maybe_gc (); | ||
| 792 | BYTE_CODE_QUIT; | 794 | BYTE_CODE_QUIT; |
| 793 | op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */ | 795 | op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */ |
| 794 | CHECK_RANGE (op); | 796 | CHECK_RANGE (op); |
| @@ -798,7 +800,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 798 | CASE (Bgotoifnonnil): | 800 | CASE (Bgotoifnonnil): |
| 799 | { | 801 | { |
| 800 | Lisp_Object v1; | 802 | Lisp_Object v1; |
| 801 | maybe_gc (); | ||
| 802 | op = FETCH2; | 803 | op = FETCH2; |
| 803 | v1 = POP; | 804 | v1 = POP; |
| 804 | if (!NILP (v1)) | 805 | if (!NILP (v1)) |
| @@ -811,7 +812,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 811 | } | 812 | } |
| 812 | 813 | ||
| 813 | CASE (Bgotoifnilelsepop): | 814 | CASE (Bgotoifnilelsepop): |
| 814 | maybe_gc (); | ||
| 815 | op = FETCH2; | 815 | op = FETCH2; |
| 816 | if (NILP (TOP)) | 816 | if (NILP (TOP)) |
| 817 | { | 817 | { |
| @@ -823,7 +823,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 823 | NEXT; | 823 | NEXT; |
| 824 | 824 | ||
| 825 | CASE (Bgotoifnonnilelsepop): | 825 | CASE (Bgotoifnonnilelsepop): |
| 826 | maybe_gc (); | ||
| 827 | op = FETCH2; | 826 | op = FETCH2; |
| 828 | if (!NILP (TOP)) | 827 | if (!NILP (TOP)) |
| 829 | { | 828 | { |
| @@ -835,7 +834,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 835 | NEXT; | 834 | NEXT; |
| 836 | 835 | ||
| 837 | CASE (BRgoto): | 836 | CASE (BRgoto): |
| 838 | maybe_gc (); | ||
| 839 | BYTE_CODE_QUIT; | 837 | BYTE_CODE_QUIT; |
| 840 | stack.pc += (int) *stack.pc - 127; | 838 | stack.pc += (int) *stack.pc - 127; |
| 841 | NEXT; | 839 | NEXT; |
| @@ -843,7 +841,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 843 | CASE (BRgotoifnil): | 841 | CASE (BRgotoifnil): |
| 844 | { | 842 | { |
| 845 | Lisp_Object v1; | 843 | Lisp_Object v1; |
| 846 | maybe_gc (); | ||
| 847 | v1 = POP; | 844 | v1 = POP; |
| 848 | if (NILP (v1)) | 845 | if (NILP (v1)) |
| 849 | { | 846 | { |
| @@ -857,7 +854,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 857 | CASE (BRgotoifnonnil): | 854 | CASE (BRgotoifnonnil): |
| 858 | { | 855 | { |
| 859 | Lisp_Object v1; | 856 | Lisp_Object v1; |
| 860 | maybe_gc (); | ||
| 861 | v1 = POP; | 857 | v1 = POP; |
| 862 | if (!NILP (v1)) | 858 | if (!NILP (v1)) |
| 863 | { | 859 | { |
| @@ -869,7 +865,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 869 | } | 865 | } |
| 870 | 866 | ||
| 871 | CASE (BRgotoifnilelsepop): | 867 | CASE (BRgotoifnilelsepop): |
| 872 | maybe_gc (); | ||
| 873 | op = *stack.pc++; | 868 | op = *stack.pc++; |
| 874 | if (NILP (TOP)) | 869 | if (NILP (TOP)) |
| 875 | { | 870 | { |
| @@ -880,7 +875,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 880 | NEXT; | 875 | NEXT; |
| 881 | 876 | ||
| 882 | CASE (BRgotoifnonnilelsepop): | 877 | CASE (BRgotoifnonnilelsepop): |
| 883 | maybe_gc (); | ||
| 884 | op = *stack.pc++; | 878 | op = *stack.pc++; |
| 885 | if (!NILP (TOP)) | 879 | if (!NILP (TOP)) |
| 886 | { | 880 | { |