[pypy-commit] pypy framestate: handle POP_JUMP_IF_FALSE in the bc_flow() phase

rlamy noreply at buildbot.pypy.org
Mon Nov 24 17:29:52 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: framestate
Changeset: r74682:1bd3dde04463
Date: 2014-05-10 05:38 +0100
http://bitbucket.org/pypy/pypy/changeset/1bd3dde04463/

Log:	handle POP_JUMP_IF_FALSE in the bc_flow() phase

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -295,6 +295,26 @@
         ctx.pushvalue(const(self.arg))
 
 @flow_opcode
+def POP_JUMP_IF_FALSE(self, block, graph):
+    on_False, _ = graph.pos_index[self.arg]
+    on_True, _ = graph.pos_index[graph.next_pos(self)]
+    block.operations[-1] = SWITCH_BOOL(on_False, on_True, offset=self.offset)
+    block.set_exits([on_False, on_True])
+
+class SWITCH_BOOL(BCInstruction):
+    def __init__(self, on_False, on_True, offset=-1):
+        self.on_False = on_False
+        self.on_True = on_True
+        self.offset = offset
+
+    def eval(self, ctx):
+        w_value = ctx.popvalue()
+        if ctx.guessbool(op.bool(w_value).eval(ctx)):
+            return self.on_True
+        else:
+            return self.on_False
+
+ at flow_opcode
 def JUMP_ABSOLUTE(self, block, graph):
     target_block, _ = graph.pos_index[self.arg]
     graph.add_jump(block, target_block)
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -697,11 +697,6 @@
         if self.guessbool(op.bool(w_cond).eval(self)):
             return target
 
-    def POP_JUMP_IF_FALSE(self, target):
-        w_value = self.popvalue()
-        if not self.guessbool(op.bool(w_value).eval(self)):
-            return target
-
     def POP_JUMP_IF_TRUE(self, target):
         w_value = self.popvalue()
         if self.guessbool(op.bool(w_value).eval(self)):


More information about the pypy-commit mailing list