[pypy-svn] r53498 - pypy/branch/jit-hotpath/pypy/jit/tl

fijal at codespeak.net fijal at codespeak.net
Mon Apr 7 04:45:21 CEST 2008


Author: fijal
Date: Mon Apr  7 04:45:16 2008
New Revision: 53498

Modified:
   pypy/branch/jit-hotpath/pypy/jit/tl/targettiny3hotpath.py
   pypy/branch/jit-hotpath/pypy/jit/tl/tiny3_hotpath.py
Log:
Make it all a bit more jit-friendly


Modified: pypy/branch/jit-hotpath/pypy/jit/tl/targettiny3hotpath.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/tl/targettiny3hotpath.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/tl/targettiny3hotpath.py	Mon Apr  7 04:45:16 2008
@@ -1,4 +1,4 @@
-from pypy.jit.tl import tiny2_hotpath as tiny2
+from pypy.jit.tl import tiny3_hotpath as tiny3
 from pypy.jit.codegen.hlinfo import highleveljitinfo
 
 
@@ -6,7 +6,7 @@
     print err
     print highleveljitinfo.sys_executable,
     print "[-j param=value,...]",
-    print "'tiny2 program string' arg0 [arg1 [arg2 [...]]]"
+    print "'tiny3 program string' arg0 [arg1 [arg2 [...]]]"
     return 1
 
 def entry_point(args):
@@ -22,14 +22,19 @@
         if len(args) < 3:
             return help()
         try:
-            tiny2.tinyjitdriver.set_user_param(args[1])
+            tiny3.tinyjitdriver.set_user_param(args[1])
         except ValueError:
             return help("Bad argument to -j.")
         args = args[2:]
     bytecode = [s for s in args[0].split(' ') if s != '']
-    args = [tiny2.StrBox(arg) for arg in args[1:]]
-    res = tiny2.interpret(bytecode, args)
-    print tiny2.repr(res)
+    real_args = []
+    for arg in args[1:]:
+        try:
+            real_args.append(tiny3.IntBox(int(arg)))
+        except ValueError:
+            real_args.append(tiny3.FloatBox(float(arg)))
+    res = tiny3.interpret(bytecode, real_args)
+    print tiny3.repr(res)
     return 0
 
 def target(driver, args):
@@ -46,7 +51,8 @@
 
     def look_inside_graph(self, graph):
         # temporary workaround
-        return getattr(graph, 'func', None) is not tiny2.myint_internal
+        return getattr(graph, 'func', None) not in (tiny3.myint_internal,
+                                                    tiny3.myfloat)
 
 def portal(driver):
     """Return the 'portal' function, and the hint-annotator policy.

Modified: pypy/branch/jit-hotpath/pypy/jit/tl/tiny3_hotpath.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/tl/tiny3_hotpath.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/tl/tiny3_hotpath.py	Mon Apr  7 04:45:16 2008
@@ -29,6 +29,7 @@
 
 """
 from pypy.rlib.jit import hint, _is_early_constant, JitDriver
+from pypy.rlib.objectmodel import specialize
 
 #
 # See pypy/doc/jit.txt for a higher-level overview of the JIT techniques
@@ -50,7 +51,7 @@
     def as_int(self):
         return self.intval
     def as_float(self):
-        return float(self.intval)
+        return myfloat(self.intval)
     def as_str(self):
         return str(self.intval)
 
@@ -201,7 +202,7 @@
                 try:
                     v = IntBox(int(opcode))
                 except ValueError:
-                    v = FloatBox(float(opcode))
+                    v = FloatBox(myfloat(opcode))
                 stack = Stack(v, stack)
             except ValueError:
                 pass # ignore rest
@@ -247,6 +248,10 @@
         if n < 0:
             raise ValueError
     return n
+
+ at specialize.argtype(0)
+def myfloat(i):
+    return float(i)
 # ------------------------------
 
 



More information about the Pypy-commit mailing list