[pypy-commit] pypy gc-minimark-pinning: make pin return a boolean

fijal noreply at buildbot.pypy.org
Mon Apr 23 12:04:06 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: gc-minimark-pinning
Changeset: r54662:05b513555e3c
Date: 2012-04-23 10:49 +0200
http://bitbucket.org/pypy/pypy/changeset/05b513555e3c/

Log:	make pin return a boolean

diff --git a/pypy/rlib/rgc.py b/pypy/rlib/rgc.py
--- a/pypy/rlib/rgc.py
+++ b/pypy/rlib/rgc.py
@@ -19,7 +19,7 @@
     pass
 
 def pin(obj):
-    pass
+    return False
 
 def unpin(obj):
     pass
@@ -75,15 +75,8 @@
     With other moving GCs like the MiniMark GC, it can be True for some
     time, then False for the same object, when we are sure that it won't
     move any more.
-
-    We keep it for False when uncompiled, because malloc_and_pin would actually
-    return an object. This executes more interesting paths, but also:
-
-    x = malloc_and_pin(T)
-    if x:
-       assert not can_move(x)
     """
-    return False
+    return True
 
 class CanMoveEntry(ExtRegistryEntry):
     _about_ = can_move
@@ -506,14 +499,15 @@
     _about_ = pin
 
     def compute_result_annotation(self, s_arg):
-        pass
+        from pypy.annotation.model import SomeBool
+        return SomeBool()
 
     def specialize_call(self, hop):
         hop.exception_cannot_occur()
         v_obj, = hop.inputargs(hop.args_r[0])
         v_addr = hop.genop('cast_ptr_to_adr', [v_obj],
                            resulttype=llmemory.Address)
-        hop.genop('gc_pin', [v_addr])
+        return hop.genop('gc_pin', [v_addr], resulttype=lltype.Bool)
 
 class UnpinEntry(ExtRegistryEntry):
     _about_ = unpin
diff --git a/pypy/rpython/llinterp.py b/pypy/rpython/llinterp.py
--- a/pypy/rpython/llinterp.py
+++ b/pypy/rpython/llinterp.py
@@ -891,7 +891,7 @@
         pass       # marker for trackgcroot.py
 
     def op_gc_pin(self, obj):
-        self.heap.pin(obj)
+        return self.heap.pin(obj)
 
     def op_gc_unpin(self, obj):
         self.heap.unpin(obj)
diff --git a/pypy/rpython/lltypesystem/llheap.py b/pypy/rpython/lltypesystem/llheap.py
--- a/pypy/rpython/lltypesystem/llheap.py
+++ b/pypy/rpython/lltypesystem/llheap.py
@@ -38,7 +38,7 @@
     pass
 
 def pin(obj):
-    pass
+    return False
 
 def unpin(obj):
     pass
diff --git a/pypy/rpython/lltypesystem/rffi.py b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -739,11 +739,12 @@
         # if 'buf' points inside 'data'.  This is only possible if we
         # followed the 2nd case in get_nonmovingbuffer(); in the first case,
         # 'buf' points to its own raw-malloced memory.
-        data = llstrtype(data)
-        data_start = cast_ptr_to_adr(data) + \
+        ll_data = llstrtype(data)
+        data_start = cast_ptr_to_adr(ll_data) + \
             offsetof(STRTYPE, 'chars') + itemoffsetof(STRTYPE.chars, 0)
         followed_2nd_path = (buf == cast(TYPEP, data_start))
         keepalive_until_here(data)
+        keepalive_until_here(ll_data)
         if followed_2nd_path:
             rgc.unpin(data)
         else:
diff --git a/pypy/rpython/memory/gcwrapper.py b/pypy/rpython/memory/gcwrapper.py
--- a/pypy/rpython/memory/gcwrapper.py
+++ b/pypy/rpython/memory/gcwrapper.py
@@ -133,7 +133,7 @@
         return self.gc.can_move(addr)
 
     def pin(self, addr):
-        self.gc.pin(addr)
+        return self.gc.pin(addr)
 
     def unpin(self, addr):
         self.gc.unpin(addr)    


More information about the pypy-commit mailing list