[pypy-svn] pypy default: the CALL_METHOD opcode did not profile builtin methods called with keyword arguments

amauryfa commits-noreply at bitbucket.org
Thu Jan 27 14:56:53 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r41388:6229439ba517
Date: 2011-01-27 10:24 +0100
http://bitbucket.org/pypy/pypy/changeset/6229439ba517/

Log:	the CALL_METHOD opcode did not profile builtin methods called with
	keyword arguments

diff --git a/pypy/interpreter/test/test_executioncontext.py b/pypy/interpreter/test/test_executioncontext.py
--- a/pypy/interpreter/test/test_executioncontext.py
+++ b/pypy/interpreter/test/test_executioncontext.py
@@ -164,6 +164,25 @@
         events = space.unwrap(w_events)
         assert events == ['return', 'c_call', 'c_return', 'return', 'c_call']
 
+    def test_c_call_setprofile_kwargs(self):
+        space = self.space
+        w_events = space.appexec([], """():
+        import sys
+        l = []
+        def profile(frame, event, arg):
+            l.append(event)
+
+        def bar():
+            sys.setprofile(profile)
+            [].sort(reverse=True)
+            sys.setprofile(None)
+
+        bar()
+        return l
+        """)
+        events = space.unwrap(w_events)
+        assert events == ['c_call', 'c_return', 'c_call']
+
     def test_c_call_setprofile_strange_method(self):
         space = self.space
         w_events = space.appexec([], """():

diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py
--- a/pypy/objspace/std/callmethod.py
+++ b/pypy/objspace/std/callmethod.py
@@ -104,7 +104,10 @@
         if w_self is None:
             f.popvalue()    # removes w_self, which is None
         w_callable = f.popvalue()
-        w_result = f.space.call_args(w_callable, args)
+        if f.is_being_profiled and function.is_builtin_code(w_callable):
+            w_result = f.space.call_args_and_c_profile(f, w_callable, args)
+        else:
+            w_result = f.space.call_args(w_callable, args)
         rstack.resume_point("CALL_METHOD_KW", f, returns=w_result)
     f.pushvalue(w_result)
 


More information about the Pypy-commit mailing list