[pypy-svn] r60537 - in pypy/branch/oo-jit/pypy/jit/tl: . test

antocuni at codespeak.net antocuni at codespeak.net
Wed Dec 17 12:26:14 CET 2008


Author: antocuni
Date: Wed Dec 17 12:26:11 2008
New Revision: 60537

Modified:
   pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py
   pypy/branch/oo-jit/pypy/jit/tl/tlc.py
   pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py
Log:
add unconditional branches, to make examples easier to understand



Modified: pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py	Wed Dec 17 12:26:11 2008
@@ -36,7 +36,20 @@
     def interp(code='', pc=0, inputarg=0):
         from pypy.jit.tl.tlc import interp
         return interp(code, pc, inputarg)
- 
+
+    def test_unconditional_branch(self):
+        bytecode = compile("""
+    main:
+        BR target
+        PUSH 123
+        RETURN
+    target:
+        PUSH 42
+        RETURN
+    """)
+        res = self.interp(bytecode, 0, 0)
+        assert res == 42
+
     def test_basic_cons_cell(self):
         bytecode = compile("""
             NIL

Modified: pypy/branch/oo-jit/pypy/jit/tl/tlc.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/tlc.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/tl/tlc.py	Wed Dec 17 12:26:11 2008
@@ -385,6 +385,10 @@
                 hint(b, promote_class=True)
                 stack.append(IntObj(not b.lt(a)))
 
+            elif opcode == BR:
+                pc += char2int(code[pc])
+                pc += 1
+                
             elif opcode == BR_COND:
                 cond = stack.pop()
                 hint(cond, promote_class=True)

Modified: pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py	Wed Dec 17 12:26:11 2008
@@ -53,6 +53,7 @@
 
 opcode(33, "PRINT")
 opcode(34, "DUMP")
+opcode(35, "BR")
 
 del opcode
 



More information about the Pypy-commit mailing list