[pypy-svn] r41312 - pypy/dist/pypy/jit/tl
arigo at codespeak.net
arigo at codespeak.net
Mon Mar 26 11:02:20 CEST 2007
Author: arigo
Date: Mon Mar 26 11:02:17 2007
New Revision: 41312
Added:
pypy/dist/pypy/jit/tl/targettiny1.py (contents, props changed)
pypy/dist/pypy/jit/tl/tiny1.py (contents, props changed)
Log:
The small example from draft-jit.txt.
Added: pypy/dist/pypy/jit/tl/targettiny1.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/jit/tl/targettiny1.py Mon Mar 26 11:02:17 2007
@@ -0,0 +1,29 @@
+from pypy.jit.tl import tiny1
+from pypy.jit.codegen.hlinfo import highleveljitinfo
+
+
+def entry_point(args):
+ highleveljitinfo.sys_executable = args[0]
+ if len(args) < 4:
+ print "Usage: %s bytecode x y" % (args[0],)
+ return 2
+ bytecode = args[1]
+ x = int(args[2])
+ y = int(args[3])
+ res = tiny1.ll_plus_minus(bytecode, x, y)
+ print res
+ return 0
+
+def target(driver, args):
+ return entry_point, None
+
+# ____________________________________________________________
+
+from pypy.jit.hintannotator.annotator import HintAnnotatorPolicy
+
+class MyHintAnnotatorPolicy(HintAnnotatorPolicy):
+ novirtualcontainer = True
+ oopspec = True
+
+def portal(driver):
+ return tiny2.interpret, MyHintAnnotatorPolicy()
Added: pypy/dist/pypy/jit/tl/tiny1.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/jit/tl/tiny1.py Mon Mar 26 11:02:17 2007
@@ -0,0 +1,20 @@
+from pypy.rlib.objectmodel import hint
+
+
+def ll_plus_minus(s, x, y):
+ acc = x
+ pc = 0
+ while pc < len(s):
+ op = s[pc]
+ op = hint(op, concrete=True)
+ if op == '+':
+ acc += y
+ elif op == '-':
+ acc -= y
+ pc += 1
+ return acc
+
+
+def test_simple():
+ res = ll_plus_minus("+-++", 100, 10)
+ assert res == 120
More information about the Pypy-commit
mailing list