[pypy-commit] pypy py3k: Fix the optimization for sys.exc_info().

arigo noreply at buildbot.pypy.org
Tue Apr 17 14:03:25 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: py3k
Changeset: r54461:062d8a9acdf2
Date: 2012-04-17 14:02 +0200
http://bitbucket.org/pypy/pypy/changeset/062d8a9acdf2/

Log:	Fix the optimization for sys.exc_info().

diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -114,13 +114,10 @@
     #       BINARY_SUBSCR
     # or:
     #       CALL_FUNCTION/CALL_METHOD
+    #       LOAD_CONST any integer or None
     #       LOAD_CONST <=2
-    #       SLICE_2
-    # or:
-    #       CALL_FUNCTION/CALL_METHOD
-    #       LOAD_CONST any integer
-    #       LOAD_CONST <=2
-    #       SLICE_3
+    #       BUILD_SLICE 2
+    #       BINARY_SUBSCR
     need_all_three_args = True
     co = frame.getcode().co_code
     p = frame.last_instr
@@ -130,16 +127,16 @@
             lo = ord(co[p+4])
             hi = ord(co[p+5])
             w_constant = frame.getconstant_w((hi * 256) | lo)
-            if space.isinstance_w(w_constant, space.w_int):
-                constant = space.int_w(w_constant)
-                if ord(co[p+6]) == stdlib_opcode.BINARY_SUBSCR:
+            if ord(co[p+6]) == stdlib_opcode.BINARY_SUBSCR:
+                if space.isinstance_w(w_constant, space.w_int):
+                    constant = space.int_w(w_constant)
                     if -3 <= constant <= 1 and constant != -1:
                         need_all_three_args = False
-                elif ord(co[p+6]) == stdlib_opcode.SLICE+2:
-                    if constant <= 2:
-                        need_all_three_args = False
-                elif (ord(co[p+6]) == stdlib_opcode.LOAD_CONST and
-                      ord(co[p+9]) == stdlib_opcode.SLICE+3):
+            elif (ord(co[p+6]) == stdlib_opcode.LOAD_CONST and
+                  ord(co[p+9]) == stdlib_opcode.BUILD_SLICE and
+                  ord(co[p+12]) == stdlib_opcode.BINARY_SUBSCR):
+                if (space.is_w(w_constant, space.w_None) or
+                    space.isinstance_w(w_constant, space.w_int)):
                     lo = ord(co[p+7])
                     hi = ord(co[p+8])
                     w_constant = frame.getconstant_w((hi * 256) | lo)


More information about the pypy-commit mailing list