[pypy-commit] pypy Opcode-class: Resolve LOAD_CONST constants at decoding time
rlamy
noreply at buildbot.pypy.org
Sat May 4 02:05:49 CEST 2013
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: Opcode-class
Changeset: r63839:64d1839ad4a4
Date: 2013-05-02 16:02 +0100
http://bitbucket.org/pypy/pypy/changeset/64d1839ad4a4/
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
@@ -184,5 +184,16 @@
def register_opcode(cls):
"""Class decorator: register opcode class as real Python opcode"""
name = cls.__name__
+ cls.name = name
cls.num = Opcode.register_name(name, cls)
return cls
+
+ at register_opcode
+class LOAD_CONST(Opcode):
+ 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
@@ -595,9 +595,6 @@
def getlocalvarname(self, index):
return self.pycode.co_varnames[index]
- def getconstant_w(self, index):
- return self.space.wrap(self.pycode.consts[index])
-
def getname_u(self, index):
return self.pycode.names[index]
@@ -866,8 +863,8 @@
raise FlowingError(self, "Local variable referenced before assignment")
self.pushvalue(w_value)
- def LOAD_CONST(self, constindex):
- w_const = self.getconstant_w(constindex)
+ def LOAD_CONST(self, const):
+ w_const = self.space.wrap(const)
self.pushvalue(w_const)
def LOAD_GLOBAL(self, nameindex):
More information about the pypy-commit
mailing list