Commits

Brian Kearns committed 9fcfef8

restore previous unroll heuristic cutoffs

Comments (0)

Files changed (5)

pypy/objspace/std/dictmultiobject.py

 
 from rpython.rlib import rerased, jit
 
+UNROLL_CUTOFF = 5
+
 def _is_str(space, w_key):
     return space.is_w(space.type(w_key), space.w_str)
 
     an actual dict
     """
     return jit.isvirtual(w_dct) or (jit.isconstant(w_dct) and
-                                    w_dct.length() <= jit.UNROLL_CUTOFF)
+                                    w_dct.length() <= UNROLL_CUTOFF)
 
 
 class W_DictMultiObject(W_Object):

pypy/objspace/std/listobject.py

 from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
 from sys import maxint
 
+UNROLL_CUTOFF = 5
 
 class W_AbstractListObject(W_Object):
     __slots__ = ()
     return W_ListObject.from_storage_and_strategy(space, storage, strategy)
 
 @jit.look_inside_iff(lambda space, list_w, sizehint:
-                     jit.loop_unrolling_heuristic(list_w, len(list_w)))
+        jit.loop_unrolling_heuristic(list_w, len(list_w), UNROLL_CUTOFF))
 def get_strategy_from_list_objects(space, list_w, sizehint):
     if not list_w:
         if sizehint != -1:
         raise NotImplementedError("abstract base class")
 
     @jit.look_inside_iff(lambda space, w_list, list_w:
-                         jit.loop_unrolling_heuristic(list_w, len(list_w)))
+            jit.loop_unrolling_heuristic(list_w, len(list_w), UNROLL_CUTOFF))
     def init_from_list_w(self, w_list, list_w):
         l = [self.unwrap(w_item) for w_item in list_w]
         w_list.lstorage = self.erase(l)
         return self.wrap(r)
 
     @jit.look_inside_iff(lambda self, w_list:
-                         jit.loop_unrolling_heuristic(w_list, w_list.length()))
+            jit.loop_unrolling_heuristic(w_list, w_list.length(), UNROLL_CUTOFF))
     def getitems_copy(self, w_list):
         return [self.wrap(item) for item in self.unerase(w_list.lstorage)]
 
         return [self.wrap(item) for item in self.unerase(w_list.lstorage)]
 
     @jit.look_inside_iff(lambda self, w_list:
-                         jit.loop_unrolling_heuristic(w_list, w_list.length()))
+            jit.loop_unrolling_heuristic(w_list, w_list.length(), UNROLL_CUTOFF))
     def getitems_fixedsize(self, w_list):
         return self.getitems_unroll(w_list)
 
     return w_list
 
 def list_unroll_condition(space, w_list1, w_list2):
-    return jit.loop_unrolling_heuristic(w_list1, w_list1.length()) or \
-           jit.loop_unrolling_heuristic(w_list2, w_list2.length())
+    return jit.loop_unrolling_heuristic(w_list1, w_list1.length(), UNROLL_CUTOFF) or \
+           jit.loop_unrolling_heuristic(w_list2, w_list2.length(), UNROLL_CUTOFF)
 
 @jit.look_inside_iff(list_unroll_condition)
 def eq__List_List(space, w_list1, w_list2):

pypy/objspace/std/setobject.py

 from rpython.rlib.rarithmetic import intmask, r_uint
 from rpython.rlib import rerased, jit
 
+UNROLL_CUTOFF = 5
+
 class W_BaseSetObject(W_Object):
     typedef = None
 
         raise NotImplementedError
 
     @jit.look_inside_iff(lambda self, list_w:
-                         jit.loop_unrolling_heuristic(list_w, len(list_w)))
+            jit.loop_unrolling_heuristic(list_w, len(list_w), UNROLL_CUTOFF))
     def get_storage_from_list(self, list_w):
         setdata = self.get_empty_dict()
         for w_item in list_w:
         return self.erase(setdata)
 
     @jit.look_inside_iff(lambda self, items:
-                         jit.loop_unrolling_heuristic(items, len(items)))
+            jit.loop_unrolling_heuristic(items, len(items), UNROLL_CUTOFF))
     def get_storage_from_unwrapped_list(self, items):
         setdata = self.get_empty_dict()
         for item in items:
     _pick_correct_strategy(space, w_set, iterable_w)
 
 @jit.look_inside_iff(lambda space, w_set, iterable_w:
-                     jit.loop_unrolling_heuristic(iterable_w, len(iterable_w)))
+        jit.loop_unrolling_heuristic(iterable_w, len(iterable_w), UNROLL_CUTOFF))
 def _pick_correct_strategy(space, w_set, iterable_w):
     # check for integers
     for w_item in iterable_w:

pypy/objspace/std/tupleobject.py

 from rpython.rlib import jit
 from rpython.tool.sourcetools import func_with_new_name
 
+UNROLL_CUTOFF = 10
 
 class W_AbstractTupleObject(W_Object):
     __slots__ = ()
     return space.newtuple(w_tuple.wrappeditems[start:stop])
 
 @jit.look_inside_iff(lambda space, w_tuple, w_obj:
-        jit.loop_unrolling_heuristic(w_tuple, len(w_tuple.wrappeditems)))
+        jit.loop_unrolling_heuristic(w_tuple, len(w_tuple.wrappeditems), UNROLL_CUTOFF))
 def contains__Tuple_ANY(space, w_tuple, w_obj):
     for w_item in w_tuple.wrappeditems:
         if space.eq_w(w_item, w_obj):
     return mul_tuple_times(space, w_tuple, w_times)
 
 def tuple_unroll_condition(space, w_tuple1, w_tuple2):
-    return jit.loop_unrolling_heuristic(w_tuple1, len(w_tuple1.wrappeditems)) or \
-           jit.loop_unrolling_heuristic(w_tuple2, len(w_tuple2.wrappeditems))
+    return jit.loop_unrolling_heuristic(w_tuple1, len(w_tuple1.wrappeditems), UNROLL_CUTOFF) or \
+           jit.loop_unrolling_heuristic(w_tuple2, len(w_tuple2.wrappeditems), UNROLL_CUTOFF)
 
 @jit.look_inside_iff(tuple_unroll_condition)
 def eq__Tuple_Tuple(space, w_tuple1, w_tuple2):
     return space.wrap(hash_tuple(space, w_tuple.wrappeditems))
 
 @jit.look_inside_iff(lambda space, wrappeditems:
-        jit.loop_unrolling_heuristic(wrappeditems, len(wrappeditems)))
+        jit.loop_unrolling_heuristic(wrappeditems, len(wrappeditems), UNROLL_CUTOFF))
 def hash_tuple(space, wrappeditems):
     # this is the CPython 2.4 algorithm (changed from 2.3)
     mult = 1000003

rpython/rlib/jit.py

     return NonConstant(False)
 isvirtual._annspecialcase_ = "specialize:call_location"
 
-UNROLL_CUTOFF = 5
-
 @specialize.call_location()
-def loop_unrolling_heuristic(lst, size):
+def loop_unrolling_heuristic(lst, size, cutoff=2):
     """ In which cases iterating over items of lst can be unrolled
     """
-    return isvirtual(lst) or (isconstant(size) and size <= UNROLL_CUTOFF)
+    return isvirtual(lst) or (isconstant(size) and size <= cutoff)
 
 class Entry(ExtRegistryEntry):
     _about_ = hint