[pypy-svn] r77561 - in pypy/branch/jitffi/pypy/rlib: . test

antocuni at codespeak.net antocuni at codespeak.net
Mon Oct 4 11:29:01 CEST 2010


Author: antocuni
Date: Mon Oct  4 11:29:00 2010
New Revision: 77561

Modified:
   pypy/branch/jitffi/pypy/rlib/jit.py
   pypy/branch/jitffi/pypy/rlib/libffi.py
   pypy/branch/jitffi/pypy/rlib/test/test_jit.py
Log:
introduce a new decorator to set oopspec, and use it in libffi.py


Modified: pypy/branch/jitffi/pypy/rlib/jit.py
==============================================================================
--- pypy/branch/jitffi/pypy/rlib/jit.py	(original)
+++ pypy/branch/jitffi/pypy/rlib/jit.py	Mon Oct  4 11:29:00 2010
@@ -77,6 +77,12 @@
         return result
     return decorator
 
+def oopspec(spec):
+    def decorator(func):
+        func.oopspec = spec
+        return func
+    return decorator
+
 class Entry(ExtRegistryEntry):
     _about_ = hint
 

Modified: pypy/branch/jitffi/pypy/rlib/libffi.py
==============================================================================
--- pypy/branch/jitffi/pypy/rlib/libffi.py	(original)
+++ pypy/branch/jitffi/pypy/rlib/libffi.py	Mon Oct  4 11:29:00 2010
@@ -105,10 +105,10 @@
     # the following methods are supposed to be seen opaquely by the JIT
     # optimizer. Don't call them
 
+    @jit.oopspec('libffi_prepare_call(self)')
     def _prepare(self):
         ll_args = lltype.malloc(rffi.VOIDPP.TO, len(self.argtypes), flavor='raw')
         return ll_args
-    _prepare.oopspec = 'libffi_prepare_call(self)'
 
     @specialize.arg(1)
     def _push_arg(self, TYPE, value, ll_args, i):
@@ -119,15 +119,17 @@
         push_arg_as_ffiptr(argtype, value, ll_buf)
         ll_args[i] = ll_buf
 
+    @jit.oopspec('libffi_push_int(self, value, ll_args, i)')
     def _push_int(self, value, ll_args, i):
         self._push_arg(lltype.Signed, value, ll_args, i)
-    _push_int.oopspec = 'libffi_push_int(self, value, ll_args, i)'
     _push_int._annenforceargs_ = [None, int, None, int]
 
+    @jit.oopspec('libffi_push_float(self, value, ll_args, i)')
     def _push_float(self, value, ll_args, i):
         self._push_arg(lltype.Float, value, ll_args, i)
-    _push_float.oopspec = 'libffi_push_float(self, value, ll_args, i)'
 
+    @specialize.arg(3)
+    @jit.oopspec('libffi_call(self, funcsym, ll_args, RESULT)')
     def _do_call(self, funcsym, ll_args, RESULT):
         # XXX: check len(args)?
         ll_result = lltype.nullptr(rffi.CCHARP.TO)
@@ -147,8 +149,6 @@
         self._free_buffers(ll_result, ll_args)
         #check_fficall_result(ffires, self.flags)
         return res
-    _do_call._annspecialcase_ = 'specialize:arg(3)'
-    _do_call.oopspec = 'libffi_call(self, funcsym, ll_args, RESULT)'
 
     def _free_buffers(self, ll_result, ll_args):
         lltype.free(ll_result, flavor='raw')

Modified: pypy/branch/jitffi/pypy/rlib/test/test_jit.py
==============================================================================
--- pypy/branch/jitffi/pypy/rlib/test/test_jit.py	(original)
+++ pypy/branch/jitffi/pypy/rlib/test/test_jit.py	Mon Oct  4 11:29:00 2010
@@ -1,10 +1,16 @@
 import py
 from pypy.rlib.jit import hint, we_are_jitted, JitDriver, purefunction_promote
-from pypy.rlib.jit import JitHintError
+from pypy.rlib.jit import JitHintError, oopspec
 from pypy.translator.translator import TranslationContext, graphof
 from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
 from pypy.rpython.lltypesystem import lltype
 
+def test_oopspec():
+    @oopspec('foobar')
+    def fn():
+        pass
+    assert fn.oopspec == 'foobar'
+    
 class BaseTestJIT(BaseRtypingTest):
     def test_hint(self):
         def f():



More information about the Pypy-commit mailing list