[pypy-svn] r68530 - in pypy/branch/gc-hash/pypy/translator/c: . test
arigo at codespeak.net
arigo at codespeak.net
Fri Oct 16 12:36:07 CEST 2009
Author: arigo
Date: Fri Oct 16 12:36:07 2009
New Revision: 68530
Modified:
pypy/branch/gc-hash/pypy/translator/c/gc.py
pypy/branch/gc-hash/pypy/translator/c/test/test_newgc.py
Log:
Test and fix.
Modified: pypy/branch/gc-hash/pypy/translator/c/gc.py
==============================================================================
--- pypy/branch/gc-hash/pypy/translator/c/gc.py (original)
+++ pypy/branch/gc-hash/pypy/translator/c/gc.py Fri Oct 16 12:36:07 2009
@@ -346,6 +346,8 @@
TYPE = typeOf(obj)
if not isinstance(TYPE, lltype.GcStruct):
return None
+ if TYPE._is_varsize():
+ return None
return getattr(obj, '_hash_cache_', None)
def need_no_typeptr(self):
Modified: pypy/branch/gc-hash/pypy/translator/c/test/test_newgc.py
==============================================================================
--- pypy/branch/gc-hash/pypy/translator/c/test/test_newgc.py (original)
+++ pypy/branch/gc-hash/pypy/translator/c/test/test_newgc.py Fri Oct 16 12:36:07 2009
@@ -802,6 +802,20 @@
res = self.run('hash_overflow')
assert res == -42
+ def define_hash_varsized(self):
+ S = lltype.GcStruct('S', ('abc', lltype.Signed),
+ ('def', lltype.Array(lltype.Signed)))
+ s = lltype.malloc(S, 3, zero=True)
+ h_s = lltype.identityhash(s)
+ def f():
+ return lltype.identityhash(s) - h_s # != 0 (so far),
+ # because S is a varsized structure.
+ return f
+
+ def test_hash_varsized(self):
+ res = self.run('hash_varsized')
+ assert res != 0
+
class TestSemiSpaceGC(TestUsingFramework, snippet.SemiSpaceGCTestDefines):
gcpolicy = "semispace"
should_be_moving = True
More information about the Pypy-commit
mailing list