[pypy-svn] r70454 - pypy/trunk/pypy/interpreter

arigo at codespeak.net arigo at codespeak.net
Fri Jan 8 14:41:51 CET 2010


Author: arigo
Date: Fri Jan  8 14:41:50 2010
New Revision: 70454

Modified:
   pypy/trunk/pypy/interpreter/baseobjspace.py
   pypy/trunk/pypy/interpreter/executioncontext.py
   pypy/trunk/pypy/interpreter/pyframe.py
   pypy/trunk/pypy/interpreter/pyopcode.py
Log:
For now, just killing a lot of "if we_are_jitted" is enough.
These changes should be consistent with the branch/jit-trace-hook.


Modified: pypy/trunk/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/trunk/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/trunk/pypy/interpreter/baseobjspace.py	Fri Jan  8 14:41:50 2010
@@ -9,7 +9,7 @@
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.debug import make_sure_not_resized
 from pypy.rlib.timer import DummyTimer, Timer
-from pypy.rlib.jit import we_are_jitted, unroll_safe
+from pypy.rlib.jit import unroll_safe
 import os, sys
 
 __all__ = ['ObjSpace', 'OperationError', 'Wrappable', 'W_Root']
@@ -791,8 +791,7 @@
 
     def call_valuestack(self, w_func, nargs, frame):
         from pypy.interpreter.function import Function, Method, is_builtin_code
-        if (not we_are_jitted() and frame.is_being_profiled and
-            is_builtin_code(w_func)):
+        if frame.is_being_profiled 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/trunk/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/trunk/pypy/interpreter/executioncontext.py	(original)
+++ pypy/trunk/pypy/interpreter/executioncontext.py	Fri Jan  8 14:41:50 2010
@@ -14,6 +14,11 @@
     """An ExecutionContext holds the state of an execution thread
     in the Python interpreter."""
 
+    # XXX JIT: when tracing (but not when blackholing!), the following
+    # XXX fields should be known to a constant None or False:
+    # XXX   self.w_tracefunc, self.profilefunc
+    # XXX   frame.is_being_profiled
+
     def __init__(self, space):
         self.space = space
         self.topframeref = jit.vref_None
@@ -53,17 +58,15 @@
 
     def leave(self, frame):
         try:
-            if not jit.we_are_jitted():
-                if self.profilefunc:
-                    self._trace(frame, 'leaveframe', self.space.w_None)
+            if self.profilefunc:
+                self._trace(frame, 'leaveframe', self.space.w_None)
         finally:
             self.topframeref = frame.f_backref
             self.framestackdepth -= 1
             jit.virtual_ref_finish(frame)
 
-        if not jit.we_are_jitted():
-            if self.w_tracefunc is not None and not frame.hide():
-                self.space.frame_trace_action.fire()
+        if self.w_tracefunc is not None and not frame.hide():
+            self.space.frame_trace_action.fire()
 
     # ________________________________________________________________
 
@@ -182,6 +185,14 @@
             actionflag.action_dispatcher(self, frame)     # slow path
     bytecode_trace._always_inline_ = True
 
+    def bytecode_trace_after_exception(self, frame):
+        "Like bytecode_trace(), but without increasing the ticker."
+        actionflag = self.space.actionflag
+        ticker = actionflag.get()
+        if ticker & actionflag.interesting_bits:  # fast check
+            actionflag.action_dispatcher(self, frame)     # slow path
+    bytecode_trace_after_exception._always_inline_ = True
+
     def exception_trace(self, frame, operationerr):
         "Trace function called upon OperationError."
         operationerr.record_interpreter_traceback()

Modified: pypy/trunk/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyframe.py	(original)
+++ pypy/trunk/pypy/interpreter/pyframe.py	Fri Jan  8 14:41:50 2010
@@ -9,7 +9,7 @@
 from pypy.interpreter import pytraceback
 import opcode
 from pypy.rlib.objectmodel import we_are_translated, instantiate
-from pypy.rlib.jit import we_are_jitted, hint
+from pypy.rlib.jit import hint
 from pypy.rlib.debug import make_sure_not_resized
 from pypy.rlib import jit
 
@@ -141,8 +141,7 @@
         executioncontext = self.space.getexecutioncontext()
         executioncontext.enter(self)
         try:
-            if not we_are_jitted():
-                executioncontext.call_trace(self)
+            executioncontext.call_trace(self)
             # Execution starts just after the last_instr.  Initially,
             # last_instr is -1.  After a generator suspends it points to
             # the YIELD_VALUE instruction.
@@ -153,11 +152,9 @@
                 rstack.resume_point("execute_frame", self, executioncontext,
                                     returns=w_exitvalue)
             except Exception:
-                if not we_are_jitted():
-                    executioncontext.return_trace(self, self.space.w_None)
+                executioncontext.return_trace(self, self.space.w_None)
                 raise
-            if not we_are_jitted():
-                executioncontext.return_trace(self, w_exitvalue)
+            executioncontext.return_trace(self, w_exitvalue)
         finally:
             executioncontext.leave(self)
         return w_exitvalue

Modified: pypy/trunk/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyopcode.py	(original)
+++ pypy/trunk/pypy/interpreter/pyopcode.py	Fri Jan  8 14:41:50 2010
@@ -130,7 +130,7 @@
 
     def handle_operation_error(self, ec, operr, attach_tb=True):
         if attach_tb:
-            if not jit.we_are_jitted():
+            if 1:
                 # xxx this is a hack.  It allows bytecode_trace() to
                 # call a signal handler which raises, and catch the
                 # raised exception immediately.  See test_alarm_raise in
@@ -146,15 +146,14 @@
                     trace = self.w_f_trace
                     self.w_f_trace = None
                     try:
-                        ec.bytecode_trace(self)
+                        ec.bytecode_trace_after_exception(self)
                     finally:
                         self.w_f_trace = trace
                 except OperationError, e:
                     operr = e
             pytraceback.record_application_traceback(
                 self.space, operr, self, self.last_instr)
-            if not jit.we_are_jitted():
-                ec.exception_trace(self, operr)
+            ec.exception_trace(self, operr)
 
         block = self.unrollstack(SApplicationException.kind)
         if block is None:
@@ -913,13 +912,10 @@
         arguments = f.popvalues(n_arguments)
         args = f.argument_factory(arguments, keywords, keywords_w, w_star, w_starstar)
         w_function  = f.popvalue()
-        if jit.we_are_jitted():
-            w_result = f.space.call_args(w_function, args)
+        if f.is_being_profiled and is_builtin_code(w_function):
+            w_result = f.space.call_args_and_c_profile(f, w_function, args)
         else:
-            if f.is_being_profiled 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)
+            w_result = f.space.call_args(w_function, args)
         rstack.resume_point("call_function", f, returns=w_result)
         f.pushvalue(w_result)
         



More information about the Pypy-commit mailing list