Author: Richard Plangger <[email protected]>
Branch: strbuf-as-buffer
Changeset: r89195:725a0620e75c
Date: 2016-12-20 10:47 +0100
http://bitbucket.org/pypy/pypy/changeset/725a0620e75c/

Log:    add a test and copy some more code from trace_out to
        move_out_of_nursery

diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -735,7 +735,21 @@
         totalsize = size_gc_header + self.get_size(obj)
         self.nursery_surviving_size += raw_malloc_usage(totalsize)
         newhdr = self._malloc_out_of_nursery(totalsize)
-        #return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
+        llmemory.raw_memcopy(obj - size_gc_header, newhdr, totalsize)
+
+        # Set the old object's tid to -42 (containing all flags) and
+        # replace the old object's content with the target address.
+        # A bit of no-ops to convince llarena that we are changing
+        # the layout, in non-translated versions.
+        typeid = self.get_type_id(obj)
+        obj = llarena.getfakearenaaddress(obj)
+        llarena.arena_reset(obj - size_gc_header, totalsize, 0)
+        llarena.arena_reserve(obj - size_gc_header,
+                              size_gc_header + llmemory.sizeof(FORWARDSTUB))
+        self.header(obj).tid = -42
+        newobj = newhdr + size_gc_header
+        llmemory.cast_adr_to_ptr(obj, FORWARDSTUBPTR).forw = newobj
+        return llmemory.cast_adr_to_ptr(newobj, llmemory.GCREF)
 
 
     def collect(self, gen=2):
diff --git a/rpython/rtyper/lltypesystem/test/test_ztranslated.py 
b/rpython/rtyper/lltypesystem/test/test_ztranslated.py
new file mode 100644
--- /dev/null
+++ b/rpython/rtyper/lltypesystem/test/test_ztranslated.py
@@ -0,0 +1,34 @@
+import time, os, sys
+import py
+import gc
+from rpython.tool.udir import udir
+from rpython.rlib import rvmprof, rthread
+from rpython.translator.c.test.test_genc import compile
+from rpython.rlib.nonconst import NonConstant
+from rpython.rtyper.lltypesystem import rffi
+
+def setup_module(mod):
+    pass
+
+def use_str():
+    mystr = b"abc"
+    ptr = rffi.get_raw_address_of_string(mystr)
+    assert ptr[0] == 79
+    gc.collect()
+    assert ptr[0] == 79
+    mystr = None
+
+
+
+def main(argv=[]):
+    use_str()
+    return 0
+
+# ____________________________________________________________
+
+def target(driver, args):
+    return main
+
+def test_compiled():
+    fn = compile(main, [], gcpolicy="minimark")
+    fn()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to