Author: Armin Rigo <ar...@tunes.org>
Branch: reverse-debugger
Changeset: r85123:1f9da349e92c
Date: 2016-06-13 12:03 +0200
http://bitbucket.org/pypy/pypy/changeset/1f9da349e92c/

Log:    Don't record the reads out of the small funcset arrays

diff --git a/rpython/rlib/revdb.py b/rpython/rlib/revdb.py
--- a/rpython/rlib/revdb.py
+++ b/rpython/rlib/revdb.py
@@ -47,7 +47,8 @@
 def creation_time_of(x):
     """Returns the time at which the object 'x' was created.
     More precisely, returns t such that object 'x' was created when
-    current_time()==t; this means that the object exists from time t+1.
+    current_time()==t; this means that the object exists at the stop
+    point number t+1, but does not exist yet at the stop point number t.
     """
     return llop.revdb_creation_time_of(lltype.SignedLongLong, x)
 
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -414,7 +414,8 @@
         if self.s_pbc.can_be_None:
             self.descriptions.insert(0, None)
         POINTER_TABLE = Array(self.pointer_repr.lowleveltype,
-                              hints={'nolength': True, 'immutable': True})
+                              hints={'nolength': True, 'immutable': True,
+                                     'static_immutable': True})
         pointer_table = malloc(POINTER_TABLE, len(self.descriptions),
                                immortal=True)
         for i, desc in enumerate(self.descriptions):
@@ -564,7 +565,8 @@
     if r_to in r_from._conversion_tables:
         return r_from._conversion_tables[r_to]
     else:
-        t = malloc(Array(Char, hints={'nolength': True, 'immutable': True}),
+        t = malloc(Array(Char, hints={'nolength': True, 'immutable': True,
+                                      'static_immutable': True}),
                    len(r_from.descriptions), immortal=True)
         l = []
         for i, d in enumerate(r_from.descriptions):
diff --git a/rpython/translator/revdb/test/test_basic.py 
b/rpython/translator/revdb/test/test_basic.py
--- a/rpython/translator/revdb/test/test_basic.py
+++ b/rpython/translator/revdb/test/test_basic.py
@@ -59,12 +59,15 @@
         return self.cur == len(self.buffer)
 
 
-def compile(self, entry_point, argtypes, backendopt=True):
+def compile(self, entry_point, argtypes, backendopt=True,
+            withsmallfuncsets=None):
     t = Translation(entry_point, None, gc="boehm")
     self.t = t
     t.config.translation.reverse_debugger = True
     t.config.translation.rweakref = False
     t.config.translation.lldebug0 = True
+    if withsmallfuncsets is not None:
+        t.config.translation.withsmallfuncsets = withsmallfuncsets
     if not backendopt:
         t.disable(["backendopt_lltype"])
     t.annotate()
@@ -171,6 +174,40 @@
         x = rdb.next('q'); assert x == 0      # number of stop points
         assert rdb.done()
 
+    @py.test.mark.parametrize('limit', [3, 5])
+    def test_dont_record_small_funcset_conversions(self, limit):
+        def f1():
+            return 111
+        def f2():
+            return 222
+        def f3():
+            return 333
+        def g(n):
+            if n & 1:
+                return f1
+            else:
+                return f2
+        def main(argv):
+            x = g(len(argv))    # can be f1 or f2
+            if len(argv) > 5:
+                x = f3  # now can be f1 or f2 or f3
+            print x()
+            return 9
+        self.compile(main, [], backendopt=False, withsmallfuncsets=limit)
+        for input, expected_output in [
+                ('2 3', '111\n'),
+                ('2 3 4', '222\n'),
+                ('2 3 4 5 6 7', '333\n'),
+                ]:
+            out = self.run(input)
+            assert out == expected_output
+            rdb = self.fetch_rdb([self.exename] + input.split())
+            # write() call
+            x = rdb.next(); assert x == len(out)
+            x = rdb.next('i'); assert x == 0      # errno
+            x = rdb.next('q'); assert x == 0      # number of stop points
+            assert rdb.done()
+
 
 class InteractiveTests(object):
     EOF = pexpect.EOF
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to