emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master d896f78 2/5: Tune bytecode quitting


From: Paul Eggert
Subject: [Emacs-diffs] master d896f78 2/5: Tune bytecode quitting
Date: Tue, 9 Aug 2016 08:31:27 +0000 (UTC)

branch: master
commit d896f78973bce33da7b4629089122bb58103d75c
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 src/bytecode.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/bytecode.c b/src/bytecode.c
index 6be17e3..52f827f 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))
            {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]