diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-08-09 00:37:39 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-08-09 01:31:21 -0700 |
commit | d896f78973bce33da7b4629089122bb58103d75c (patch) | |
tree | 8c9c094265e217ef5ba92f0476d77f81ecd0cd19 | |
parent | 4d07064a4374a2f74a256e64027ef80f355c7a7e (diff) | |
download | emacs-d896f78973bce33da7b4629089122bb58103d75c.tar.gz emacs-d896f78973bce33da7b4629089122bb58103d75c.tar.bz2 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.
-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) #define BYTE_CODE_QUIT \ do { \ + if (quitcounter++) \ + break; \ + maybe_gc (); \ if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ { \ Lisp_Object flag = Vquit_flag; \ @@ -446,6 +449,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, stack.pc = stack.byte_string_start = SDATA (bytestr); if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth)) memory_full (SIZE_MAX); + unsigned char quitcounter = 0; int stack_items = XFASTINT (maxdepth) + 1; Lisp_Object *stack_base = alloca (stack_items * sizeof *top); Lisp_Object *stack_lim = stack_base + stack_items; @@ -601,7 +605,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, CASE (Bgotoifnil): { Lisp_Object v1; - maybe_gc (); op = FETCH2; v1 = POP; if (NILP (v1)) @@ -788,7 +791,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, NEXT; CASE (Bgoto): - maybe_gc (); BYTE_CODE_QUIT; op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */ CHECK_RANGE (op); @@ -798,7 +800,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, CASE (Bgotoifnonnil): { Lisp_Object v1; - maybe_gc (); op = FETCH2; v1 = POP; if (!NILP (v1)) @@ -811,7 +812,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, } CASE (Bgotoifnilelsepop): - maybe_gc (); op = FETCH2; if (NILP (TOP)) { @@ -823,7 +823,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, NEXT; CASE (Bgotoifnonnilelsepop): - maybe_gc (); op = FETCH2; if (!NILP (TOP)) { @@ -835,7 +834,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, NEXT; CASE (BRgoto): - maybe_gc (); BYTE_CODE_QUIT; stack.pc += (int) *stack.pc - 127; NEXT; @@ -843,7 +841,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, CASE (BRgotoifnil): { Lisp_Object v1; - maybe_gc (); v1 = POP; if (NILP (v1)) { @@ -857,7 +854,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, CASE (BRgotoifnonnil): { Lisp_Object v1; - maybe_gc (); v1 = POP; if (!NILP (v1)) { @@ -869,7 +865,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, } CASE (BRgotoifnilelsepop): - maybe_gc (); op = *stack.pc++; if (NILP (TOP)) { @@ -880,7 +875,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, NEXT; CASE (BRgotoifnonnilelsepop): - maybe_gc (); op = *stack.pc++; if (!NILP (TOP)) { |