[pypy-svn] r59600 - in pypy/branch/oo-jit/pypy/jit: rainbow tl

antocuni at codespeak.net antocuni at codespeak.net
Fri Oct 31 16:28:57 CET 2008


Author: antocuni
Date: Fri Oct 31 16:28:56 2008
New Revision: 59600

Added:
   pypy/branch/oo-jit/pypy/jit/tl/targettlc.py   (contents, props changed)
Modified:
   pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py
   pypy/branch/oo-jit/pypy/jit/tl/tlc.py
Log:
- rpython fix for the rainbow interpreter

- add a target to translate tlc into a standalone interpreter, which also
  translates with JIT to CLI, with good results



Modified: pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py	Fri Oct 31 16:28:56 2008
@@ -1112,7 +1112,9 @@
             return rtimeshift.geninstanceof(self.jitstate, objbox,
                                             typedesc)
         # else it's a vstruct
-        objtypedesc = objbox.content.typedesc
+        content = objbox.content
+        assert isinstance(content, rcontainer.VirtualStruct)
+        objtypedesc = content.typedesc
         result = objtypedesc.issubtype(typedesc)
         return rvalue.ll_fromvalue(self.jitstate, result)
 

Added: pypy/branch/oo-jit/pypy/jit/tl/targettlc.py
==============================================================================
--- (empty file)
+++ pypy/branch/oo-jit/pypy/jit/tl/targettlc.py	Fri Oct 31 16:28:56 2008
@@ -0,0 +1,51 @@
+import py
+py.magic.autopath()
+from pypy.jit.tl.tlc import interp, interp_eval
+from pypy.jit.codegen.hlinfo import highleveljitinfo
+
+
+def entry_point(args):
+    """Main entry point of the stand-alone executable:
+    takes a list of strings and returns the exit code.
+    """
+    # store args[0] in a place where the JIT log can find it (used by
+    # viewcode.py to know the executable whose symbols it should display)
+    highleveljitinfo.sys_executable = args[0]
+    if len(args) < 3:
+        print "Usage: %s filename x" % (args[0],)
+        return 2
+    filename = args[1]
+    x = int(args[2])
+    bytecode = load_bytecode(filename)
+    res = interp(bytecode, inputarg=x)
+    print res
+    return 0
+
+def load_bytecode(filename):
+    from pypy.rlib.streamio import open_file_as_stream
+    f = open_file_as_stream(filename)
+    bytecode = f.readall()
+    f.close()
+    return bytecode
+
+def target(driver, args):
+    return entry_point, None
+
+# ____________________________________________________________
+
+from pypy.jit.hintannotator.policy import HintAnnotatorPolicy
+
+class MyHintAnnotatorPolicy(HintAnnotatorPolicy):
+    novirtualcontainer = True
+    oopspec = True
+
+def portal(driver):
+    """Return the 'portal' function, and the hint-annotator policy.
+    The portal is the function that gets patched with a call to the JIT
+    compiler.
+    """
+    return interp_eval, MyHintAnnotatorPolicy()
+
+if __name__ == '__main__':
+    import sys
+    sys.exit(entry_point(sys.argv))

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	Fri Oct 31 16:28:56 2008
@@ -1,5 +1,6 @@
 '''Toy Language with Cons Cells'''
 
+import autopath
 import py
 from pypy.jit.tl.tlopcode import *
 from pypy.jit.tl import tlopcode
@@ -240,7 +241,7 @@
 
             elif opcode == BR_COND:
                 cond = stack.pop()
-                hint(cond.__class__, promote=True)
+                hint(cond, promote_class=True)
                 if cond.t():
                     pc += char2int(code[pc])
                 pc += 1
@@ -272,3 +273,12 @@
 
 interp             , interp_eval               = make_interp(supports_call = True)
 interp_without_call, interp_eval_without_call  = make_interp(supports_call = False)
+
+if __name__ == '__main__':
+    import sys
+    from pypy.jit.tl.test.test_tl import FACTORIAL_SOURCE
+    bytecode = compile(FACTORIAL_SOURCE)
+    if len(sys.argv) >= 2 and sys.argv[1] == 'assemble':
+        print bytecode
+    else:
+        print ','.join([str(ord(n)) for n in bytecode])



More information about the Pypy-commit mailing list