Armin Rigo avatar Armin Rigo committed 452ef15

test_cast_gcref_to_int: when running untranslated, accept
also _llgcopaque objects and force a cast to integer.

Comments (0)

Files changed (2)

rpython/rlib/rgc.py

     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):

rpython/rlib/test/test_rgc.py

     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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.