Author: Ronan Lamy <[email protected]>
Branch: framestate
Changeset: r74665:0d89e1419435
Date: 2013-08-11 17:42 +0100
http://bitbucket.org/pypy/pypy/changeset/0d89e1419435/
Log: Resolve LOAD_CONST constants at decoding time
diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -155,5 +155,16 @@
def register_opcode(cls):
"""Class decorator: register opcode class as real Python opcode"""
name = cls.__name__
- cls.num = Opcode.register_name(name, cls)
+ cls.name = name
+ cls.num = BCInstruction.register_name(name, cls)
return cls
+
+@register_opcode
+class LOAD_CONST(BCInstruction):
+ def __init__(self, arg, offset=-1):
+ self.arg = arg
+ self.offset = offset
+
+ @staticmethod
+ def decode(arg, offset, code):
+ return LOAD_CONST(code.consts[arg], offset)
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -521,9 +521,6 @@
def getlocalvarname(self, index):
return self.pycode.co_varnames[index]
- def getconstant_w(self, index):
- return const(self.pycode.consts[index])
-
def getname_u(self, index):
return self.pycode.names[index]
@@ -850,8 +847,8 @@
raise FlowingError("Local variable referenced before assignment")
self.pushvalue(w_value)
- def LOAD_CONST(self, constindex):
- w_const = self.getconstant_w(constindex)
+ def LOAD_CONST(self, constant):
+ w_const = const(constant)
self.pushvalue(w_const)
def find_global(self, w_globals, varname):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit