Author: Laurence Tratt <[email protected]>
Branch:
Changeset: r66719:66de007c669a
Date: 2013-08-31 14:35 +0100
http://bitbucket.org/pypy/pypy/changeset/66de007c669a/
Log: Merge in sanitise_bytecode_dispatch.
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -127,11 +127,6 @@
pypy_optiondescription = OptionDescription("objspace", "Object Space Options",
[
- OptionDescription("opcodes", "opcodes to enable in the interpreter", [
- BoolOption("CALL_METHOD", "emit a special bytecode for expr.name()",
- default=False),
- ]),
-
OptionDescription("usemodules", "Which Modules should be used", [
BoolOption(modname, "use module %s" % (modname, ),
default=modname in default_modules,
@@ -307,7 +302,6 @@
# all the good optimizations for PyPy should be listed here
if level in ['2', '3', 'jit']:
- config.objspace.opcodes.suggest(CALL_METHOD=True)
config.objspace.std.suggest(withrangelist=True)
config.objspace.std.suggest(withmethodcache=True)
config.objspace.std.suggest(withprebuiltchar=True)
diff --git a/pypy/doc/config/objspace.opcodes.CALL_METHOD.txt
b/pypy/doc/config/objspace.opcodes.CALL_METHOD.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.opcodes.CALL_METHOD.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Enable a pair of bytecodes that speed up method calls.
-See ``pypy.interpreter.callmethod`` for a description.
-
-The goal is to avoid creating the bound method object in the common
-case. So far, this only works for calls with no keyword, no ``*arg``
-and no ``**arg`` but it would be easy to extend.
-
-For more information, see the section in `Standard Interpreter Optimizations`_.
-
-.. _`Standard Interpreter Optimizations`:
../interpreter-optimizations.html#lookup-method-call-method
diff --git a/pypy/doc/config/objspace.opcodes.txt
b/pypy/doc/config/objspace.opcodes.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.opcodes.txt
+++ /dev/null
@@ -1,1 +0,0 @@
-.. intentionally empty
diff --git a/pypy/doc/interpreter-optimizations.rst
b/pypy/doc/interpreter-optimizations.rst
--- a/pypy/doc/interpreter-optimizations.rst
+++ b/pypy/doc/interpreter-optimizations.rst
@@ -198,9 +198,6 @@
if it is not None, then it is considered to be an additional first
argument in the call to the *im_func* object from the stack.
-You can enable this feature with the :config:`objspace.opcodes.CALL_METHOD`
-option.
-
.. more here?
Overall Effects
diff --git a/pypy/interpreter/astcompiler/codegen.py
b/pypy/interpreter/astcompiler/codegen.py
--- a/pypy/interpreter/astcompiler/codegen.py
+++ b/pypy/interpreter/astcompiler/codegen.py
@@ -982,9 +982,8 @@
return self._call_has_no_star_args(call) and not call.keywords
def _optimize_method_call(self, call):
- if not self.space.config.objspace.opcodes.CALL_METHOD or \
- not self._call_has_no_star_args(call) or \
- not isinstance(call.func, ast.Attribute):
+ if not self._call_has_no_star_args(call) or \
+ not isinstance(call.func, ast.Attribute):
return False
attr_lookup = call.func
assert isinstance(attr_lookup, ast.Attribute)
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -251,8 +251,10 @@
tuple(self.co_cellvars))
def exec_host_bytecode(self, w_globals, w_locals):
- from pypy.interpreter.pyframe import CPythonFrame
- frame = CPythonFrame(self.space, self, w_globals, None)
+ if sys.version_info < (2, 7):
+ raise Exception("PyPy no longer supports Python 2.6 or lower")
+ from pypy.interpreter.pyframe import PyFrame
+ frame = PyFrame(self.space, self, w_globals, None)
frame.setdictscope(w_locals)
return frame.run()
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -52,7 +52,7 @@
def __init__(self, space, code, w_globals, outer_func):
if not we_are_translated():
- assert type(self) in (space.FrameClass, CPythonFrame), (
+ assert type(self) == space.FrameClass, (
"use space.FrameClass(), not directly PyFrame()")
self = hint(self, access_directly=True, fresh_virtualizable=True)
assert isinstance(code, pycode.PyCode)
@@ -674,17 +674,6 @@
return space.wrap(self.builtin is not space.builtin)
return space.w_False
-class CPythonFrame(PyFrame):
- """
- Execution of host (CPython) opcodes.
- """
-
- bytecode_spec = host_bytecode_spec
- opcode_method_names = host_bytecode_spec.method_names
- opcodedesc = host_bytecode_spec.opcodedesc
- opdescmap = host_bytecode_spec.opdescmap
- HAVE_ARGUMENT = host_bytecode_spec.HAVE_ARGUMENT
-
# ____________________________________________________________
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -13,10 +13,8 @@
from rpython.rlib.objectmodel import we_are_translated
from rpython.rlib import jit, rstackovf
from rpython.rlib.rarithmetic import r_uint, intmask
-from rpython.rlib.unroll import unrolling_iterable
from rpython.rlib.debug import check_nonneg
-from pypy.tool.stdlib_opcode import (bytecode_spec,
- unrolling_all_opcode_descs)
+from pypy.tool.stdlib_opcode import bytecode_spec
def unaryoperation(operationname):
"""NOT_RPYTHON"""
@@ -41,34 +39,14 @@
return func_with_new_name(opimpl, "opcode_impl_for_%s" % operationname)
-compare_dispatch_table = [
- "cmp_lt", # "<"
- "cmp_le", # "<="
- "cmp_eq", # "=="
- "cmp_ne", # "!="
- "cmp_gt", # ">"
- "cmp_ge", # ">="
- "cmp_in",
- "cmp_not_in",
- "cmp_is",
- "cmp_is_not",
- "cmp_exc_match",
- ]
-unrolling_compare_dispatch_table = unrolling_iterable(
- enumerate(compare_dispatch_table))
-
+opcodedesc = bytecode_spec.opcodedesc
+HAVE_ARGUMENT = bytecode_spec.HAVE_ARGUMENT
class __extend__(pyframe.PyFrame):
"""A PyFrame that knows about interpretation of standard Python opcodes
minus the ones related to nested scopes."""
- bytecode_spec = bytecode_spec
- opcode_method_names = bytecode_spec.method_names
- opcodedesc = bytecode_spec.opcodedesc
- opdescmap = bytecode_spec.opdescmap
- HAVE_ARGUMENT = bytecode_spec.HAVE_ARGUMENT
-
### opcode dispatch ###
def dispatch(self, pycode, next_instr, ec):
@@ -170,7 +148,7 @@
opcode = ord(co_code[next_instr])
next_instr += 1
- if opcode >= self.HAVE_ARGUMENT:
+ if opcode >= HAVE_ARGUMENT:
lo = ord(co_code[next_instr])
hi = ord(co_code[next_instr+1])
next_instr += 2
@@ -180,19 +158,18 @@
# note: the structure of the code here is such that it makes
# (after translation) a big "if/elif" chain, which is then
- # turned into a switch(). It starts here: even if the first
- # one is not an "if" but a "while" the effect is the same.
+ # turned into a switch().
- while opcode == self.opcodedesc.EXTENDED_ARG.index:
+ while opcode == opcodedesc.EXTENDED_ARG.index:
opcode = ord(co_code[next_instr])
- if opcode < self.HAVE_ARGUMENT:
+ if opcode < HAVE_ARGUMENT:
raise BytecodeCorruption
lo = ord(co_code[next_instr+1])
hi = ord(co_code[next_instr+2])
next_instr += 3
oparg = (oparg * 65536) | (hi * 256) | lo
- if opcode == self.opcodedesc.RETURN_VALUE.index:
+ if opcode == opcodedesc.RETURN_VALUE.index:
w_returnvalue = self.popvalue()
block = self.unrollstack(SReturnValue.kind)
if block is None:
@@ -202,8 +179,7 @@
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:
+ elif opcode == opcodedesc.END_FINALLY.index:
unroller = self.end_finally()
if isinstance(unroller, SuspendedUnroller):
# go on unrolling the stack
@@ -215,49 +191,248 @@
else:
next_instr = block.handle(self, unroller)
return next_instr
-
- if opcode == self.opcodedesc.JUMP_ABSOLUTE.index:
+ elif opcode == opcodedesc.JUMP_ABSOLUTE.index:
return self.jump_absolute(oparg, ec)
-
- if we_are_translated():
- for opdesc in unrolling_all_opcode_descs:
- # static checks to skip this whole case if necessary
- if opdesc.bytecode_spec is not self.bytecode_spec:
- continue
- if not opdesc.is_enabled(space):
- continue
- if opdesc.methodname in (
- 'EXTENDED_ARG', 'RETURN_VALUE',
- 'END_FINALLY', 'JUMP_ABSOLUTE'):
- continue # opcodes implemented above
-
- # the following "if" is part of the big switch described
- # above.
- if opcode == opdesc.index:
- # dispatch to the opcode method
- meth = getattr(self, opdesc.methodname)
- res = meth(oparg, next_instr)
- # !! warning, for the annotator the next line is not
- # comparing an int and None - you can't do that.
- # Instead, it's constant-folded to either True or False
- if res is not None:
- next_instr = res
- break
- else:
- self.MISSING_OPCODE(oparg, next_instr)
-
- else: # when we are not translated, a list lookup is much faster
- methodname = self.opcode_method_names[opcode]
- try:
- meth = getattr(self, methodname)
- except AttributeError:
- raise BytecodeCorruption("unimplemented opcode, ofs=%d, "
- "code=%d, name=%s" %
- (self.last_instr, opcode,
- methodname))
- res = meth(oparg, next_instr)
- if res is not None:
- next_instr = res
+ elif opcode == opcodedesc.BREAK_LOOP.index:
+ next_instr = self.BREAK_LOOP(oparg, next_instr)
+ elif opcode == opcodedesc.CONTINUE_LOOP.index:
+ next_instr = self.CONTINUE_LOOP(oparg, next_instr)
+ elif opcode == opcodedesc.FOR_ITER.index:
+ next_instr = self.FOR_ITER(oparg, next_instr)
+ elif opcode == opcodedesc.JUMP_FORWARD.index:
+ next_instr = self.JUMP_FORWARD(oparg, next_instr)
+ elif opcode == opcodedesc.JUMP_IF_FALSE_OR_POP.index:
+ next_instr = self.JUMP_IF_FALSE_OR_POP(oparg, next_instr)
+ elif opcode == opcodedesc.JUMP_IF_NOT_DEBUG.index:
+ next_instr = self.JUMP_IF_NOT_DEBUG(oparg, next_instr)
+ elif opcode == opcodedesc.JUMP_IF_TRUE_OR_POP.index:
+ next_instr = self.JUMP_IF_TRUE_OR_POP(oparg, next_instr)
+ elif opcode == opcodedesc.POP_JUMP_IF_FALSE.index:
+ next_instr = self.POP_JUMP_IF_FALSE(oparg, next_instr)
+ elif opcode == opcodedesc.POP_JUMP_IF_TRUE.index:
+ next_instr = self.POP_JUMP_IF_TRUE(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_ADD.index:
+ self.BINARY_ADD(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_AND.index:
+ self.BINARY_AND(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_DIVIDE.index:
+ self.BINARY_DIVIDE(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_FLOOR_DIVIDE.index:
+ self.BINARY_FLOOR_DIVIDE(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_LSHIFT.index:
+ self.BINARY_LSHIFT(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_MODULO.index:
+ self.BINARY_MODULO(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_MULTIPLY.index:
+ self.BINARY_MULTIPLY(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_OR.index:
+ self.BINARY_OR(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_POWER.index:
+ self.BINARY_POWER(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_RSHIFT.index:
+ self.BINARY_RSHIFT(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_SUBSCR.index:
+ self.BINARY_SUBSCR(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_SUBTRACT.index:
+ self.BINARY_SUBTRACT(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_TRUE_DIVIDE.index:
+ self.BINARY_TRUE_DIVIDE(oparg, next_instr)
+ elif opcode == opcodedesc.BINARY_XOR.index:
+ self.BINARY_XOR(oparg, next_instr)
+ elif opcode == opcodedesc.BUILD_CLASS.index:
+ self.BUILD_CLASS(oparg, next_instr)
+ elif opcode == opcodedesc.BUILD_LIST.index:
+ self.BUILD_LIST(oparg, next_instr)
+ elif opcode == opcodedesc.BUILD_LIST_FROM_ARG.index:
+ self.BUILD_LIST_FROM_ARG(oparg, next_instr)
+ elif opcode == opcodedesc.BUILD_MAP.index:
+ self.BUILD_MAP(oparg, next_instr)
+ elif opcode == opcodedesc.BUILD_SET.index:
+ self.BUILD_SET(oparg, next_instr)
+ elif opcode == opcodedesc.BUILD_SLICE.index:
+ self.BUILD_SLICE(oparg, next_instr)
+ elif opcode == opcodedesc.BUILD_TUPLE.index:
+ self.BUILD_TUPLE(oparg, next_instr)
+ elif opcode == opcodedesc.CALL_FUNCTION.index:
+ self.CALL_FUNCTION(oparg, next_instr)
+ elif opcode == opcodedesc.CALL_FUNCTION_KW.index:
+ self.CALL_FUNCTION_KW(oparg, next_instr)
+ elif opcode == opcodedesc.CALL_FUNCTION_VAR.index:
+ self.CALL_FUNCTION_VAR(oparg, next_instr)
+ elif opcode == opcodedesc.CALL_FUNCTION_VAR_KW.index:
+ self.CALL_FUNCTION_VAR_KW(oparg, next_instr)
+ elif opcode == opcodedesc.CALL_METHOD.index:
+ self.CALL_METHOD(oparg, next_instr)
+ elif opcode == opcodedesc.COMPARE_OP.index:
+ self.COMPARE_OP(oparg, next_instr)
+ elif opcode == opcodedesc.DELETE_ATTR.index:
+ self.DELETE_ATTR(oparg, next_instr)
+ elif opcode == opcodedesc.DELETE_FAST.index:
+ self.DELETE_FAST(oparg, next_instr)
+ elif opcode == opcodedesc.DELETE_GLOBAL.index:
+ self.DELETE_GLOBAL(oparg, next_instr)
+ elif opcode == opcodedesc.DELETE_NAME.index:
+ self.DELETE_NAME(oparg, next_instr)
+ elif opcode == opcodedesc.DELETE_SLICE_0.index:
+ self.DELETE_SLICE_0(oparg, next_instr)
+ elif opcode == opcodedesc.DELETE_SLICE_1.index:
+ self.DELETE_SLICE_1(oparg, next_instr)
+ elif opcode == opcodedesc.DELETE_SLICE_2.index:
+ self.DELETE_SLICE_2(oparg, next_instr)
+ elif opcode == opcodedesc.DELETE_SLICE_3.index:
+ self.DELETE_SLICE_3(oparg, next_instr)
+ elif opcode == opcodedesc.DELETE_SUBSCR.index:
+ self.DELETE_SUBSCR(oparg, next_instr)
+ elif opcode == opcodedesc.DUP_TOP.index:
+ self.DUP_TOP(oparg, next_instr)
+ elif opcode == opcodedesc.DUP_TOPX.index:
+ self.DUP_TOPX(oparg, next_instr)
+ elif opcode == opcodedesc.EXEC_STMT.index:
+ self.EXEC_STMT(oparg, next_instr)
+ elif opcode == opcodedesc.GET_ITER.index:
+ self.GET_ITER(oparg, next_instr)
+ elif opcode == opcodedesc.IMPORT_FROM.index:
+ self.IMPORT_FROM(oparg, next_instr)
+ elif opcode == opcodedesc.IMPORT_NAME.index:
+ self.IMPORT_NAME(oparg, next_instr)
+ elif opcode == opcodedesc.IMPORT_STAR.index:
+ self.IMPORT_STAR(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_ADD.index:
+ self.INPLACE_ADD(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_AND.index:
+ self.INPLACE_AND(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_DIVIDE.index:
+ self.INPLACE_DIVIDE(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_FLOOR_DIVIDE.index:
+ self.INPLACE_FLOOR_DIVIDE(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_LSHIFT.index:
+ self.INPLACE_LSHIFT(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_MODULO.index:
+ self.INPLACE_MODULO(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_MULTIPLY.index:
+ self.INPLACE_MULTIPLY(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_OR.index:
+ self.INPLACE_OR(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_POWER.index:
+ self.INPLACE_POWER(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_RSHIFT.index:
+ self.INPLACE_RSHIFT(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_SUBTRACT.index:
+ self.INPLACE_SUBTRACT(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_TRUE_DIVIDE.index:
+ self.INPLACE_TRUE_DIVIDE(oparg, next_instr)
+ elif opcode == opcodedesc.INPLACE_XOR.index:
+ self.INPLACE_XOR(oparg, next_instr)
+ elif opcode == opcodedesc.LIST_APPEND.index:
+ self.LIST_APPEND(oparg, next_instr)
+ elif opcode == opcodedesc.LOAD_ATTR.index:
+ self.LOAD_ATTR(oparg, next_instr)
+ elif opcode == opcodedesc.LOAD_CLOSURE.index:
+ self.LOAD_CLOSURE(oparg, next_instr)
+ elif opcode == opcodedesc.LOAD_CONST.index:
+ self.LOAD_CONST(oparg, next_instr)
+ elif opcode == opcodedesc.LOAD_DEREF.index:
+ self.LOAD_DEREF(oparg, next_instr)
+ elif opcode == opcodedesc.LOAD_FAST.index:
+ self.LOAD_FAST(oparg, next_instr)
+ elif opcode == opcodedesc.LOAD_GLOBAL.index:
+ self.LOAD_GLOBAL(oparg, next_instr)
+ elif opcode == opcodedesc.LOAD_LOCALS.index:
+ self.LOAD_LOCALS(oparg, next_instr)
+ elif opcode == opcodedesc.LOAD_NAME.index:
+ self.LOAD_NAME(oparg, next_instr)
+ elif opcode == opcodedesc.LOOKUP_METHOD.index:
+ self.LOOKUP_METHOD(oparg, next_instr)
+ elif opcode == opcodedesc.MAKE_CLOSURE.index:
+ self.MAKE_CLOSURE(oparg, next_instr)
+ elif opcode == opcodedesc.MAKE_FUNCTION.index:
+ self.MAKE_FUNCTION(oparg, next_instr)
+ elif opcode == opcodedesc.MAP_ADD.index:
+ self.MAP_ADD(oparg, next_instr)
+ elif opcode == opcodedesc.NOP.index:
+ self.NOP(oparg, next_instr)
+ elif opcode == opcodedesc.POP_BLOCK.index:
+ self.POP_BLOCK(oparg, next_instr)
+ elif opcode == opcodedesc.POP_TOP.index:
+ self.POP_TOP(oparg, next_instr)
+ elif opcode == opcodedesc.PRINT_EXPR.index:
+ self.PRINT_EXPR(oparg, next_instr)
+ elif opcode == opcodedesc.PRINT_ITEM.index:
+ self.PRINT_ITEM(oparg, next_instr)
+ elif opcode == opcodedesc.PRINT_ITEM_TO.index:
+ self.PRINT_ITEM_TO(oparg, next_instr)
+ elif opcode == opcodedesc.PRINT_NEWLINE.index:
+ self.PRINT_NEWLINE(oparg, next_instr)
+ elif opcode == opcodedesc.PRINT_NEWLINE_TO.index:
+ self.PRINT_NEWLINE_TO(oparg, next_instr)
+ elif opcode == opcodedesc.RAISE_VARARGS.index:
+ self.RAISE_VARARGS(oparg, next_instr)
+ elif opcode == opcodedesc.ROT_FOUR.index:
+ self.ROT_FOUR(oparg, next_instr)
+ elif opcode == opcodedesc.ROT_THREE.index:
+ self.ROT_THREE(oparg, next_instr)
+ elif opcode == opcodedesc.ROT_TWO.index:
+ self.ROT_TWO(oparg, next_instr)
+ elif opcode == opcodedesc.SETUP_EXCEPT.index:
+ self.SETUP_EXCEPT(oparg, next_instr)
+ elif opcode == opcodedesc.SETUP_FINALLY.index:
+ self.SETUP_FINALLY(oparg, next_instr)
+ elif opcode == opcodedesc.SETUP_LOOP.index:
+ self.SETUP_LOOP(oparg, next_instr)
+ elif opcode == opcodedesc.SETUP_WITH.index:
+ self.SETUP_WITH(oparg, next_instr)
+ elif opcode == opcodedesc.SET_ADD.index:
+ self.SET_ADD(oparg, next_instr)
+ elif opcode == opcodedesc.SLICE_0.index:
+ self.SLICE_0(oparg, next_instr)
+ elif opcode == opcodedesc.SLICE_1.index:
+ self.SLICE_1(oparg, next_instr)
+ elif opcode == opcodedesc.SLICE_2.index:
+ self.SLICE_2(oparg, next_instr)
+ elif opcode == opcodedesc.SLICE_3.index:
+ self.SLICE_3(oparg, next_instr)
+ elif opcode == opcodedesc.STOP_CODE.index:
+ self.STOP_CODE(oparg, next_instr)
+ elif opcode == opcodedesc.STORE_ATTR.index:
+ self.STORE_ATTR(oparg, next_instr)
+ elif opcode == opcodedesc.STORE_DEREF.index:
+ self.STORE_DEREF(oparg, next_instr)
+ elif opcode == opcodedesc.STORE_FAST.index:
+ self.STORE_FAST(oparg, next_instr)
+ elif opcode == opcodedesc.STORE_GLOBAL.index:
+ self.STORE_GLOBAL(oparg, next_instr)
+ elif opcode == opcodedesc.STORE_MAP.index:
+ self.STORE_MAP(oparg, next_instr)
+ elif opcode == opcodedesc.STORE_NAME.index:
+ self.STORE_NAME(oparg, next_instr)
+ elif opcode == opcodedesc.STORE_SLICE_0.index:
+ self.STORE_SLICE_0(oparg, next_instr)
+ elif opcode == opcodedesc.STORE_SLICE_1.index:
+ self.STORE_SLICE_1(oparg, next_instr)
+ elif opcode == opcodedesc.STORE_SLICE_2.index:
+ self.STORE_SLICE_2(oparg, next_instr)
+ elif opcode == opcodedesc.STORE_SLICE_3.index:
+ self.STORE_SLICE_3(oparg, next_instr)
+ elif opcode == opcodedesc.STORE_SUBSCR.index:
+ self.STORE_SUBSCR(oparg, next_instr)
+ elif opcode == opcodedesc.UNARY_CONVERT.index:
+ self.UNARY_CONVERT(oparg, next_instr)
+ elif opcode == opcodedesc.UNARY_INVERT.index:
+ self.UNARY_INVERT(oparg, next_instr)
+ elif opcode == opcodedesc.UNARY_NEGATIVE.index:
+ self.UNARY_NEGATIVE(oparg, next_instr)
+ elif opcode == opcodedesc.UNARY_NOT.index:
+ self.UNARY_NOT(oparg, next_instr)
+ elif opcode == opcodedesc.UNARY_POSITIVE.index:
+ self.UNARY_POSITIVE(oparg, next_instr)
+ elif opcode == opcodedesc.UNPACK_SEQUENCE.index:
+ self.UNPACK_SEQUENCE(oparg, next_instr)
+ elif opcode == opcodedesc.WITH_CLEANUP.index:
+ self.WITH_CLEANUP(oparg, next_instr)
+ elif opcode == opcodedesc.YIELD_VALUE.index:
+ self.YIELD_VALUE(oparg, next_instr)
+ else:
+ self.MISSING_OPCODE(oparg, next_instr)
if jit.we_are_jitted():
return next_instr
@@ -733,36 +908,6 @@
self.pushvalue(w_value)
LOAD_ATTR._always_inline_ = True
- def cmp_lt(self, w_1, w_2):
- return self.space.lt(w_1, w_2)
-
- def cmp_le(self, w_1, w_2):
- return self.space.le(w_1, w_2)
-
- def cmp_eq(self, w_1, w_2):
- return self.space.eq(w_1, w_2)
-
- def cmp_ne(self, w_1, w_2):
- return self.space.ne(w_1, w_2)
-
- def cmp_gt(self, w_1, w_2):
- return self.space.gt(w_1, w_2)
-
- def cmp_ge(self, w_1, w_2):
- return self.space.ge(w_1, w_2)
-
- def cmp_in(self, w_1, w_2):
- return self.space.contains(w_2, w_1)
-
- def cmp_not_in(self, w_1, w_2):
- return self.space.not_(self.space.contains(w_2, w_1))
-
- def cmp_is(self, w_1, w_2):
- return self.space.is_(w_1, w_2)
-
- def cmp_is_not(self, w_1, w_2):
- return self.space.not_(self.space.is_(w_1, w_2))
-
@jit.unroll_safe
def cmp_exc_match(self, w_1, w_2):
space = self.space
@@ -779,11 +924,28 @@
def COMPARE_OP(self, testnum, next_instr):
w_2 = self.popvalue()
w_1 = self.popvalue()
- w_result = None
- for i, attr in unrolling_compare_dispatch_table:
- if i == testnum:
- w_result = getattr(self, attr)(w_1, w_2)
- break
+ if testnum == 0:
+ w_result = self.space.lt(w_1, w_2)
+ elif testnum == 1:
+ w_result = self.space.le(w_1, w_2)
+ elif testnum == 2:
+ w_result = self.space.eq(w_1, w_2)
+ elif testnum == 3:
+ w_result = self.space.ne(w_1, w_2)
+ elif testnum == 4:
+ w_result = self.space.gt(w_1, w_2)
+ elif testnum == 5:
+ w_result = self.space.ge(w_1, w_2)
+ elif testnum == 6:
+ w_result = self.space.contains(w_2, w_1)
+ elif testnum == 7:
+ w_result = self.space.not_(self.space.contains(w_2, w_1))
+ elif testnum == 8:
+ w_result = self.space.is_(w_1, w_2)
+ elif testnum == 9:
+ w_result = self.space.not_(self.space.is_(w_1, w_2))
+ elif testnum == 10:
+ w_result = self.cmp_exc_match(w_1, w_2)
else:
raise BytecodeCorruption("bad COMPARE_OP oparg")
self.pushvalue(w_result)
@@ -1086,49 +1248,6 @@
self.space.setitem(w_dict, w_key, w_value)
-class __extend__(pyframe.CPythonFrame):
-
- def JUMP_IF_FALSE(self, stepby, next_instr):
- w_cond = self.peekvalue()
- if not self.space.is_true(w_cond):
- next_instr += stepby
- return next_instr
-
- def JUMP_IF_TRUE(self, stepby, next_instr):
- w_cond = self.peekvalue()
- if self.space.is_true(w_cond):
- next_instr += stepby
- return next_instr
-
- def BUILD_MAP(self, itemcount, next_instr):
- if sys.version_info >= (2, 6):
- # We could pre-allocate a dict here
- # but for the moment this code is not translated.
- pass
- else:
- if itemcount != 0:
- raise BytecodeCorruption
- w_dict = self.space.newdict()
- self.pushvalue(w_dict)
-
- def STORE_MAP(self, zero, next_instr):
- if sys.version_info >= (2, 6):
- w_key = self.popvalue()
- w_value = self.popvalue()
- w_dict = self.peekvalue()
- self.space.setitem(w_dict, w_key, w_value)
- else:
- raise BytecodeCorruption
-
- def LIST_APPEND(self, oparg, next_instr):
- w = self.popvalue()
- if sys.version_info < (2, 7):
- v = self.popvalue()
- else:
- v = self.peekvalue(oparg - 1)
- self.space.call_method(v, 'append', w)
-
-
### ____________________________________________________________ ###
class ExitFrame(Exception):
diff --git a/pypy/interpreter/test/test_compiler.py
b/pypy/interpreter/test/test_compiler.py
--- a/pypy/interpreter/test/test_compiler.py
+++ b/pypy/interpreter/test/test_compiler.py
@@ -953,10 +953,6 @@
assert i > -1
assert isinstance(co.co_consts[i], frozenset)
-
-class AppTestCallMethod(object):
- spaceconfig = {'objspace.opcodes.CALL_METHOD': True}
-
def test_call_method_kwargs(self):
source = """def _f(a):
return a.f(a=a)
diff --git a/pypy/interpreter/test/test_executioncontext.py
b/pypy/interpreter/test/test_executioncontext.py
--- a/pypy/interpreter/test/test_executioncontext.py
+++ b/pypy/interpreter/test/test_executioncontext.py
@@ -253,10 +253,6 @@
""")
-class TestExecutionContextWithCallMethod(TestExecutionContext):
- spaceconfig ={'objspace.opcodes.CALL_METHOD': True}
-
-
class AppTestDelNotBlocked:
def setup_method(self, meth):
diff --git a/pypy/interpreter/test/test_gateway.py
b/pypy/interpreter/test/test_gateway.py
--- a/pypy/interpreter/test/test_gateway.py
+++ b/pypy/interpreter/test/test_gateway.py
@@ -812,10 +812,6 @@
assert len(called) == 1
assert isinstance(called[0], argument.Arguments)
-class TestPassThroughArguments_CALL_METHOD(TestPassThroughArguments):
- spaceconfig = dict(usemodules=('itertools',), **{
- "objspace.opcodes.CALL_METHOD": True
- })
class AppTestKeywordsToBuiltinSanity(object):
diff --git a/pypy/module/_continuation/interp_pickle.py
b/pypy/module/_continuation/interp_pickle.py
--- a/pypy/module/_continuation/interp_pickle.py
+++ b/pypy/module/_continuation/interp_pickle.py
@@ -120,8 +120,7 @@
nkwds = (oparg >> 8) & 0xff
if nkwds == 0: # only positional arguments
# fast paths leaves things on the stack, pop them
- if (frame.space.config.objspace.opcodes.CALL_METHOD and
- opcode == map['CALL_METHOD']):
+ if opcode == map['CALL_METHOD']:
frame.dropvalues(nargs + 2)
elif opcode == map['CALL_FUNCTION']:
frame.dropvalues(nargs + 1)
diff --git a/pypy/module/_lsprof/test/test_cprofile.py
b/pypy/module/_lsprof/test/test_cprofile.py
--- a/pypy/module/_lsprof/test/test_cprofile.py
+++ b/pypy/module/_lsprof/test/test_cprofile.py
@@ -191,11 +191,6 @@
sys.path.pop(0)
-class AppTestWithDifferentBytecodes(AppTestCProfile):
- spaceconfig = AppTestCProfile.spaceconfig.copy()
- spaceconfig['objspace.opcodes.CALL_METHOD'] = True
-
-
expected_output = {}
expected_output['print_stats'] = """\
126 function calls (106 primitive calls) in 1.000 seconds
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -841,8 +841,7 @@
#
# default_magic - 6 -- used by CPython without the -U option
# default_magic - 5 -- used by CPython with the -U option
-# default_magic -- used by PyPy without the CALL_METHOD opcode
-# default_magic + 2 -- used by PyPy with the CALL_METHOD opcode
+# default_magic -- used by PyPy [because of CALL_METHOD]
#
from pypy.interpreter.pycode import default_magic
MARSHAL_VERSION_FOR_PYC = 2
@@ -855,10 +854,7 @@
magic = __import__('imp').get_magic()
return struct.unpack('<i', magic)[0]
- result = default_magic
- if space.config.objspace.opcodes.CALL_METHOD:
- result += 2
- return result
+ return default_magic
def parse_source_module(space, pathname, source):
diff --git a/pypy/module/sys/test/test_sysmodule.py
b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -710,7 +710,3 @@
except:
assert g() is e
test_call_in_subfunction.expected = 'n'
-
-
-class AppTestSysExcInfoDirectCallMethod(AppTestSysExcInfoDirect):
- spaceconfig = {"objspace.opcodes.CALL_METHOD": True}
diff --git a/pypy/objspace/std/frame.py b/pypy/objspace/std/frame.py
--- a/pypy/objspace/std/frame.py
+++ b/pypy/objspace/std/frame.py
@@ -91,10 +91,9 @@
StdObjSpaceFrame.BINARY_ADD = int_BINARY_ADD
if space.config.objspace.std.optimized_list_getitem:
StdObjSpaceFrame.BINARY_SUBSCR = list_BINARY_SUBSCR
- if space.config.objspace.opcodes.CALL_METHOD:
- from pypy.objspace.std.callmethod import LOOKUP_METHOD, CALL_METHOD
- StdObjSpaceFrame.LOOKUP_METHOD = LOOKUP_METHOD
- StdObjSpaceFrame.CALL_METHOD = CALL_METHOD
+ from pypy.objspace.std.callmethod import LOOKUP_METHOD, CALL_METHOD
+ StdObjSpaceFrame.LOOKUP_METHOD = LOOKUP_METHOD
+ StdObjSpaceFrame.CALL_METHOD = CALL_METHOD
if space.config.objspace.std.optimized_comparison_op:
StdObjSpaceFrame.COMPARE_OP = fast_COMPARE_OP
return StdObjSpaceFrame
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -591,10 +591,7 @@
return ObjSpace.getindex_w(self, w_obj, w_exception, objdescr)
def call_method(self, w_obj, methname, *arg_w):
- if self.config.objspace.opcodes.CALL_METHOD:
- return callmethod.call_method_opt(self, w_obj, methname, *arg_w)
- else:
- return ObjSpace.call_method(self, w_obj, methname, *arg_w)
+ return callmethod.call_method_opt(self, w_obj, methname, *arg_w)
def _type_issubtype(self, w_sub, w_type):
if isinstance(w_sub, W_TypeObject) and isinstance(w_type,
W_TypeObject):
diff --git a/pypy/objspace/std/test/test_callmethod.py
b/pypy/objspace/std/test/test_callmethod.py
--- a/pypy/objspace/std/test/test_callmethod.py
+++ b/pypy/objspace/std/test/test_callmethod.py
@@ -2,8 +2,6 @@
# The exec hacking is needed to have the code snippets compiled
# by our own compiler, not CPython's
- spaceconfig = {"objspace.opcodes.CALL_METHOD": True}
-
def test_call_method(self):
exec """if 1:
class C(object):
@@ -111,13 +109,10 @@
class AppTestCallMethodWithGetattributeShortcut(AppTestCallMethod):
- spaceconfig = AppTestCallMethod.spaceconfig.copy()
- spaceconfig["objspace.std.getattributeshortcut"] = True
+ spaceconfig = {"objspace.std.getattributeshortcut": True}
class TestCallMethod:
- spaceconfig = {"objspace.opcodes.CALL_METHOD": True}
-
def test_space_call_method(self):
space = self.space
w_lst = space.newlist([])
diff --git a/pypy/objspace/std/test/test_mapdict.py
b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -656,8 +656,7 @@
class AppTestWithMapDictAndCounters(object):
spaceconfig = {"objspace.std.withmapdict": True,
- "objspace.std.withmethodcachecounter": True,
- "objspace.opcodes.CALL_METHOD": True}
+ "objspace.std.withmethodcachecounter": True}
def setup_class(cls):
from pypy.interpreter import gateway
@@ -1001,8 +1000,7 @@
class AppTestGlobalCaching(AppTestWithMapDict):
spaceconfig = {"objspace.std.withmethodcachecounter": True,
- "objspace.std.withmapdict": True,
- "objspace.opcodes.CALL_METHOD": True}
+ "objspace.std.withmapdict": True}
def test_mix_classes(self):
import __pypy__
diff --git a/rpython/tool/stdlib_opcode.py b/rpython/tool/stdlib_opcode.py
--- a/rpython/tool/stdlib_opcode.py
+++ b/rpython/tool/stdlib_opcode.py
@@ -9,13 +9,6 @@
def _freeze_(self):
return True
- def is_enabled(self, space):
- """Check if the opcode should be enabled in the space's configuration.
- (Returns True for all standard opcodes.)"""
- opt = space.config.objspace.opcodes
- return getattr(opt, self.name, True)
- is_enabled._annspecialcase_ = 'specialize:memo'
-
# for predictable results, we try to order opcodes most-used-first
opcodeorder = [124, 125, 100, 105, 1, 131, 116, 111, 106, 83, 23, 93, 113,
25, 95, 64, 112, 66, 102, 110, 60, 92, 62, 120, 68, 87, 32, 136, 4, 103, 24,
63, 18, 65, 15, 55, 121, 3, 101, 22, 12, 80, 86, 135, 126, 90, 140, 104, 2, 33,
20, 108, 107, 31, 134, 132, 88, 30, 133, 130, 137, 141, 61, 122, 11, 40, 74,
73, 51, 96, 21, 42, 56, 85, 82, 89, 142, 77, 78, 79, 91, 76, 97, 57, 19, 43,
84, 50, 41, 99, 53, 26]
@@ -63,7 +56,7 @@
for name, index in opmap.items():
tbl[index] = methodname = name.replace('+', '_')
desc = OpcodeDesc(self, name, index, methodname)
- setattr(self.opcodedesc, name, desc)
+ setattr(self.opcodedesc, methodname, desc)
self.opdescmap[index] = desc
# fill the ordered opdesc list
self.ordered_opdescs = lst = self.opdescmap.values()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit