[pypy-svn] r70689 - in pypy/branch/jit-profiling/pypy/interpreter: . test

fijal at codespeak.net fijal at codespeak.net
Mon Jan 18 16:31:49 CET 2010


Author: fijal
Date: Mon Jan 18 16:31:48 2010
New Revision: 70689

Modified:
   pypy/branch/jit-profiling/pypy/interpreter/baseobjspace.py
   pypy/branch/jit-profiling/pypy/interpreter/executioncontext.py
   pypy/branch/jit-profiling/pypy/interpreter/pyframe.py
   pypy/branch/jit-profiling/pypy/interpreter/pyopcode.py
   pypy/branch/jit-profiling/pypy/interpreter/test/test_profiling.py
Log:
(pedronis, fijal) A tentative checkin, try to kill frame.is_being_profiled.


Modified: pypy/branch/jit-profiling/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/jit-profiling/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/branch/jit-profiling/pypy/interpreter/baseobjspace.py	Mon Jan 18 16:31:48 2010
@@ -791,7 +791,8 @@
 
     def call_valuestack(self, w_func, nargs, frame):
         from pypy.interpreter.function import Function, Method, is_builtin_code
-        if frame.is_being_profiled and is_builtin_code(w_func):
+        if (self.getexecutioncontext().profilefunc is not None
+            and is_builtin_code(w_func)):
             # XXX: this code is copied&pasted :-( from the slow path below
             # call_valuestack().
             args = frame.make_arguments(nargs)

Modified: pypy/branch/jit-profiling/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/branch/jit-profiling/pypy/interpreter/executioncontext.py	(original)
+++ pypy/branch/jit-profiling/pypy/interpreter/executioncontext.py	Mon Jan 18 16:31:48 2010
@@ -33,7 +33,7 @@
 
     # JIT: when tracing (but not when blackholing!), the following
     # self.w_tracefunc should be a constant None
-    # frame.is_being_profiled should be False for virtual frames
+    # we should not profile virtual frames
 
     # bind it here, so tests can overwrite it
     _we_are_jitted = staticmethod(jit.we_are_jitted)
@@ -77,14 +77,9 @@
 
     def leave(self, frame):
         try:
-            # below we need to check if is_being_profiled is set, instead
-            # of profilefunc, since when jitted we have profilefunc, but not
-            # is_being_profiled
-            if frame.is_being_profiled:
-                self._trace(frame, TRACE_LEAVEFRAME, self.space.w_None)
-                nextframe = frame.f_backref()
-                if nextframe is not None:
-                    nextframe.is_being_profiled = True
+            if not self._we_are_jitted():
+                if self.profilefunc is not None:
+                    self._trace(frame, TRACE_LEAVEFRAME, self.space.w_None)
         finally:
             self.topframeref = frame.f_backref
             self.framestackdepth -= 1
@@ -156,20 +151,10 @@
             return lst
         # coroutine: I think this is all, folks!
 
-
-    def get_builtin(self):
-        frame = self.gettopframe_nohidden()
-        if frame is not None:
-            return frame.builtin
-        else:
-            return self.space.builtin
-
     def c_call_trace(self, frame, w_func):
         "Profile the call of a builtin function"
         if self._we_are_jitted():
             return
-        if self.profilefunc is None:
-            frame.is_being_profiled = False
         else:
             self._trace(frame, TRACE_C_CALL, w_func)
 
@@ -177,8 +162,6 @@
         "Profile the return from a builtin function"
         if self._we_are_jitted():
             return
-        if self.profilefunc is None:
-            frame.is_being_profiled = False
         else:
             self._trace(frame, TRACE_C_RETURN, w_retval)
 
@@ -186,18 +169,14 @@
         "Profile function called upon OperationError."
         if self._we_are_jitted():
             return
-        if self.profilefunc is None:
-            frame.is_being_profiled = False
         else:
             self._trace(frame, TRACE_C_EXCEPTION, w_exc)
 
     def call_trace(self, frame):
         "Trace the call of a function"
-        if (self.w_tracefunc is not None or
-           (not self._we_are_jitted() and self.profilefunc is not None)):
-            self._trace(frame, TRACE_CALL, self.space.w_None)
-            if self.profilefunc:
-                frame.is_being_profiled = True
+        if not self._we_are_jitted():
+            if (self.w_tracefunc is not None or self.profilefunc is not None):
+                self._trace(frame, TRACE_CALL, self.space.w_None)
 
     def return_trace(self, frame, w_retval):
         "Trace the return from a function"
@@ -263,9 +242,6 @@
         if func is not None:
             if w_arg is None:
                 raise ValueError("Cannot call setllprofile with real None")
-            topframe = self.gettopframe_nohidden()
-            if topframe is not None:
-                topframe.is_being_profiled = True
         self.profilefunc = func
         self.w_profilefuncarg = w_arg
 

Modified: pypy/branch/jit-profiling/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/branch/jit-profiling/pypy/interpreter/pyframe.py	(original)
+++ pypy/branch/jit-profiling/pypy/interpreter/pyframe.py	Mon Jan 18 16:31:48 2010
@@ -8,7 +8,7 @@
 from pypy.interpreter.executioncontext import ExecutionContext
 from pypy.interpreter import pytraceback
 import opcode
-from pypy.rlib.objectmodel import we_are_translated, instantiate
+from pypy.rlib.objectmodel import instantiate
 from pypy.rlib.jit import hint
 from pypy.rlib.debug import make_sure_not_resized
 from pypy.rlib import jit
@@ -46,7 +46,6 @@
     instr_lb                 = 0
     instr_ub                 = -1
     instr_prev               = -1
-    is_being_profiled        = False
 
     def __init__(self, space, code, w_globals, closure):
         self = hint(self, access_directly=True, fresh_virtualizable=True)

Modified: pypy/branch/jit-profiling/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/branch/jit-profiling/pypy/interpreter/pyopcode.py	(original)
+++ pypy/branch/jit-profiling/pypy/interpreter/pyopcode.py	Mon Jan 18 16:31:48 2010
@@ -912,7 +912,8 @@
         arguments = f.popvalues(n_arguments)
         args = f.argument_factory(arguments, keywords, keywords_w, w_star, w_starstar)
         w_function  = f.popvalue()
-        if f.is_being_profiled and is_builtin_code(w_function):
+        if (f.space.getexecutioncontext().profilefunc is not None and
+            is_builtin_code(w_function)):
             w_result = f.space.call_args_and_c_profile(f, w_function, args)
         else:
             w_result = f.space.call_args(w_function, args)

Modified: pypy/branch/jit-profiling/pypy/interpreter/test/test_profiling.py
==============================================================================
--- pypy/branch/jit-profiling/pypy/interpreter/test/test_profiling.py	(original)
+++ pypy/branch/jit-profiling/pypy/interpreter/test/test_profiling.py	Mon Jan 18 16:31:48 2010
@@ -21,7 +21,6 @@
 class MockFrame(object):
     w_f_trace         = None
     last_exception    = None
-    is_being_profiled = False
     
     def hide(self):
         return False
@@ -57,3 +56,11 @@
         ec.leave_jit()
         ec.leave(frame)
         assert events == [(TRACE_CALL, frame), (TRACE_RETURN, frame)]
+
+    def test_recursive_call(self):
+        events = []
+        def profilefunc(space, ignored, frame, event, w_arg):
+            events.append((event, frame))
+        
+        ec = MockExecutionContext(self.space)
+                



More information about the Pypy-commit mailing list