[pypy-svn] r65940 - in pypy/branch/pyjitpl5/pypy/jit/tl/spli: . test

fijal at codespeak.net fijal at codespeak.net
Wed Jun 24 23:44:32 CEST 2009


Author: fijal
Date: Wed Jun 24 23:44:28 2009
New Revision: 65940

Added:
   pypy/branch/pyjitpl5/pypy/jit/tl/spli/test/test_jit.py   (contents, props changed)
Modified:
   pypy/branch/pyjitpl5/pypy/jit/tl/spli/interpreter.py
Log:
start jit tests


Modified: pypy/branch/pyjitpl5/pypy/jit/tl/spli/interpreter.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/spli/interpreter.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/spli/interpreter.py	Wed Jun 24 23:44:28 2009
@@ -26,7 +26,8 @@
     enumerate(compare_ops))
 
 jitdriver = JitDriver(greens = ['code', 'instr_index'],
-                      reds = ['frame'])
+                      reds = ['frame'],
+                      virtualizables = ['frame'])
 
 def spli_run_from_cpython_code(co, args=[]):
     space = objects.DumbObjSpace()
@@ -55,10 +56,13 @@
 
 class SPLIFrame(object):
 
+    _virtualizable2_ = ['value_stack[*]', 'locals[*]', 'stack_depth']
+
     def __init__(self, code):
         self.code = code
         self.value_stack = [None] * code.co_stacksize
         self.locals = [None] * code.co_nlocals
+        self.stack_depth = 0
 
     def run(self):
         self.stack_depth = 0

Added: pypy/branch/pyjitpl5/pypy/jit/tl/spli/test/test_jit.py
==============================================================================
--- (empty file)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/spli/test/test_jit.py	Wed Jun 24 23:44:28 2009
@@ -0,0 +1,40 @@
+
+import py
+from pypy.jit.metainterp.test.test_basic import JitMixin
+from pypy.jit.tl.spli import interpreter, objects, serializer
+from pypy.jit.metainterp.typesystem import LLTypeHelper, OOTypeHelper
+from pypy.jit.backend.llgraph import runner
+from pypy.rpython.annlowlevel import llstr, hlstr
+
+class TestSPLIJit(JitMixin):
+    type_system = 'lltype'
+    CPUClass = runner.LLtypeCPU
+    ts = LLTypeHelper()
+
+    
+    def interpret(self, f, args):
+        coderepr = serializer.serialize(f.func_code)
+        space = objects.DumbObjSpace()
+        arg_params = ", ".join(['arg%d' % i for i in range(len(args))])
+        arg_ass = "\n    ".join(['frame.locals[%d] = arg%d' % (i, i) for
+                                 i in range(len(args))])
+        source = py.code.Source("""
+        def bootstrap(%(arg_params)s):
+            co = serializer.deserialize(coderepr, space)
+            frame = interpreter.SPLIFrame(co)
+            %(arg_ass)s
+            return frame.run()
+        """ % locals())
+        d = globals().copy()
+        d['space'] = space
+        d['coderepr'] = coderepr
+        exec source.compile() in d
+        self.meta_interp(d['bootstrap'], args)
+    
+    def test_basic(self):
+        def f():
+            i = 0
+            while i < 20:
+                i = i + 1
+            return i
+        self.interpret(f, [])



More information about the Pypy-commit mailing list