emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r117293: Further adjustments to mark_object and frie


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r117293: Further adjustments to mark_object and friends.
Date: Mon, 09 Jun 2014 15:04:48 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117293
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Mon 2014-06-09 19:03:49 +0400
message:
  Further adjustments to mark_object and friends.
  Now the mark_object's stack is just 32 bytes on a 64-bit
  system, which means extra 20% off the stack usage.
  * alloc.c (mark_save_value): As before, refactored out from ...
  (mark_object): ... adjusted user.  Also add comment.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/alloc.c                    alloc.c-20091113204419-o5vbwnq5f7feedwu-252
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-06-09 14:50:57 +0000
+++ b/src/ChangeLog     2014-06-09 15:03:49 +0000
@@ -1,3 +1,11 @@
+2014-06-09  Dmitry Antipov  <address@hidden>
+
+       Further adjustments to mark_object and friends.
+       Now the mark_object's stack is just 32 bytes on a 64-bit
+       system, which means extra 20% off the stack usage.
+       * alloc.c (mark_save_value): As before, refactored out from ...
+       (mark_object): ... adjusted user.  Also add comment.
+
 2014-06-09  Paul Eggert  <address@hidden>
 
        Fix core dump after a dropped X connection (Bug#17704).

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2014-06-08 15:06:03 +0000
+++ b/src/alloc.c       2014-06-09 15:03:49 +0000
@@ -6068,6 +6068,30 @@
   mark_object (blv->defcell);
 }
 
+NO_INLINE /* To reduce stack depth in mark_object.  */
+static void
+mark_save_value (struct Lisp_Save_Value *ptr)
+{
+  /* If `save_type' is zero, `data[0].pointer' is the address
+     of a memory area containing `data[1].integer' potential
+     Lisp_Objects.  */
+  if (GC_MARK_STACK && ptr->save_type == SAVE_TYPE_MEMORY)
+    {
+      Lisp_Object *p = ptr->data[0].pointer;
+      ptrdiff_t nelt;
+      for (nelt = ptr->data[1].integer; nelt > 0; nelt--, p++)
+       mark_maybe_object (*p);
+    }
+  else
+    {
+      /* Find Lisp_Objects in `data[N]' slots and mark them.  */
+      int i;
+      for (i = 0; i < SAVE_VALUE_SLOTS; i++)
+       if (save_type (ptr, i) == SAVE_OBJECT)
+         mark_object (ptr->data[i].object);
+    }
+}
+
 /* Remove killed buffers or items whose car is a killed buffer from
    LIST, and mark other items.  Return changed LIST, which is marked.  */
 
@@ -6095,7 +6119,13 @@
   return list;
 }
 
-/* Determine type of generic Lisp_Object and mark it accordingly.  */
+/* Determine type of generic Lisp_Object and mark it accordingly.
+
+   This function implements a straightforward depth-first marking
+   algorithm and so the recursion depth may be very high (a few
+   tens of thousands is not uncommon).  To minimize stack usage,
+   a few cold paths are moved out to NO_INLINE functions above.
+   In general, inlining them doesn't help you to gain more speed.  */
 
 void
 mark_object (Lisp_Object arg)
@@ -6363,27 +6393,7 @@
 
        case Lisp_Misc_Save_Value:
          XMISCANY (obj)->gcmarkbit = 1;
-         {
-           struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj);
-           /* If `save_type' is zero, `data[0].pointer' is the address
-              of a memory area containing `data[1].integer' potential
-              Lisp_Objects.  */
-           if (GC_MARK_STACK && ptr->save_type == SAVE_TYPE_MEMORY)
-             {
-               Lisp_Object *p = ptr->data[0].pointer;
-               ptrdiff_t nelt;
-               for (nelt = ptr->data[1].integer; nelt > 0; nelt--, p++)
-                 mark_maybe_object (*p);
-             }
-           else
-             {
-               /* Find Lisp_Objects in `data[N]' slots and mark them.  */
-               int i;
-               for (i = 0; i < SAVE_VALUE_SLOTS; i++)
-                 if (save_type (ptr, i) == SAVE_OBJECT)
-                   mark_object (ptr->data[i].object);
-             }
-         }
+         mark_save_value (XSAVE_VALUE (obj));
          break;
 
        case Lisp_Misc_Overlay:


reply via email to

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