[pypy-svn] r66205 - pypy/branch/pyjitpl5/pypy/jit/tl/tla

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Jul 14 14:47:49 CEST 2009


Author: cfbolz
Date: Tue Jul 14 14:47:48 2009
New Revision: 66205

Modified:
   pypy/branch/pyjitpl5/pypy/jit/tl/tla/targettla.py
   pypy/branch/pyjitpl5/pypy/jit/tl/tla/test_tla.py
   pypy/branch/pyjitpl5/pypy/jit/tl/tla/tla.py
Log:
(arigo, cfbolz): a version of tla with JIT hints


Modified: pypy/branch/pyjitpl5/pypy/jit/tl/tla/targettla.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/tla/targettla.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/tla/targettla.py	Tue Jul 14 14:47:48 2009
@@ -28,6 +28,10 @@
 def target(driver, args):
     return entry_point, None
 
+from pypy.jit.metainterp.policy import JitPolicy
+
+def jitpolicy(driver):
+    return JitPolicy()
 # ____________________________________________________________
 
 

Modified: pypy/branch/pyjitpl5/pypy/jit/tl/tla/test_tla.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/tla/test_tla.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/tla/test_tla.py	Tue Jul 14 14:47:48 2009
@@ -155,3 +155,22 @@
 
 # ____________________________________________________________ 
 
+from pypy.jit.metainterp.test.test_basic import LLJitMixin
+from pypy.jit.metainterp import optimize4
+
+class TestLLtype(LLJitMixin):
+    def test_loop(self):
+        code = [
+            tla.CONST_INT, 1,
+            tla.SUB,
+            tla.DUP,
+            tla.JUMP_IF, 0,
+            tla.RETURN
+            ]
+        def interp_w(intvalue):
+            w_result = interp(code, tla.W_IntObject(intvalue))
+            assert isinstance(w_result, tla.W_IntObject)
+            return w_result.intvalue
+        res = self.meta_interp(interp_w, [42], listops=True,
+                               optimizer=optimize4)
+        assert res == 0

Modified: pypy/branch/pyjitpl5/pypy/jit/tl/tla/tla.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/tla/tla.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/tla/tla.py	Tue Jul 14 14:47:48 2009
@@ -1,5 +1,6 @@
 
-from pypy.rlib.jit import JitDriver
+from pypy.rlib.jit import JitDriver, hint
+from pypy.rlib.objectmodel import UnboxedValue
 
 
 class W_Object:
@@ -18,7 +19,7 @@
 
 
 
-class W_IntObject(W_Object):
+class W_IntObject(W_Object, UnboxedValue):
 
     def __init__(self, intvalue):
         self.intvalue = intvalue
@@ -55,7 +56,7 @@
         return len(self.strvalue) != 0
 
 
-class OperationError:
+class OperationError(Exception):
     pass
 
 # ____________________________________________________________
@@ -71,6 +72,9 @@
 
 # ____________________________________________________________
 
+jitdriver = JitDriver(greens=['bytecode', 'pc'],
+                      reds=['self'],
+                      virtualizables=['self'])
 
 class Frame(object):
     _virtualizable2_ = ['stackpos', 'stack[*]']
@@ -81,19 +85,22 @@
         self.stackpos = 0
 
     def push(self, w_x):
-        self.stack[self.stackpos] = w_x
-        self.stackpos += 1
+        stackpos = hint(self.stackpos, promote=True)
+        self.stack[stackpos] = w_x
+        self.stackpos = stackpos + 1
 
     def pop(self):
-        self.stackpos -= 1
-        assert self.stackpos >= 0
-        return self.stack[self.stackpos]
+        stackpos = hint(self.stackpos, promote=True) - 1
+        assert stackpos >= 0
+        self.stackpos = stackpos
+        return self.stack[stackpos]
 
     def interp(self):
         bytecode = self.bytecode
         pc = 0
 
         while pc < len(bytecode):
+            jitdriver.jit_merge_point(bytecode=bytecode, pc=pc, self=self)
             opcode = ord(bytecode[pc])
             pc += 1
 
@@ -128,6 +135,7 @@
                 w_x = self.pop()
                 if w_x.is_true():
                     pc = target
+                    jitdriver.can_enter_jit(bytecode=bytecode, pc=pc, self=self)
 
             elif opcode == NEWSTR:
                 char = bytecode[pc]



More information about the Pypy-commit mailing list