Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r88191:b9832c7d5255
Date: 2016-11-07 19:04 +0100
http://bitbucket.org/pypy/pypy/changeset/b9832c7d5255/

Log:    Use the same logic as default for the Return and Yield exceptions.
        Should fix the major issue with the JIT performance right now.

diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -307,19 +307,18 @@
             # last_instr is -1.  After a generator suspends it points to
             # the YIELD_VALUE/YIELD_FROM instruction.
             try:
-                if in_generator is None:
-                    assert self.last_instr == -1
-                    next_instr = r_uint(0)
+                try:
+                    if in_generator is None:
+                        assert self.last_instr == -1
+                        next_instr = r_uint(0)
+                    else:
+                        next_instr = in_generator.resume_execute_frame(
+                                                        self, w_arg_or_err)
+                except pyopcode.Yield:
+                    w_exitvalue = self.popvalue()
                 else:
-                    next_instr = in_generator.resume_execute_frame(
-                                                    self, w_arg_or_err)
-                #
-                self.dispatch(self.pycode, next_instr, executioncontext)
-            except pyopcode.Return:
-                self.last_exception = None
-                w_exitvalue = self.popvalue()
-            except pyopcode.Yield:
-                w_exitvalue = self.popvalue()
+                    w_exitvalue = self.dispatch(self.pycode, next_instr,
+                                                executioncontext)
             finally:
                 executioncontext.return_trace(self, w_exitvalue)
             # it used to say self.last_exception = None
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -60,8 +60,14 @@
         # For the sequel, force 'next_instr' to be unsigned for performance
         next_instr = r_uint(next_instr)
         co_code = pycode.co_code
-        while True:
-            next_instr = self.handle_bytecode(co_code, next_instr, ec)
+        try:
+            while True:
+                next_instr = self.handle_bytecode(co_code, next_instr, ec)
+        except Return:
+            self.last_exception = None
+            return self.popvalue()
+        except Yield:
+            return self.popvalue()
 
     def handle_bytecode(self, co_code, next_instr, ec):
         try:
@@ -1539,6 +1545,7 @@
 
 ### ____________________________________________________________ ###
 
+
 class Return(Exception):
     """Raised when exiting a frame via a 'return' statement."""
 
diff --git a/pypy/module/pypyjit/interp_jit.py 
b/pypy/module/pypyjit/interp_jit.py
--- a/pypy/module/pypyjit/interp_jit.py
+++ b/pypy/module/pypyjit/interp_jit.py
@@ -91,8 +91,12 @@
                 next_instr = self.handle_bytecode(co_code, next_instr, ec)
                 is_being_profiled = self.get_is_being_profiled()
         except Yield:
+            w_result = self.popvalue()
             jit.hint(self, force_virtualizable=True)
-            raise
+            return w_result
+        except Return:
+            self.last_exception = None
+            return self.popvalue()
 
     def jump_absolute(self, jumpto, ec):
         if we_are_jitted():
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to