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

arigo noreply at buildbot.pypy.org
Sat Apr 5 19:55:10 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: gc-small-uniform
Changeset: r1131:48f7f40cd3b2
Date: 2014-04-05 19:55 +0200
http://bitbucket.org/pypy/stmgc/changeset/48f7f40cd3b2/

Log:	in-progress

diff --git a/c7/stm/smallmalloc.c b/c7/stm/smallmalloc.c
--- a/c7/stm/smallmalloc.c
+++ b/c7/stm/smallmalloc.c
@@ -153,27 +153,59 @@
     return (char *)result;
 }
 
+void sweep_small_page_full(char *page, long szword)
+{
+    abort();
+}
+
+void sweep_small_page_partial(struct small_free_loc_s *free_loc, long szword)
+{
+    abort();
+}
+
 void _stm_smallmalloc_sweep(void)
 {
-    long i;
-    for (i = 2; i < GC_N_SMALL_REQUESTS; i++) {
-        struct small_page_list_s *page = small_page_lists[i];
+    long i, szword;
+    for (szword = 2; szword < GC_N_SMALL_REQUESTS; szword++) {
+        struct small_page_list_s *page = small_page_lists[szword];
+        struct small_page_list_s *nextpage;
+        small_page_lists[szword] = NULL;
+
+        /* process the pages that the various segments are busy filling */
+        for (i = 1; i <= NB_SEGMENTS; i++) {
+            struct stm_priv_segment_info_s *pseg = get_priv_segment(i);
+            struct small_free_loc_s **fl =
+                    &pseg->small_malloc_data.loc_free[szword];
+            if (*fl != NULL) {
+                /* the entry in full_pages_object_size[] should already be
+                   szword.  We reset it to 0. */
+                fpsz_t *fpsz = get_fp_sz((char *)*fl);
+                assert(fpsz->sz == szword);
+                fpsz->sz = 0;
+                sweep_small_page_partial(*fl, szword);
+                *fl = NULL;
+            }
+        }
+
+        /* process all the other partially-filled pages */
         while (page != NULL) {
             /* for every page in small_page_lists: assert that the
                corresponding full_pages_object_size[] entry is 0 */
             assert(get_fp_sz((char *)page)->sz == 0);
-            abort();  // walk
-            page = page->nextpage;
+            nextpage = page->nextpage;
+            sweep_small_page_partial(&page->header, szword);
+            page = nextpage;
         }
     }
 
-    fpsz_t *fpsz_start = get_fp_sz(uninitialized_page_stop);
+    char *pageptr = uninitialized_page_stop;
+    fpsz_t *fpsz_start = get_fp_sz(pageptr);
     fpsz_t *fpsz_end = &full_pages_object_size[PAGE_SMSIZE_END -
                                                PAGE_SMSIZE_START];
     fpsz_t *fpsz;
-    for (fpsz = fpsz_start; fpsz < fpsz_end; fpsz++) {
+    for (fpsz = fpsz_start; fpsz < fpsz_end; fpsz++, pageptr += 4096) {
         if (fpsz->sz != 0) {
-            abort();  // walk
+            sweep_small_page_full(pageptr, fpsz->sz);
         }
     }
 }
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -81,6 +81,7 @@
 void *memset(void *s, int c, size_t n);
 bool (*_stm_largemalloc_keep)(char *data);
 void _stm_largemalloc_sweep(void);
+bool (*_stm_smallmalloc_keep)(char *data);
 void _stm_smallmalloc_sweep(void);
 
 ssize_t stmcb_size_rounded_up(struct object_s *obj);


More information about the pypy-commit mailing list