[pypy-commit] pypy translation-cleanup: Handle opcodes uniformly in FlowSpaceFrame.dispatch_bytecode()

rlamy noreply at buildbot.pypy.org
Thu Aug 30 18:38:13 CEST 2012


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r56993:df995c5b63f1
Date: 2012-08-11 16:36 +0100
http://bitbucket.org/pypy/pypy/changeset/df995c5b63f1/

Log:	Handle opcodes uniformly in FlowSpaceFrame.dispatch_bytecode()

	Dispatch all opcodes to a method of the frame (except EXTENDED_ARG
	which isn't really an opcode).

diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -460,32 +460,6 @@
                 next_instr += 3
                 oparg = (oparg * 65536) | (hi * 256) | lo
 
-            if opcode == self.opcodedesc.RETURN_VALUE.index:
-                w_returnvalue = self.popvalue()
-                block = self.unrollstack(SReturnValue.kind)
-                if block is None:
-                    self.pushvalue(w_returnvalue)   # XXX ping pong
-                    raise Return
-                else:
-                    unroller = SReturnValue(w_returnvalue)
-                    next_instr = block.handle(self, unroller)
-                    return next_instr    # now inside a 'finally' block
-
-            if opcode == self.opcodedesc.END_FINALLY.index:
-                unroller = self.end_finally()
-                if isinstance(unroller, SuspendedUnroller):
-                    # go on unrolling the stack
-                    block = self.unrollstack(unroller.kind)
-                    if block is None:
-                        w_result = unroller.nomoreblocks()
-                        self.pushvalue(w_result)
-                        raise Return
-                    else:
-                        next_instr = block.handle(self, unroller)
-                return next_instr
-
-            if opcode == self.opcodedesc.JUMP_ABSOLUTE.index:
-                return self.jump_absolute(oparg, next_instr, ec)
 
             methodname = self.opcode_method_names[opcode]
             try:
@@ -498,6 +472,33 @@
             if res is not None:
                 next_instr = res
 
+    def RETURN_VALUE(self, oparg, next_instr):
+        w_returnvalue = self.popvalue()
+        block = self.unrollstack(SReturnValue.kind)
+        if block is None:
+            self.pushvalue(w_returnvalue)   # XXX ping pong
+            raise Return
+        else:
+            unroller = SReturnValue(w_returnvalue)
+            next_instr = block.handle(self, unroller)
+            return next_instr    # now inside a 'finally' block
+
+    def END_FINALLY(self, oparg, next_instr):
+        unroller = self.end_finally()
+        if isinstance(unroller, SuspendedUnroller):
+            # go on unrolling the stack
+            block = self.unrollstack(unroller.kind)
+            if block is None:
+                w_result = unroller.nomoreblocks()
+                self.pushvalue(w_result)
+                raise Return
+            else:
+                next_instr = block.handle(self, unroller)
+        return next_instr
+
+    def JUMP_ABSOLUTE(self, jumpto, next_instr):
+        return jumpto
+
     def YIELD_VALUE(self, _, next_instr):
         assert self.is_generator
         w_result = self.popvalue()


More information about the pypy-commit mailing list