[pypy-svn] r62596 - in pypy/branch/pyjitpl5/pypy/jit/backend/llgraph: . test

arigo at codespeak.net arigo at codespeak.net
Thu Mar 5 17:34:01 CET 2009


Author: arigo
Date: Thu Mar  5 17:34:00 2009
New Revision: 62596

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
Log:
setarrayitem_gc


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	Thu Mar  5 17:34:00 2009
@@ -954,6 +954,18 @@
     x = lltype.malloc(TYPE, count)
     return cast_to_ptr(x)
 
+def do_setarrayitem_gc_int(array, index, newvalue, memocast):
+    array = array._obj.container
+    ITEMTYPE = lltype.typeOf(array).OF
+    newvalue = cast_from_int(ITEMTYPE, newvalue, memocast)
+    array.setitem(index, newvalue)
+
+def do_setarrayitem_gc_ptr(array, index, newvalue):
+    array = array._obj.container
+    ITEMTYPE = lltype.typeOf(array).OF
+    newvalue = cast_from_ptr(ITEMTYPE, newvalue)
+    array.setitem(index, newvalue)
+
 def do_setfield_gc_int(struct, fielddesc, newvalue, memocast):
     STRUCT, fieldname = symbolic.TokenToField[fielddesc/2]
     ptr = lltype.cast_opaque_ptr(lltype.Ptr(STRUCT), struct)
@@ -1053,4 +1065,6 @@
 setannotation(do_getfield_raw_ptr, annmodel.SomePtr(llmemory.GCREF))
 setannotation(do_new, annmodel.SomePtr(llmemory.GCREF))
 setannotation(do_new_array, annmodel.SomePtr(llmemory.GCREF))
+setannotation(do_setarrayitem_gc_int, annmodel.s_None)
+setannotation(do_setarrayitem_gc_ptr, annmodel.s_None)
 setannotation(do_setfield_gc_int, annmodel.s_None)

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py	Thu Mar  5 17:34:00 2009
@@ -372,6 +372,18 @@
         count = args[1].getint()
         return history.BoxPtr(llimpl.do_new_array(size, count))
 
+    def do_setarrayitem_gc(self, args):
+        array = args[0].getptr_base()
+        arraydescr = args[1].getint()
+        index = args[2].getint()
+        if self.typefor(arraydescr) == 'ptr':
+            newvalue = args[3].getptr_base()
+            llimpl.do_setarrayitem_gc_ptr(array, index, newvalue)
+        else:
+            newvalue = args[3].getint()
+            llimpl.do_setarrayitem_gc_int(array, index, newvalue,
+                                          self.memo_cast)
+
 
 class GuardFailed(object):
     returns = False

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py	Thu Mar  5 17:34:00 2009
@@ -243,3 +243,12 @@
             [BoxInt(arraydescr), BoxInt(7)])
         assert isinstance(x, BoxPtr)
         assert len(x.getptr(lltype.Ptr(A))) == 7
+        #
+        cpu.do_setarrayitem_gc(
+            [x, descrbox_A, BoxInt(5), BoxInt(ord('*'))])
+        assert x.getptr(lltype.Ptr(A))[5] == '*'
+        #
+        cpu.do_setarrayitem_gc(
+            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, b)), descrbox_B,
+             BoxInt(1), x])
+        assert b[1] == x.getptr(lltype.Ptr(A))



More information about the Pypy-commit mailing list