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

arigo at codespeak.net arigo at codespeak.net
Thu Mar 5 16:48:35 CET 2009


Author: arigo
Date: Thu Mar  5 16:48:34 2009
New Revision: 62591

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:
continuing...


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 16:48:34 2009
@@ -922,6 +922,18 @@
     x = getattr(ptr, fieldname)
     return cast_to_ptr(x)
 
+def do_getfield_raw_int(struct, fielddesc, memocast):
+    STRUCT, fieldname = symbolic.TokenToField[fielddesc/2]
+    ptr = llmemory.cast_adr_to_ptr(struct, lltype.Ptr(STRUCT))
+    x = getattr(ptr, fieldname)
+    return cast_to_int(x, memocast)
+
+def do_getfield_raw_ptr(struct, fielddesc):
+    STRUCT, fieldname = symbolic.TokenToField[fielddesc/2]
+    ptr = llmemory.cast_adr_to_ptr(struct, lltype.Ptr(STRUCT))
+    x = getattr(ptr, fieldname)
+    return cast_to_ptr(x)
+
 # ____________________________________________________________
 
 
@@ -1010,3 +1022,5 @@
 setannotation(do_getarrayitem_gc_ptr, annmodel.SomePtr(llmemory.GCREF))
 setannotation(do_getfield_gc_int, annmodel.SomeInteger())
 setannotation(do_getfield_gc_ptr, annmodel.SomePtr(llmemory.GCREF))
+setannotation(do_getfield_raw_int, annmodel.SomeInteger())
+setannotation(do_getfield_raw_ptr, annmodel.SomePtr(llmemory.GCREF))

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 16:48:34 2009
@@ -343,6 +343,17 @@
                                                             fielddescr,
                                                             self.memo_cast))
 
+    def do_getfield_raw(self, args):
+        struct = self.cast_int_to_adr(args[0].getint())
+        fielddescr = args[1].getint()
+        if self.typefor(fielddescr) == 'ptr':
+            return history.BoxPtr(llimpl.do_getfield_raw_ptr(struct,
+                                                             fielddescr))
+        else:
+            return history.BoxInt(llimpl.do_getfield_raw_int(struct,
+                                                             fielddescr,
+                                                             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 16:48:34 2009
@@ -206,3 +206,20 @@
              BoxInt(descrfld_y)])
         assert isinstance(x, BoxPtr)
         assert x.getptr(lltype.Ptr(A)) == a
+        #
+        RS = lltype.Struct('S', ('x', lltype.Char), ('y', lltype.Ptr(A)))
+        descrfld_rx = cpu.fielddescrof(RS, 'x')
+        rs = lltype.malloc(RS, immortal=True)
+        rs.x = '?'
+        x = cpu.do_getfield_raw(
+            [BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs))),
+             BoxInt(descrfld_rx)])
+        assert x.value == ord('?')
+        #
+        descrfld_ry = cpu.fielddescrof(RS, 'y')
+        rs.y = a
+        x = cpu.do_getfield_raw(
+            [BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs))),
+             BoxInt(descrfld_ry)])
+        assert isinstance(x, BoxPtr)
+        assert x.getptr(lltype.Ptr(A)) == a



More information about the Pypy-commit mailing list