[pypy-commit] pypy squeaky/use-cflags-for-compiling-asm: Use CFLAGS
Author: squeaky squeaky...@gmx.com Branch: squeaky/use-cflags-for-compiling-asm Changeset: r75213:e27b54a9d700 Date: 2015-01-02 22:42 + http://bitbucket.org/pypy/pypy/changeset/e27b54a9d700/ Log:Use CFLAGS diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py --- a/rpython/translator/c/genc.py +++ b/rpython/translator/c/genc.py @@ -449,7 +449,7 @@ '-o $*.s -S $ $(INCLUDEDIRS)', '$(PYTHON) $(RPYDIR)/translator/c/gcc/trackgcroot.py ' '-t $*.s $*.gctmp', -'$(CC) -o $*.o -c $*.lbl.s', +'$(CC) $(CFLAGS) -o $*.o -c $*.lbl.s', 'mv $*.gctmp $*.gcmap', 'rm $*.s $*.lbl.s']) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix test_range_iter_simple
Author: Squeaky squeaky...@gmx.com Branch: Changeset: r69716:10e1e307844f Date: 2014-03-05 11:54 +0100 http://bitbucket.org/pypy/pypy/changeset/10e1e307844f/ Log:fix test_range_iter_simple diff --git a/pypy/module/pypyjit/test_pypy_c/test_misc.py b/pypy/module/pypyjit/test_pypy_c/test_misc.py --- a/pypy/module/pypyjit/test_pypy_c/test_misc.py +++ b/pypy/module/pypyjit/test_pypy_c/test_misc.py @@ -176,14 +176,14 @@ loop, = log.loops_by_filename(self.filepath) assert loop.match( guard_not_invalidated? -i16 = int_ge(i11, i12) -guard_false(i16, descr=...) +i16 = int_lt(i11, i12) +guard_true(i16, descr=...) i20 = int_add(i11, 1) i21 = force_token() setfield_gc(p4, i20, descr=.* .*W_AbstractSeqIterObject.inst_index .*) guard_not_invalidated? -i25 = int_ge(i11, i9) -guard_false(i25, descr=...) +i25 = int_lt(i11, i9) +guard_true(i25, descr=...) i27 = int_add_ovf(i7, i11) guard_no_overflow(descr=...) --TICK-- ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: move checks to separate test method
Author: Squeaky squeaky...@gmx.com Branch: Changeset: r69719:838e4aa1dc2d Date: 2014-03-05 12:45 +0100 http://bitbucket.org/pypy/pypy/changeset/838e4aa1dc2d/ Log:move checks to separate test method diff --git a/pypy/objspace/std/test/test_rangeobject.py b/pypy/objspace/std/test/test_rangeobject.py --- a/pypy/objspace/std/test/test_rangeobject.py +++ b/pypy/objspace/std/test/test_rangeobject.py @@ -109,6 +109,7 @@ assert not self.not_forced(r) assert r == [1, 2, 3, 4, 5, 6, 7] +def test_getitem_simple(self): r = range(4) assert r[-1] == 3 assert r[3] == 3 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Backed out changeset: 925eec5518eb, bdk fixed everything properly before
Author: Squeaky squeaky...@gmx.com Branch: Changeset: r69728:75a2fb413619 Date: 2014-03-05 18:12 +0100 http://bitbucket.org/pypy/pypy/changeset/75a2fb413619/ Log:Backed out changeset: 925eec5518eb, bdk fixed everything properly before diff --git a/pypy/module/pypyjit/test_pypy_c/test_misc.py b/pypy/module/pypyjit/test_pypy_c/test_misc.py --- a/pypy/module/pypyjit/test_pypy_c/test_misc.py +++ b/pypy/module/pypyjit/test_pypy_c/test_misc.py @@ -214,10 +214,10 @@ i21 = force_token() setfield_gc(p4, i20, descr=.* .*W_AbstractSeqIterObject.inst_index .*) guard_not_invalidated? -i23 = int_ge(i18, 0) -guard_true(i23, descr=...) -i25 = int_lt(i18, i9) -guard_true(i25, descr=...) +i23 = int_lt(i18, 0) +guard_false(i23, descr=...) +i25 = int_ge(i18, i9) +guard_false(i25, descr=...) i27 = int_add_ovf(i7, i18) guard_no_overflow(descr=...) --TICK-- ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: fix range tests
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69681:499b5b290cd9 Date: 2014-03-04 18:09 +0100 http://bitbucket.org/pypy/pypy/changeset/499b5b290cd9/ Log:fix range tests diff --git a/pypy/objspace/std/test/test_rangeobject.py b/pypy/objspace/std/test/test_rangeobject.py --- a/pypy/objspace/std/test/test_rangeobject.py +++ b/pypy/objspace/std/test/test_rangeobject.py @@ -72,28 +72,28 @@ r.sort(key=lambda x: -x) assert r == range(9, -1, -1) def test_pop(self): -r = range(10) +r = range(1, 10) res = r.pop() assert res == 9 assert self.not_forced(r) -assert repr(r) == repr(range(9)) +assert repr(r) == repr(range(1, 9)) res = r.pop(0) -assert res == 0 +assert res == 1 assert self.not_forced(r) -assert repr(r) == repr(range(1, 9)) +assert repr(r) == repr(range(2, 9)) res = r.pop(len(r) - 1) assert res == 8 assert self.not_forced(r) -assert repr(r) == repr(range(1, 8)) -res = r.pop(2) -assert res == 3 -assert not self.not_forced(r) -assert r == [1, 2, 4, 5, 6, 7] +assert repr(r) == repr(range(2, 8)) res = r.pop(2) assert res == 4 assert not self.not_forced(r) -assert r == [1, 2, 5, 6, 7] - +assert r == [2, 3, 5, 6, 7] +res = r.pop(2) +assert res == 5 +assert not self.not_forced(r) +assert r == [2, 3, 6, 7] + def test_reduce(self): it = iter(range(10)) assert it.next() == 0 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: fix test
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69679:97595f9d3e7f Date: 2014-03-04 17:26 +0100 http://bitbucket.org/pypy/pypy/changeset/97595f9d3e7f/ Log:fix test diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -1154,10 +1154,13 @@ func_with_new_name(_getitems_range, _getitems_range_unroll)) def pop_end(self, w_list): -length_m1 = self.unerase(w_list.lstorage)[0] - 1 -w_result = self.wrap(length_m1) -assert length_m1 0 -w_list.lstorage = self.erase((length_m1,)) +new_length = self.unerase(w_list.lstorage)[0] - 1 +w_result = self.wrap(new_length) +if new_length 0: +w_list.lstorage = self.erase((new_length,)) +else: +strategy = w_list.strategy = self.space.fromcache(EmptyListStrategy) +w_list.lstorage = strategy.erase(None) return w_result def pop(self, w_list, index): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: test for fixed failure
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69678:0697804c87a8 Date: 2014-03-04 14:53 +0100 http://bitbucket.org/pypy/pypy/changeset/0697804c87a8/ Log:test for fixed failure diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -1019,7 +1019,7 @@ raise NotImplementedError def clone(self, w_list): -storage = w_list.lstorage # lstorage is tuple/int, no need to clone +storage = w_list.lstorage # lstorage is tuple, no need to clone w_clone = W_ListObject.from_storage_and_strategy(self.space, storage, self) return w_clone diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py --- a/pypy/objspace/std/test/test_liststrategies.py +++ b/pypy/objspace/std/test/test_liststrategies.py @@ -467,6 +467,8 @@ l.sort(False) assert isinstance(l.strategy, SimpleRangeListStrategy) +assert self.space.eq_w(l.getitem(5), self.space.wrap(5)) + def test_keep_range(self): # simple list l = make_range_list(self.space, 1,1,5) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: finish spliting strategy methods
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69670:0fe74ad8f602 Date: 2014-03-03 20:51 +0100 http://bitbucket.org/pypy/pypy/changeset/0fe74ad8f602/ Log:finish spliting strategy methods diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -1041,6 +1041,52 @@ # tuple/int is immutable return w_list.lstorage +@jit.dont_look_inside +def getitems_fixedsize(self, w_list): +return self._getitems_range_unroll(w_list, True) + +def getitems_unroll(self, w_list): +return self._getitems_range_unroll(w_list, True) + +def getslice(self, w_list, start, stop, step, length): +self.switch_to_integer_strategy(w_list) +return w_list.getslice(start, stop, step, length) + +def append(self, w_list, w_item): +if type(w_item) is W_IntObject: +self.switch_to_integer_strategy(w_list) +else: +w_list.switch_to_object_strategy() +w_list.append(w_item) + +def inplace_mul(self, w_list, times): +self.switch_to_integer_strategy(w_list) +w_list.inplace_mul(times) + +def deleteslice(self, w_list, start, step, slicelength): +self.switch_to_integer_strategy(w_list) +w_list.deleteslice(start, step, slicelength) + +def setitem(self, w_list, index, w_item): +self.switch_to_integer_strategy(w_list) +w_list.setitem(index, w_item) + +def setslice(self, w_list, start, step, slicelength, sequence_w): +self.switch_to_integer_strategy(w_list) +w_list.setslice(start, step, slicelength, sequence_w) + +def insert(self, w_list, index, w_item): +self.switch_to_integer_strategy(w_list) +w_list.insert(index, w_item) + +def extend(self, w_list, w_any): +self.switch_to_integer_strategy(w_list) +w_list.extend(w_any) + +def reverse(self, w_list): +self.switch_to_integer_strategy(w_list) +w_list.reverse() + class SimpleRangeListStrategy(BaseRangeListStrategy): SimpleRangeListStrategy is used when a list is created using the range @@ -1073,6 +1119,42 @@ else: raise IndexError +@specialize.arg(2) +def _getitems_range(self, w_list, wrap_items): +length = self.unerase(w_list.lstorage) +if wrap_items: +r = [None] * length +else: +r = [0] * length +i = 0 +while i length: +if wrap_items: +r[n] = self.wrap(i) +else: +r[n] = i +i += 1 + +return r + +_getitems_range_unroll = jit.unroll_safe( +func_with_new_name(_getitems_range, _getitems_range_unroll)) + +def pop_end(self, w_list): +length_m1 = self.unerase(w_list.lstorage) - 1 +w_result = self.wrap(length_m1) +w_list.lstorage = self.erase(length_m1) +return w_result + +def pop(self, w_list, index): +# XXX could be promoted to RangeListStrategy +self.switch_to_integer_strategy(w_list) +return w_list.pop(index) + +def sort(self, w_list, reverse): +if reverse: +self.switch_to_integer_strategy(w_list) +w_list.sort(reverse) + class RangeListStrategy(BaseRangeListStrategy): RangeListStrategy is used when a list is created using the range method. @@ -1141,34 +1223,9 @@ return r -@jit.dont_look_inside -def getitems_fixedsize(self, w_list): -return self._getitems_range_unroll(w_list, True) - -def getitems_unroll(self, w_list): -return self._getitems_range_unroll(w_list, True) _getitems_range_unroll = jit.unroll_safe( func_with_new_name(_getitems_range, _getitems_range_unroll)) -def getslice(self, w_list, start, stop, step, length): -self.switch_to_integer_strategy(w_list) -return w_list.getslice(start, stop, step, length) - -def append(self, w_list, w_item): -if type(w_item) is W_IntObject: -self.switch_to_integer_strategy(w_list) -else: -w_list.switch_to_object_strategy() -w_list.append(w_item) - -def inplace_mul(self, w_list, times): -self.switch_to_integer_strategy(w_list) -w_list.inplace_mul(times) - -def deleteslice(self, w_list, start, step, slicelength): -self.switch_to_integer_strategy(w_list) -w_list.deleteslice(start, step, slicelength) - def pop_end(self, w_list): start, step, length = self.unerase(w_list.lstorage) w_result = self.wrap(start + (length - 1) * step) @@ -1192,32 +1249,12 @@ self.switch_to_integer_strategy(w_list) return w_list.pop(index) -def setitem(self, w_list, index, w_item): -self.switch_to_integer_strategy(w_list) -w_list.setitem(index, w_item) - -def setslice(self
[pypy-commit] pypy simple-range-strategy: make range now uses SimpeRangeListStrategy
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69671:8d005ad2deff Date: 2014-03-03 21:02 +0100 http://bitbucket.org/pypy/pypy/changeset/8d005ad2deff/ Log:make range now uses SimpeRangeListStrategy diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -43,6 +43,9 @@ if length = 0: strategy = space.fromcache(EmptyListStrategy) storage = strategy.erase(None) +elif start == 0 and step == 1 and length = 2 ** 31 - 1: +strategy = space.fromcache(SimpleRangeListStrategy) +storage = strategy.erase(length) else: strategy = space.fromcache(RangeListStrategy) storage = strategy.erase((start, step, length)) @@ -1084,6 +1087,7 @@ w_list.extend(w_any) def reverse(self, w_list): +# XXX this could be specialized for SimpleRange to promote to Range self.switch_to_integer_strategy(w_list) w_list.reverse() @@ -1129,9 +1133,9 @@ i = 0 while i length: if wrap_items: -r[n] = self.wrap(i) +r[i] = self.wrap(i) else: -r[n] = i +r[i] = i i += 1 return r ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: move sort to base class
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69676:1e70d4d7d970 Date: 2014-03-04 12:43 +0100 http://bitbucket.org/pypy/pypy/changeset/1e70d4d7d970/ Log:move sort to base class diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -1088,15 +1088,20 @@ w_list.extend(w_any) def reverse(self, w_list): -# XXX this could be specialized for SimpleRange to promote to Range self.switch_to_integer_strategy(w_list) w_list.reverse() +def sort(self, w_list, reverse): +step = self.step(w_list) +if step 0 and reverse or step 0 and not reverse: +self.switch_to_integer_strategy(w_list) +w_list.sort(reverse) + class SimpleRangeListStrategy(BaseRangeListStrategy): SimpleRangeListStrategy is used when a list is created using the range method providing only positive length. The storage is a one element tuple - with positive integer less than 2**31 - 1 storing length. + with positive integer storing length. _applevel_repr = simple_range @@ -1117,6 +1122,9 @@ def length(self, w_list): return self.unerase(w_list.lstorage)[0] +def step(self, w_list): +return 1 + def _getitem_unwrapped(self, w_list, i): length = self.unerase(w_list.lstorage) if 0 = i length: @@ -1155,11 +1163,6 @@ self.switch_to_integer_strategy(w_list) return w_list.pop(index) -def sort(self, w_list, reverse): -if reverse: -self.switch_to_integer_strategy(w_list) -w_list.sort(reverse) - class RangeListStrategy(BaseRangeListStrategy): RangeListStrategy is used when a list is created using the range method. @@ -1193,6 +1196,9 @@ def length(self, w_list): return self.unerase(w_list.lstorage)[2] +def step(self, w_list): +return self.unerase(w_list.lstorage)[1] + def _getitem_unwrapped(self, w_list, i): v = self.unerase(w_list.lstorage) start = v[0] @@ -1254,12 +1260,6 @@ self.switch_to_integer_strategy(w_list) return w_list.pop(index) -def sort(self, w_list, reverse): -step = self.unerase(w_list.lstorage)[1] -if step 0 and reverse or step 0 and not reverse: -self.switch_to_integer_strategy(w_list) -w_list.sort(reverse) - class AbstractUnwrappedStrategy(object): diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py --- a/pypy/objspace/std/test/test_liststrategies.py +++ b/pypy/objspace/std/test/test_liststrategies.py @@ -460,8 +460,12 @@ assert l.length() == 5 +l = make_range_list(self.space, 0, 1, 1) +assert self.space.eq_w(l.pop(0), self.space.wrap(0)) - +l = make_range_list(self.space, 0, 1, 10) +l.sort(False) +assert isinstance(l.strategy, SimpleRangeListStrategy) def test_keep_range(self): # simple list ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: update test_pop in test_rangeobject
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69682:0e7a793d817a Date: 2014-03-04 18:14 +0100 http://bitbucket.org/pypy/pypy/changeset/0e7a793d817a/ Log:update test_pop in test_rangeobject diff --git a/pypy/objspace/std/test/test_rangeobject.py b/pypy/objspace/std/test/test_rangeobject.py --- a/pypy/objspace/std/test/test_rangeobject.py +++ b/pypy/objspace/std/test/test_rangeobject.py @@ -72,6 +72,7 @@ r.sort(key=lambda x: -x) assert r == range(9, -1, -1) def test_pop(self): +# RangeListStrategy r = range(1, 10) res = r.pop() assert res == 9 @@ -94,6 +95,19 @@ assert not self.not_forced(r) assert r == [2, 3, 6, 7] +# SimpleRangeListStrategy +r = range(10) +res = r.pop() +assert res == 9 +assert self.not_forced(r) +res = r.pop() +assert res == 8 +assert self.not_forced(r) +res = r.pop(0) +assert res == 0 +assert not self.not_forced(r) +assert r == [1, 2, 3, 4, 5, 6, 7] + def test_reduce(self): it = iter(range(10)) assert it.next() == 0 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: progress
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69669:8e13e6806176 Date: 2014-03-03 19:43 +0100 http://bitbucket.org/pypy/pypy/changeset/8e13e6806176/ Log:progress diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -1000,26 +1000,6 @@ class BaseRangeListStrategy(ListStrategy): -pass - - -class SimpleRangeListStrategy(BaseRangeListStrategy): -SimpleRangeListStrategy is used when a list is created using the range - method providing only positive length. The storage is a positive integer - less than 2**31 - 1 storing length. - -_applevel_repr = simple_range - - -class RangeListStrategy(BaseRangeListStrategy): -RangeListStrategy is used when a list is created using the range method. -The storage is a tuple containing only three integers start, step and -length and elements are calculated based on these values. On any operation -destroying the range (inserting, appending non-ints) the strategy is -switched to IntegerListStrategy. - -_applevel_repr = range - def switch_to_integer_strategy(self, w_list): items = self._getitems_range(w_list, False) strategy = w_list.strategy = self.space.fromcache(IntegerListStrategy) @@ -1034,12 +1014,8 @@ def init_from_list_w(self, w_list, list_w): raise NotImplementedError -erase, unerase = rerased.new_erasing_pair(range) -erase = staticmethod(erase) -unerase = staticmethod(unerase) - def clone(self, w_list): -storage = w_list.lstorage # lstorage is tuple, no need to clone +storage = w_list.lstorage # lstorage is tuple/int, no need to clone w_clone = W_ListObject.from_storage_and_strategy(self.space, storage, self) return w_clone @@ -1052,6 +1028,65 @@ w_other.strategy = self w_other.lstorage = w_list.lstorage +def getitem(self, w_list, i): +return self.wrap(self._getitem_unwrapped(w_list, i)) + +def getitems_int(self, w_list): +return self._getitems_range(w_list, False) + +def getitems_copy(self, w_list): +return self._getitems_range(w_list, True) + +def getstorage_copy(self, w_list): +# tuple/int is immutable +return w_list.lstorage + + +class SimpleRangeListStrategy(BaseRangeListStrategy): +SimpleRangeListStrategy is used when a list is created using the range + method providing only positive length. The storage is a positive integer + less than 2**31 - 1 storing length. + +_applevel_repr = simple_range + +erase, unerase = rerased.new_erasing_pair(simple_range) +erase = staticmethod(erase) +unerase = staticmethod(unerase) + +def find(self, w_list, w_obj, startindex, stopindex): +if type(w_obj) is W_IntObject: +obj = self.unwrap(w_obj) +length = self.unerase(w_list.lstorage) +if 0 = obj length and startindex = obj stopindex: +return obj +else: +raise ValueError +return ListStrategy.find(self, w_list, w_obj, startindex, stopindex) + +def length(self, w_list): +return self.unerase(w_list.lstorage) + +def _getitem_unwrapped(self, w_list, i): +length = self.unerase(w_list.lstorage) +if 0 = i length: +return i +else: +raise IndexError + + +class RangeListStrategy(BaseRangeListStrategy): +RangeListStrategy is used when a list is created using the range method. +The storage is a tuple containing only three integers start, step and +length and elements are calculated based on these values. On any operation +destroying the range (inserting, appending non-ints) the strategy is +switched to IntegerListStrategy. + +_applevel_repr = range + +erase, unerase = rerased.new_erasing_pair(range) +erase = staticmethod(erase) +unerase = staticmethod(unerase) + def find(self, w_list, w_obj, startindex, stopindex): if type(w_obj) is W_IntObject: obj = self.unwrap(w_obj) @@ -1084,19 +1119,6 @@ raise IndexError return start + i * step -def getitems_int(self, w_list): -return self._getitems_range(w_list, False) - -def getitem(self, w_list, i): -return self.wrap(self._getitem_unwrapped(w_list, i)) - -def getitems_copy(self, w_list): -return self._getitems_range(w_list, True) - -def getstorage_copy(self, w_list): -# tuple is unmutable -return w_list.lstorage - @specialize.arg(2) def _getitems_range(self, w_list, wrap_items): l = self.unerase(w_list.lstorage) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: some asserts for annotator
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69674:b80212121437 Date: 2014-03-04 11:28 +0100 http://bitbucket.org/pypy/pypy/changeset/b80212121437/ Log:some asserts for annotator diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -43,8 +43,9 @@ if length = 0: strategy = space.fromcache(EmptyListStrategy) storage = strategy.erase(None) -elif start == 0 and step == 1 and length = 2 ** 31 - 1: +elif start == 0 and step == 1: strategy = space.fromcache(SimpleRangeListStrategy) +assert length 0 storage = strategy.erase((length,)) else: strategy = space.fromcache(RangeListStrategy) @@ -1146,11 +1147,11 @@ def pop_end(self, w_list): length_m1 = self.unerase(w_list.lstorage)[0] - 1 w_result = self.wrap(length_m1) +assert length_m1 0 w_list.lstorage = self.erase((length_m1,)) return w_result def pop(self, w_list, index): -# XXX could be promoted to RangeListStrategy self.switch_to_integer_strategy(w_list) return w_list.pop(index) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: want more test case
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69680:d0f90833cf28 Date: 2014-03-04 17:31 +0100 http://bitbucket.org/pypy/pypy/changeset/d0f90833cf28/ Log:want more test case diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py --- a/pypy/objspace/std/test/test_liststrategies.py +++ b/pypy/objspace/std/test/test_liststrategies.py @@ -469,6 +469,10 @@ assert self.space.eq_w(l.getitem(5), self.space.wrap(5)) +l = make_range_list(self.space, 0, 1, 1) +assert self.space.eq_w(l.pop_end(), self.space.wrap(0)) +assert isinstance(l.strategy, EmptyListStrategy) + def test_keep_range(self): # simple list l = make_range_list(self.space, 1,1,5) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: use tuple for storage
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69673:16d6e5eb5c28 Date: 2014-03-04 11:18 +0100 http://bitbucket.org/pypy/pypy/changeset/16d6e5eb5c28/ Log:use tuple for storage diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -45,7 +45,7 @@ storage = strategy.erase(None) elif start == 0 and step == 1 and length = 2 ** 31 - 1: strategy = space.fromcache(SimpleRangeListStrategy) -storage = strategy.erase(length) +storage = strategy.erase((length,)) else: strategy = space.fromcache(RangeListStrategy) storage = strategy.erase((start, step, length)) @@ -1041,7 +1041,7 @@ return self._getitems_range(w_list, True) def getstorage_copy(self, w_list): -# tuple/int is immutable +# tuple is immutable return w_list.lstorage @jit.dont_look_inside @@ -1094,8 +1094,8 @@ class SimpleRangeListStrategy(BaseRangeListStrategy): SimpleRangeListStrategy is used when a list is created using the range - method providing only positive length. The storage is a positive integer - less than 2**31 - 1 storing length. + method providing only positive length. The storage is a one element tuple + with positive integer less than 2**31 - 1 storing length. _applevel_repr = simple_range @@ -1106,7 +1106,7 @@ def find(self, w_list, w_obj, startindex, stopindex): if type(w_obj) is W_IntObject: obj = self.unwrap(w_obj) -length = self.unerase(w_list.lstorage) +length = self.unerase(w_list.lstorage)[0] if 0 = obj length and startindex = obj stopindex: return obj else: @@ -1114,7 +1114,7 @@ return ListStrategy.find(self, w_list, w_obj, startindex, stopindex) def length(self, w_list): -return self.unerase(w_list.lstorage) +return self.unerase(w_list.lstorage)[0] def _getitem_unwrapped(self, w_list, i): length = self.unerase(w_list.lstorage) @@ -1125,7 +1125,7 @@ @specialize.arg(2) def _getitems_range(self, w_list, wrap_items): -length = self.unerase(w_list.lstorage) +length = self.unerase(w_list.lstorage)[0] if wrap_items: r = [None] * length else: @@ -1144,9 +1144,9 @@ func_with_new_name(_getitems_range, _getitems_range_unroll)) def pop_end(self, w_list): -length_m1 = self.unerase(w_list.lstorage) - 1 +length_m1 = self.unerase(w_list.lstorage)[0] - 1 w_result = self.wrap(length_m1) -w_list.lstorage = self.erase(length_m1) +w_list.lstorage = self.erase((length_m1,)) return w_result def pop(self, w_list, index): diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py --- a/pypy/objspace/std/test/test_liststrategies.py +++ b/pypy/objspace/std/test/test_liststrategies.py @@ -418,7 +418,6 @@ assert isinstance(l.strategy, SimpleRangeListStrategy) v = l.pop(0) assert self.space.eq_w(v, self.space.wrap(0)) -# XXX promote to RangeListStrategy assert isinstance(l.strategy, IntegerListStrategy) l = make_range_list(self.space, 0, 1, 10) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Implements SimpleRangeListStrategy for case range(n) where n is a positive number.
Author: Squeaky squeaky...@gmx.com Branch: Changeset: r69685:4d70ac4b69b1 Date: 2014-03-04 18:47 +0100 http://bitbucket.org/pypy/pypy/changeset/4d70ac4b69b1/ Log:Implements SimpleRangeListStrategy for case range(n) where n is a positive number. diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -94,3 +94,8 @@ .. branch: test-58c3d8552833 Fix for getarrayitem_gc_pure optimization + +.. branch: simple-range-strategy +Implements SimpleRangeListStrategy for case range(n) where n is a positive number. +Makes some traces nicer by getting rid of multiplication for calculating loop counter +and propagates that n 0 further to get rid of guards. diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -43,6 +43,10 @@ if length = 0: strategy = space.fromcache(EmptyListStrategy) storage = strategy.erase(None) +elif start == 0 and step == 1: +strategy = space.fromcache(SimpleRangeListStrategy) +assert length 0 +storage = strategy.erase((length,)) else: strategy = space.fromcache(RangeListStrategy) storage = strategy.erase((start, step, length)) @@ -999,15 +1003,7 @@ self.sizehint = hint -class RangeListStrategy(ListStrategy): -RangeListStrategy is used when a list is created using the range method. -The storage is a tuple containing only three integers start, step and -length and elements are calculated based on these values. On any operation -destroying the range (inserting, appending non-ints) the strategy is -switched to IntegerListStrategy. - -_applevel_repr = range - +class BaseRangeListStrategy(ListStrategy): def switch_to_integer_strategy(self, w_list): items = self._getitems_range(w_list, False) strategy = w_list.strategy = self.space.fromcache(IntegerListStrategy) @@ -1022,10 +1018,6 @@ def init_from_list_w(self, w_list, list_w): raise NotImplementedError -erase, unerase = rerased.new_erasing_pair(range) -erase = staticmethod(erase) -unerase = staticmethod(unerase) - def clone(self, w_list): storage = w_list.lstorage # lstorage is tuple, no need to clone w_clone = W_ListObject.from_storage_and_strategy(self.space, storage, @@ -1040,6 +1032,155 @@ w_other.strategy = self w_other.lstorage = w_list.lstorage +def getitem(self, w_list, i): +return self.wrap(self._getitem_unwrapped(w_list, i)) + +def getitems_int(self, w_list): +return self._getitems_range(w_list, False) + +def getitems_copy(self, w_list): +return self._getitems_range(w_list, True) + +def getstorage_copy(self, w_list): +# tuple is immutable +return w_list.lstorage + +@jit.dont_look_inside +def getitems_fixedsize(self, w_list): +return self._getitems_range_unroll(w_list, True) + +def getitems_unroll(self, w_list): +return self._getitems_range_unroll(w_list, True) + +def getslice(self, w_list, start, stop, step, length): +self.switch_to_integer_strategy(w_list) +return w_list.getslice(start, stop, step, length) + +def append(self, w_list, w_item): +if type(w_item) is W_IntObject: +self.switch_to_integer_strategy(w_list) +else: +w_list.switch_to_object_strategy() +w_list.append(w_item) + +def inplace_mul(self, w_list, times): +self.switch_to_integer_strategy(w_list) +w_list.inplace_mul(times) + +def deleteslice(self, w_list, start, step, slicelength): +self.switch_to_integer_strategy(w_list) +w_list.deleteslice(start, step, slicelength) + +def setitem(self, w_list, index, w_item): +self.switch_to_integer_strategy(w_list) +w_list.setitem(index, w_item) + +def setslice(self, w_list, start, step, slicelength, sequence_w): +self.switch_to_integer_strategy(w_list) +w_list.setslice(start, step, slicelength, sequence_w) + +def insert(self, w_list, index, w_item): +self.switch_to_integer_strategy(w_list) +w_list.insert(index, w_item) + +def extend(self, w_list, w_any): +self.switch_to_integer_strategy(w_list) +w_list.extend(w_any) + +def reverse(self, w_list): +self.switch_to_integer_strategy(w_list) +w_list.reverse() + +def sort(self, w_list, reverse): +step = self.step(w_list) +if step 0 and reverse or step 0 and not reverse: +self.switch_to_integer_strategy(w_list) +w_list.sort(reverse) + + +class SimpleRangeListStrategy(BaseRangeListStrategy): +SimpleRangeListStrategy is used when a list is created using the range + method providing only positive length. The storage is a one element tuple
[pypy-commit] pypy simple-range-strategy: oops
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69677:8d186d3ee7de Date: 2014-03-04 14:08 +0100 http://bitbucket.org/pypy/pypy/changeset/8d186d3ee7de/ Log:oops diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -1126,7 +1126,8 @@ return 1 def _getitem_unwrapped(self, w_list, i): -length = self.unerase(w_list.lstorage) +length = self.unerase(w_list.lstorage)[0] +assert length 0 if 0 = i length: return i else: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: fix tests and add more
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69672:dd78cd5b33b4 Date: 2014-03-03 22:11 +0100 http://bitbucket.org/pypy/pypy/changeset/dd78cd5b33b4/ Log:fix tests and add more diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -1616,7 +1616,7 @@ _base_extend_from_list = _extend_from_list def _extend_from_list(self, w_list, w_other): -if w_other.strategy is self.space.fromcache(RangeListStrategy): +if isinstance(w_other.strategy, BaseRangeListStrategy): l = self.unerase(w_list.lstorage) other = w_other.getitems_int() assert other is not None diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py --- a/pypy/objspace/std/test/test_liststrategies.py +++ b/pypy/objspace/std/test/test_liststrategies.py @@ -1,5 +1,8 @@ import sys -from pypy.objspace.std.listobject import W_ListObject, EmptyListStrategy, ObjectListStrategy, IntegerListStrategy, FloatListStrategy, BytesListStrategy, RangeListStrategy, make_range_list, UnicodeListStrategy +from pypy.objspace.std.listobject import ( +W_ListObject, EmptyListStrategy, ObjectListStrategy, IntegerListStrategy, +FloatListStrategy, BytesListStrategy, RangeListStrategy, +SimpleRangeListStrategy, make_range_list, UnicodeListStrategy) from pypy.objspace.std import listobject from pypy.objspace.std.test.test_listobject import TestW_ListObject @@ -18,7 +21,7 @@ UnicodeListStrategy) assert isinstance(W_ListObject(space, [w(u'a'), w('b')]).strategy, ObjectListStrategy) # mixed unicode and bytes - + def test_empty_to_any(self): space = self.space w = space.wrap @@ -183,7 +186,7 @@ def test_setslice(self): space = self.space w = space.wrap - + l = W_ListObject(space, []) assert isinstance(l.strategy, EmptyListStrategy) l.setslice(0, 1, 2, W_ListObject(space, [w(1), w(2), w(3)])) @@ -286,7 +289,7 @@ def test_empty_setslice_with_objectlist(self): space = self.space w = space.wrap - + l = W_ListObject(space, []) o = W_ListObject(space, [space.wrap(1), space.wrap(2), space.wrap(3)]) l.setslice(0, 1, o.length(), o) @@ -347,6 +350,13 @@ empty = W_ListObject(space, []) assert isinstance(empty.strategy, EmptyListStrategy) +r = make_range_list(space, 0, 1, 10) +empty.extend(r) +assert isinstance(empty.strategy, SimpleRangeListStrategy) +assert space.is_true(space.eq(empty.getitem(1), w(1))) + +empty = W_ListObject(space, []) +assert isinstance(empty.strategy, EmptyListStrategy) empty.extend(W_ListObject(space, [w(1), w(2), w(3)])) assert isinstance(empty.strategy, IntegerListStrategy) @@ -397,6 +407,40 @@ l.append(self.space.wrap(19)) assert isinstance(l.strategy, IntegerListStrategy) +def test_simplerangelist(self): +l = make_range_list(self.space, 0, 1, 10) +assert isinstance(l.strategy, SimpleRangeListStrategy) +v = l.pop(5) +assert self.space.eq_w(v, self.space.wrap(5)) +assert isinstance(l.strategy, IntegerListStrategy) + +l = make_range_list(self.space, 0, 1, 10) +assert isinstance(l.strategy, SimpleRangeListStrategy) +v = l.pop(0) +assert self.space.eq_w(v, self.space.wrap(0)) +# XXX promote to RangeListStrategy +assert isinstance(l.strategy, IntegerListStrategy) + +l = make_range_list(self.space, 0, 1, 10) +assert isinstance(l.strategy, SimpleRangeListStrategy) +v = l.pop_end() +assert self.space.eq_w(v, self.space.wrap(9)) +assert isinstance(l.strategy, SimpleRangeListStrategy) +v = l.pop_end() +assert self.space.eq_w(v, self.space.wrap(8)) +assert isinstance(l.strategy, SimpleRangeListStrategy) + +l = make_range_list(self.space, 0, 1, 5) +assert isinstance(l.strategy, SimpleRangeListStrategy) +l.append(self.space.wrap(string)) +assert isinstance(l.strategy, ObjectListStrategy) + +l = make_range_list(self.space, 0,1,5) +assert isinstance(l.strategy, SimpleRangeListStrategy) +l.append(self.space.wrap(19)) +assert isinstance(l.strategy, IntegerListStrategy) + + def test_keep_range(self): # simple list l = make_range_list(self.space, 1,1,5) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: and this
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69683:eb5fef9132bf Date: 2014-03-04 18:16 +0100 http://bitbucket.org/pypy/pypy/changeset/eb5fef9132bf/ Log:and this diff --git a/pypy/objspace/std/test/test_rangeobject.py b/pypy/objspace/std/test/test_rangeobject.py --- a/pypy/objspace/std/test/test_rangeobject.py +++ b/pypy/objspace/std/test/test_rangeobject.py @@ -102,6 +102,7 @@ assert self.not_forced(r) res = r.pop() assert res == 8 +assert repr(r) == repr(range(8)) assert self.not_forced(r) res = r.pop(0) assert res == 0 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy simple-range-strategy: Close merged branch
Author: Squeaky squeaky...@gmx.com Branch: simple-range-strategy Changeset: r69686:c20fe0db3889 Date: 2014-03-04 18:48 +0100 http://bitbucket.org/pypy/pypy/changeset/c20fe0db3889/ Log:Close merged branch ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: add and test next_power2 utility
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69188:5eca705b5884 Date: 2014-02-17 14:51 +0100 http://bitbucket.org/pypy/pypy/changeset/5eca705b5884/ Log:add and test next_power2 utility diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -23,6 +23,17 @@ return (1 ((byte_size 3) - 1)) - 1 +def next_power2(val): +Calculate next power of 2 greater than val. + + Danger: this can overflow, use only when val is sufficiently + lower than symbolic.WORD +power = 1 +while power val + 1: +power = 1 +return power + + class OptIntBounds(Optimization): Keeps track of the bounds placed on integers by guards and remove redundant guards @@ -82,6 +93,8 @@ val = v1.box.getint() if val = 0: r.intbound.intersect(IntBound(0, val)) +elif v1.intbound.lower = 0 and v2.intbound.lower = 0: +pass def optimize_INT_SUB(self, op): v1 = self.getvalue(op.getarg(0)) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_intbounds.py b/rpython/jit/metainterp/optimizeopt/test/test_intbounds.py new file mode 100644 --- /dev/null +++ b/rpython/jit/metainterp/optimizeopt/test/test_intbounds.py @@ -0,0 +1,10 @@ +from rpython.jit.metainterp.optimizeopt.intbounds import next_power2 + + +def test_next_power2(): +assert next_power2(0) == 1 +assert next_power2(1) == 2 +assert next_power2(7) == 8 +assert next_power2(256) == 512 +assert next_power2(255) == 256 +assert next_power2(80) == 128 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: implement optimization and fix the test
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69192:0e8fc6825162 Date: 2014-02-17 16:55 +0100 http://bitbucket.org/pypy/pypy/changeset/0e8fc6825162/ Log:implement optimization and fix the test diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -68,6 +68,19 @@ optimize_GUARD_FALSE = optimize_GUARD_TRUE optimize_GUARD_VALUE = optimize_GUARD_TRUE +def optimize_INT_OR(self, op): +v1 = self.getvalue(op.getarg(0)) +v2 = self.getvalue(op.getarg(1)) +self.emit_operation(op) +r = self.getvalue(op.result) + +if v1.intbound.lower = 0 and v2.intbound.lower = 0: +mostsignificant = v1.intbound.upper | v2.intbound.upper +# check if next_power2 won't overflow +if mostsignificant (1 ((symbolic.WORD - 1) 3)): +r.intbound.intersect( +IntBound(0, next_power2(mostsignificant) - 1)) + def optimize_INT_XOR(self, op): v1 = self.getvalue(op.getarg(0)) v2 = self.getvalue(op.getarg(1)) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: stylistic tweaks
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69194:f4da31595578 Date: 2014-02-17 18:01 +0100 http://bitbucket.org/pypy/pypy/changeset/f4da31595578/ Log:stylistic tweaks diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -74,7 +74,8 @@ self.emit_operation(op) r = self.getvalue(op.result) -if v1.intbound.lower = 0 and v2.intbound.lower = 0: +if v1.intbound.known_ge(IntBound(0, 0)) and \ + v2.intbound.known_ge(IntBound(0, 0)): mostsignificant = v1.intbound.upper | v2.intbound.upper # check if next_power2 won't overflow if mostsignificant (1 ((symbolic.WORD - 1) 3)): @@ -92,11 +93,11 @@ v2.intbound.known_ge(IntBound(0, 0)): r = self.getvalue(op.result) r.intbound.make_ge(IntLowerBound(0)) -if v1.intbound.lower = 0 and v2.intbound.lower = 0: -lesser = min(v1.intbound.upper, v2.intbound.upper) + +mostsignificant = v1.intbound.upper | v2.intbound.upper # check if next_power2 won't overflow -if lesser (1 ((symbolic.WORD - 1) 3)): -r.intbound.intersect(IntBound(0, next_power2(lesser) - 1)) +if mostsignificant (1 ((symbolic.WORD - 1) 3)): +r.intbound.make_lt(IntUpperBound(next_power2(mostsignificant))) def optimize_INT_AND(self, op): @@ -113,7 +114,8 @@ val = v1.box.getint() if val = 0: r.intbound.intersect(IntBound(0, val)) -elif v1.intbound.lower = 0 and v2.intbound.lower = 0: +elif v1.intbound.known_ge(IntBound(0, 0)) and \ + v2.intbound.known_ge(IntBound(0, 0)): lesser = min(v1.intbound.upper, v2.intbound.upper) # check if next_power2 won't overflow if lesser (1 ((symbolic.WORD - 1) 3)): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: create branch
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69186:6835ecfc3a5b Date: 2014-02-17 15:49 +0100 http://bitbucket.org/pypy/pypy/changeset/6835ecfc3a5b/ Log:create branch ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: tweak test to bounding value
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69189:fc047124598c Date: 2014-02-17 15:31 +0100 http://bitbucket.org/pypy/pypy/changeset/fc047124598c/ Log:tweak test to bounding value diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5352,7 +5352,7 @@ i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) i2 = int_and(i0, i1) -i3 = int_le(i2, 80) +i3 = int_lt(i2, 255) guard_true(i3) [] jump(i2) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: test for int_xor and fix
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69193:531ef2c5d656 Date: 2014-02-17 17:34 +0100 http://bitbucket.org/pypy/pypy/changeset/531ef2c5d656/ Log:test for int_xor and fix diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -92,6 +92,12 @@ v2.intbound.known_ge(IntBound(0, 0)): r = self.getvalue(op.result) r.intbound.make_ge(IntLowerBound(0)) +if v1.intbound.lower = 0 and v2.intbound.lower = 0: +lesser = min(v1.intbound.upper, v2.intbound.upper) +# check if next_power2 won't overflow +if lesser (1 ((symbolic.WORD - 1) 3)): +r.intbound.intersect(IntBound(0, next_power2(lesser) - 1)) + def optimize_INT_AND(self, op): v1 = self.getvalue(op.getarg(0)) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5390,6 +5390,38 @@ self.optimize_loop(ops, ops) +def test_int_xor_cmp_above_bounds(self): +ops = +[p0] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i2 = int_xor(i0, i1) +i3 = int_le(i2, 255) +guard_true(i3) [] +jump(i2) + + +expected = +[p0] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i2 = int_xor(i0, i1) +jump(i2) + +self.optimize_loop(ops, expected) + +def test_int_xor_cmp_below_bounds(self): +ops = +[p0] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i2 = int_xor(i0, i1) +i3 = int_lt(i2, 255) +guard_true(i3) [] +jump(i2) + +self.optimize_loop(ops, ops) + class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: add bounds propagation from INT_AND
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69190:41581d8d194b Date: 2014-02-17 15:24 +0100 http://bitbucket.org/pypy/pypy/changeset/41581d8d194b/ Log:add bounds propagation from INT_AND diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -7,6 +7,7 @@ CONST_0, MODE_ARRAY, MODE_STR, MODE_UNICODE) from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method from rpython.jit.metainterp.resoperation import rop +from rpython.jit.backend.llsupport import symbolic def get_integer_min(is_unsigned, byte_size): @@ -94,7 +95,10 @@ if val = 0: r.intbound.intersect(IntBound(0, val)) elif v1.intbound.lower = 0 and v2.intbound.lower = 0: -pass +lesser = min(v1.intbound.upper, v2.intbound.upper) +# check if next_power2 won't overflow +if lesser (1 ((symbolic.WORD - 1) 3)): +r.intbound.intersect(IntBound(0, next_power2(lesser) - 1)) def optimize_INT_SUB(self, op): v1 = self.getvalue(op.getarg(0)) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: failing and passing test
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69187:17814d1be480 Date: 2014-02-17 13:03 +0100 http://bitbucket.org/pypy/pypy/changeset/17814d1be480/ Log:failing and passing test diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5326,6 +5326,38 @@ self.optimize_loop(ops, ops) +def test_int_and_cmp_above_bounds(self): +ops = +[p0] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i2 = int_and(i0, i1) +i3 = int_le(i2, 255) +guard_true(i3) [] +jump(i2) + + +expected = +[p0] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i2 = int_and(i0, i1) +jump(i2) + +self.optimize_loop(ops, expected) + +def test_int_and_cmp_below_bounds(self): +ops = +[p0] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i2 = int_and(i0, i1) +i3 = int_le(i2, 80) +guard_true(i3) [] +jump(i2) + +self.optimize_loop(ops, ops) + class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin): pass ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: rewrite to use power of two minus 2, no more overflow
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69199:e19230cb6257 Date: 2014-02-17 21:14 +0100 http://bitbucket.org/pypy/pypy/changeset/e19230cb6257/ Log:rewrite to use power of two minus 2, no more overflow diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -81,12 +81,8 @@ if v1.intbound.known_ge(IntBound(0, 0)) and \ v2.intbound.known_ge(IntBound(0, 0)): r = self.getvalue(op.result) -r.intbound.make_ge(IntLowerBound(0)) - mostsignificant = v1.intbound.upper | v2.intbound.upper -# check if next_power2 won't overflow -if mostsignificant (1 ((symbolic.WORD - 1) 3)): -r.intbound.make_lt(IntUpperBound(next_power2(mostsignificant))) +r.intbound.intersect(IntBound(0, next_pow2_m1(mostsignificant))) optimize_INT_OR = optimize_INT_OR_or_XOR optimize_INT_XOR = optimize_INT_OR_or_XOR @@ -108,9 +104,7 @@ elif v1.intbound.known_ge(IntBound(0, 0)) and \ v2.intbound.known_ge(IntBound(0, 0)): lesser = min(v1.intbound.upper, v2.intbound.upper) -# check if next_power2 won't overflow -if lesser (1 ((symbolic.WORD - 1) 3)): -r.intbound.intersect(IntBound(0, next_power2(lesser) - 1)) +r.intbound.intersect(IntBound(0, next_pow2_m1(lesser))) def optimize_INT_SUB(self, op): v1 = self.getvalue(op.getarg(0)) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5422,7 +5422,7 @@ self.optimize_loop(ops, ops) -def test_or_same_arg(self): +def test_int_or_same_arg(self): ops = [i0] i1 = int_or(i0, i0) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: improve tests
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69195:cd8ee0a2d7af Date: 2014-02-17 18:50 +0100 http://bitbucket.org/pypy/pypy/changeset/cd8ee0a2d7af/ Log:improve tests diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5328,9 +5328,9 @@ def test_int_and_cmp_above_bounds(self): ops = -[p0] +[p0,p1] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) -i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr) i2 = int_and(i0, i1) i3 = int_le(i2, 255) guard_true(i3) [] @@ -5338,9 +5338,9 @@ expected = -[p0] +[p0,p1] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) -i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr) i2 = int_and(i0, i1) jump(i2) @@ -5348,9 +5348,9 @@ def test_int_and_cmp_below_bounds(self): ops = -[p0] +[p0,p1] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) -i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr) i2 = int_and(i0, i1) i3 = int_lt(i2, 255) guard_true(i3) [] @@ -5360,19 +5360,19 @@ def test_int_or_cmp_above_bounds(self): ops = -[p0] +[p0,p1] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) -i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr) i2 = int_or(i0, i1) -i3 = int_le(i2, 255) +i3 = int_le(i2, 65535) guard_true(i3) [] jump(i2) expected = -[p0] +[p0,p1] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) -i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr) i2 = int_or(i0, i1) jump(i2) @@ -5380,11 +5380,11 @@ def test_int_or_cmp_below_bounds(self): ops = -[p0] +[p0,p1] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) -i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr) i2 = int_or(i0, i1) -i3 = int_lt(i2, 255) +i3 = int_lt(i2, 65535) guard_true(i3) [] jump(i2) @@ -5392,19 +5392,19 @@ def test_int_xor_cmp_above_bounds(self): ops = -[p0] +[p0,p1] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) -i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr) i2 = int_xor(i0, i1) -i3 = int_le(i2, 255) +i3 = int_le(i2, 65535) guard_true(i3) [] jump(i2) expected = -[p0] +[p0,p1] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) -i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr) i2 = int_xor(i0, i1) jump(i2) @@ -5412,17 +5412,16 @@ def test_int_xor_cmp_below_bounds(self): ops = -[p0] +[p0,p1] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) -i1 = getarrayitem_gc(p0, 1, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr) i2 = int_xor(i0, i1) -i3 = int_lt(i2, 255) +i3 = int_lt(i2, 65535) guard_true(i3) [] jump(i2) self.optimize_loop(ops, ops) - class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin): pass diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py b/rpython/jit/metainterp/optimizeopt/test/test_util.py --- a/rpython/jit/metainterp/optimizeopt/test/test_util.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py @@ -1,6 +1,6 @@ import py, random -from rpython.rtyper.lltypesystem import lltype, llmemory, rclass, rstr +from rpython.rtyper.lltypesystem import lltype, llmemory, rclass, rstr, rffi from rpython.rtyper.lltypesystem.rclass import OBJECT, OBJECT_VTABLE from rpython.rtyper.rclass import FieldListAccessor, IR_QUASIIMMUTABLE @@ -208,6 +208,8 @@ chararray = lltype.GcArray(lltype.Char) chararraydescr = cpu.arraydescrof(chararray) +u2array = lltype.GcArray(rffi.USHORT) +u2arraydescr = cpu.arraydescrof(u2array) # array of structs (complex data) complexarray = lltype.GcArray( ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Merge branch bounds-int-add-or
Author: Squeaky squeaky...@gmx.com Branch: Changeset: r69201:2b0a11075c0e Date: 2014-02-17 23:54 +0100 http://bitbucket.org/pypy/pypy/changeset/2b0a11075c0e/ Log:Merge branch bounds-int-add-or Propagate appropriate bounds through INT_(OR|XOR|AND) operations if the operands are positive to kill some guards diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -78,3 +78,7 @@ .. branch: optimize-int-and Optimize away INT_AND with constant mask of 1s that fully cover the bitrange of other operand. + +.. branch: bounds-int-add-or +Propagate appropriate bounds through INT_(OR|XOR|AND) operations if the +operands are positive to kill some guards diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -7,6 +7,7 @@ CONST_0, MODE_ARRAY, MODE_STR, MODE_UNICODE) from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method from rpython.jit.metainterp.resoperation import rop +from rpython.jit.backend.llsupport import symbolic def get_integer_min(is_unsigned, byte_size): @@ -23,6 +24,17 @@ return (1 ((byte_size 3) - 1)) - 1 +def next_pow2_m1(n): +Calculate next power of 2 greater than n minus one. +n |= n 1 +n |= n 2 +n |= n 4 +n |= n 8 +n |= n 16 +n |= n 32 +return n + + class OptIntBounds(Optimization): Keeps track of the bounds placed on integers by guards and remove redundant guards @@ -56,17 +68,24 @@ optimize_GUARD_FALSE = optimize_GUARD_TRUE optimize_GUARD_VALUE = optimize_GUARD_TRUE -def optimize_INT_XOR(self, op): +def optimize_INT_OR_or_XOR(self, op): v1 = self.getvalue(op.getarg(0)) v2 = self.getvalue(op.getarg(1)) if v1 is v2: -self.make_constant_int(op.result, 0) +if op.getopnum() == rop.INT_OR: +self.make_equal_to(op.result, v1) +else: +self.make_constant_int(op.result, 0) return self.emit_operation(op) if v1.intbound.known_ge(IntBound(0, 0)) and \ v2.intbound.known_ge(IntBound(0, 0)): r = self.getvalue(op.result) -r.intbound.make_ge(IntLowerBound(0)) +mostsignificant = v1.intbound.upper | v2.intbound.upper +r.intbound.intersect(IntBound(0, next_pow2_m1(mostsignificant))) + +optimize_INT_OR = optimize_INT_OR_or_XOR +optimize_INT_XOR = optimize_INT_OR_or_XOR def optimize_INT_AND(self, op): v1 = self.getvalue(op.getarg(0)) @@ -82,6 +101,10 @@ val = v1.box.getint() if val = 0: r.intbound.intersect(IntBound(0, val)) +elif v1.intbound.known_ge(IntBound(0, 0)) and \ + v2.intbound.known_ge(IntBound(0, 0)): +lesser = min(v1.intbound.upper, v2.intbound.upper) +r.intbound.intersect(IntBound(0, next_pow2_m1(lesser))) def optimize_INT_SUB(self, op): v1 = self.getvalue(op.getarg(0)) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_intbounds.py b/rpython/jit/metainterp/optimizeopt/test/test_intbounds.py new file mode 100644 --- /dev/null +++ b/rpython/jit/metainterp/optimizeopt/test/test_intbounds.py @@ -0,0 +1,12 @@ +from rpython.jit.metainterp.optimizeopt.intbounds import next_pow2_m1 + + +def test_next_pow2_m1(): +assert next_pow2_m1(0) == 0 +assert next_pow2_m1(1) == 1 +assert next_pow2_m1(7) == 7 +assert next_pow2_m1(256) == 511 +assert next_pow2_m1(255) == 255 +assert next_pow2_m1(80) == 127 +assert next_pow2_m1((1 32) - 5) == (1 32) - 1 +assert next_pow2_m1((1 64) - 1) == (1 64) - 1 diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5326,6 +5326,114 @@ self.optimize_loop(ops, ops) +def test_int_and_cmp_above_bounds(self): +ops = +[p0,p1] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr) +i2 = int_and(i0, i1) +i3 = int_le(i2, 255) +guard_true(i3) [] +jump(i2) + + +expected = +[p0,p1] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr) +i2 = int_and(i0, i1) +jump(i2) + +self.optimize_loop(ops, expected) + +def test_int_and_cmp_below_bounds(self): +ops = +[p0,p1] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = getarrayitem_gc(p1, 0, descr=u2arraydescr
[pypy-commit] pypy bounds-int-add-or: merge OR and XOR optimization into one
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69197:d091b8c6f8e8 Date: 2014-02-17 20:26 +0100 http://bitbucket.org/pypy/pypy/changeset/d091b8c6f8e8/ Log:merge OR and XOR optimization into one diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -68,25 +68,14 @@ optimize_GUARD_FALSE = optimize_GUARD_TRUE optimize_GUARD_VALUE = optimize_GUARD_TRUE -def optimize_INT_OR(self, op): -v1 = self.getvalue(op.getarg(0)) -v2 = self.getvalue(op.getarg(1)) -self.emit_operation(op) -r = self.getvalue(op.result) - -if v1.intbound.known_ge(IntBound(0, 0)) and \ - v2.intbound.known_ge(IntBound(0, 0)): -mostsignificant = v1.intbound.upper | v2.intbound.upper -# check if next_power2 won't overflow -if mostsignificant (1 ((symbolic.WORD - 1) 3)): -r.intbound.intersect( -IntBound(0, next_power2(mostsignificant) - 1)) - -def optimize_INT_XOR(self, op): +def optimize_INT_OR_or_XOR(self, op): v1 = self.getvalue(op.getarg(0)) v2 = self.getvalue(op.getarg(1)) if v1 is v2: -self.make_constant_int(op.result, 0) +if op.getopnum() == rop.INT_OR: +self.make_equal_to(op.result, v1) +else: +self.make_constant_int(op.result, 0) return self.emit_operation(op) if v1.intbound.known_ge(IntBound(0, 0)) and \ @@ -99,6 +88,8 @@ if mostsignificant (1 ((symbolic.WORD - 1) 3)): r.intbound.make_lt(IntUpperBound(next_power2(mostsignificant))) +optimize_INT_OR = optimize_INT_OR_or_XOR +optimize_INT_XOR = optimize_INT_OR_or_XOR def optimize_INT_AND(self, op): v1 = self.getvalue(op.getarg(0)) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5422,6 +5422,18 @@ self.optimize_loop(ops, ops) +def test_or_same_arg(self): +ops = +[i0] +i1 = int_or(i0, i0) +jump(i1) + +expected = +[i0] +jump(i0) + +self.optimize_loop(ops, expected) + class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin): pass ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: merge default
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69200:ae0283f76a9c Date: 2014-02-17 21:38 +0100 http://bitbucket.org/pypy/pypy/changeset/ae0283f76a9c/ Log:merge default diff --git a/pypy/doc/man/pypy.1.rst b/pypy/doc/man/pypy.1.rst --- a/pypy/doc/man/pypy.1.rst +++ b/pypy/doc/man/pypy.1.rst @@ -19,10 +19,10 @@ Skip assert statements. -OO -Remove docstrings when importing modules in addition to -O. +Remove docstrings when importing modules in addition to ``-O``. --c *cmd* -Program passed in as CMD (terminates option list). +-c CMD +Program passed in as ``CMD`` (terminates option list). -S Do not ``import site`` on initialization. @@ -36,10 +36,10 @@ -h, --help Show a help message and exit. --m *mod* +-m MOD Library module to be run as a script (terminates option list). --W *arg* +-W ARG Warning control (*arg* is *action*:*message*:*category*:*module*:*lineno*). -E @@ -54,44 +54,9 @@ --info Print translation information about this PyPy executable. ---jit *arg* -Low level JIT parameters. Format is -*arg*\ ``=``\ *value*\ [``,``\ *arg*\ ``=``\ *value*\ ...] - -``off`` -Disable the JIT. - -``threshold=``\ *value* -Number of times a loop has to run for it to become hot. - -``function_threshold=``\ *value* -Number of times a function must run for it to become traced from -start. - -``inlining=``\ *value* -Inline python functions or not (``1``/``0``). - -``loop_longevity=``\ *value* -A parameter controlling how long loops will be kept before being -freed, an estimate. - -``max_retrace_guards=``\ *value* -Number of extra guards a retrace can cause. - -``retrace_limit=``\ *value* -How many times we can try retracing before giving up. - -``trace_eagerness=``\ *value* -Number of times a guard has to fail before we start compiling a -bridge. - -``trace_limit=``\ *value* -Number of recorded operations before we abort tracing with -``ABORT_TRACE_TOO_LONG``. - -``enable_opts=``\ *value* -Optimizations to enabled or ``all``. -Warning, this option is dangerous, and should be avoided. +--jit ARG +Low level JIT parameters. Mostly internal. Run ``--jit help`` +for more information. ENVIRONMENT === @@ -144,7 +109,7 @@ Multiple prefixes can be specified, comma-separated. Only sections whose name match the prefix will be logged. -``PYPYLOG``\ =\ ``jit-log-opt,jit-backend:``\ *logfile* will +``PYPYLOG=jit-log-opt,jit-backend:logfile`` will generate a log suitable for *jitviewer*, a tool for debugging performance issues under PyPy. diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -75,7 +75,7 @@ Kill some guards and operations in JIT traces by adding integer bounds propagation for getfield_(raw|gc) and getarrayitem_(raw|gc). -.. branch: optimize-int-and: +.. branch: optimize-int-and Optimize away INT_AND with constant mask of 1s that fully cover the bitrange of other operand. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: substitute pow2 with loop-less non-overflowing pow2 - 1
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69198:c57dc327e758 Date: 2014-02-17 20:52 +0100 http://bitbucket.org/pypy/pypy/changeset/c57dc327e758/ Log:substitute pow2 with loop-less non-overflowing pow2 - 1 diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -24,15 +24,15 @@ return (1 ((byte_size 3) - 1)) - 1 -def next_power2(val): -Calculate next power of 2 greater than val. - - Danger: this can overflow, use only when val is sufficiently - lower than symbolic.WORD -power = 1 -while power val + 1: -power = 1 -return power +def next_pow2_m1(n): +Calculate next power of 2 greater than n minus one. +n |= n 1 +n |= n 2 +n |= n 4 +n |= n 8 +n |= n 16 +n |= n 32 +return n class OptIntBounds(Optimization): diff --git a/rpython/jit/metainterp/optimizeopt/test/test_intbounds.py b/rpython/jit/metainterp/optimizeopt/test/test_intbounds.py --- a/rpython/jit/metainterp/optimizeopt/test/test_intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_intbounds.py @@ -1,10 +1,12 @@ -from rpython.jit.metainterp.optimizeopt.intbounds import next_power2 +from rpython.jit.metainterp.optimizeopt.intbounds import next_pow2_m1 -def test_next_power2(): -assert next_power2(0) == 1 -assert next_power2(1) == 2 -assert next_power2(7) == 8 -assert next_power2(256) == 512 -assert next_power2(255) == 256 -assert next_power2(80) == 128 +def test_next_pow2_m1(): +assert next_pow2_m1(0) == 0 +assert next_pow2_m1(1) == 1 +assert next_pow2_m1(7) == 7 +assert next_pow2_m1(256) == 511 +assert next_pow2_m1(255) == 255 +assert next_pow2_m1(80) == 127 +assert next_pow2_m1((1 32) - 5) == (1 32) - 1 +assert next_pow2_m1((1 64) - 1) == (1 64) - 1 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: Closing merged branch
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69202:a1c20073e6f9 Date: 2014-02-17 23:56 +0100 http://bitbucket.org/pypy/pypy/changeset/a1c20073e6f9/ Log:Closing merged branch ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy bounds-int-add-or: update whatsnew
Author: Squeaky squeaky...@gmx.com Branch: bounds-int-add-or Changeset: r69196:cc09acf5f43e Date: 2014-02-17 19:17 +0100 http://bitbucket.org/pypy/pypy/changeset/cc09acf5f43e/ Log:update whatsnew diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -78,3 +78,7 @@ .. branch: optimize-int-and: Optimize away INT_AND with constant mask of 1s that fully cover the bitrange of other operand. + +.. branch: bounds-int-add-or +Propagate appropriate bounds through INT_(OR|XOR|AND) operations if the +operands are positive to kill some guards ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy optimize-int-and: failing and passing test
Author: Squeaky squeaky...@gmx.com Branch: optimize-int-and Changeset: r69172:bb6064d9cde5 Date: 2014-02-16 02:36 +0100 http://bitbucket.org/pypy/pypy/changeset/bb6064d9cde5/ Log:failing and passing test diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5298,6 +5298,30 @@ self.optimize_loop(ops, expected) +def test_intand_1mask_covering_bitrange(self): +ops = +[p0] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = int_and(i0, 255) +jump(i1) + + +expected = +[p0] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +jump(i0) + +self.optimize_loop(ops, expected) + +def test_intand_maskwith0_in_bitrange(self): +ops = +[p0] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = int_and(i0, 257) +jump(i1) + +self.optimize_loop(ops, ops) + class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin): pass ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy optimize-int-and: fix and improve test
Author: Squeaky squeaky...@gmx.com Branch: optimize-int-and Changeset: r69174:92dba00162ff Date: 2014-02-16 13:35 +0100 http://bitbucket.org/pypy/pypy/changeset/92dba00162ff/ Log:fix and improve test diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py --- a/rpython/jit/metainterp/optimizeopt/rewrite.py +++ b/rpython/jit/metainterp/optimizeopt/rewrite.py @@ -86,6 +86,13 @@ v2 = self.getvalue(op.getarg(1)) if v1.is_null() or v2.is_null(): self.make_constant_int(op.result, 0) +elif v2.is_constant(): +val = v2.box.getint() +if val == -1 or v1.intbound.lower = 0 and \ +v1.intbound.upper = val ~(val + 1): +self.make_equal_to(op.result, v1) +else: +self.emit_operation(op) else: self.emit_operation(op) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5303,7 +5303,8 @@ [p0] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) i1 = int_and(i0, 255) -jump(i1) +i2 = int_and(i1, -1) +jump(i2) expected = ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy optimize-int-and: improve test
Author: Squeaky squeaky...@gmx.com Branch: optimize-int-and Changeset: r69176:242fd9b72daa Date: 2014-02-16 16:23 +0100 http://bitbucket.org/pypy/pypy/changeset/242fd9b72daa/ Log:improve test diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5304,7 +5304,8 @@ i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) i1 = int_and(i0, 255) i2 = int_and(i1, -1) -jump(i2) +i3 = int_and(511, i2) +jump(i3) expected = @@ -5319,7 +5320,9 @@ [p0] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) i1 = int_and(i0, 257) -jump(i1) +i2 = getarrayitem_gc(p0, 1, descr=chararraydescr)a +i3 = int_and(259, i2) +jump(i1, i3) self.optimize_loop(ops, ops) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy optimize-int-and: fix another test, make optimization symetric
Author: Squeaky squeaky...@gmx.com Branch: optimize-int-and Changeset: r69175:caba2738c3ab Date: 2014-02-16 15:56 +0100 http://bitbucket.org/pypy/pypy/changeset/caba2738c3ab/ Log:fix another test, make optimization symetric diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py --- a/rpython/jit/metainterp/optimizeopt/rewrite.py +++ b/rpython/jit/metainterp/optimizeopt/rewrite.py @@ -86,15 +86,21 @@ v2 = self.getvalue(op.getarg(1)) if v1.is_null() or v2.is_null(): self.make_constant_int(op.result, 0) +return elif v2.is_constant(): val = v2.box.getint() -if val == -1 or v1.intbound.lower = 0 and \ -v1.intbound.upper = val ~(val + 1): +if val == -1 or v1.intbound.lower = 0 \ +and v1.intbound.upper = val ~(val + 1): self.make_equal_to(op.result, v1) -else: -self.emit_operation(op) -else: -self.emit_operation(op) +return +elif v1.is_constant(): +val = v1.box.getint() +if val == -1 or v2.intbound.lower = 0 \ +and v2.intbound.upper = val ~(val + 1): +self.make_equal_to(op.result, v2) +return + +self.emit_operation(op) def optimize_INT_OR(self, op): v1 = self.getvalue(op.getarg(0)) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py @@ -4753,7 +4753,8 @@ def test_bound_and(self): ops = -[i0] +[] +i0 = escape() i1 = int_and(i0, 255) i2 = int_lt(i1, 500) guard_true(i2) [] @@ -4779,10 +4780,11 @@ guard_true(i14) [] i15 = int_ge(i1, 20) guard_true(i15) [] -jump(i1) - -expected = -[i0] +jump() + +expected = +[] +i0 = escape() i1 = int_and(i0, 255) i12 = int_lt(i1, 100) guard_true(i12) [] @@ -4792,7 +4794,7 @@ guard_true(i14) [] i15 = int_ge(i1, 20) guard_true(i15) [] -jump(i1) +jump() self.optimize_loop(ops, expected) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy optimize-int-and: cosmetic tweak to get(array|field)
Author: Squeaky squeaky...@gmx.com Branch: optimize-int-and Changeset: r69173:0ccecf7a9518 Date: 2014-02-16 11:30 +0100 http://bitbucket.org/pypy/pypy/changeset/0ccecf7a9518/ Log:cosmetic tweak to get(array|field) diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -342,7 +342,7 @@ if descr.is_integer_bounded(): v1 = self.getvalue(op.result) v1.intbound.make_ge(IntLowerBound(descr.get_integer_min())) -v1.intbound.make_lt(IntUpperBound(descr.get_integer_max() + 1)) +v1.intbound.make_le(IntUpperBound(descr.get_integer_max())) optimize_GETFIELD_GC = optimize_GETFIELD_RAW @@ -354,8 +354,7 @@ if descr and descr.is_item_integer_bounded(): v1 = self.getvalue(op.result) v1.intbound.make_ge(IntLowerBound(descr.get_item_integer_min())) -v1.intbound.make_lt( -IntUpperBound(descr.get_item_integer_max() + 1)) +v1.intbound.make_le(IntUpperBound(descr.get_item_integer_max())) optimize_GETARRAYITEM_GC = optimize_GETARRAYITEM_RAW ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy optimize-int-and: update whatsnew
Author: Squeaky squeaky...@gmx.com Branch: optimize-int-and Changeset: r69177:92fee8613f8c Date: 2014-02-16 19:15 +0100 http://bitbucket.org/pypy/pypy/changeset/92fee8613f8c/ Log:update whatsnew diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -74,3 +74,7 @@ .. branch: array-propagate-len Kill some guards and operations in JIT traces by adding integer bounds propagation for getfield_(raw|gc) and getarrayitem_(raw|gc). + +.. branch: optimize-int-and: +Optimize away INT_AND with constant mask of 1s that fully cover the bitrange +of other operand. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy optimize-int-and: oups, typo
Author: Squeaky squeaky...@gmx.com Branch: optimize-int-and Changeset: r69178:111057c44543 Date: 2014-02-16 19:30 +0100 http://bitbucket.org/pypy/pypy/changeset/111057c44543/ Log:oups, typo diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5320,7 +5320,7 @@ [p0] i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) i1 = int_and(i0, 257) -i2 = getarrayitem_gc(p0, 1, descr=chararraydescr)a +i2 = getarrayitem_gc(p0, 1, descr=chararraydescr) i3 = int_and(259, i2) jump(i1, i3) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix array test that was failing after int bounds propagation from array operations
Author: Squeaky squeaky...@gmx.com Branch: Changeset: r69181:f9b8b76b4c41 Date: 2014-02-16 21:10 +0100 http://bitbucket.org/pypy/pypy/changeset/f9b8b76b4c41/ Log:fix array test that was failing after int bounds propagation from array operations diff --git a/pypy/module/pypyjit/test_pypy_c/test_array.py b/pypy/module/pypyjit/test_pypy_c/test_array.py --- a/pypy/module/pypyjit/test_pypy_c/test_array.py +++ b/pypy/module/pypyjit/test_pypy_c/test_array.py @@ -67,26 +67,46 @@ log = self.run(main, []) assert log.result == 73574560 loop, = log.loops_by_filename(self.filepath) -assert loop.match( -i13 = int_lt(i8, 307200) -guard_true(i13, descr=...) -guard_not_invalidated(descr=...) -# the bound check guard on img has been killed (thanks to the asserts) -i14 = getarrayitem_raw(i10, i8, descr=ArrayS .) -i15 = int_add_ovf(i9, i14) -guard_no_overflow(descr=...) -i17 = int_sub(i8, 640) -# the bound check guard on intimg has been killed (thanks to the asserts) -i18 = getarrayitem_raw(i11, i17, descr=ArrayS .) -i19 = int_add_ovf(i18, i15) -guard_no_overflow(descr=...) -# on 64bit, there is a guard checking that i19 actually fits into 32bit -... -setarrayitem_raw(i11, i8, _, descr=ArrayS .) -i28 = int_add(i8, 1) ---TICK-- -jump(..., descr=...) -) + +if sys.maxint == 2 ** 31 - 1: +assert loop.match( +i13 = int_lt(i8, 307200) +guard_true(i13, descr=...) +guard_not_invalidated(descr=...) +# the bound check guard on img has been killed (thanks to the asserts) +i14 = getarrayitem_raw(i10, i8, descr=ArrayS .) +i15 = int_add_ovf(i9, i14) +guard_no_overflow(descr=...) +i17 = int_sub(i8, 640) +# the bound check guard on intimg has been killed (thanks to the asserts) +i18 = getarrayitem_raw(i11, i17, descr=ArrayS .) +i19 = int_add_ovf(i18, i15) +guard_no_overflow(descr=...) +setarrayitem_raw(i11, i8, _, descr=ArrayS .) +i28 = int_add(i8, 1) +--TICK-- +jump(..., descr=...) +) +elif sys.maxint == 2 ** 63 - 1: +assert loop.match( +i13 = int_lt(i8, 307200) +guard_true(i13, descr=...) +guard_not_invalidated(descr=...) +# the bound check guard on img has been killed (thanks to the asserts) +i14 = getarrayitem_raw(i10, i8, descr=ArrayS .) +i15 = int_add(i9, i14) +i17 = int_sub(i8, 640) +# the bound check guard on intimg has been killed (thanks to the asserts) +i18 = getarrayitem_raw(i11, i17, descr=ArrayS .) +i19 = int_add(i18, i15) +# on 64bit, there is a guard checking that i19 actually fits into 32bit +... +setarrayitem_raw(i11, i8, _, descr=ArrayS .) +i28 = int_add(i8, 1) +--TICK-- +jump(..., descr=...) +) + def test_array_of_doubles(self): def main(): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: typo angered test_whatsnew
Author: Squeaky squeaky...@gmx.com Branch: Changeset: r69182:00f906eb59a1 Date: 2014-02-17 02:03 +0100 http://bitbucket.org/pypy/pypy/changeset/00f906eb59a1/ Log:typo angered test_whatsnew diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -75,6 +75,6 @@ Kill some guards and operations in JIT traces by adding integer bounds propagation for getfield_(raw|gc) and getarrayitem_(raw|gc). -.. branch: optimize-int-and: +.. branch: optimize-int-and Optimize away INT_AND with constant mask of 1s that fully cover the bitrange of other operand. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: add integer bounds on FieldDescr
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69153:3830704ee5eb Date: 2014-02-14 15:52 +0100 http://bitbucket.org/pypy/pypy/changeset/3830704ee5eb/ Log:add integer bounds on FieldDescr diff --git a/rpython/jit/backend/llsupport/descr.py b/rpython/jit/backend/llsupport/descr.py --- a/rpython/jit/backend/llsupport/descr.py +++ b/rpython/jit/backend/llsupport/descr.py @@ -103,6 +103,26 @@ def is_field_signed(self): return self.flag == FLAG_SIGNED +def is_integer_bounded(self): +return self.flag in (FLAG_SIGNED, FLAG_UNSIGNED) \ +and self.field_size symbolic.WORD + +def get_integer_min(self): +if self.flag == FLAG_UNSIGNED: +return 0 +elif self.flag == FLAG_SIGNED: +return -(1 ((self.field_size 3) - 1)) + +assert False + +def get_integer_max(self): +if self.flag == FLAG_UNSIGNED: +return (1 (self.field_size 3)) - 1 +elif self.flag == FLAG_SIGNED: +return (1 ((self.field_size 3) - 1)) - 1 + +assert False + def sort_key(self): return self.offset diff --git a/rpython/jit/backend/llsupport/test/test_descr.py b/rpython/jit/backend/llsupport/test/test_descr.py --- a/rpython/jit/backend/llsupport/test/test_descr.py +++ b/rpython/jit/backend/llsupport/test/test_descr.py @@ -432,3 +432,21 @@ assert descr.basesize == struct.calcsize(PP) # hash, length assert descr.lendescr.offset == struct.calcsize(P) # hash assert not descr.is_array_of_pointers() + + +def test_descr_integer_bounded(): +descr = FieldDescr('descr', 0, 1, FLAG_SIGNED) +assert descr.is_integer_bounded() + +descr = FieldDescr('descr', 0, symbolic.WORD, FLAG_UNSIGNED) +assert not descr.is_integer_bounded() + + +def test_descr_get_integer_bounds(): +descr = FieldDescr('decr', 0, 1, FLAG_UNSIGNED) +assert descr.get_integer_min() == 0 +assert descr.get_integer_max() == 255 + +descr = FieldDescr('descr', 0, 1, FLAG_SIGNED) +assert descr.get_integer_min() == -128 +assert descr.get_integer_max() == 127 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: merge default
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69159:51b35f5af6cf Date: 2014-02-15 12:14 +0100 http://bitbucket.org/pypy/pypy/changeset/51b35f5af6cf/ Log:merge default diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py --- a/rpython/translator/c/genc.py +++ b/rpython/translator/c/genc.py @@ -402,7 +402,7 @@ ('debug_exc', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT -DDO_LOG_EXC debug_target'), ('debug_mem', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT -DPYPY_USE_TRIVIAL_MALLOC debug_target'), ('no_obmalloc', '', '$(MAKE) CFLAGS=-g -O2 -DRPY_ASSERT -DPYPY_NO_OBMALLOC $(TARGET)'), -('linuxmemchk', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT -DPPY_USE_LINUXMEMCHK debug_target'), +('linuxmemchk', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT -DPYPY_USE_LINUXMEMCHK debug_target'), ('llsafer', '', '$(MAKE) CFLAGS=-O2 -DRPY_LL_ASSERT $(TARGET)'), ('lldebug', '', '$(MAKE) CFLAGS=$(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT debug_target'), ('lldebug0','', '$(MAKE) CFLAGS=-O0 $(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT debug_target'), ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: add optimization, move stuff around
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69154:17003c30fe47 Date: 2014-02-14 19:23 +0100 http://bitbucket.org/pypy/pypy/changeset/17003c30fe47/ Log:add optimization, move stuff around diff --git a/rpython/jit/backend/llgraph/runner.py b/rpython/jit/backend/llgraph/runner.py --- a/rpython/jit/backend/llgraph/runner.py +++ b/rpython/jit/backend/llgraph/runner.py @@ -1,10 +1,12 @@ import py, weakref from rpython.jit.backend import model from rpython.jit.backend.llgraph import support +from rpython.jit.backend.llsupport import symbolic from rpython.jit.metainterp.history import AbstractDescr from rpython.jit.metainterp.history import Const, getkind from rpython.jit.metainterp.history import INT, REF, FLOAT, VOID from rpython.jit.metainterp.resoperation import rop +from rpython.jit.metainterp.optimizeopt import intbounds from rpython.jit.codewriter import longlong, heaptracker from rpython.jit.codewriter.effectinfo import EffectInfo @@ -119,6 +121,24 @@ def is_field_signed(self): return _is_signed_kind(self.FIELD) +def is_integer_bounded(self): +return getkind(self.FIELD) == 'int' \ +and rffi.sizeof(self.FIELD) symbolic.WORD + +def get_integer_min(self): +if getkind(self.FIELD) != 'int': +assert False + +return intbounds.get_integer_min( +not _is_signed_kind(self.FIELD), rffi.sizeof(self.FIELD)) + +def get_integer_max(self): +if getkind(self.FIELD) != 'int': +assert False + +return intbounds.get_integer_max( +not _is_signed_kind(self.FIELD), rffi.sizeof(self.FIELD)) + def _is_signed_kind(TYPE): return (TYPE is not lltype.Bool and isinstance(TYPE, lltype.Number) and rffi.cast(TYPE, -1) == -1) diff --git a/rpython/jit/backend/llsupport/descr.py b/rpython/jit/backend/llsupport/descr.py --- a/rpython/jit/backend/llsupport/descr.py +++ b/rpython/jit/backend/llsupport/descr.py @@ -6,6 +6,7 @@ from rpython.jit.metainterp import history from rpython.jit.codewriter import heaptracker, longlong from rpython.jit.codewriter.longlong import is_longlong +from rpython.jit.metainterp.optimizeopt import intbounds class GcCache(object): @@ -109,17 +110,17 @@ def get_integer_min(self): if self.flag == FLAG_UNSIGNED: -return 0 +return intbounds.get_integer_min(True, self.field_size) elif self.flag == FLAG_SIGNED: -return -(1 ((self.field_size 3) - 1)) +return intbounds.get_integer_min(False, self.field_size) assert False def get_integer_max(self): if self.flag == FLAG_UNSIGNED: -return (1 (self.field_size 3)) - 1 +return intbounds.get_integer_max(True, self.field_size) elif self.flag == FLAG_SIGNED: -return (1 ((self.field_size 3) - 1)) - 1 +return intbounds.get_integer_max(False, self.field_size) assert False diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -9,6 +9,20 @@ from rpython.jit.metainterp.resoperation import rop +def get_integer_min(is_unsigned, byte_size): +if is_unsigned: +return 0 +else: +return -(1 ((byte_size 3) - 1)) + + +def get_integer_max(is_unsigned, byte_size): +if is_unsigned: +return (1 (byte_size 3)) - 1 +else: +return (1 ((byte_size 3) - 1)) - 1 + + class OptIntBounds(Optimization): Keeps track of the bounds placed on integers by guards and remove redundant guards @@ -322,6 +336,14 @@ v1.intbound.make_ge(IntLowerBound(0)) v1.intbound.make_lt(IntUpperBound(256)) +def optimize_GETFIELD_GC(self, op): +self.emit_operation(op) +descr = op.getdescr() +if descr.is_integer_bounded(): +v1 = self.getvalue(op.result) +v1.intbound.make_ge(IntLowerBound(descr.get_integer_min())) +v1.intbound.make_lt(IntUpperBound(descr.get_integer_max() + 1)) + def optimize_UNICODEGETITEM(self, op): self.emit_operation(op) v1 = self.getvalue(op.result) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5200,7 +5200,7 @@ self.optimize_loop(ops, ops) -def test_cmp_outside_intbounds(self): +def test_getfield_cmp_outside_intbounds(self): ops = [p0] i0 = getfield_gc(p0, descr=chardescr) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: fix getfieldraw
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69160:141205b24825 Date: 2014-02-15 12:21 +0100 http://bitbucket.org/pypy/pypy/changeset/141205b24825/ Log:fix getfieldraw diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -336,7 +336,7 @@ v1.intbound.make_ge(IntLowerBound(0)) v1.intbound.make_lt(IntUpperBound(256)) -def optimize_GETFIELD_GC(self, op): +def optimize_GETFIELD_RAW(self, op): self.emit_operation(op) descr = op.getdescr() if descr.is_integer_bounded(): @@ -344,6 +344,8 @@ v1.intbound.make_ge(IntLowerBound(descr.get_integer_min())) v1.intbound.make_lt(IntUpperBound(descr.get_integer_max() + 1)) +optimize_GETFIELD_GC = optimize_GETFIELD_RAW + def optimize_GETARRAYITEM_RAW(self, op): self.emit_operation(op) descr = op.getdescr() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: Fix optimized trace debugging utility. Previously the print loop would use
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69151:6bace6054472 Date: 2014-02-14 12:15 +0100 http://bitbucket.org/pypy/pypy/changeset/6bace6054472/ Log:Fix optimized trace debugging utility. Previously the print loop would use zip which always truncates the output to the shorter list. This produces confusing output becuase it would later fail on trace length mismatch but printing truncated output to stdout looks like there is same number of operations. diff --git a/rpython/jit/metainterp/optimizeopt/util.py b/rpython/jit/metainterp/optimizeopt/util.py --- a/rpython/jit/metainterp/optimizeopt/util.py +++ b/rpython/jit/metainterp/optimizeopt/util.py @@ -1,3 +1,5 @@ +import itertools + import py from rpython.rlib.objectmodel import r_dict, compute_identity_hash from rpython.rlib.rarithmetic import intmask @@ -136,13 +138,16 @@ print ' Comparing lists '.center(totwidth, '-') text_right = text_right or 'expected' print '%s| %s' % ('optimized'.center(width), text_right.center(width)) -for op1, op2 in zip(oplist1, oplist2): +for op1, op2 in itertools.izip_longest(oplist1, oplist2, fillvalue=''): txt1 = str(op1) txt2 = str(op2) while txt1 or txt2: print '%s| %s' % (txt1[:width].ljust(width), txt2[:width]) txt1 = txt1[width:] txt2 = txt2[width:] +print '-' * totwidth + +for op1, op2 in zip(oplist1, oplist2): assert op1.getopnum() == op2.getopnum() assert op1.numargs() == op2.numargs() for i in range(op1.numargs()): @@ -177,6 +182,5 @@ else: assert False assert len(oplist1) == len(oplist2) -print '-'*totwidth return True ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: more tests for getfield_gc, failing test for arrays
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69155:14f943c2f482 Date: 2014-02-14 22:42 +0100 http://bitbucket.org/pypy/pypy/changeset/14f943c2f482/ Log:more tests for getfield_gc, failing test for arrays diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5200,7 +5200,7 @@ self.optimize_loop(ops, ops) -def test_getfield_cmp_outside_intbounds(self): +def test_getfield_cmp_above_bounds(self): ops = [p0] i0 = getfield_gc(p0, descr=chardescr) @@ -5214,6 +5214,46 @@ self.optimize_loop(ops, expected) +def test_getfield_cmp_below_bounds(self): +ops = +[p0] +i0 = getfield_gc(p0, descr=chardescr) +i1 = int_gt(i0, -1) +guard_true(i1) [] + + +expected = +[p0] +i0 = getfield_gc(p0, descr=chardescr) + +self.optimize_loop(ops, expected) + +def test_getfield_cmp_in_bounds(self): +ops = +[p0] +i0 = getfield_gc(p0, descr=chardescr) +i1 = int_gt(i0, 0) +guard_true(i1) [] +i2 = int_lt(i0, 255) +guard_true(i2) [] + +self.optimize_loop(ops, ops) + + +def test_rawarray_cmp_outside_intbounds(self): +ops = +[i0] +i1 = getarrayitem_raw(i0, 0, descr=rawarraydescr_char) +i2 = int_lt(i1, 256) +guard_true(i2) [] + + +expected = +[i0] +i1 = getarrayitem_raw(i0, 0, descr=rawarraydescr_char) + +self.optimize_loop(ops, expected) + class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin): pass ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: optimize array raw, make test pass
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69156:6717c9190ff4 Date: 2014-02-14 23:57 +0100 http://bitbucket.org/pypy/pypy/changeset/6717c9190ff4/ Log:optimize array raw, make test pass diff --git a/rpython/jit/backend/llgraph/runner.py b/rpython/jit/backend/llgraph/runner.py --- a/rpython/jit/backend/llgraph/runner.py +++ b/rpython/jit/backend/llgraph/runner.py @@ -164,6 +164,25 @@ def is_array_of_structs(self): return isinstance(self.A.OF, lltype.Struct) +def is_item_integer_bounded(self): +return getkind(self.A.OF) == 'int' \ +and rffi.sizeof(self.A.OF) symbolic.WORD + +def get_item_integer_min(self): +if getkind(self.A.OF) != 'int': +assert False + +return intbounds.get_integer_min( +not _is_signed_kind(self.A.OF), rffi.sizeof(self.A.OF)) + +def get_item_integer_max(self): +if getkind(self.A.OF) != 'int': +assert False + +return intbounds.get_integer_max( +not _is_signed_kind(self.A.OF), rffi.sizeof(self.A.OF)) + + class InteriorFieldDescr(AbstractDescr): def __init__(self, A, fieldname): self.A = A diff --git a/rpython/jit/backend/llsupport/descr.py b/rpython/jit/backend/llsupport/descr.py --- a/rpython/jit/backend/llsupport/descr.py +++ b/rpython/jit/backend/llsupport/descr.py @@ -203,6 +203,28 @@ def is_array_of_structs(self): return self.flag == FLAG_STRUCT +def is_item_integer_bounded(self): +return self.flag in (FLAG_SIGNED, FLAG_UNSIGNED) \ +and self.itemsize symbolic.WORD + +def get_item_integer_min(self): +if self.flag == FLAG_UNSIGNED: +return intbounds.get_integer_min(True, self.itemsize) +elif self.flag == FLAG_SIGNED: +return intbounds.get_integer_min(False, self.itemsize) + +assert False + +def get_item_integer_max(self): +if self.flag == FLAG_UNSIGNED: +return intbounds.get_integer_max(True, self.itemsize) +elif self.flag == FLAG_SIGNED: +return intbounds.get_integer_max(False, self.itemsize) + +assert False + + + def repr_of_descr(self): return 'Array%s %s' % (self.flag, self.itemsize) diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -344,6 +344,15 @@ v1.intbound.make_ge(IntLowerBound(descr.get_integer_min())) v1.intbound.make_lt(IntUpperBound(descr.get_integer_max() + 1)) +def optimize_GETARRAYITEM_RAW(self, op): +self.emit_operation(op) +descr = op.getdescr() +if descr.is_item_integer_bounded(): +v1 = self.getvalue(op.result) +v1.intbound.make_ge(IntLowerBound(descr.get_item_integer_min())) +v1.intbound.make_lt( +IntUpperBound(descr.get_item_integer_max() + 1)) + def optimize_UNICODEGETITEM(self, op): self.emit_operation(op) v1 = self.getvalue(op.result) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: improve test
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69162:6898ded0f2af Date: 2014-02-15 13:42 +0100 http://bitbucket.org/pypy/pypy/changeset/6898ded0f2af/ Log:improve test diff --git a/rpython/jit/backend/llsupport/test/test_descr.py b/rpython/jit/backend/llsupport/test/test_descr.py --- a/rpython/jit/backend/llsupport/test/test_descr.py +++ b/rpython/jit/backend/llsupport/test/test_descr.py @@ -435,12 +435,15 @@ def test_descr_integer_bounded(): -descr = FieldDescr('descr', 0, 1, FLAG_SIGNED) +descr = FieldDescr('descr', 0, symbolic.SIZEOF_CHAR, FLAG_SIGNED) assert descr.is_integer_bounded() descr = FieldDescr('descr', 0, symbolic.WORD, FLAG_UNSIGNED) assert not descr.is_integer_bounded() +descr = FieldDescr('descr', 0, symbolic.SIZEOF_FLOAT, FLAG_FLOAT) +assert not descr.is_integer_bounded() + def test_descr_get_integer_bounds(): descr = FieldDescr('decr', 0, 1, FLAG_UNSIGNED) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: failing test
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69152:e5565168e86f Date: 2014-02-14 14:34 +0100 http://bitbucket.org/pypy/pypy/changeset/e5565168e86f/ Log:failing test diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5200,6 +5200,20 @@ self.optimize_loop(ops, ops) +def test_cmp_outside_intbounds(self): +ops = +[p0] +i0 = getfield_gc(p0, descr=chardescr) +i1 = int_lt(i0, 256) +guard_true(i1) [] + + +expected = +[p0] +i0 = getfield_gc(p0, descr=chardescr) + +self.optimize_loop(ops, expected) + class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin): pass diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py b/rpython/jit/metainterp/optimizeopt/test/test_util.py --- a/rpython/jit/metainterp/optimizeopt/test/test_util.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py @@ -92,6 +92,7 @@ NODE.become(lltype.GcStruct('NODE', ('parent', OBJECT), ('value', lltype.Signed), ('floatval', lltype.Float), +('charval', lltype.Char), ('next', lltype.Ptr(NODE NODE2 = lltype.GcStruct('NODE2', ('parent', NODE), ('other', lltype.Ptr(NODE))) @@ -108,6 +109,7 @@ nodesize2 = cpu.sizeof(NODE2) valuedescr = cpu.fielddescrof(NODE, 'value') floatdescr = cpu.fielddescrof(NODE, 'floatval') +chardescr = cpu.fielddescrof(NODE, 'charval') nextdescr = cpu.fielddescrof(NODE, 'next') otherdescr = cpu.fielddescrof(NODE2, 'other') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: test and implement optimization for interior fields
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69161:41e8eb67d110 Date: 2014-02-15 13:38 +0100 http://bitbucket.org/pypy/pypy/changeset/41e8eb67d110/ Log:test and implement optimization for interior fields diff --git a/rpython/jit/backend/llgraph/runner.py b/rpython/jit/backend/llgraph/runner.py --- a/rpython/jit/backend/llgraph/runner.py +++ b/rpython/jit/backend/llgraph/runner.py @@ -201,6 +201,24 @@ def is_float_field(self): return getkind(self.FIELD) == 'float' +def is_integer_bounded(self): +return getkind(self.FIELD) == 'int' \ +and rffi.sizeof(self.FIELD) symbolic.WORD + +def get_integer_min(self): +if getkind(self.FIELD) != 'int': +assert False + +return intbounds.get_integer_min( +not _is_signed_kind(self.FIELD), rffi.sizeof(self.FIELD)) + +def get_integer_max(self): +if getkind(self.FIELD) != 'int': +assert False + +return intbounds.get_integer_max( +not _is_signed_kind(self.FIELD), rffi.sizeof(self.FIELD)) + _example_res = {'v': None, 'r': lltype.nullptr(llmemory.GCREF.TO), 'i': 0, diff --git a/rpython/jit/backend/llsupport/descr.py b/rpython/jit/backend/llsupport/descr.py --- a/rpython/jit/backend/llsupport/descr.py +++ b/rpython/jit/backend/llsupport/descr.py @@ -273,6 +273,15 @@ def is_float_field(self): return self.fielddescr.is_float_field() +def is_integer_bounded(self): +return self.fielddescr.is_integer_bounded() + +def get_integer_min(self): +return self.fielddescr.get_integer_min() + +def get_integer_max(self): +return self.fielddescr.get_integer_max() + def repr_of_descr(self): return 'InteriorFieldDescr %s' % self.fielddescr.repr_of_descr() diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -346,6 +346,8 @@ optimize_GETFIELD_GC = optimize_GETFIELD_RAW +optimize_GETINTERIORFIELD_GC = optimize_GETFIELD_RAW + def optimize_GETARRAYITEM_RAW(self, op): self.emit_operation(op) descr = op.getdescr() diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5282,6 +5282,22 @@ self.optimize_loop(ops, expected) +def test_getinterior_outside_intbounds(self): +ops = +[p0] +f0 = getinteriorfield_gc(p0, 0, descr=fc_array_floatdescr) +i0 = getinteriorfield_gc(p0, 0, descr=fc_array_chardescr) +i1 = int_lt(i0, 256) +guard_true(i1) [] + + +expected = +[p0] +f0 = getinteriorfield_gc(p0, 0, descr=fc_array_floatdescr) +i0 = getinteriorfield_gc(p0, 0, descr=fc_array_chardescr) + +self.optimize_loop(ops, expected) + class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin): pass diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py b/rpython/jit/metainterp/optimizeopt/test/test_util.py --- a/rpython/jit/metainterp/optimizeopt/test/test_util.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py @@ -225,6 +225,12 @@ rawarraydescr_char = cpu.arraydescrof(lltype.Array(lltype.Char, hints={'nolength': True})) +fc_array = lltype.GcArray( +lltype.Struct( +floatchar, (float, lltype.Float), (char, lltype.Char))) +fc_array_descr = cpu.arraydescrof(fc_array) +fc_array_floatdescr = cpu.interiorfielddescrof(fc_array, float) +fc_array_chardescr = cpu.interiorfielddescrof(fc_array, char) for _name, _os in [ ('strconcatdescr', 'OS_STR_CONCAT'), ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: failing test for gc array
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69157:95039bc14ef6 Date: 2014-02-15 01:26 +0100 http://bitbucket.org/pypy/pypy/changeset/95039bc14ef6/ Log:failing test for gc array diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5239,7 +5239,6 @@ self.optimize_loop(ops, ops) - def test_rawarray_cmp_outside_intbounds(self): ops = [i0] @@ -5254,6 +5253,20 @@ self.optimize_loop(ops, expected) +def test_gcarray_outside_intbounds(self): +ops = +[p0] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) +i1 = int_lt(i0, 256) +guard_true(i1) [] + + +expected = +[p0] +i0 = getarrayitem_gc(p0, 0, descr=chararraydescr) + +self.optimize_loop(ops, expected) + class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin): pass diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py b/rpython/jit/metainterp/optimizeopt/test/test_util.py --- a/rpython/jit/metainterp/optimizeopt/test/test_util.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py @@ -206,6 +206,8 @@ EffectInfo.EF_CANNOT_RAISE, oopspecindex=EffectInfo.OS_RAW_FREE)) +chararray = lltype.GcArray(lltype.Char) +chararraydescr = cpu.arraydescrof(chararray) # array of structs (complex data) complexarray = lltype.GcArray( ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: fix FakeDescr, document branch
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69163:6be6ca6b8558 Date: 2014-02-15 18:07 +0100 http://bitbucket.org/pypy/pypy/changeset/6be6ca6b8558/ Log:fix FakeDescr, document branch diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -67,3 +67,7 @@ With a properly configured 256-color terminal (TERM=...-256color), the Mandelbrot set shown during translation now uses a range of 50 colours. Essential! + +.. branch: array-propagate-len +Kill some guards and operations in JIT traces by adding integer bounds +propagation for getfield_(raw|gc) and getarrayitem_(raw|gc). diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py @@ -5563,6 +5563,8 @@ self.name = name def sort_key(self): return id(self) +def is_integer_bounded(self): +return False for n in ('inst_w_seq', 'inst_index', 'inst_w_list', 'inst_length', ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy array-propagate-len: failing test for getfield_raw, skip bounds check if descr is None
Author: Squeaky squeaky...@gmx.com Branch: array-propagate-len Changeset: r69158:a17311d182d4 Date: 2014-02-15 12:11 +0100 http://bitbucket.org/pypy/pypy/changeset/a17311d182d4/ Log:failing test for getfield_raw, skip bounds check if descr is None diff --git a/rpython/jit/metainterp/optimizeopt/__init__.py b/rpython/jit/metainterp/optimizeopt/__init__.py --- a/rpython/jit/metainterp/optimizeopt/__init__.py +++ b/rpython/jit/metainterp/optimizeopt/__init__.py @@ -63,7 +63,7 @@ optimizer.propagate_all_forward() finally: debug_stop(jit-optimize) - + if __name__ == '__main__': print ALL_OPTS_NAMES diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -347,12 +347,14 @@ def optimize_GETARRAYITEM_RAW(self, op): self.emit_operation(op) descr = op.getdescr() -if descr.is_item_integer_bounded(): +if descr and descr.is_item_integer_bounded(): v1 = self.getvalue(op.result) v1.intbound.make_ge(IntLowerBound(descr.get_item_integer_min())) v1.intbound.make_lt( IntUpperBound(descr.get_item_integer_max() + 1)) +optimize_GETARRAYITEM_GC = optimize_GETARRAYITEM_RAW + def optimize_UNICODEGETITEM(self, op): self.emit_operation(op) v1 = self.getvalue(op.result) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -5239,6 +5239,21 @@ self.optimize_loop(ops, ops) +def test_getfieldraw_cmp_outside_bounds(self): +ops = +[p0] +i0 = getfield_raw(p0, descr=chardescr) +i1 = int_gt(i0, -1) +guard_true(i1) [] + + +expected = +[p0] +i0 = getfield_raw(p0, descr=chardescr) + +self.optimize_loop(ops, expected) + + def test_rawarray_cmp_outside_intbounds(self): ops = [i0] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] jitviewer default: Don't duplicate requirements from setup.py
Author: Squeaky squeaky...@gmx.com Branch: Changeset: r254:709f1b155aaf Date: 2014-02-06 15:53 +0100 http://bitbucket.org/pypy/jitviewer/changeset/709f1b155aaf/ Log:Don't duplicate requirements from setup.py diff --git a/requirements.txt b/requirements.txt --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,1 @@ -flask -pygments -simplejson +-e . ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy release-2.1.x: revert setting cppflags and ldflagsto original appraoch, this doesnt break setuptools monkeypatching distutils
Author: Pawe#322; Piotr Przeradowski przeradow...@gmail.com Branch: release-2.1.x Changeset: r65766:522f7674a168 Date: 2013-07-28 01:08 +0200 http://bitbucket.org/pypy/pypy/changeset/522f7674a168/ Log:revert setting cppflags and ldflagsto original appraoch, this doesnt break setuptools monkeypatching distutils (transplanted from 9fad3a8b420858513f1356f3d82f6e4b7f377e6e) diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py --- a/lib-python/2.7/distutils/sysconfig_pypy.py +++ b/lib-python/2.7/distutils/sysconfig_pypy.py @@ -12,6 +12,7 @@ import sys import os +import shlex from distutils.errors import DistutilsPlatformError @@ -65,11 +66,6 @@ g['SOABI'] = g['SO'].rsplit('.')[0] g['LIBDIR'] = os.path.join(sys.prefix, 'lib') g['CC'] = gcc -pthread # -pthread might not be valid on OS/X, check -g['OPT'] = -g['CFLAGS'] = -g['CPPFLAGS'] = -g['CCSHARED'] = '-shared -O2 -fPIC -Wimplicit' -g['LDSHARED'] = g['CC'] + ' -shared' global _config_vars _config_vars = g @@ -127,34 +123,21 @@ optional C speedup components. if compiler.compiler_type == unix: -cc, opt, cflags, ccshared, ldshared = get_config_vars( -'CC', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED') - +compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit']) compiler.shared_lib_extension = get_config_var('SO') - -if 'LDSHARED' in os.environ: -ldshared = os.environ['LDSHARED'] -if 'CPP' in os.environ: -cpp = os.environ['CPP'] -else: -cpp = cc + -E # not always -if 'LDFLAGS' in os.environ: -ldshared = ldshared + ' ' + os.environ['LDFLAGS'] -if 'CFLAGS' in os.environ: -cflags = opt + ' ' + os.environ['CFLAGS'] -ldshared = ldshared + ' ' + os.environ['CFLAGS'] -if 'CPPFLAGS' in os.environ: -cpp = cpp + ' ' + os.environ['CPPFLAGS'] -cflags = cflags + ' ' + os.environ['CPPFLAGS'] -ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] - -cc_cmd = cc + ' ' + cflags - -compiler.set_executables( -preprocessor=cpp, -compiler=cc_cmd, -compiler_so=cc_cmd + ' ' + ccshared, -linker_so=ldshared) +if CPPFLAGS in os.environ: +cppflags = shlex.split(os.environ[CPPFLAGS]) +compiler.compiler.extend(cppflags) +compiler.compiler_so.extend(cppflags) +compiler.linker_so.extend(cppflags) +if CFLAGS in os.environ: +cflags = shlex.split(os.environ[CFLAGS]) +compiler.compiler.extend(cflags) +compiler.compiler_so.extend(cflags) +compiler.linker_so.extend(cflags) +if LDFLAGS in os.environ: +ldflags = shlex.split(os.environ[LDFLAGS]) +compiler.linker_so.extend(ldflags) from sysconfig_cpython import ( ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: revert setting cppflags and ldflagsto original appraoch, this doesnt break setuptools monkeypatching distutils
Author: Pawe#322; Piotr Przeradowski przeradow...@gmail.com Branch: Changeset: r65733:9fad3a8b4208 Date: 2013-07-28 01:08 +0200 http://bitbucket.org/pypy/pypy/changeset/9fad3a8b4208/ Log:revert setting cppflags and ldflagsto original appraoch, this doesnt break setuptools monkeypatching distutils diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py --- a/lib-python/2.7/distutils/sysconfig_pypy.py +++ b/lib-python/2.7/distutils/sysconfig_pypy.py @@ -12,6 +12,7 @@ import sys import os +import shlex from distutils.errors import DistutilsPlatformError @@ -65,11 +66,6 @@ g['SOABI'] = g['SO'].rsplit('.')[0] g['LIBDIR'] = os.path.join(sys.prefix, 'lib') g['CC'] = gcc -pthread # -pthread might not be valid on OS/X, check -g['OPT'] = -g['CFLAGS'] = -g['CPPFLAGS'] = -g['CCSHARED'] = '-shared -O2 -fPIC -Wimplicit' -g['LDSHARED'] = g['CC'] + ' -shared' global _config_vars _config_vars = g @@ -127,34 +123,21 @@ optional C speedup components. if compiler.compiler_type == unix: -cc, opt, cflags, ccshared, ldshared = get_config_vars( -'CC', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED') - +compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit']) compiler.shared_lib_extension = get_config_var('SO') - -if 'LDSHARED' in os.environ: -ldshared = os.environ['LDSHARED'] -if 'CPP' in os.environ: -cpp = os.environ['CPP'] -else: -cpp = cc + -E # not always -if 'LDFLAGS' in os.environ: -ldshared = ldshared + ' ' + os.environ['LDFLAGS'] -if 'CFLAGS' in os.environ: -cflags = opt + ' ' + os.environ['CFLAGS'] -ldshared = ldshared + ' ' + os.environ['CFLAGS'] -if 'CPPFLAGS' in os.environ: -cpp = cpp + ' ' + os.environ['CPPFLAGS'] -cflags = cflags + ' ' + os.environ['CPPFLAGS'] -ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] - -cc_cmd = cc + ' ' + cflags - -compiler.set_executables( -preprocessor=cpp, -compiler=cc_cmd, -compiler_so=cc_cmd + ' ' + ccshared, -linker_so=ldshared) +if CPPFLAGS in os.environ: +cppflags = shlex.split(os.environ[CPPFLAGS]) +compiler.compiler.extend(cppflags) +compiler.compiler_so.extend(cppflags) +compiler.linker_so.extend(cppflags) +if CFLAGS in os.environ: +cflags = shlex.split(os.environ[CFLAGS]) +compiler.compiler.extend(cflags) +compiler.compiler_so.extend(cflags) +compiler.linker_so.extend(cflags) +if LDFLAGS in os.environ: +ldflags = shlex.split(os.environ[LDFLAGS]) +compiler.linker_so.extend(ldflags) from sysconfig_cpython import ( ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pythoninspect-fix: attempt to fix app_main
Author: Pawe#322; Piotr Przeradowski przeradow...@gmail.com Branch: pythoninspect-fix Changeset: r65665:0806ff7d7880 Date: 2013-07-23 23:00 +0200 http://bitbucket.org/pypy/pypy/changeset/0806ff7d7880/ Log:attempt to fix app_main diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py --- a/pypy/interpreter/app_main.py +++ b/pypy/interpreter/app_main.py @@ -460,8 +460,11 @@ if os.getenv('PYTHONVERBOSE'): options[verbose] = 1 +# skip environment cache since PYTHONINSPECT could be set in same process +from __pypy__.os import real_getenv + if (options[interactive] or -(not options[ignore_environment] and os.getenv('PYTHONINSPECT'))): +(not options[ignore_environment] and real_getenv('PYTHONINSPECT'))): options[inspect] = 1 ##We don't print the warning, because it offers no additional security ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pythoninspect-fix: failing test
Author: Pawe#322; Piotr Przeradowski przeradow...@gmail.com Branch: pythoninspect-fix Changeset: r65663:5dff0c40663d Date: 2013-07-23 01:02 +0200 http://bitbucket.org/pypy/pypy/changeset/5dff0c40663d/ Log:failing test diff --git a/pypy/interpreter/test/test_app_main.py b/pypy/interpreter/test/test_app_main.py --- a/pypy/interpreter/test/test_app_main.py +++ b/pypy/interpreter/test/test_app_main.py @@ -48,7 +48,7 @@ pdir = _get_next_path(ext='') p = pdir.ensure(dir=1).join('__main__.py') p.write(str(py.code.Source(source))) -# return relative path for testing purposes +# return relative path for testing purposes return py.path.local().bestrelpath(pdir) demo_script = getscript( @@ -706,6 +706,15 @@ assert 'hello world\n' in data assert '42\n' in data +def test_putenv_fires_interactive_within_process(self): +# should be noninteractive when piped in +data = 'import os\nos.putenv(PYTHONINSPECT, 1)\n' +self.run('', senddata=data, expect_prompt=False) + +# should go interactive with -c +data = data.replace('\n', ';') +self.run(-c '%s' % data, expect_prompt=True) + def test_option_S_copyright(self): data = self.run('-S -i', expect_prompt=True, expect_banner=True) assert 'copyright' not in data @@ -971,7 +980,7 @@ pypy_c = os.path.join(self.trunkdir, 'pypy', 'goal', 'pypy-c') app_main.setup_bootstrap_path(pypy_c) newpath = sys.path[:] -# we get at least lib_pypy +# we get at least lib_pypy # lib-python/X.Y.Z, and maybe more (e.g. plat-linux2) assert len(newpath) = 2 for p in newpath: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pythoninspect-fix: fix merge, typos
Author: Pawe#322; Piotr Przeradowski przeradow...@gmail.com Branch: pythoninspect-fix Changeset: r65671:7d2d7703eb8b Date: 2013-07-25 22:20 +0200 http://bitbucket.org/pypy/pypy/changeset/7d2d7703eb8b/ Log:fix merge, typos diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -32,13 +32,12 @@ .. branch: ssl_moving_write_buffer - local .. branch: pythoninspect-fix Make PyPy respect PYTHONINSPECT variable set via os.putenv in the same process to start interactive prompt when the script execution finishes. This adds new __pypy__.os.real_getenv call that bypasses Python cache and looksup env in the underlying OS. Translatorshell now works on PyPy. -=== + .. branch: add-statvfs Added os.statvfs and os.fstatvfs diff --git a/pypy/interpreter/test/test_app_main.py b/pypy/interpreter/test/test_app_main.py --- a/pypy/interpreter/test/test_app_main.py +++ b/pypy/interpreter/test/test_app_main.py @@ -710,7 +710,7 @@ try: import __pypy__ except ImportError: -py.test.skip(This can be only tested on PyPy with get_realenv) +py.test.skip(This can be only tested on PyPy with real_getenv) # should be noninteractive when piped in data = 'import os\nos.putenv(PYTHONINSPECT, 1)\n' ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pythoninspect-fix: no None allowed
Author: Pawe#322; Piotr Przeradowski przeradow...@gmail.com Branch: pythoninspect-fix Changeset: r65667:0f1dbffcb578 Date: 2013-07-24 21:46 +0200 http://bitbucket.org/pypy/pypy/changeset/0f1dbffcb578/ Log:no None allowed diff --git a/pypy/module/__pypy__/interp_os.py b/pypy/module/__pypy__/interp_os.py --- a/pypy/module/__pypy__/interp_os.py +++ b/pypy/module/__pypy__/interp_os.py @@ -3,7 +3,7 @@ from pypy.interpreter.gateway import unwrap_spec -@unwrap_spec(name=str) +@unwrap_spec(name='str0') def real_getenv(space, name): Get an OS environment value skipping Python cache -return space.wrap(os.getenv(name)) +return space.wrap(os.environ.get(name)) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pythoninspect-fix: use __pypy__.os
Author: Pawe#322; Piotr Przeradowski przeradow...@gmail.com Branch: pythoninspect-fix Changeset: r65668:c1575d6e1de5 Date: 2013-07-25 15:45 +0200 http://bitbucket.org/pypy/pypy/changeset/c1575d6e1de5/ Log:use __pypy__.os diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py --- a/pypy/interpreter/app_main.py +++ b/pypy/interpreter/app_main.py @@ -460,11 +460,8 @@ if os.getenv('PYTHONVERBOSE'): options[verbose] = 1 -# skip environment cache since PYTHONINSPECT could be set in same process -from __pypy__.os import real_getenv - if (options[interactive] or -(not options[ignore_environment] and real_getenv('PYTHONINSPECT'))): +(not options[ignore_environment] and os.getenv('PYTHONINSPECT'))): options[inspect] = 1 ##We don't print the warning, because it offers no additional security @@ -559,8 +556,15 @@ # or # * PYTHONINSPECT is set and stdin is a tty. # +try: +# we need a version of getenv that bypasses Python caching +from __pypy__.os import real_getenv +except ImportError: +# dont fail on CPython here +real_getenv = os.getenv + return (interactive or -((inspect or (readenv and os.getenv('PYTHONINSPECT'))) +((inspect or (readenv and real_getenv('PYTHONINSPECT'))) and sys.stdin.isatty())) success = True ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pythoninspect-fix: try using RPython os.getenv instead of LL version
Author: Pawe#322; Piotr Przeradowski przeradow...@gmail.com Branch: pythoninspect-fix Changeset: r65666:9a20d5ede0ec Date: 2013-07-24 08:45 +0200 http://bitbucket.org/pypy/pypy/changeset/9a20d5ede0ec/ Log:try using RPython os.getenv instead of LL version diff --git a/pypy/module/__pypy__/interp_os.py b/pypy/module/__pypy__/interp_os.py --- a/pypy/module/__pypy__/interp_os.py +++ b/pypy/module/__pypy__/interp_os.py @@ -1,4 +1,4 @@ -from rpython.rtyper.module.ll_os_environ import getenv_llimpl +import os from pypy.interpreter.gateway import unwrap_spec @@ -6,4 +6,4 @@ @unwrap_spec(name=str) def real_getenv(space, name): Get an OS environment value skipping Python cache -return space.wrap(getenv_llimpl(name)) +return space.wrap(os.getenv(name)) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pythoninspect-fix: implement __pypy__.os.real_getenv with a test
Author: Pawe#322; Piotr Przeradowski przeradow...@gmail.com Branch: pythoninspect-fix Changeset: r65664:8f98f2b808f9 Date: 2013-07-23 22:52 +0200 http://bitbucket.org/pypy/pypy/changeset/8f98f2b808f9/ Log:implement __pypy__.os.real_getenv with a test diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py --- a/pypy/module/__pypy__/__init__.py +++ b/pypy/module/__pypy__/__init__.py @@ -50,6 +50,13 @@ } +class OsModule(MixedModule): +appleveldefs = {} +interpleveldefs = { +'real_getenv': 'interp_os.real_getenv' +} + + class Module(MixedModule): appleveldefs = { } @@ -82,6 +89,7 @@ time: TimeModule, thread: ThreadModule, intop: IntOpModule, +os: OsModule, } def setup_after_space_initialization(self): diff --git a/pypy/module/__pypy__/interp_os.py b/pypy/module/__pypy__/interp_os.py new file mode 100644 --- /dev/null +++ b/pypy/module/__pypy__/interp_os.py @@ -0,0 +1,9 @@ +from rpython.rtyper.module.ll_os_environ import getenv_llimpl + +from pypy.interpreter.gateway import unwrap_spec + + +@unwrap_spec(name=str) +def real_getenv(space, name): +Get an OS environment value skipping Python cache +return space.wrap(getenv_llimpl(name)) diff --git a/pypy/module/__pypy__/test/test_os.py b/pypy/module/__pypy__/test/test_os.py new file mode 100644 --- /dev/null +++ b/pypy/module/__pypy__/test/test_os.py @@ -0,0 +1,16 @@ +class AppTestOs: +spaceconfig = dict(usemodules=['__pypy__']) + +def test_real_getenv(self): +import __pypy__.os +import os + +key = 'UNLIKELY_SET' +assert key not in os.environ +os.putenv(key, '42') +# this one skips Python cache +assert __pypy__.os.real_getenv(key) == '42' +# this one can only see things set on interpter start (cached) +assert os.getenv(key) is None +os.unsetenv(key) +assert __pypy__.os.real_getenv(key) is None ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pythoninspect-fix: argh
Author: Pawe#322; Piotr Przeradowski przeradow...@gmail.com Branch: pythoninspect-fix Changeset: r65672:e026c95e2f05 Date: 2013-07-25 22:25 +0200 http://bitbucket.org/pypy/pypy/changeset/e026c95e2f05/ Log:argh diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -43,4 +43,3 @@ .. branch: statvfs_tests Added some addition tests for statvfs. - other ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy pythoninspect-fix: skip on CPython, whatsnew
Author: Pawe#322; Piotr Przeradowski przeradow...@gmail.com Branch: pythoninspect-fix Changeset: r65669:a4689d27a2ef Date: 2013-07-25 21:49 +0200 http://bitbucket.org/pypy/pypy/changeset/a4689d27a2ef/ Log:skip on CPython, whatsnew diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -31,3 +31,9 @@ more precise information about which functions can be called. Needed for Topaz. .. branch: ssl_moving_write_buffer + +.. branch: pythoninspect-fix +Make PyPy respect PYTHONINSPECT variable set via os.putenv in the same process +to start interactive prompt when the script execution finishes. This adds +new __pypy__.os.real_getenv call that bypasses Python cache and looksup env +in the underlying OS. Translatorshell now works on PyPy. diff --git a/pypy/interpreter/test/test_app_main.py b/pypy/interpreter/test/test_app_main.py --- a/pypy/interpreter/test/test_app_main.py +++ b/pypy/interpreter/test/test_app_main.py @@ -707,6 +707,11 @@ assert '42\n' in data def test_putenv_fires_interactive_within_process(self): +try: +import __pypy__ +except ImportError: +py.test.skip(This can be only tested on PyPy with get_realenv) + # should be noninteractive when piped in data = 'import os\nos.putenv(PYTHONINSPECT, 1)\n' self.run('', senddata=data, expect_prompt=False) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit