[pypy-commit] pypy framestate: Add Opcodes JUMP_FORWARD and JUMP_ABSOLUTE
rlamy
noreply at buildbot.pypy.org
Mon Nov 24 17:29:50 CET 2014
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: framestate
Changeset: r74680:0b2185c0097b
Date: 2013-09-15 06:22 +0100
http://bitbucket.org/pypy/pypy/changeset/0b2185c0097b/
Log: Add Opcodes JUMP_FORWARD and JUMP_ABSOLUTE
diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -271,6 +271,20 @@
return getattr(ctx, self.name)(self.arg)
+def flow_opcode(func):
+ name = func.__name__
+ class Op(BCInstruction):
+ def __init__(self, arg=0, offset=-1):
+ self.arg = arg
+ self.offset = offset
+
+ def eval(self, ctx):
+ pass
+ Op.__name__ = Op.name = name
+ Op.bc_flow = func
+ bc_reader.register_opcode(Op)
+ return Op
+
@bc_reader.register_opcode
class LOAD_CONST(BCInstruction):
@staticmethod
@@ -280,6 +294,16 @@
def eval(self, ctx):
ctx.pushvalue(const(self.arg))
+ at flow_opcode
+def JUMP_ABSOLUTE(self, block, graph):
+ target_block, _ = graph.pos_index[self.arg]
+ graph.add_jump(block, target_block)
+
+ at flow_opcode
+def JUMP_FORWARD(self, block, graph):
+ target_block, _ = graph.pos_index[self.arg]
+ graph.add_jump(block, target_block)
+
_unary_ops = [
('UNARY_POSITIVE', op.pos),
('UNARY_NEGATIVE', op.neg),
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -666,7 +666,7 @@
block.cleanupstack(self) # the block knows how to clean up the value stack
def JUMP_ABSOLUTE(self, jumpto):
- return jumpto
+ pass
def YIELD_VALUE(self, _):
assert self.pycode.is_generator
@@ -689,7 +689,7 @@
self.appcall(rpython_print_newline)
def JUMP_FORWARD(self, target):
- return target
+ pass
def JUMP_IF_FALSE(self, target):
# Python <= 2.6 only
More information about the pypy-commit
mailing list