[pypy-commit] pypy vecopt-merge: merged default
plan_rich
noreply at buildbot.pypy.org
Thu Oct 8 13:40:55 CEST 2015
Author: Richard Plangger <planrichi at gmail.com>
Branch: vecopt-merge
Changeset: r80046:b022ce811db0
Date: 2015-10-08 13:40 +0200
http://bitbucket.org/pypy/pypy/changeset/b022ce811db0/
Log: merged default
diff --git a/pypy/module/itertools/__init__.py b/pypy/module/itertools/__init__.py
--- a/pypy/module/itertools/__init__.py
+++ b/pypy/module/itertools/__init__.py
@@ -10,7 +10,6 @@
repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times
Iterators terminating on the shortest input sequence:
- izip(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...
ifilter(pred, seq) --> elements of seq where pred(elem) is True
ifilterfalse(pred, seq) --> elements of seq where pred(elem) is False
islice(seq, [start,] stop [, step]) --> elements from
@@ -22,6 +21,14 @@
takewhile(pred, seq) --> seq[0], seq[1], until pred fails
dropwhile(pred, seq) --> seq[n], seq[n+1], starting when pred fails
groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of keyfunc(v)
+ izip(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...
+ izip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...
+
+ Combinatoric generators:
+ product(p, q, ... [repeat=1]) --> cartesian product
+ permutations(p[, r])
+ combinations(p, r)
+ combinations_with_replacement(p, r)
"""
interpleveldefs = {
diff --git a/pypy/module/itertools/interp_itertools.py b/pypy/module/itertools/interp_itertools.py
--- a/pypy/module/itertools/interp_itertools.py
+++ b/pypy/module/itertools/interp_itertools.py
@@ -649,33 +649,38 @@
class W_IZipLongest(W_IMap):
_error_name = "izip_longest"
+ _immutable_fields_ = ["w_fillvalue"]
+
+ def _fetch(self, index):
+ w_iter = self.iterators_w[index]
+ if w_iter is not None:
+ space = self.space
+ try:
+ return space.next(w_iter)
+ except OperationError, e:
+ if not e.match(space, space.w_StopIteration):
+ raise
+ self.active -= 1
+ if self.active <= 0:
+ # It was the last active iterator
+ raise
+ self.iterators_w[index] = None
+ return self.w_fillvalue
def next_w(self):
- space = self.space
+ # common case: 2 arguments
+ if len(self.iterators_w) == 2:
+ objects = [self._fetch(0), self._fetch(1)]
+ else:
+ objects = self._get_objects()
+ return self.space.newtuple(objects)
+
+ def _get_objects(self):
+ # the loop is out of the way of the JIT
nb = len(self.iterators_w)
-
if nb == 0:
- raise OperationError(space.w_StopIteration, space.w_None)
-
- objects_w = [None] * nb
- for index in range(nb):
- w_value = self.w_fillvalue
- w_it = self.iterators_w[index]
- if w_it is not None:
- try:
- w_value = space.next(w_it)
- except OperationError, e:
- if not e.match(space, space.w_StopIteration):
- raise
-
- self.active -= 1
- if self.active == 0:
- # It was the last active iterator
- raise
- self.iterators_w[index] = None
-
- objects_w[index] = w_value
- return space.newtuple(objects_w)
+ raise OperationError(self.space.w_StopIteration, self.space.w_None)
+ return [self._fetch(index) for index in range(nb)]
def W_IZipLongest___new__(space, w_subtype, __args__):
arguments_w, kwds_w = __args__.unpack()
diff --git a/rpython/jit/codewriter/jtransform.py b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -205,6 +205,8 @@
if v is op.result:
if op.opname not in ('int_lt', 'int_le', 'int_eq', 'int_ne',
'int_gt', 'int_ge',
+ 'float_lt', 'float_le', 'float_eq',
+ 'float_ne', 'float_gt', 'float_ge',
'int_is_zero', 'int_is_true',
'ptr_eq', 'ptr_ne',
'ptr_iszero', 'ptr_nonzero'):
diff --git a/rpython/jit/codewriter/test/test_flatten.py b/rpython/jit/codewriter/test/test_flatten.py
--- a/rpython/jit/codewriter/test/test_flatten.py
+++ b/rpython/jit/codewriter/test/test_flatten.py
@@ -576,7 +576,7 @@
return ovfcheck(i + j)
err = py.test.raises(Exception, "self.encoding_test(f, [7, 2], '',"
"transform=True, liveness=True)")
- assert "ovfcheck()" in str(err)
+ assert "ovfcheck()" in str(err.value)
def test_ovfcheck_reraise(self):
def f(i, j):
diff --git a/rpython/jit/metainterp/blackhole.py b/rpython/jit/metainterp/blackhole.py
--- a/rpython/jit/metainterp/blackhole.py
+++ b/rpython/jit/metainterp/blackhole.py
@@ -672,6 +672,55 @@
b = longlong.getrealfloat(b)
return a >= b
+ @arguments("f", "f", "L", "pc", returns="L")
+ def bhimpl_goto_if_not_float_lt(a, b, target, pc):
+ a = longlong.getrealfloat(a)
+ b = longlong.getrealfloat(b)
+ if a < b:
+ return pc
+ else:
+ return target
+ @arguments("f", "f", "L", "pc", returns="L")
+ def bhimpl_goto_if_not_float_le(a, b, target, pc):
+ a = longlong.getrealfloat(a)
+ b = longlong.getrealfloat(b)
+ if a <= b:
+ return pc
+ else:
+ return target
+ @arguments("f", "f", "L", "pc", returns="L")
+ def bhimpl_goto_if_not_float_eq(a, b, target, pc):
+ a = longlong.getrealfloat(a)
+ b = longlong.getrealfloat(b)
+ if a == b:
+ return pc
+ else:
+ return target
+ @arguments("f", "f", "L", "pc", returns="L")
+ def bhimpl_goto_if_not_float_ne(a, b, target, pc):
+ a = longlong.getrealfloat(a)
+ b = longlong.getrealfloat(b)
+ if a != b:
+ return pc
+ else:
+ return target
+ @arguments("f", "f", "L", "pc", returns="L")
+ def bhimpl_goto_if_not_float_gt(a, b, target, pc):
+ a = longlong.getrealfloat(a)
+ b = longlong.getrealfloat(b)
+ if a > b:
+ return pc
+ else:
+ return target
+ @arguments("f", "f", "L", "pc", returns="L")
+ def bhimpl_goto_if_not_float_ge(a, b, target, pc):
+ a = longlong.getrealfloat(a)
+ b = longlong.getrealfloat(b)
+ if a >= b:
+ return pc
+ else:
+ return target
+
@arguments("f", returns="i")
def bhimpl_cast_float_to_int(a):
a = longlong.getrealfloat(a)
diff --git a/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -358,16 +358,18 @@
self.opimpl_goto_if_not(condbox, target, orgpc)
for _opimpl in ['int_lt', 'int_le', 'int_eq', 'int_ne', 'int_gt', 'int_ge',
- 'ptr_eq', 'ptr_ne']:
+ 'ptr_eq', 'ptr_ne', 'float_lt', 'float_le', 'float_eq',
+ 'float_ne', 'float_gt', 'float_ge']:
exec py.code.Source('''
@arguments("box", "box", "label", "orgpc")
def opimpl_goto_if_not_%s(self, b1, b2, target, orgpc):
- if b1 is b2:
+ if %s and b1 is b2:
condbox = %s
else:
condbox = self.execute(rop.%s, b1, b2)
self.opimpl_goto_if_not(condbox, target, orgpc)
- ''' % (_opimpl, FASTPATHS_SAME_BOXES[_opimpl.split("_")[-1]], _opimpl.upper())
+ ''' % (_opimpl, not _opimpl.startswith('float_'),
+ FASTPATHS_SAME_BOXES[_opimpl.split("_")[-1]], _opimpl.upper())
).compile()
def _establish_nullity(self, box, orgpc):
diff --git a/rpython/jit/metainterp/resoperation.py b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -316,12 +316,17 @@
args = self.getarglist()
descr = self.getdescr()
if descr is None or we_are_translated():
- return '%s%s%s(%s)' % (prefix, sres, self.getopname(),
- ', '.join([a.repr_short(memo) for a in args]))
+ s = '%s%s%s(%s)' % (prefix, sres, self.getopname(),
+ ', '.join([a.repr_short(memo) for a in args]))
else:
- return '%s%s%s(%s)' % (prefix, sres, self.getopname(),
- ', '.join([a.repr_short(memo) for a in args] +
- ['descr=%r' % descr]))
+ s = '%s%s%s(%s)' % (prefix, sres, self.getopname(),
+ ', '.join([a.repr_short(memo) for a in args] +
+ ['descr=%r' % descr]))
+ # --- enable to display the failargs too:
+ #if isinstance(self, GuardResOp):
+ # s += ' [%s]' % (', '.join([a.repr_short(memo) for a in
+ # self.getfailargs()]),)
+ return s
def repr_short(self, memo):
try:
diff --git a/rpython/rlib/_stacklet_shadowstack.py b/rpython/rlib/_stacklet_shadowstack.py
--- a/rpython/rlib/_stacklet_shadowstack.py
+++ b/rpython/rlib/_stacklet_shadowstack.py
@@ -76,9 +76,12 @@
def alloc_stacklet():
new_stacklet = lltype.malloc(STACKLET)
new_stacklet.s_handle = _c.null_handle
+ new_stacklet.s_sscopy = llmemory.NULL
return new_stacklet
def attach_handle_on_stacklet(stacklet, h):
+ ll_assert(stacklet.s_handle == _c.null_handle, "attach stacklet 1: garbage")
+ ll_assert(stacklet.s_sscopy == llmemory.NULL, "attach stacklet 2: garbage")
if not h:
raise MemoryError
elif _c.is_empty_handle(h):
More information about the pypy-commit
mailing list