[pypy-svn] r49975 - in pypy/dist/pypy/translator/llvm: . test

arigo at codespeak.net arigo at codespeak.net
Fri Dec 21 11:01:45 CET 2007


Author: arigo
Date: Fri Dec 21 11:01:44 2007
New Revision: 49975

Modified:
   pypy/dist/pypy/translator/llvm/database.py
   pypy/dist/pypy/translator/llvm/test/test_bigtest.py
   pypy/dist/pypy/translator/llvm/test/test_new_gc.py
   pypy/dist/pypy/translator/llvm/test/test_symbolic.py
Log:
Fix failing tests.  Improve test_new_gc (still skipped though).


Modified: pypy/dist/pypy/translator/llvm/database.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/database.py	(original)
+++ pypy/dist/pypy/translator/llvm/database.py	Fri Dec 21 11:01:44 2007
@@ -584,9 +584,9 @@
 
         from_, indices, to = self.get_offset(value, [])
 
-        if from_ is lltype.Void:
-            assert isinstance(value, llmemory.ItemOffset)
+        if from_ is lltype.Void or not indices:
             return "0"
+        assert to is not lltype.Void
 
         r = self.database.repr_type
         indices_as_str = ", ".join("%s %s" % (w, i) for w, i in indices)
@@ -605,9 +605,10 @@
             
             # skips over a fixed size item (eg array access)
             from_ = value.TYPE
-            lasttype, lastvalue = indices[-1]
-            assert lasttype == word
-            indices[-1] = (word, lastvalue + value.repeat)
+            if from_ is not lltype.Void:
+                lasttype, lastvalue = indices[-1]
+                assert lasttype == word
+                indices[-1] = (word, lastvalue + value.repeat)
             to = value.TYPE
         
         elif isinstance(value, llmemory.FieldOffset):

Modified: pypy/dist/pypy/translator/llvm/test/test_bigtest.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/test_bigtest.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/test_bigtest.py	Fri Dec 21 11:01:44 2007
@@ -7,7 +7,7 @@
 
     result, start, end = entry_point(1000)
     assert result
-    assert end - start > 0 and end - start < 5.0
+    assert end - start > 0 and end - start < 15.0
 
 def test_rpystone():
     from pypy.translator.test.rpystone import pystones as entry_point

Modified: pypy/dist/pypy/translator/llvm/test/test_new_gc.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/test_new_gc.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/test_new_gc.py	Fri Dec 21 11:01:44 2007
@@ -2,7 +2,36 @@
 
 import py
 from pypy.translator.llvm.test.runtest import *
+from pypy.rpython.lltypesystem import lltype, llmemory, llarena
 
+def test_gc_offsets():
+    py.test.skip("in-progress")
+    STRUCT = lltype.GcStruct('S1', ('x', lltype.Signed))
+    ARRAY = lltype.GcArray(lltype.Signed)
+    s1 = llarena.round_up_for_allocation(llmemory.sizeof(STRUCT))
+    s2 = llmemory.offsetof(STRUCT, 'x')
+    s3 = llmemory.ArrayLengthOffset(ARRAY)
+    s4 = llmemory.sizeof(ARRAY, 0)
+    s5 = llmemory.ArrayItemsOffset(ARRAY)
+    def fn():
+        return (s1 * 100000000 +
+                s2 * 1000000 +
+                s3 * 10000 +
+                s4 * 100 +
+                s5)
+    mod, f = compile_test(fn, [], gcpolicy="semispace")
+    res = f()
+    i1 = (res // 100000000) % 100
+    i2 = (res // 1000000) % 100
+    i3 = (res // 10000) % 100
+    i4 = (res // 100) % 100
+    i5 = (res // 1) % 100
+    assert i1 % 8 == 0
+    assert 12 <= i1 <= 24
+    assert 8 <= i2 <= i1 - 4
+    assert 8 <= i3 <= 16
+    assert i4 == i5
+    assert i3 + 4 <= i5
 
 def test_1():
     py.test.skip("in-progress")

Modified: pypy/dist/pypy/translator/llvm/test/test_symbolic.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/test_symbolic.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/test_symbolic.py	Fri Dec 21 11:01:44 2007
@@ -23,12 +23,14 @@
 
 def test_sizeof_array_with_no_length():
     A = lltype.GcArray(lltype.Signed, hints={'nolength': True})
+    B = lltype.Array(lltype.Signed, hints={'nolength': True})
     a = lltype.malloc(A, 5, zero=True)
     
     arraysize = llmemory.itemoffsetof(A, 10)
     signedsize = llmemory.sizeof(lltype.Signed)
+    b_items = llmemory.ArrayItemsOffset(B)
     def f():
-        return a[0] + arraysize-signedsize*10
+        return (a[0] + arraysize-signedsize*10) * 1000 + b_items
     fn = compile_function(f, [])
     res = fn()
     assert res == 0



More information about the Pypy-commit mailing list