[pypy-svn] r52213 - in pypy/branch/jit-refactoring/pypy/rpython: . test

arigo at codespeak.net arigo at codespeak.net
Thu Mar 6 13:32:33 CET 2008


Author: arigo
Date: Thu Mar  6 13:32:33 2008
New Revision: 52213

Modified:
   pypy/branch/jit-refactoring/pypy/rpython/annlowlevel.py
   pypy/branch/jit-refactoring/pypy/rpython/test/test_llann.py
Log:
A skipped test documenting what doesn't work with llhelper().


Modified: pypy/branch/jit-refactoring/pypy/rpython/annlowlevel.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/rpython/annlowlevel.py	(original)
+++ pypy/branch/jit-refactoring/pypy/rpython/annlowlevel.py	Thu Mar  6 13:32:33 2008
@@ -344,6 +344,7 @@
 def llhelper(F, f):
     # implementation for the purpose of direct running only
     # XXX need more cleverness to support translation of prebuilt llhelper ptr
+    # (see test_prebuilt_llhelper)
     return lltype.functionptr(F.TO, f.func_name, _callable=f,
                               _debugexc = getattr(f, '_debugexc', False))
 

Modified: pypy/branch/jit-refactoring/pypy/rpython/test/test_llann.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/rpython/test/test_llann.py	(original)
+++ pypy/branch/jit-refactoring/pypy/rpython/test/test_llann.py	Thu Mar  6 13:32:33 2008
@@ -1,3 +1,4 @@
+import py
 from pypy.rpython.lltypesystem.lltype import *
 from pypy.rpython.lltypesystem.rclass import OBJECTPTR
 from pypy.rpython.rclass import fishllattr
@@ -10,6 +11,7 @@
 from pypy.rpython.annlowlevel import base_ptr_lltype
 from pypy.rpython.llinterp import LLInterpreter
 from pypy.rpython.test.test_llinterp import interpret
+from pypy.rlib.objectmodel import we_are_translated
 from pypy.objspace.flow.objspace import FlowObjSpace 
 from pypy.conftest import option
 
@@ -426,9 +428,11 @@
 def test_llhelper():
     S = GcStruct('S', ('x', Signed), ('y', Signed))
     def f(s,z):
+        assert we_are_translated()
         return s.x*s.y+z
 
     def g(s):
+        assert we_are_translated()
         return s.x+s.y
 
     F = Ptr(FuncType([Ptr(S), Signed], Signed))
@@ -447,6 +451,33 @@
     assert res == 99
 
 
+def test_prebuilt_llhelper():
+    py.test.skip("does not work")
+    S = GcStruct('S', ('x', Signed), ('y', Signed))
+    def f(s,z):
+        assert we_are_translated()
+        return s.x*s.y+z
+
+    def g(s):
+        assert we_are_translated()
+        return s.x+s.y
+
+    F = Ptr(FuncType([Ptr(S), Signed], Signed))
+    G = Ptr(FuncType([Ptr(S)], Signed))
+    fptr = llhelper(F, f)
+    gptr = llhelper(G, g)
+        
+    def h(x, y, z):
+        s = malloc(S)
+        s.x = x
+        s.y = y
+        assert typeOf(fptr) == F
+        return fptr(s, z)+fptr(s, z*2)+gptr(s)
+
+    res = interpret(h, [8, 5, 2])
+    assert res == 99
+
+
 def test_cast_instance_to_base_ptr():
     class A:
         def __init__(self, x, y):



More information about the Pypy-commit mailing list