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

arigo at codespeak.net arigo at codespeak.net
Thu Mar 5 16:07:03 CET 2009


Author: arigo
Date: Thu Mar  5 16:07:01 2009
New Revision: 62587

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:
Start to write individual backend-specific operations.
Only arraylen_gc for now.


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:07:01 2009
@@ -883,6 +883,12 @@
 
 # ____________________________________________________________
 
+def do_arraylen_gc(array):
+    array = array._obj.container
+    return array.getlength()
+
+# ____________________________________________________________
+
 
 def setannotation(func, annotation, specialize_as_constant=False):
 
@@ -961,3 +967,5 @@
 setannotation(new_memo_cast, s_MemoCast)
 setannotation(cast_adr_to_int, annmodel.SomeInteger())
 setannotation(cast_int_to_adr, annmodel.SomeAddress())
+
+setannotation(do_arraylen_gc, annmodel.SomeInteger())

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:07:01 2009
@@ -307,6 +307,12 @@
     def cast_int_to_adr(self, int):
         return llimpl.cast_int_to_adr(self.memo_cast, int)
 
+    # ---------- the backend-dependent operations ----------
+
+    def do_arraylen_gc(self, args):
+        array = args[0].getptr_base()
+        return history.BoxInt(llimpl.do_arraylen_gc(array))
+
 
 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:07:01 2009
@@ -153,3 +153,12 @@
                            [BoxInt(10), BoxInt(2)], "int",
                            expected_class = BoxInt,
                            expected_value = 8)
+
+    def test_do_operations(self):
+        cpu = CPU(None)
+        A = lltype.GcArray(lltype.Signed)
+        a = lltype.malloc(A, 5)
+        descrbox = ConstInt(cpu.arraydescrof(A))
+        x = cpu.do_arraylen_gc(
+            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, a)), descrbox])
+        assert x.value == 5



More information about the Pypy-commit mailing list