[pypy-svn] r61685 - pypy/trunk/pypy/rpython

arigo at codespeak.net arigo at codespeak.net
Tue Feb 10 13:02:26 CET 2009


Author: arigo
Date: Tue Feb 10 13:02:25 2009
New Revision: 61685

Modified:
   pypy/trunk/pypy/rpython/rlist.py
Log:
(fijal, arigo)
Two more functions that need a constant-foldable version.


Modified: pypy/trunk/pypy/rpython/rlist.py
==============================================================================
--- pypy/trunk/pypy/rpython/rlist.py	(original)
+++ pypy/trunk/pypy/rpython/rlist.py	Tue Feb 10 13:02:25 2009
@@ -117,11 +117,19 @@
     
     def rtype_len(self, hop):
         v_lst, = hop.inputargs(self)
-        return hop.gendirectcall(ll_len, v_lst)
+        if hop.args_s[0].listdef.listitem.resized:
+            ll_func = ll_len
+        else:
+            ll_func = ll_len_foldable
+        return hop.gendirectcall(ll_func, v_lst)
 
     def rtype_is_true(self, hop):
         v_lst, = hop.inputargs(self)
-        return hop.gendirectcall(ll_list_is_true, v_lst)
+        if hop.args_s[0].listdef.listitem.resized:
+            ll_func = ll_list_is_true
+        else:
+            ll_func = ll_list_is_true_foldable
+        return hop.gendirectcall(ll_func, v_lst)
     
     def rtype_method_reverse(self, hop):
         v_lst, = hop.inputargs(self)
@@ -522,6 +530,16 @@
 ll_list_is_true.oopspec = 'list.nonzero(l)'
 ll_list_is_true.oopargcheck = lambda l: True
 
+def ll_len_foldable(l):
+    return l.ll_length()
+ll_len_foldable.oopspec = 'list.len_foldable(l)'
+ll_len_foldable.oopargcheck = lambda l: bool(l)
+
+def ll_list_is_true_foldable(l):
+    return ll_list_is_true(l)
+ll_list_is_true_foldable.oopspec = 'list.nonzero_foldable(l)'
+ll_list_is_true_foldable.oopargcheck = lambda l: True
+
 def ll_append(l, newitem):
     length = l.ll_length()
     l._ll_resize_ge(length+1)           # see "a note about overflows" above



More information about the Pypy-commit mailing list