[pypy-svn] r65937 - pypy/branch/pyjitpl5/pypy/jit/tl/spli

fijal at codespeak.net fijal at codespeak.net
Wed Jun 24 22:19:42 CEST 2009


Author: fijal
Date: Wed Jun 24 22:19:41 2009
New Revision: 65937

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/targetspli.py
Log:
add a jit. tests coming


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	Wed Jun 24 22:19:41 2009
@@ -4,3 +4,9 @@
 
 def adder(a, b):
     return a + b
+
+def while_loop():
+    i = 0
+    while i < 10000000:
+        i = i + 1
+    return None

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 22:19:41 2009
@@ -4,6 +4,7 @@
 from pypy.tool.stdlib_opcode import unrolling_opcode_descs
 from pypy.tool.stdlib_opcode import opcode_method_names
 from pypy.rlib.unroll import unrolling_iterable
+from pypy.rlib.jit import JitDriver, hint
 from pypy.rlib.objectmodel import we_are_translated
 
 import dis
@@ -24,6 +25,9 @@
 unrolling_compare_dispatch_table = unrolling_iterable(
     enumerate(compare_ops))
 
+jitdriver = JitDriver(greens = ['code', 'instr_index'],
+                      reds = ['frame'])
+
 def spli_run_from_cpython_code(co, args=[]):
     space = objects.DumbObjSpace()
     pyco = Code._from_code(space, co)
@@ -67,6 +71,8 @@
         code = self.code.co_code
         instr_index = 0
         while True:
+            jitdriver.jit_merge_point(code=code, instr_index=instr_index,
+                                      frame=self)
             op = ord(code[instr_index])
             instr_index += 1
             if op >= opcode.HAVE_ARGUMENT:
@@ -80,13 +86,13 @@
                 for opdesc in unrolling_opcode_descs:
                     if op == opdesc.index:
                         meth = getattr(self, opdesc.methodname)
-                        instr_index = meth(oparg, instr_index)
+                        instr_index = meth(oparg, instr_index, code)
                         break
                 else:
                     raise MissingOpcode(op)
             else:
                 meth = getattr(self, opcode_method_names[op])
-                instr_index = meth(oparg, instr_index)
+                instr_index = meth(oparg, instr_index, code)
 
     def push(self, value):
         self.value_stack[self.stack_depth] = value
@@ -101,47 +107,48 @@
     def peek(self):
         return self.value_stack[self.stack_depth - 1]
 
-    def POP_TOP(self, _, next_instr):
+    def POP_TOP(self, _, next_instr, code):
         self.pop()
         return next_instr
 
-    def LOAD_FAST(self, name_index, next_instr):
+    def LOAD_FAST(self, name_index, next_instr, code):
         self.push(self.locals[name_index])
         return next_instr
 
-    def STORE_FAST(self, name_index, next_instr):
+    def STORE_FAST(self, name_index, next_instr, code):
         self.locals[name_index] = self.pop()
         return next_instr
 
-    def RETURN_VALUE(self, _, next_instr):
+    def RETURN_VALUE(self, _, next_instr, code):
         raise Return(self.pop())
 
-    def LOAD_CONST(self, const_index, next_instr):
+    def LOAD_CONST(self, const_index, next_instr, code):
         self.push(self.code.co_consts_w[const_index])
         return next_instr
 
-    def BINARY_ADD(self, _, next_instr):
+    def BINARY_ADD(self, _, next_instr, code):
         right = self.pop()
         left = self.pop()
         self.push(left.add(right))
         return next_instr
 
-    def SETUP_LOOP(self, _, next_instr):
+    def SETUP_LOOP(self, _, next_instr, code):
         return next_instr
 
-    def POP_BLOCK(self, _, next_instr):
+    def POP_BLOCK(self, _, next_instr, code):
         return next_instr
 
-    def JUMP_IF_FALSE(self, arg, next_instr):
+    def JUMP_IF_FALSE(self, arg, next_instr, code):
         w_cond = self.peek()
         if not w_cond.is_true():
             next_instr += arg
         return next_instr
 
-    def JUMP_ABSOLUTE(self, arg, next_instr):
+    def JUMP_ABSOLUTE(self, arg, next_instr, code):
+        jitdriver.can_enter_jit(frame=self, code=code, instr_index=arg)
         return arg
 
-    def COMPARE_OP(self, arg, next_instr):
+    def COMPARE_OP(self, arg, next_instr, code):
         right = self.pop()
         left = self.pop()
         for num, name in unrolling_compare_dispatch_table:

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	Wed Jun 24 22:19:41 2009
@@ -62,6 +62,9 @@
     def repr(self):
         raise InvalidOperation
 
+    def is_true(self):
+        raise InvalidOperation
+
 class Bool(SPLIObject):
 
     def __init__(self, value):
@@ -105,7 +108,8 @@
         return self.value
 
 class SPLINone(SPLIObject):
-    pass
+    def repr(self):
+        return 'None'
 
 spli_None = SPLINone()
 

Modified: pypy/branch/pyjitpl5/pypy/jit/tl/spli/targetspli.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/spli/targetspli.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/spli/targetspli.py	Wed Jun 24 22:19:41 2009
@@ -33,5 +33,10 @@
 def target(drver, args):
     return entry_point, None
 
+def jitpolicy(driver):
+    """Returns the JIT policy to use when translating."""
+    from pypy.jit.metainterp.policy import JitPolicy
+    return JitPolicy()
+
 if __name__ == '__main__':
     entry_point(sys.argv)



More information about the Pypy-commit mailing list