[pypy-svn] pypy default: using longs leads to different traces on 32 and 64 bits. Instead, we use

antocuni commits-noreply at bitbucket.org
Thu Mar 10 14:04:14 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r42491:2fcffa92e796
Date: 2011-03-08 12:15 +0100
http://bitbucket.org/pypy/pypy/changeset/2fcffa92e796/

Log:	using longs leads to different traces on 32 and 64 bits. Instead, we
	use another function which is not seen by the JIT for this test

diff --git a/pypy/module/pypyjit/test_pypy_c/model.py b/pypy/module/pypyjit/test_pypy_c/model.py
--- a/pypy/module/pypyjit/test_pypy_c/model.py
+++ b/pypy/module/pypyjit/test_pypy_c/model.py
@@ -133,11 +133,11 @@
             for op in self._ops_for_chunk(chunk, include_debug_merge_points):
                 yield op
 
-    def print_ops(self, id=None):
+    def print_ops(self, id=None, **kwds):
         if id is None:
             ops = self.allops()
         else:
-            ops = self.ops_by_id(id)
+            ops = self.ops_by_id(id, **kwds)
         print '\n'.join(map(str, ops))
 
     def ops_by_id(self, id, include_debug_merge_points=False, opcode=None):

diff --git a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
--- a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
@@ -124,6 +124,22 @@
         ops = list(loop.ops_by_id("except", opcode="COMPARE_OP"))
         assert ops == []
 
+    def test_simple_call(self):
+        src = """
+            OFFSET = 0
+            def f(i):
+                return i + 1 + OFFSET # ID: add
+            def main(n):
+                i = 0
+                while i < n+OFFSET:
+                    i = f(f(i)) # ID: call
+                return i
+        """
+        log = self.run(src, [1000], threshold=400)
+        assert log.result == 1000
+        entry_bridge, = log.loops_by_id('call', is_entry_bridge=True)
+        import pdb;pdb.set_trace()
+
     def test_reraise(self):
         def f(n):
             i = 0

diff --git a/pypy/module/pypyjit/test_pypy_c/test_model.py b/pypy/module/pypyjit/test_pypy_c/test_model.py
--- a/pypy/module/pypyjit/test_pypy_c/test_model.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_model.py
@@ -400,20 +400,22 @@
 
     def test_match_constants(self):
         def f():
-            i = 0L # force it to long, so that we get calls to rbigint
+            from socket import ntohs
+            i = 0
             while i < 1003:
-                i += 1L # ID: increment
+                i += 1
+                j = ntohs(1) # ID: ntohs
                 a = 0
             return i
         log = self.run(f)
-        loop, = log.loops_by_id('increment')
-        assert loop.match_by_id('increment', """
-            p12 = call(ConstClass(rbigint.add), p4, ConstPtr(ptr11), descr=...)
+        loop, = log.loops_by_id('ntohs')
+        assert loop.match_by_id('ntohs', """
+            p12 = call(ConstClass(ntohs), 1, descr=...)
             guard_no_exception(descr=...)
         """)
         #
-        assert not loop.match_by_id('increment', """
-            p12 = call(ConstClass(rbigint.SUB), p4, ConstPtr(ptr11), descr=...)
+        assert not loop.match_by_id('ntohs', """
+            p12 = call(ConstClass(foobar), 1, descr=...)
             guard_no_exception(descr=...)
         """)
         


More information about the Pypy-commit mailing list