Author: Armin Rigo <ar...@tunes.org>
Branch: all_ordered_dicts
Changeset: r75391:dfe68418c314
Date: 2015-01-16 17:00 +0100
http://bitbucket.org/pypy/pypy/changeset/dfe68418c314/

Log:    Fix this test (unsure if it's worth it but well)

diff --git a/rpython/translator/tool/staticsizereport.py 
b/rpython/translator/tool/staticsizereport.py
--- a/rpython/translator/tool/staticsizereport.py
+++ b/rpython/translator/tool/staticsizereport.py
@@ -3,6 +3,7 @@
 
 from rpython.tool.ansicolor import red, yellow, green
 from rpython.rtyper.lltypesystem.lltype import typeOf, _ptr, Ptr, ContainerType
+from rpython.rtyper.lltypesystem.lltype import GcOpaqueType
 from rpython.rtyper.lltypesystem import llmemory
 from rpython.memory.lltypelayout import convert_offset_to_int
 
@@ -54,6 +55,8 @@
         if isinstance(typeOf(value), Ptr):
             container = value._obj
             if isinstance(typeOf(container), ContainerType):
+                if isinstance(typeOf(container), GcOpaqueType):
+                    container = container.container
                 node = database.getcontainernode(container)
                 if node.nodekind != 'func':
                     nodes.append(node)
@@ -77,7 +80,10 @@
                 return 0
     else:
         length = None
-    return convert_offset_to_int(llmemory.sizeof(TYPE, length))
+    #print obj, ', length =', length
+    r = convert_offset_to_int(llmemory.sizeof(TYPE, length))
+    #print '\tr =', r
+    return r
 
 
 def guess_size(database, node, recursive=None):
diff --git a/rpython/translator/tool/test/test_staticsizereport.py 
b/rpython/translator/tool/test/test_staticsizereport.py
--- a/rpython/translator/tool/test/test_staticsizereport.py
+++ b/rpython/translator/tool/test/test_staticsizereport.py
@@ -57,10 +57,17 @@
         P = rffi.sizeof(rffi.VOIDP)
         B = 1 # bool
         assert guess_size(func.builder.db, dictvalnode, set()) > 100
-        assert guess_size(func.builder.db, dictvalnode2, set()) == 2 * S + 1 * 
P + 1 * S + 8 * (2*S + 1 * B)
+        assert guess_size(func.builder.db, dictvalnode2, set()) == (
+            (4 * S + 2 * P) +     # struct dicttable
+            (S + 8) +             # indexes, length 8
+            (S + S + S))          # entries, length 1
         r_set = set()
         dictnode_size = guess_size(db, test_dictnode, r_set)
-        assert dictnode_size == 2 * S + 1 * P + 1 * S + (4096-256) * (1*S+1*P 
+ (1 * S + 1*P + 5)) + (8192-4096+256) * (1*S+1*P)
+        assert dictnode_size == (
+            (4 * S + 2 * P) +      # struct dicttable
+            (S + 2 * 8192) +       # indexes, length 8192, rffi.USHORT
+            (S + (S + S) * 3840) + # entries, length 3840
+            (S + S + 5) * 3840)    # 3840 strings with 5 chars each
         assert guess_size(func.builder.db, fixarrayvalnode, set()) == 100 * 
rffi.sizeof(lltype.Signed) + 1 * rffi.sizeof(lltype.Signed)
         assert guess_size(func.builder.db, dynarrayvalnode, set()) == 100 * 
rffi.sizeof(lltype.Signed) + 2 * rffi.sizeof(lltype.Signed) + 1 * 
rffi.sizeof(rffi.VOIDP)
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to