[pypy-svn] r70002 - in pypy/branch/listcopyop/pypy: rlib rpython rpython/lltypesystem rpython/memory/gctransform
fijal at codespeak.net
fijal at codespeak.net
Tue Dec 8 22:48:28 CET 2009
Author: fijal
Date: Tue Dec 8 22:48:24 2009
New Revision: 70002
Modified:
pypy/branch/listcopyop/pypy/rlib/rgc.py
pypy/branch/listcopyop/pypy/rpython/llinterp.py
pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py
pypy/branch/listcopyop/pypy/rpython/memory/gctransform/refcounting.py
pypy/branch/listcopyop/pypy/rpython/memory/gctransform/transform.py
Log:
Sort-of-solution for refcounting. Not too happy about it, any other idea?
Modified: pypy/branch/listcopyop/pypy/rlib/rgc.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rlib/rgc.py (original)
+++ pypy/branch/listcopyop/pypy/rlib/rgc.py Tue Dec 8 22:48:24 2009
@@ -332,6 +332,7 @@
def ll_arraycopy(source, dest, source_start, dest_start, length):
from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rpython.lltypesystem import lltype, llmemory
+ from pypy.rlib.objectmodel import keepalive_until_here
assert source != dest
TP = lltype.typeOf(source).TO
@@ -340,12 +341,17 @@
# perform a write barrier that copies necessary flags from
# source to dest
llop.gc_writebarrier_before_copy(lltype.Void, source, dest)
+ # the hack below is a write barrier version for refcounting :-/
+ for i in range(length):
+ llop.gc_push_alive(lltype.Void, source[source_start + i])
source_addr = llmemory.cast_ptr_to_adr(source)
dest_addr = llmemory.cast_ptr_to_adr(dest)
cp_source_addr = (source_addr + llmemory.itemoffsetof(TP, 0) +
llmemory.sizeof(TP.OF) * source_start)
cp_dest_addr = (dest_addr + llmemory.itemoffsetof(TP, 0) +
llmemory.sizeof(TP.OF) * dest_start)
+
llmemory.raw_memcopy(cp_source_addr, cp_dest_addr,
llmemory.sizeof(TP.OF) * length)
+ keepalive_until_here(source)
ll_arraycopy._annspecialcase_ = 'specialize:ll'
Modified: pypy/branch/listcopyop/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/llinterp.py (original)
+++ pypy/branch/listcopyop/pypy/rpython/llinterp.py Tue Dec 8 22:48:24 2009
@@ -859,6 +859,9 @@
def op_gc_push_alive_pyobj(self, pyobj):
raise NotImplementedError("gc_push_alive_pyobj")
+ def op_gc_push_alive(self, pyobj):
+ pass
+
def op_gc_pop_alive_pyobj(self, pyobj):
raise NotImplementedError("gc_pop_alive_pyobj")
Modified: pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py (original)
+++ pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py Tue Dec 8 22:48:24 2009
@@ -443,6 +443,7 @@
'gc_restore_exception': LLOp(),
'gc_call_rtti_destructor': LLOp(),
'gc_deallocate': LLOp(),
+ 'gc_push_alive': LLOp(),
'gc_push_alive_pyobj': LLOp(),
'gc_pop_alive_pyobj': LLOp(),
'gc_reload_possibly_moved': LLOp(),
Modified: pypy/branch/listcopyop/pypy/rpython/memory/gctransform/refcounting.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/memory/gctransform/refcounting.py (original)
+++ pypy/branch/listcopyop/pypy/rpython/memory/gctransform/refcounting.py Tue Dec 8 22:48:24 2009
@@ -142,6 +142,9 @@
def var_needs_set_transform(self, var):
return var_needsgc(var)
+ def gct_gc_push_alive(self, hop):
+ self.push_alive_nopyobj(hop.spaceop.args[0], hop.llops)
+
def push_alive_nopyobj(self, var, llops):
v_adr = gen_cast(llops, llmemory.Address, var)
llops.genop("direct_call", [self.increfptr, v_adr])
Modified: pypy/branch/listcopyop/pypy/rpython/memory/gctransform/transform.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/memory/gctransform/transform.py (original)
+++ pypy/branch/listcopyop/pypy/rpython/memory/gctransform/transform.py Tue Dec 8 22:48:24 2009
@@ -377,6 +377,9 @@
gct_getfield = default
+ def gct_gc_push_alive(self, hop):
+ pass
+
def gct_zero_gc_pointers_inside(self, hop):
pass
More information about the Pypy-commit
mailing list