[pypy-commit] pypy default: unroll this function when the size of the list is constant and small

alex_gaynor noreply at buildbot.pypy.org
Sun Dec 2 17:13:38 CET 2012


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r59210:b2f7e5c13c37
Date: 2012-12-02 08:13 -0800
http://bitbucket.org/pypy/pypy/changeset/b2f7e5c13c37/

Log:	unroll this function when the size of the list is constant and small

diff --git a/pypy/rpython/rlist.py b/pypy/rpython/rlist.py
--- a/pypy/rpython/rlist.py
+++ b/pypy/rpython/rlist.py
@@ -461,7 +461,6 @@
         return self.r_list.recast(hop.llops, v_res)
 
 
-
 # ____________________________________________________________
 #
 #  Low-level methods.  These can be run for testing, but are meant to
@@ -481,6 +480,8 @@
 #  done with it.  So in the sequel we don't bother checking for overflow
 #  when we compute "ll_length() + 1".
 
+ at jit.look_inside_iff(lambda LIST, count, item: jit.isconstant(count) and count < 15)
+ at jit.oopspec("newlist(count, item)")
 def ll_alloc_and_set(LIST, count, item):
     if count < 0:
         count = 0
@@ -492,14 +493,14 @@
         check = widen(item)
     else:
         check = item
-    if (not malloc_zero_filled) or check: # as long as malloc it is known to zero the allocated memory avoid zeroing twice
-
+    # as long as malloc is known to zero the allocated memory avoid zeroing
+    # twice
+    if (not malloc_zero_filled) or check:
         i = 0
         while i < count:
             l.ll_setitem_fast(i, item)
             i += 1
     return l
-ll_alloc_and_set.oopspec = 'newlist(count, item)'
 
 
 # return a nullptr() if lst is a list of pointers it, else None.  Note


More information about the pypy-commit mailing list