[pypy-commit] stmgc gc-small-uniform: in-progress

arigo noreply at buildbot.pypy.org
Tue Mar 18 08:40:23 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: gc-small-uniform
Changeset: r1061:34fbe565894a
Date: 2014-03-18 08:38 +0100
http://bitbucket.org/pypy/stmgc/changeset/34fbe565894a/

Log:	in-progress

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -84,6 +84,7 @@
            the common case. Otherwise, we need to compute it based on
            its location and size. */
         if (is_small_uniform(obj)) {
+            abort();
             page_privatize(first_page);
         }
         else {
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -97,7 +97,7 @@
                 obj->stm_flags &= ~GCFLAG_HAS_SHADOW;
                 realobj = REAL_ADDRESS(STM_SEGMENT->segment_base, obj);
                 size = stmcb_size_rounded_up((struct object_s *)realobj);
-                goto copy_large_object;
+                goto handle_large_object;
             }
         }
         /* We need to make a copy of this object.  It goes either in
@@ -107,25 +107,27 @@
         realobj = REAL_ADDRESS(STM_SEGMENT->segment_base, obj);
         size = stmcb_size_rounded_up((struct object_s *)realobj);
 
-        if (1 /*size >= GC_N_SMALL_REQUESTS*8*/) {
+        if (size >= GC_N_SMALL_REQUESTS) {
 
             /* case 1: object is not small enough.
                Ask gcpage.c for an allocation via largemalloc. */
             char *allocated = allocate_outside_nursery_large(size);
             nobj = (object_t *)(allocated - stm_object_pages);
 
-            /* Copy the object */
-         copy_large_object:;
-            char *realnobj = REAL_ADDRESS(STM_SEGMENT->segment_base, nobj);
-            memcpy(realnobj, realobj, size);
-
+         handle_large_object:
             nobj_sync_now = ((uintptr_t)nobj) | FLAG_SYNC_LARGE;
         }
         else {
             /* case "small enough" */
-            abort();  //...
+            char *allocated = allocate_outside_nursery_small(size);
+            nobj = (object_t *)(allocated - stm_object_pages);
+            nobj_sync_now = (uintptr_t)nobj;
         }
 
+        /* Copy the object */
+        char *realnobj = REAL_ADDRESS(STM_SEGMENT->segment_base, nobj);
+        memcpy(realnobj, realobj, size);
+
         /* Done copying the object. */
         //dprintf(("\t\t\t\t\t%p -> %p\n", obj, nobj));
         pforwarded_array[0] = GCWORD_MOVED;
@@ -153,6 +155,7 @@
 
     /* Must trace the object later */
     LIST_APPEND(STM_PSEGMENT->objects_pointing_to_nursery, nobj_sync_now);
+    assert(nobj_sync_now == ((uintptr_t)nobj | is_small_uniform(nobj)));
 }
 
 static void collect_roots_in_nursery(void)
diff --git a/c7/stm/smallmalloc.c b/c7/stm/smallmalloc.c
--- a/c7/stm/smallmalloc.c
+++ b/c7/stm/smallmalloc.c
@@ -25,7 +25,7 @@
             goto out_of_memory;
 
         uninitialized_page_stop -= decrease_by;
-        first_small_uniform_loc = (uintptr_t)uninitialized_page_stop;
+        first_small_uniform_loc = uninitialized_page_stop - stm_object_pages;
 
         char *base = stm_object_pages + END_NURSERY_PAGE * 4096UL;
         if (!_stm_largemalloc_resize_arena(uninitialized_page_stop - base))
@@ -51,8 +51,6 @@
 
 static char *_allocate_small_slowpath(uint64_t size)
 {
-    /* First try to grab the next page from the global 'small_page_list'
-     */
     long n = size / 8;
     struct small_page_list_s *smallpage;
     struct small_free_loc_s *TLPREFIX *fl =
@@ -60,6 +58,8 @@
     assert(*fl == NULL);
 
  retry:
+    /* First try to grab the next page from the global 'small_page_list'
+     */
     smallpage = small_page_lists[n];
     if (smallpage != NULL) {
         if (UNLIKELY(!__sync_bool_compare_and_swap(&small_page_lists[n],
@@ -72,8 +72,8 @@
         return (char *)smallpage;
     }
 
-    /* There is no more page waiting.  Maybe we can pick one from
-       free_uniform_pages.
+    /* There is no more page waiting for the correct size of objects.
+       Maybe we can pick one from free_uniform_pages.
      */
     smallpage = free_uniform_pages;
     if (smallpage != NULL) {
@@ -104,7 +104,8 @@
         return (char *)smallpage;
     }
 
-    /* Not a single free page left.  Grab some more free pges and retry. */
+    /* Not a single free page left.  Grab some more free pages and retry.
+     */
     grab_more_free_pages_for_small_allocations();
     goto retry;
 }


More information about the pypy-commit mailing list