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

fijal at codespeak.net fijal at codespeak.net
Fri Jun 26 20:08:40 CEST 2009


Author: fijal
Date: Fri Jun 26 20:08:39 2009
New Revision: 66001

Modified:
   pypy/branch/pyjitpl5/pypy/jit/tl/spli/examples.py
   pypy/branch/pyjitpl5/pypy/jit/tl/spli/interpreter.py
   pypy/branch/pyjitpl5/pypy/jit/tl/spli/objects.py
   pypy/branch/pyjitpl5/pypy/jit/tl/spli/test/test_interpreter.py
   pypy/branch/pyjitpl5/pypy/jit/tl/spli/test/test_jit.py
Log:
Implement enough to support the loop. unfortunately it still works with
jit


Modified: pypy/branch/pyjitpl5/pypy/jit/tl/spli/examples.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/spli/examples.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/spli/examples.py	Fri Jun 26 20:08:39 2009
@@ -12,3 +12,5 @@
     while i < 10000000:
         i = i + 1
     return None
+
+while_loop()

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	Fri Jun 26 20:08:39 2009
@@ -182,6 +182,9 @@
             next_instr += arg
         return next_instr
 
+    def JUMP_FORWARD(self, arg, next_instr, code):
+        return next_instr + arg
+
     def JUMP_ABSOLUTE(self, arg, next_instr, code):
         jitdriver.can_enter_jit(frame=self, code=code, instr_index=arg)
         return arg

Modified: pypy/branch/pyjitpl5/pypy/jit/tl/spli/objects.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/spli/objects.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/spli/objects.py	Fri Jun 26 20:08:39 2009
@@ -117,6 +117,9 @@
     def as_int(self):
         return self.value
 
+    def is_true(self):
+        return bool(self.value)
+
     def repr(self):
         return Str(str(self.value))
 

Modified: pypy/branch/pyjitpl5/pypy/jit/tl/spli/test/test_interpreter.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/spli/test/test_interpreter.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/spli/test/test_interpreter.py	Fri Jun 26 20:08:39 2009
@@ -98,3 +98,16 @@
 
         v = self.eval(f, [1, 2])
         assert v.value == f(1, 2)
+
+    def test_while_2(self):
+        def f(a, b):
+            total = 0
+            i = 0
+            while i < 100:
+                if i & 1:
+                    total = total + a
+                else:
+                    total = total + b
+                i = i + 1
+            return total
+        assert self.eval(f, [1, 10]).value == f(1, 10)

Modified: pypy/branch/pyjitpl5/pypy/jit/tl/spli/test/test_jit.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/spli/test/test_jit.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/spli/test/test_jit.py	Fri Jun 26 20:08:39 2009
@@ -15,8 +15,9 @@
     def interpret(self, f, args):
         coderepr = serializer.serialize(f.func_code)
         arg_params = ", ".join(['arg%d' % i for i in range(len(args))])
-        arg_ass = "\n    ".join(['frame.locals[%d] = arg%d' % (i, i) for
+        arg_ass = ";".join(['frame.locals[%d] = space.wrap(arg%d)' % (i, i) for
                                  i in range(len(args))])
+        space = objects.DumbObjSpace()
         source = py.code.Source("""
         def bootstrap(%(arg_params)s):
             co = serializer.deserialize(coderepr)
@@ -26,6 +27,7 @@
         """ % locals())
         d = globals().copy()
         d['coderepr'] = coderepr
+        d['space'] = space
         exec source.compile() in d
         return self.meta_interp(d['bootstrap'], args, listops=True,
                                 optimizer=Optimizer)
@@ -37,3 +39,17 @@
                 i = i + 1
             return i
         self.interpret(f, [])
+
+    def test_bridge(self):
+        def f(a, b):
+            total = 0
+            i = 0
+            while i < 100:
+                if i & 1:
+                    total = total + a
+                else:
+                    total = total + b
+                i = i + 1
+            return total
+
+        self.interpret(f, [1, 10])



More information about the Pypy-commit mailing list