[pypy-commit] pypy default: Unroll a loop, which allows super() to go through method caches in the JIT.
alex_gaynor
noreply at buildbot.pypy.org
Sat Feb 25 20:16:39 CET 2012
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r52899:d7300e63b1f7
Date: 2012-02-25 20:15 +0100
http://bitbucket.org/pypy/pypy/changeset/d7300e63b1f7/
Log: Unroll a loop, which allows super() to go through method caches in
the JIT.
diff --git a/pypy/module/pypyjit/test_pypy_c/test_instance.py b/pypy/module/pypyjit/test_pypy_c/test_instance.py
--- a/pypy/module/pypyjit/test_pypy_c/test_instance.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_instance.py
@@ -201,3 +201,28 @@
loop, = log.loops_by_filename(self.filepath)
assert loop.match_by_id("compare", "") # optimized away
+ def test_super(self):
+ def main():
+ class A(object):
+ def m(self, x):
+ return x + 1
+ class B(A):
+ def m(self, x):
+ return super(B, self).m(x)
+ i = 0
+ while i < 300:
+ i = B().m(i)
+ return i
+
+ log = self.run(main, [])
+ loop, = log.loops_by_filename(self.filepath)
+ assert loop.match("""
+ i78 = int_lt(i72, 300)
+ guard_true(i78, descr=...)
+ guard_not_invalidated(descr=...)
+ i79 = force_token()
+ i80 = force_token()
+ i81 = int_add(i72, 1)
+ --TICK--
+ jump(..., descr=...)
+ """)
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -345,9 +345,9 @@
return w_self._lookup_where(name)
+ @unroll_safe
def lookup_starting_at(w_self, w_starttype, name):
space = w_self.space
- # XXX Optimize this with method cache
look = False
for w_class in w_self.mro_w:
if w_class is w_starttype:
More information about the pypy-commit
mailing list