[pypy-commit] pypy default: list.insert() in RPython should not force the list in the JIT, at least
arigo
pypy.commits at gmail.com
Sun Jan 8 10:30:06 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r89418:9c99515a58a3
Date: 2017-01-08 16:29 +0100
http://bitbucket.org/pypy/pypy/changeset/9c99515a58a3/
Log: list.insert() in RPython should not force the list in the JIT, at
least if the index is constant
diff --git a/rpython/jit/codewriter/support.py b/rpython/jit/codewriter/support.py
--- a/rpython/jit/codewriter/support.py
+++ b/rpython/jit/codewriter/support.py
@@ -210,7 +210,6 @@
return rlist.ll_pop(rlist.dum_checkidx, l, index)
_ll_2_list_append = rlist.ll_append
_ll_2_list_extend = rlist.ll_extend
-_ll_3_list_insert = rlist.ll_insert_nonneg
_ll_2_list_delslice_startonly = rlist.ll_listdelslice_startonly
_ll_3_list_delslice_startstop = rlist.ll_listdelslice_startstop
_ll_2_list_inplace_mul = rlist.ll_inplace_mul
diff --git a/rpython/jit/metainterp/test/test_list.py b/rpython/jit/metainterp/test/test_list.py
--- a/rpython/jit/metainterp/test/test_list.py
+++ b/rpython/jit/metainterp/test/test_list.py
@@ -212,6 +212,8 @@
s += lst[0]
lst.pop()
lst.append(1)
+ lst.insert(0, 5)
+ lst.insert(1, 6)
s *= lst.pop()
return s
res = self.meta_interp(f, [15], listops=True)
diff --git a/rpython/rtyper/rlist.py b/rpython/rtyper/rlist.py
--- a/rpython/rtyper/rlist.py
+++ b/rpython/rtyper/rlist.py
@@ -588,6 +588,7 @@
l.ll_setitem_fast(length, newitem)
# this one is for the special case of insert(0, x)
+ at jit.look_inside_iff(lambda l,n: jit.isvirtual(l))
def ll_prepend(l, newitem):
length = l.ll_length()
l._ll_resize_ge(length+1) # see "a note about overflows" above
@@ -597,7 +598,6 @@
l.ll_setitem_fast(dst, l.ll_getitem_fast(src))
dst = src
l.ll_setitem_fast(0, newitem)
-ll_prepend.oopspec = 'list.insert(l, 0, newitem)'
def ll_concat(RESLIST, l1, l2):
len1 = l1.ll_length()
@@ -612,6 +612,7 @@
return l
# no oopspec -- the function is inlined by the JIT
+ at jit.look_inside_iff(lambda l,i,n: jit.isvirtual(l) and jit.isconstant(i))
def ll_insert_nonneg(l, index, newitem):
length = l.ll_length()
ll_assert(0 <= index, "negative list insertion index")
@@ -623,7 +624,6 @@
l.ll_setitem_fast(dst, l.ll_getitem_fast(src))
dst = src
l.ll_setitem_fast(index, newitem)
-ll_insert_nonneg.oopspec = 'list.insert(l, index, newitem)'
def ll_pop_nonneg(func, l, index):
ll_assert(index >= 0, "unexpectedly negative list pop index")
More information about the pypy-commit
mailing list