aboutsummaryrefslogtreecommitdiff
path: root/pypy
diff options
context:
space:
mode:
authorCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2020-02-19 21:28:33 +0100
committerCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2020-02-19 21:28:33 +0100
commitb5aab55b6b6881eee2e76954af9f846216d2b6aa (patch)
tree8397abf132f74c229d8da62c7bea57ee08747da5 /pypy
parenttypo (diff)
downloadpypy-b5aab55b6b6881eee2e76954af9f846216d2b6aa.tar.gz
pypy-b5aab55b6b6881eee2e76954af9f846216d2b6aa.tar.bz2
pypy-b5aab55b6b6881eee2e76954af9f846216d2b6aa.zip
annoying: the jit main loops get split at the can_enter_jit (or
jit_merge_point), this means that the list iterators (and range iterator) aren't optimized away by backenopt.malloc. just replace these with an index instead
Diffstat (limited to 'pypy')
-rw-r--r--pypy/module/array/interp_array.py8
-rw-r--r--pypy/objspace/std/tupleobject.py16
2 files changed, 18 insertions, 6 deletions
diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
index 19ad6ab823..58927af9b8 100644
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -72,7 +72,8 @@ def compare_arrays(space, arr1, arr2, comp_op):
if comp_op == NE and arr1.len != arr2.len:
return space.w_True
lgt = min(arr1.len, arr2.len)
- for i in range(lgt):
+ i = 0
+ while i < lgt:
arr_eq_driver.jit_merge_point(comp_func=comp_op)
w_elem1 = arr1.w_getitem(space, i, integer_instead_of_char=True)
w_elem2 = arr2.w_getitem(space, i, integer_instead_of_char=True)
@@ -102,6 +103,7 @@ def compare_arrays(space, arr1, arr2, comp_op):
return space.w_False
elif not space.is_true(space.eq(w_elem1, w_elem2)):
return space.w_True
+ i += 1
# we have some leftovers
if comp_op == EQ:
return space.w_True
@@ -128,7 +130,8 @@ def index_count_array(arr, w_val, count=False):
tp_item = space.type(w_val)
arrclass = arr.__class__
cnt = 0
- for i in range(arr.len):
+ i = 0
+ while i < arr.len:
index_count_jd.jit_merge_point(
tp_item=tp_item, count=count,
arrclass=arrclass)
@@ -138,6 +141,7 @@ def index_count_array(arr, w_val, count=False):
cnt += 1
else:
return i
+ i += 1
if count:
return cnt
return -1
diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py
index 9641bad567..d45521ebec 100644
--- a/pypy/objspace/std/tupleobject.py
+++ b/pypy/objspace/std/tupleobject.py
@@ -30,7 +30,7 @@ def _unroll_condition_cmp(self, space, other):
def get_printable_location(tp):
return "tuple.contains [%s]" % (tp.getname(tp.space), )
-contains_jmp = jit.JitDriver(greens = ['tp'], reds = 'auto',
+contains_driver = jit.JitDriver(greens = ['tp'], reds = 'auto',
name = 'tuple.contains',
get_printable_location=get_printable_location)
@@ -168,10 +168,14 @@ class W_AbstractTupleObject(W_Root):
def _descr_contains_jmp(self, space, w_obj):
tp = space.type(w_obj)
- for w_item in self.tolist():
- contains_jmp.jit_merge_point(tp=tp)
+ list_w = self.tolist()
+ i = 0
+ while i < len(list_w):
+ w_item = list_w[i]
+ contains_driver.jit_merge_point(tp=tp)
if space.eq_w(w_obj, w_item):
return space.w_True
+ i += 1
return space.w_False
def descr_add(self, space, w_other):
@@ -316,12 +320,16 @@ class W_TupleObject(W_AbstractTupleObject):
x = 0x345678
z = len(self.wrappeditems)
w_type = space.type(self.wrappeditems[0])
- for w_item in self.wrappeditems:
+ wrappeditems = self.wrappeditems
+ i = 0
+ while i < len(wrappeditems):
hash_driver.jit_merge_point(w_type=w_type)
+ w_item = wrappeditems[i]
y = space.hash_w(w_item)
x = (x ^ y) * mult
z -= 1
mult += 82520 + z + z
+ i += 1
x += 97531
return space.newint(intmask(x))