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

arigo at codespeak.net arigo at codespeak.net
Thu Mar 5 17:41:32 CET 2009


Author: arigo
Date: Thu Mar  5 17:41:31 2009
New Revision: 62599

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:
setfield_raw


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:41:31 2009
@@ -980,6 +980,20 @@
     newvalue = cast_from_ptr(FIELDTYPE, newvalue)
     setattr(ptr, fieldname, newvalue)
 
+def do_setfield_raw_int(struct, fielddesc, newvalue, memocast):
+    STRUCT, fieldname = symbolic.TokenToField[fielddesc/2]
+    ptr = llmemory.cast_adr_to_ptr(struct, lltype.Ptr(STRUCT))
+    FIELDTYPE = getattr(STRUCT, fieldname)
+    newvalue = cast_from_int(FIELDTYPE, newvalue, memocast)
+    setattr(ptr, fieldname, newvalue)
+
+def do_setfield_raw_ptr(struct, fielddesc, newvalue):
+    STRUCT, fieldname = symbolic.TokenToField[fielddesc/2]
+    ptr = llmemory.cast_adr_to_ptr(struct, lltype.Ptr(STRUCT))
+    FIELDTYPE = getattr(STRUCT, fieldname)
+    newvalue = cast_from_ptr(FIELDTYPE, newvalue)
+    setattr(ptr, fieldname, newvalue)
+
 # ____________________________________________________________
 
 
@@ -1076,3 +1090,5 @@
 setannotation(do_setarrayitem_gc_ptr, annmodel.s_None)
 setannotation(do_setfield_gc_int, annmodel.s_None)
 setannotation(do_setfield_gc_ptr, annmodel.s_None)
+setannotation(do_setfield_raw_int, annmodel.s_None)
+setannotation(do_setfield_raw_ptr, 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:41:31 2009
@@ -395,6 +395,17 @@
             llimpl.do_setfield_gc_int(struct, fielddescr, newvalue,
                                       self.memo_cast)
 
+    def do_setfield_raw(self, args):
+        struct = self.cast_int_to_adr(args[0].getint())
+        fielddescr = args[1].getint()
+        if self.typefor(fielddescr) == 'ptr':
+            newvalue = args[2].getptr_base()
+            llimpl.do_setfield_raw_ptr(struct, fielddescr, newvalue)
+        else:
+            newvalue = args[2].getint()
+            llimpl.do_setfield_raw_int(struct, fielddescr, 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:41:31 2009
@@ -229,6 +229,12 @@
              BoxInt(descrfld_rx)])
         assert x.value == ord('?')
         #
+        cpu.do_setfield_raw(
+            [BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs))),
+             BoxInt(descrfld_rx),
+             BoxInt(ord('!'))])
+        assert rs.x == '!'
+        #
         descrfld_ry = cpu.fielddescrof(RS, 'y')
         rs.y = a
         x = cpu.do_getfield_raw(
@@ -237,6 +243,13 @@
         assert isinstance(x, BoxPtr)
         assert x.getptr(lltype.Ptr(A)) == a
         #
+        rs.y = lltype.nullptr(A)
+        cpu.do_setfield_raw(
+            [BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs))),
+             BoxInt(descrfld_ry),
+             x])
+        assert rs.y == a
+        #
         descrsize = cpu.sizeof(S)
         x = cpu.do_new(
             [BoxInt(descrsize)])



More information about the Pypy-commit mailing list