[pypy-commit] pypy default: test_cast_gcref_to_int: when running untranslated, accept
arigo
noreply at buildbot.pypy.org
Mon Aug 19 16:42:18 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r66212:452ef15ded28
Date: 2013-08-19 16:41 +0200
http://bitbucket.org/pypy/pypy/changeset/452ef15ded28/
Log: test_cast_gcref_to_int: when running untranslated, accept also
_llgcopaque objects and force a cast to integer.
diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py
--- a/rpython/rlib/rgc.py
+++ b/rpython/rlib/rgc.py
@@ -346,6 +346,10 @@
if we_are_translated():
return lltype.cast_ptr_to_int(gcref)
else:
+ from rpython.rtyper.lltypesystem.ll2ctypes import _llgcopaque
+ if isinstance(gcref._obj, _llgcopaque):
+ from rpython.rtyper.lltypesystem import rffi
+ return rffi.cast(lltype.Signed, gcref)
return id(gcref._x)
def dump_rpy_heap(fd):
diff --git a/rpython/rlib/test/test_rgc.py b/rpython/rlib/test/test_rgc.py
--- a/rpython/rlib/test/test_rgc.py
+++ b/rpython/rlib/test/test_rgc.py
@@ -228,3 +228,8 @@
x1 = X()
n = rgc.get_rpy_memory_usage(rgc.cast_instance_to_gcref(x1))
assert n >= 8 and n <= 64
+
+def test_cast_gcref_to_int():
+ from rpython.rtyper.lltypesystem import rffi
+ x = rffi.cast(llmemory.GCREF, 123456)
+ assert rgc.cast_gcref_to_int(x) == 123456
More information about the pypy-commit
mailing list