Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r67372:d3f121b34d7f
Date: 2013-10-14 22:20 +0200
http://bitbucket.org/pypy/pypy/changeset/d3f121b34d7f/
Log: Specialize string decoding based on the error function when possible
diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py
b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -161,7 +161,7 @@
loops = log.loops_by_filename(self.filepath)
assert len(loops) == 1
for loop in loops:
- loop.match_by_id('getattr','''
+ assert loop.match_by_id('getattr','''
guard_not_invalidated?
i32 = strlen(p31)
i34 = int_add(5, i32)
@@ -190,11 +190,11 @@
assert log.result == main(1000)
loops = log.loops_by_filename(self.filepath)
loop, = loops
- loop.match_by_id('callone', '''
+ assert loop.match_by_id('callone', '''
p114 = call(ConstClass(ll_lower__rpy_stringPtr), p113,
descr=<Callr . r EF=3>)
guard_no_exception(descr=...)
''')
- loop.match_by_id('calltwo', '') # nothing
+ assert loop.match_by_id('calltwo', '') # nothing
def test_move_method_call_out_of_loop(self):
def main(n):
@@ -208,7 +208,7 @@
assert log.result == main(1000)
loops = log.loops_by_filename(self.filepath)
loop, = loops
- loop.match_by_id('callone', '') # nothing
+ assert loop.match_by_id('callone', '') # nothing
def test_lookup_codec(self):
log = self.run("""
@@ -220,7 +220,7 @@
return i
""", [1000])
loop, = log.loops_by_filename(self.filepath)
- loop.match("""
+ assert loop.match("""
i45 = int_lt(i43, i26)
guard_true(i45, descr=...)
i46 = int_add(i43, 1)
@@ -229,3 +229,25 @@
--TICK--
jump(..., descr=...)
""")
+
+ def test_decode_ascii(self):
+ log = self.run("""
+ def main(n):
+ for i in xrange(n):
+ unicode('abc')
+ return i
+ """, [1000])
+ loop, = log.loops_by_filename(self.filepath)
+ assert loop.match("""
+ i49 = int_lt(i47, i24)
+ guard_true(i49, descr=...)
+ i50 = int_add(i47, 1)
+ setfield_gc(p15, i50, descr=<FieldS
pypy.module.__builtin__.functional.W_XRangeIterator.inst_current 8>)
+ guard_not_invalidated(descr=...)
+ p52 =
call(ConstClass(str_decode_ascii__raise_unicode_exception_decode),
ConstPtr(ptr38), 3, 1, descr=<Callr 8 rii EF=4>)
+ guard_no_exception(descr=...)
+ p53 = getfield_gc_pure(p52, descr=<FieldP tuple2.item0 8>)
+ guard_nonnull(p53, descr=...)
+ --TICK--
+ jump(..., descr=...)
+ """)
diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -967,6 +967,8 @@
return result.build(), pos
+# Specialize on the errorhandler when it's a constant
[email protected]_or_var(4)
def str_decode_ascii(s, size, errors, final=False,
errorhandler=None):
if errorhandler is None:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit