[pypy-commit] pypy gc-hooks: rename the 'count' argument of on_gc_collect to match the name used in the source code

antocuni pypy.commits at gmail.com
Tue Apr 10 04:47:30 EDT 2018


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: gc-hooks
Changeset: r94301:09cb3ab59fa7
Date: 2018-04-10 00:25 +0200
http://bitbucket.org/pypy/pypy/changeset/09cb3ab59fa7/

Log:	rename the 'count' argument of on_gc_collect to match the name used
	in the source code

diff --git a/pypy/module/gc/hook.py b/pypy/module/gc/hook.py
--- a/pypy/module/gc/hook.py
+++ b/pypy/module/gc/hook.py
@@ -45,11 +45,12 @@
         action.newstate = newstate
         action.fire()
 
-    def on_gc_collect(self, count, arenas_count_before, arenas_count_after,
+    def on_gc_collect(self, num_major_collects,
+                      arenas_count_before, arenas_count_after,
                       arenas_bytes, rawmalloc_bytes_before,
                       rawmalloc_bytes_after):
         action = self.w_hooks.gc_collect
-        action.count = count
+        action.num_major_collects = num_major_collects
         action.arenas_count_before = arenas_count_before
         action.arenas_count_after = arenas_count_after
         action.arenas_bytes = arenas_bytes
@@ -162,7 +163,7 @@
 
 
 class GcCollectHookAction(AsyncAction):
-    count = 0
+    num_major_collects = 0
     arenas_count_before = 0
     arenas_count_after = 0
     arenas_bytes = 0
@@ -178,7 +179,7 @@
         # BEFORE we do the gc transform; this makes sure that everything is
         # annotated with the correct types
         if NonConstant(False):
-            self.count = NonConstant(-42)
+            self.num_major_collects = NonConstant(-42)
             self.arenas_count_before = NonConstant(-42)
             self.arenas_count_after = NonConstant(-42)
             self.arenas_bytes = NonConstant(r_uint(42))
@@ -187,7 +188,7 @@
             self.fire()
 
     def perform(self, ec, frame):
-        w_stats = W_GcCollectStats(self.count,
+        w_stats = W_GcCollectStats(self.num_major_collects,
                                    self.arenas_count_before,
                                    self.arenas_count_after,
                                    self.arenas_bytes,
@@ -213,10 +214,11 @@
 
 
 class W_GcCollectStats(W_Root):
-    def __init__(self, count, arenas_count_before, arenas_count_after,
+    def __init__(self, num_major_collects,
+                 arenas_count_before, arenas_count_after,
                  arenas_bytes, rawmalloc_bytes_before,
                  rawmalloc_bytes_after):
-        self.count = count
+        self.num_major_collects = num_major_collects
         self.arenas_count_before = arenas_count_before
         self.arenas_count_after = arenas_count_after
         self.arenas_bytes = arenas_bytes
@@ -274,7 +276,7 @@
 W_GcCollectStats.typedef = TypeDef(
     "GcCollectStats",
     **wrap_many_ints(W_GcCollectStats, (
-        "count",
+        "num_major_collects",
         "arenas_count_before",
         "arenas_count_after",
         "arenas_bytes",
diff --git a/pypy/module/gc/test/test_hook.py b/pypy/module/gc/test/test_hook.py
--- a/pypy/module/gc/test/test_hook.py
+++ b/pypy/module/gc/test/test_hook.py
@@ -87,7 +87,7 @@
         import gc
         lst = []
         def on_gc_collect(stats):
-            lst.append((stats.count,
+            lst.append((stats.num_major_collects,
                         stats.arenas_count_before,
                         stats.arenas_count_after,
                         stats.arenas_bytes,
diff --git a/rpython/memory/gc/hook.py b/rpython/memory/gc/hook.py
--- a/rpython/memory/gc/hook.py
+++ b/rpython/memory/gc/hook.py
@@ -37,7 +37,8 @@
         """
 
 
-    def on_gc_collect(self, count, arenas_count_before, arenas_count_after,
+    def on_gc_collect(self, num_major_collects,
+                      arenas_count_before, arenas_count_after,
                       arenas_bytes, rawmalloc_bytes_before,
                       rawmalloc_bytes_after):
         """
@@ -58,10 +59,12 @@
             self.on_gc_collect_step(duration, oldstate, newstate)
 
     @rgc.no_collect
-    def fire_gc_collect(self, count, arenas_count_before, arenas_count_after,
+    def fire_gc_collect(self, num_major_collects,
+                        arenas_count_before, arenas_count_after,
                         arenas_bytes, rawmalloc_bytes_before,
                         rawmalloc_bytes_after):
         if self.is_gc_collect_enabled():
-            self.on_gc_collect(count, arenas_count_before, arenas_count_after,
+            self.on_gc_collect(num_major_collects,
+                               arenas_count_before, arenas_count_after,
                                arenas_bytes, rawmalloc_bytes_before,
                                rawmalloc_bytes_after)
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -2430,7 +2430,7 @@
                             self.rawmalloced_total_size)
                 debug_stop("gc-collect-done")
                 self.hooks.fire_gc_collect(
-                    count=self.num_major_collects,
+                    num_major_collects=self.num_major_collects,
                     arenas_count_before=self.stat_ac_arenas_count,
                     arenas_count_after=self.ac.arenas_count,
                     arenas_bytes=self.ac.total_memory_used,
diff --git a/rpython/memory/gc/test/test_hook.py b/rpython/memory/gc/test/test_hook.py
--- a/rpython/memory/gc/test/test_hook.py
+++ b/rpython/memory/gc/test/test_hook.py
@@ -39,11 +39,12 @@
             'oldstate': oldstate,
             'newstate': newstate})
 
-    def on_gc_collect(self, count, arenas_count_before, arenas_count_after,
+    def on_gc_collect(self, num_major_collects,
+                      arenas_count_before, arenas_count_after,
                       arenas_bytes, rawmalloc_bytes_before,
                       rawmalloc_bytes_after):
         self.collects.append({
-            'count': count,
+            'num_major_collects': num_major_collects,
             'arenas_count_before': arenas_count_before,
             'arenas_count_after': arenas_count_after,
             'arenas_bytes': arenas_bytes,
@@ -93,7 +94,7 @@
             {'oldstate': m.STATE_FINALIZING, 'newstate': m.STATE_SCANNING}
         ]
         assert self.gc.hooks.collects == [
-            {'count': 1,
+            {'num_major_collects': 1,
              'arenas_count_before': 0,
              'arenas_count_after': 0,
              'arenas_bytes': 0,
@@ -108,7 +109,7 @@
         self.stackroots.append(self.malloc(S))
         self.gc.collect()
         assert self.gc.hooks.collects == [
-            {'count': 2,
+            {'num_major_collects': 2,
              'arenas_count_before': 1,
              'arenas_count_after': 1,
              'arenas_bytes': self.size_of_S,
diff --git a/rpython/memory/test/test_transformed_gc.py b/rpython/memory/test/test_transformed_gc.py
--- a/rpython/memory/test/test_transformed_gc.py
+++ b/rpython/memory/test/test_transformed_gc.py
@@ -1427,7 +1427,8 @@
     def on_gc_collect_step(self, duration, oldstate, newstate):
         self.stats.steps += 1
         
-    def on_gc_collect(self, count, arenas_count_before, arenas_count_after,
+    def on_gc_collect(self, num_major_collects,
+                      arenas_count_before, arenas_count_after,
                       arenas_bytes, rawmalloc_bytes_before,
                       rawmalloc_bytes_after):
         self.stats.collects += 1


More information about the pypy-commit mailing list