[pypy-commit] pypy unroll-if-alt: Handle ref types. Start playing with making this work for str mod, mostly copied from fijal's branch.

alex_gaynor noreply at buildbot.pypy.org
Fri Jul 29 09:08:46 CEST 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: unroll-if-alt
Changeset: r46083:d8fcab4fa290
Date: 2011-07-29 00:09 -0700
http://bitbucket.org/pypy/pypy/changeset/d8fcab4fa290/

Log:	Handle ref types. Start playing with making this work for str mod,
	mostly copied from fijal's branch.

diff --git a/pypy/jit/metainterp/blackhole.py b/pypy/jit/metainterp/blackhole.py
--- a/pypy/jit/metainterp/blackhole.py
+++ b/pypy/jit/metainterp/blackhole.py
@@ -823,6 +823,10 @@
     def bhimpl_int_isconstant(x):
         return False
 
+    @arguments("r", returns="i")
+    def bhimpl_ref_isconstant(x):
+        return False
+
     # ----------
     # the main hints and recursive calls
 
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -1050,7 +1050,7 @@
     def _opimpl_isconstant(self, box):
         return ConstInt(isinstance(box, Const))
 
-    opimpl_int_isconstant = _opimpl_isconstant
+    opimpl_int_isconstant = opimpl_ref_isconstant = _opimpl_isconstant
 
     @arguments("box")
     def opimpl_virtual_ref(self, box):
diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -1,13 +1,15 @@
 """
 String formatting routines.
 """
-from pypy.rlib.unroll import unrolling_iterable
+from pypy.interpreter.error import OperationError
+from pypy.objspace.std.unicodetype import unicode_from_object
+from pypy.rlib import jit
 from pypy.rlib.rarithmetic import ovfcheck
 from pypy.rlib.rfloat import formatd, DTSF_ALT, isnan, isinf
-from pypy.interpreter.error import OperationError
+from pypy.rlib.rstring import StringBuilder, UnicodeBuilder
+from pypy.rlib.unroll import unrolling_iterable
 from pypy.tool.sourcetools import func_with_new_name
-from pypy.rlib.rstring import StringBuilder, UnicodeBuilder
-from pypy.objspace.std.unicodetype import unicode_from_object
+
 
 class BaseStringFormatter(object):
     def __init__(self, space, values_w, w_valuedict):
@@ -233,6 +235,9 @@
 
             return w_value
 
+        # Only shows up if we've already started inlining format(), so just
+        # unconditionally unroll this.
+        @jit.unroll_safe
         def peel_flags(self):
             self.f_ljust = False
             self.f_sign  = False
@@ -255,6 +260,8 @@
                     break
                 self.forward()
 
+        # Same as peel_flags.
+        @jit.unroll_safe
         def peel_num(self):
             space = self.space
             c = self.peekchr()
@@ -276,6 +283,7 @@
                 c = self.peekchr()
             return result
 
+        @jit.unroll_if(lambda self: jit.isconstant(self.fmt))
         def format(self):
             lgt = len(self.fmt) + 4 * len(self.values_w) + 10
             if do_unicode:
diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py
--- a/pypy/rlib/jit.py
+++ b/pypy/rlib/jit.py
@@ -129,6 +129,7 @@
     return decorator
 
 @oopspec("jit.isconstant(value)")
+ at specialize.argtype(0)
 def isconstant(value):
     """
     While tracing, returns whether or not the value is currently known to be


More information about the pypy-commit mailing list