[pypy-commit] pypy rawrefcount-review: Add externally malloced gcobjects to the hypothesis test

rlamy pypy.commits at gmail.com
Sun Mar 13 12:51:45 EDT 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: rawrefcount-review
Changeset: r83012:579b1d5d2803
Date: 2016-03-13 16:50 +0000
http://bitbucket.org/pypy/pypy/changeset/579b1d5d2803/

Log:	Add externally malloced gcobjects to the hypothesis test

diff --git a/rpython/memory/gc/test/test_rawrefcount.py b/rpython/memory/gc/test/test_rawrefcount.py
--- a/rpython/memory/gc/test/test_rawrefcount.py
+++ b/rpython/memory/gc/test/test_rawrefcount.py
@@ -312,8 +312,14 @@
         r1.ob_pypy_link = 0
         return r1
 
-    def new_gcobj(self, intval):
-        p1 = self.malloc(S)
+    def new_gcobj(self, intval, external=False):
+        saved = self.gc.nonlarge_max
+        try:
+            if external:
+                self.gc.nonlarge_max = 1
+            p1 = self.malloc(S)
+        finally:
+            self.gc.nonlarge_max = saved
         p1.x = intval
         return p1
 
@@ -390,15 +396,15 @@
         self.incref(r)
         self.rawobjs.append(r)
 
-    def add_gcobj(self):
-        p = self.space.new_gcobj(self.next_id)
+    def add_gcobj(self, external=False):
+        p = self.space.new_gcobj(self.next_id, external=external)
         self.space.stackroots.append(p)
         self.rootlinks.append(False)
         self.next_id += 1
         return p
 
-    def create_gcpartner(self, raw, is_light=False, is_pyobj=False):
-        p = self.space.new_gcobj(self.next_id)
+    def create_gcpartner(self, raw, is_light=False, is_pyobj=False, external=False):
+        p = self.space.new_gcobj(self.next_id, external=external)
         self.next_id += 1
         self.space.create_link(raw, p, is_light=is_light, is_pyobj=is_pyobj)
 
@@ -427,7 +433,7 @@
             Action('major_collection', ()),
         ]
         valid_st.append(sampled_from(global_actions))
-        valid_st.append(builds(Action, just('add_gcobj'), tuples()))
+        valid_st.append(builds(Action, just('add_gcobj'), tuples(booleans())))
         if self.rawobjs:
             valid_st.append(builds(Action, just('incref'), tuples(
                 sampled_from(self.rawobjs))))
@@ -439,7 +445,7 @@
         if candidates:
             st = builds(Action, just('create_gcpartner'), tuples(
                 sampled_from(candidates),
-                booleans(), booleans()))
+                booleans(), booleans(), booleans()))
             valid_st.append(st)
         candidates = self.get_linkable_gcobjs()
         if candidates:


More information about the pypy-commit mailing list