[pypy-svn] r53622 - in pypy/branch/io-improvements/pypy: rlib rlib/test rpython rpython/lltypesystem
fijal at codespeak.net
fijal at codespeak.net
Wed Apr 9 20:07:01 CEST 2008
Author: fijal
Date: Wed Apr 9 20:07:01 2008
New Revision: 53622
Modified:
pypy/branch/io-improvements/pypy/rlib/rgc.py
pypy/branch/io-improvements/pypy/rlib/test/test_rgc.py
pypy/branch/io-improvements/pypy/rpython/llinterp.py
pypy/branch/io-improvements/pypy/rpython/lltypesystem/lloperation.py
Log:
First stub for rgc.can_move. Right now it always returns True
Modified: pypy/branch/io-improvements/pypy/rlib/rgc.py
==============================================================================
--- pypy/branch/io-improvements/pypy/rlib/rgc.py (original)
+++ pypy/branch/io-improvements/pypy/rlib/rgc.py Wed Apr 9 20:07:01 2008
@@ -171,6 +171,20 @@
[v_nbytes] = hop.inputargs(lltype.Signed)
return hop.genop('gc_set_max_heap_size', [v_nbytes],
resulttype=lltype.Void)
+def can_move(P):
+ return True
+can_move._annspecialcase_ = 'specialize:arg(0)'
+
+class CanMoveEntry(ExtRegistryEntry):
+ _about_ = can_move
+
+ def compute_result_annotation(self, s_TP):
+ from pypy.annotation import model as annmodel
+ return annmodel.SomeBool()
+
+ def specialize_call(self, hop):
+ from pypy.rpython.lltypesystem import lltype
+ return hop.genop('gc_can_move', [], resulttype=lltype.Bool)
class CollectEntry(ExtRegistryEntry):
_about_ = (disable_finalizers, enable_finalizers)
@@ -182,3 +196,4 @@
def specialize_call(self, hop):
opname = 'gc__' + self.instance.__name__
return hop.genop(opname, [], resulttype=hop.r_result)
+
Modified: pypy/branch/io-improvements/pypy/rlib/test/test_rgc.py
==============================================================================
--- pypy/branch/io-improvements/pypy/rlib/test/test_rgc.py (original)
+++ pypy/branch/io-improvements/pypy/rlib/test/test_rgc.py Wed Apr 9 20:07:01 2008
@@ -1,4 +1,5 @@
from pypy.rpython.test.test_llinterp import gengraph, interpret
+from pypy.rpython.lltypesystem import lltype
from pypy.rlib import rgc # Force registration of gc.collect
import gc
@@ -17,3 +18,21 @@
assert res is None
+def test_can_move():
+ T0 = lltype.GcStruct('T')
+ T1 = lltype.GcArray(lltype.Float)
+ def f(i):
+ if i:
+ return rgc.can_move(T0)
+ else:
+ return rgc.can_move(T1)
+
+ t, typer, graph = gengraph(f, [int])
+ ops = list(graph.iterblockops())
+ res = [op for op in ops if op[1].opname == 'gc_can_move']
+ assert len(res) == 2
+
+ res = interpret(f, [1])
+
+ assert res == True
+
Modified: pypy/branch/io-improvements/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/io-improvements/pypy/rpython/llinterp.py (original)
+++ pypy/branch/io-improvements/pypy/rpython/llinterp.py Wed Apr 9 20:07:01 2008
@@ -753,6 +753,9 @@
def op_gc__collect(self):
self.heap.collect()
+ def op_gc_can_move(self):
+ return True
+
def op_gc__disable_finalizers(self):
self.heap.disable_finalizers()
Modified: pypy/branch/io-improvements/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/io-improvements/pypy/rpython/lltypesystem/lloperation.py (original)
+++ pypy/branch/io-improvements/pypy/rpython/lltypesystem/lloperation.py Wed Apr 9 20:07:01 2008
@@ -399,6 +399,7 @@
'gc_reload_possibly_moved': LLOp(),
'gc_id': LLOp(canraise=(MemoryError,), sideeffects=False),
'gc_set_max_heap_size': LLOp(),
+ 'gc_can_move' : LLOp(canfold=True, sideeffects=False),
# experimental operations in support of thread cloning, only
# implemented by the Mark&Sweep GC
'gc_x_swap_pool': LLOp(canraise=(MemoryError,), canunwindgc=True),
More information about the Pypy-commit
mailing list