Author: Maciej Fijalkowski <[email protected]>
Branch: gc-minimark-pinning
Changeset: r54669:110160f44b5f
Date: 2012-04-23 13:01 +0200
http://bitbucket.org/pypy/pypy/changeset/110160f44b5f/

Log:    fixes

diff --git a/pypy/rpython/memory/gc/minimark.py 
b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -583,14 +583,16 @@
 
     def malloc_fixedsize_and_pin(self, typeid, size):
         r = self.malloc_fixedsize_clear(typeid, size)
-        self.pin(llmemory.cast_ptr_to_adr(r))
+        if not self.pin(llmemory.cast_ptr_to_adr(r)):
+            return lltype.nullptr(llmemory.GCREF.TO)
         return r
         
     def malloc_varsize_and_pin(self, typeid, length, size, itemsize,
                                offset_to_length):
         r = self.malloc_varsize_clear(typeid, length, size, itemsize,
                                       offset_to_length)
-        self.pin(llmemory.cast_ptr_to_adr(r))
+        if not self.pin(llmemory.cast_ptr_to_adr(r)):
+            return lltype.nullptr(llmemory.GCREF.TO)
         return r        
 
     def collect(self, gen=1):
diff --git a/pypy/rpython/memory/test/test_gc.py 
b/pypy/rpython/memory/test/test_gc.py
--- a/pypy/rpython/memory/test/test_gc.py
+++ b/pypy/rpython/memory/test/test_gc.py
@@ -4,9 +4,10 @@
 from pypy.rpython.memory import gcwrapper
 from pypy.rpython.memory.test import snippet
 from pypy.rpython.test.test_llinterp import get_interpreter
-from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.lltypesystem.lloperation import llop
-from pypy.rlib.objectmodel import we_are_translated, compute_unique_id
+from pypy.rlib.objectmodel import we_are_translated, compute_unique_id,\
+     keepalive_until_here
 from pypy.rlib import rgc
 from pypy.rlib.rstring import StringBuilder
 from pypy.rlib.rarithmetic import LONG_BIT
@@ -596,8 +597,11 @@
         TP = lltype.GcArray(lltype.Char)
         def func():
             a = rgc.malloc_and_pin(TP, 3)
+            adr = llmemory.cast_ptr_to_adr(a)
             if a:
-                assert not rgc.can_move(a)
+                rgc.collect()
+                assert adr == llmemory.cast_ptr_to_adr(a)
+                keepalive_until_here(a)
                 return 1
             return 0
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to