Commits

Manuel Jacob committed 0ef9c70 Merge

hg merge default

Comments (0)

Files changed (91)

lib-python/2.7/uuid.py

         overriding the given 'hex', 'bytes', 'bytes_le', 'fields', or 'int'.
         """
 
-        if [hex, bytes, bytes_le, fields, int].count(None) != 4:
-            raise TypeError('need one of hex, bytes, bytes_le, fields, or int')
         if hex is not None:
+            if (bytes is not None or bytes_le is not None or fields is not None
+                    or int is not None):
+                raise TypeError('if the hex argument is given, bytes, bytes_le, fields,'
+                                ' and int need to be None')
             hex = hex.replace('urn:', '').replace('uuid:', '')
             hex = hex.strip('{}').replace('-', '')
             if len(hex) != 32:
                 raise ValueError('badly formed hexadecimal UUID string')
             int = long(hex, 16)
-        if bytes_le is not None:
+        elif bytes_le is not None:
+            if bytes is not None or fields is not None or int is not None:
+                raise TypeError('if the bytes_le argument is given, bytes, fields,'
+                                ' and int need to be None')
             if len(bytes_le) != 16:
                 raise ValueError('bytes_le is not a 16-char string')
             bytes = (bytes_le[3] + bytes_le[2] + bytes_le[1] + bytes_le[0] +
                      bytes_le[5] + bytes_le[4] + bytes_le[7] + bytes_le[6] +
                      bytes_le[8:])
-        if bytes is not None:
+            int = (struct.unpack('>Q', bytes[:8])[0] << 64 |
+                   struct.unpack('>Q', bytes[8:])[0])
+        elif bytes is not None:
+            if fields is not None or int is not None:
+                raise TypeError('if the bytes argument is given, fields'
+                                ' and int need to be None')
             if len(bytes) != 16:
                 raise ValueError('bytes is not a 16-char string')
             int = (struct.unpack('>Q', bytes[:8])[0] << 64 |
                    struct.unpack('>Q', bytes[8:])[0])
-        if fields is not None:
+        elif fields is not None:
+            if int is not None:
+                raise TypeError('if the fields argument is given, int needs to be None')
             if len(fields) != 6:
                 raise ValueError('fields is not a 6-tuple')
             (time_low, time_mid, time_hi_version,
             clock_seq = (clock_seq_hi_variant << 8L) | clock_seq_low
             int = ((time_low << 96L) | (time_mid << 80L) |
                    (time_hi_version << 64L) | (clock_seq << 48L) | node)
-        if int is not None:
+        elif int is not None:
             if not 0 <= int < 1<<128L:
                 raise ValueError('int is out of range (need a 128-bit value)')
+        else:
+            raise TypeError('one of hex, bytes, bytes_le, fields,'
+                            ' or int need to be not None')
         if version is not None:
             if not 1 <= version <= 5:
                 raise ValueError('illegal version number')
             # Set the version number.
             int &= ~(0xf000 << 64L)
             int |= version << 76L
-        self.__dict__['int'] = int
+        object.__setattr__(self, 'int', int)
 
     def __cmp__(self, other):
         if isinstance(other, UUID):

lib_pypy/_curses.py

 """Reimplementation of the standard extension module '_curses' using cffi."""
 
 import sys
+if sys.platform == 'win32':
+    #This module does not exist in windows
+    raise ImportError('No module named _curses')
 from functools import wraps
 
 from cffi import FFI

pypy/config/pypyoption.py

 
 
 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,
         BoolOption("optimized_int_add",
                    "special case the addition of two integers in BINARY_ADD",
                    default=False),
-        BoolOption("optimized_comparison_op",
-                   "special case the comparison of integers",
-                   default=False),
         BoolOption("optimized_list_getitem",
                    "special case the 'list[integer]' expressions",
                    default=False),
 
     # 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)

pypy/doc/config/objspace.opcodes.CALL_METHOD.txt

-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

pypy/doc/config/objspace.opcodes.txt

-..  intentionally empty

pypy/doc/interpreter-optimizations.rst

 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

pypy/doc/tool/makecontributor.py

     'Roberto De Ioris': ['roberto@mrspurr'],
     'Sven Hager': ['hager'],
     'Tomo Cocoa': ['cocoatomo'],
+    'Romain Guillebert': ['rguillebert', 'rguillbert', 'romain', 'Guillebert Romain'],
+    'Ronan Lamy': ['ronan'],
+    'Edd Barrett': ['edd'],
+    'Manuel Jacob': ['mjacob'],
+    'Rami Chowdhury': ['necaris'],
     }
 
 alias_map = {}
     if not match:
         return set()
     ignore_words = ['around', 'consulting', 'yesterday', 'for a bit', 'thanks',
-                    'in-progress', 'bits of', 'even a little', 'floating',]
+                    'in-progress', 'bits of', 'even a little', 'floating',
+                    'a bit', 'reviewing']
     sep_words = ['and', ';', '+', '/', 'with special  by']
     nicknames = match.group(1)
     for word in ignore_words:
     ##         print '%5d %s' % (n, name)
     ##     else:
     ##         print name
-                
+
     items = authors_count.items()
     items.sort(key=operator.itemgetter(1), reverse=True)
     for name, n in items:

pypy/doc/whatsnew-head.rst

 .. this is a revision shortly after release-2.1-beta
 .. startrev: 4eb52818e7c0
 
+.. branch: sanitise_bytecode_dispatch
+Make PyPy's bytecode dispatcher easy to read, and less reliant on RPython
+magic. There is no functional change, though the removal of dead code leads
+to many fewer tests to execute.
+
 .. branch: fastjson
 Fast json decoder written in RPython, about 3-4x faster than the pure Python
 decoder which comes with the stdlib
 .. branch: reflex-support
 .. branch: numpypy-inplace-op
 .. branch: rewritten-loop-logging
+
+.. branch: nobold-backtrace
+Work on improving UnionError messages and stack trace displays.
+
+.. branch: improve-errors-again
+More improvements and refactorings of error messages.
+
+.. branch: improve-errors-again2
+Unbreak tests in rlib.
+
+.. branch: less-stringly-ops
+Use subclasses of SpaceOperation instead of SpaceOperator objects.
+Random cleanups in flowspace.
+

pypy/interpreter/astcompiler/codegen.py

         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)

pypy/interpreter/pycode.py

                         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 = self.space.FrameClass(self.space, self, w_globals, None)
         frame.setdictscope(w_locals)
         return frame.run()
 

pypy/interpreter/pyframe.py

 
     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)
             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
-
 
 # ____________________________________________________________
 

pypy/interpreter/pyopcode.py

 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"""
 
     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):
             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
 
             # 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:
                     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
                     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
         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
     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)
         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):

pypy/interpreter/test/test_compiler.py

         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)

pypy/interpreter/test/test_executioncontext.py

         """)
 
 
-class TestExecutionContextWithCallMethod(TestExecutionContext):
-    spaceconfig ={'objspace.opcodes.CALL_METHOD': True}
-
-
 class AppTestDelNotBlocked:
 
     def setup_method(self, meth):

pypy/interpreter/test/test_gateway.py

         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):
 

pypy/module/_cffi_backend/test/_backend_test_c.py

     d = BStruct.fields
     assert d[0][1].offset == d[1][1].offset == d[2][1].offset == 0
     assert d[3][1].offset == sizeof(BLong)
-    assert d[0][1].bitshift == 0
+    def f(m, r):
+        if sys.byteorder == 'little':
+            return r
+        else:
+            return LONGBITS - m - r
+    assert d[0][1].bitshift == f(1, 0)
     assert d[0][1].bitsize == 1
-    assert d[1][1].bitshift == 1
+    assert d[1][1].bitshift == f(2, 1)
     assert d[1][1].bitsize == 2
-    assert d[2][1].bitshift == 3
+    assert d[2][1].bitshift == f(3, 3)
     assert d[2][1].bitsize == 3
-    assert d[3][1].bitshift == 0
+    assert d[3][1].bitshift == f(LONGBITS - 5, 0)
     assert d[3][1].bitsize == LONGBITS - 5
     assert sizeof(BStruct) == 2 * sizeof(BLong)
     assert alignof(BStruct) == alignof(BLong)
                                        ('b1', BInt, 9),
                                        ('b2', BUInt, 7),
                                        ('c', BChar, -1)], -1, -1, -1, flag)
-    if flag % 2 == 0:   # gcc and gcc ARM
+    if flag % 2 == 0:   # gcc, any variant
         assert typeoffsetof(BStruct, 'c') == (BChar, 3)
         assert sizeof(BStruct) == 4
     else:               # msvc
         assert sizeof(BStruct) == 12
     assert alignof(BStruct) == 4
     #
+    p = newp(new_pointer_type(BStruct), None)
+    p.a = b'A'
+    p.b1 = -201
+    p.b2 = 99
+    p.c = b'\x9D'
+    raw = buffer(p)[:]
+    if sys.byteorder == 'little':
+        if flag == 0 or flag == 2:  # gcc, little endian
+            assert raw == b'A7\xC7\x9D'
+        elif flag == 1: # msvc
+            assert raw == b'A\x00\x00\x007\xC7\x00\x00\x9D\x00\x00\x00'
+        elif flag == 4: # gcc, big endian
+            assert raw == b'A\xE3\x9B\x9D'
+        else:
+            raise AssertionError("bad flag")
+    else:
+        if flag == 0 or flag == 2:  # gcc
+            assert raw == b'A\xC77\x9D'
+        elif flag == 1: # msvc
+            assert raw == b'A\x00\x00\x00\x00\x00\xC77\x9D\x00\x00\x00'
+        elif flag == 4: # gcc, big endian
+            assert raw == b'A\x9B\xE3\x9D'
+        else:
+            raise AssertionError("bad flag")
+    #
     BStruct = new_struct_type("struct foo2")
     complete_struct_or_union(BStruct, [('a', BChar, -1),
                                        ('',  BShort, 9),
     elif flag == 1: # msvc
         assert sizeof(BStruct) == 6
         assert alignof(BStruct) == 2
-    else:           # gcc ARM
+    elif flag == 2: # gcc ARM
         assert sizeof(BStruct) == 6
         assert alignof(BStruct) == 2
+    elif flag == 4: # gcc, big endian
+        assert sizeof(BStruct) == 5
+        assert alignof(BStruct) == 1
+    else:
+        raise AssertionError("bad flag")
     #
     BStruct = new_struct_type("struct foo2")
     complete_struct_or_union(BStruct, [('a', BChar, -1),
                                        ('',  BInt, 0),
                                        ('',  BInt, 0),
                                        ('c', BChar, -1)], -1, -1, -1, flag)
-    if flag == 0:   # gcc
+    if flag == 0:    # gcc
         assert typeoffsetof(BStruct, 'c') == (BChar, 4)
         assert sizeof(BStruct) == 5
         assert alignof(BStruct) == 1
         assert typeoffsetof(BStruct, 'c') == (BChar, 1)
         assert sizeof(BStruct) == 2
         assert alignof(BStruct) == 1
-    else:            # gcc ARM
+    elif flag == 2:  # gcc ARM
         assert typeoffsetof(BStruct, 'c') == (BChar, 4)
         assert sizeof(BStruct) == 8
         assert alignof(BStruct) == 4
+    elif flag == 4:  # gcc, big endian
+        assert typeoffsetof(BStruct, 'c') == (BChar, 4)
+        assert sizeof(BStruct) == 5
+        assert alignof(BStruct) == 1
+    else:
+        raise AssertionError("bad flag")
 
 
 def test_bitfield_as_gcc():
 def test_bitfield_as_arm_gcc():
     _test_bitfield_details(flag=2)
 
+def test_bitfield_as_big_endian():
+    if '__pypy__' in sys.builtin_module_names:
+        py.test.skip("no big endian machine supported on pypy for now")
+    _test_bitfield_details(flag=4)
+
 
 def test_version():
     # this test is here mostly for PyPy

pypy/module/_continuation/interp_pickle.py

     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)

pypy/module/_continuation/test/test_zpickle.py

 
 class AppTestCopy:
     spaceconfig = dict(usemodules=['_continuation'],
-                       continuation=True,
-                       CALL_METHOD=True)
+                       continuation=True)
 
     def test_basic_setup(self):
         from _continuation import continulet
     spaceconfig = {
         "usemodules": ['_continuation', 'struct', 'binascii'],
         "continuation": True,
-        "CALL_METHOD": True,
     }
 
     def setup_class(cls):

pypy/module/_lsprof/test/test_cprofile.py

             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

pypy/module/imp/importing.py

 #
 #     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
             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):

pypy/module/imp/test/test_import.py

         assert ret == 42
 
     def test_pyc_magic_changes(self):
+        py.test.skip("For now, PyPy generates only one kind of .pyc files")
         # test that the pyc files produced by a space are not reimportable
         # from another, if they differ in what opcodes they support
         allspaces = [self.space]

pypy/module/micronumpy/loop.py

 
 reduce_driver = jit.JitDriver(name='numpy_reduce',
                               greens = ['shapelen', 'func', 'done_func',
-                                        'calc_dtype', 'identity'],
+                                        'calc_dtype'],
                               reds = 'auto')
 
 def compute_reduce(obj, calc_dtype, func, done_func, identity):
     while not obj_iter.done():
         reduce_driver.jit_merge_point(shapelen=shapelen, func=func,
                                       done_func=done_func,
-                                      calc_dtype=calc_dtype, identity=identity,
+                                      calc_dtype=calc_dtype,
                                       )
         rval = obj_iter.getitem().convert_to(calc_dtype)
         if done_func is not None and done_func(calc_dtype, rval):

pypy/module/micronumpy/test/test_zjit.py

             elif isinstance(w_res, interp_boxes.W_BoolBox):
                 return float(w_res.value)
             raise TypeError(w_res)
-
+      
         if self.graph is None:
             interp, graph = self.meta_interp(f, [0],
                                              listops=True,
                                 'int_add': 3,
                                 })
 
+    def define_reduce():
+        return """
+        a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+        sum(a)
+        """
+
     def test_reduce_compile_only_once(self):
         self.compile_graph()
         reset_stats()
         pyjitpl._warmrunnerdesc.memory_manager.alive_loops.clear()
-        i = self.code_mapping['sum']
+        i = self.code_mapping['reduce']
         # run it twice
         retval = self.interp.eval_graph(self.graph, [i])
         retval = self.interp.eval_graph(self.graph, [i])

pypy/module/pypyjit/test_pypy_c/test_containers.py

         loop, = log.loops_by_filename(self.filepath)
         ops = loop.ops_by_id('getitem', include_guard_not_invalidated=False)
         assert log.opnames(ops) == []
-
-    def test_list_count_virtual_list(self):
-        def main(n):
-            i = 0
-            while i < n:
-                i += [n].count(n)
-            return i
-
-        log = self.run(main, [1000])
-        assert log.result == main(1000)
-        loop, = log.loops_by_filename(self.filepath)
-        assert loop.match("""
-            i7 = int_lt(i5, i6)
-            guard_true(i7, descr=...)
-            i9 = int_add(i5, 1)
-            guard_not_invalidated(descr=...)
-            --TICK--
-            jump(..., descr=...)
-        """)

pypy/module/sys/test/test_sysmodule.py

         except:
             assert g() is e
     test_call_in_subfunction.expected = 'n'
-
-
-class AppTestSysExcInfoDirectCallMethod(AppTestSysExcInfoDirect):
-    spaceconfig = {"objspace.opcodes.CALL_METHOD": True}

pypy/module/test_lib_pypy/test_curses.py

 import pytest
+import sys
+if sys.platform == 'win32':
+    #This module does not exist in windows
+    pytest.skip('no curses on windows')
 
 # Check that lib_pypy.cffi finds the correct version of _cffi_backend.
 # Otherwise, the test is skipped.  It should never be skipped when run

pypy/objspace/std/dictmultiobject.py

     def get_empty_storage(self):
         raise NotImplementedError
 
+    @jit.look_inside_iff(lambda self, w_dict:
+                         w_dict_unrolling_heuristic(w_dict))
     def w_keys(self, w_dict):
         iterator = self.iterkeys(w_dict)
         result = newlist_hint(self.length(w_dict))

pypy/objspace/std/frame.py

         w_result = f.space.getitem(w_1, w_2)
     f.pushvalue(w_result)
 
-compare_table = [
-    "lt",   # "<"
-    "le",   # "<="
-    "eq",   # "=="
-    "ne",   # "!="
-    "gt",   # ">"
-    "ge",   # ">="
-    ]
-unrolling_compare_ops = unrolling_iterable(enumerate(compare_table))
-
-def fast_COMPARE_OP(f, testnum, next_instr):
-    w_2 = f.popvalue()
-    w_1 = f.popvalue()
-    w_result = None
-    if (type(w_2) is intobject.W_IntObject and
-        type(w_1) is intobject.W_IntObject and
-        testnum < len(compare_table)):
-        for i, attr in unrolling_compare_ops:
-            if i == testnum:
-                op = getattr(operator, attr)
-                w_result = f.space.newbool(op(w_1.intval,
-                                              w_2.intval))
-                break
-    else:
-        for i, attr in pyopcode.unrolling_compare_dispatch_table:
-            if i == testnum:
-                w_result = getattr(f, attr)(w_1, w_2)
-                break
-        else:
-            raise pyopcode.BytecodeCorruption, "bad COMPARE_OP oparg"
-    f.pushvalue(w_result)
-
 
 def build_frame(space):
     """Consider the objspace config and return a patched frame object."""
         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
-    if space.config.objspace.std.optimized_comparison_op:
-        StdObjSpaceFrame.COMPARE_OP = fast_COMPARE_OP
+    from pypy.objspace.std.callmethod import LOOKUP_METHOD, CALL_METHOD
+    StdObjSpaceFrame.LOOKUP_METHOD = LOOKUP_METHOD
+    StdObjSpaceFrame.CALL_METHOD = CALL_METHOD
     return StdObjSpaceFrame

pypy/objspace/std/kwargsdict.py

     def _never_equal_to(self, w_lookup_type):
         return False
 
-    def w_keys(self, w_dict):
-        return self.space.newlist([self.space.wrap(key) for key in self.unerase(w_dict.dstorage)[0]])
-
     def setitem(self, w_dict, w_key, w_value):
         if self.is_correct_type(w_key):
             self.setitem_str(w_dict, self.unwrap(w_key), w_value)
             jit.isconstant(self.length(w_dict)) and jit.isconstant(key))
     def _setitem_str_indirection(self, w_dict, key, w_value):
         keys, values_w = self.unerase(w_dict.dstorage)
-        result = []
         for i in range(len(keys)):
             if keys[i] == key:
                 values_w[i] = w_value
                 values_w.append(w_value)
 
     def setdefault(self, w_dict, w_key, w_default):
-        space = self.space
         if self.is_correct_type(w_key):
             key = self.unwrap(w_key)
             w_result = self.getitem_str(w_dict, key)
             jit.isconstant(self.length(w_dict)) and jit.isconstant(key))
     def _getitem_str_indirection(self, w_dict, key):
         keys, values_w = self.unerase(w_dict.dstorage)
-        result = []
         for i in range(len(keys)):
             if keys[i] == key:
                 return values_w[i]
 
     def getiterkeys(self, w_dict):
         return iter(self.unerase(w_dict.dstorage)[0])
+
     def getitervalues(self, w_dict):
         return iter(self.unerase(w_dict.dstorage)[1])
+
     def getiteritems(self, w_dict):
         keys = self.unerase(w_dict.dstorage)[0]
         return iter(range(len(keys)))
+
     def wrapkey(space, key):
         return space.wrap(key)
 
+
 def next_item(self):
     strategy = self.strategy
     assert isinstance(strategy, KwargsDictStrategy)

pypy/objspace/std/listobject.py

         'L.reverse() -- reverse *IN PLACE*'
         self.reverse()
 
-    @jit.look_inside_iff(lambda self, space, w_value:
-            jit.loop_unrolling_heuristic(self, self.length(), UNROLL_CUTOFF))
     def descr_count(self, space, w_value):
         '''L.count(value) -> integer -- return number of
         occurrences of value'''

pypy/objspace/std/objspace.py

         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):

pypy/objspace/std/stringobject.py

 
     return space.wrap(builder.build())
 
-def str_title__String(space, w_self):
-    input = w_self._value
-    builder = StringBuilder(len(input))
+
+@jit.elidable
+def title(s):
+    builder = StringBuilder(len(s))
     prev_letter = ' '
 
-    for pos in range(len(input)):
-        ch = input[pos]
+    for ch in s:
         if not prev_letter.isalpha():
             ch = _upper(ch)
             builder.append(ch)
             builder.append(ch)
 
         prev_letter = ch
+    return builder.build()
 
-    return space.wrap(builder.build())
+
+def str_title__String(space, w_self):
+    return space.wrap(title(w_self._value))
+
 
 def str_split__String_None_ANY(space, w_self, w_none, w_maxsplit=-1):
     maxsplit = space.int_w(w_maxsplit)
-    res = []
     value = w_self._value
-    length = len(value)
-    i = 0
-    while True:
-        # find the beginning of the next word
-        while i < length:
-            if not value[i].isspace():
-                break   # found
-            i += 1
-        else:
-            break  # end of string, finished
-
-        # find the end of the word
-        if maxsplit == 0:
-            j = length   # take all the rest of the string
-        else:
-            j = i + 1
-            while j < length and not value[j].isspace():
-                j += 1
-            maxsplit -= 1   # NB. if it's already < 0, it stays < 0
-
-        # the word is value[i:j]
-        res.append(value[i:j])
-
-        # continue to look from the character following the space after the word
-        i = j + 1
-
+    res = split(value, maxsplit=maxsplit)
     return space.newlist_str(res)
 
 def str_split__String_String_ANY(space, w_self, w_by, w_maxsplit=-1):
 
 def str_rsplit__String_None_ANY(space, w_self, w_none, w_maxsplit=-1):
     maxsplit = space.int_w(w_maxsplit)
-    res = []
     value = w_self._value
-    i = len(value)-1
-    while True:
-        # starting from the end, find the end of the next word
-        while i >= 0:
-            if not value[i].isspace():
-                break   # found
-            i -= 1
-        else:
-            break  # end of string, finished
-
-        # find the start of the word
-        # (more precisely, 'j' will be the space character before the word)
-        if maxsplit == 0:
-            j = -1   # take all the rest of the string
-        else:
-            j = i - 1
-            while j >= 0 and not value[j].isspace():
-                j -= 1
-            maxsplit -= 1   # NB. if it's already < 0, it stays < 0
-
-        # the word is value[j+1:i+1]
-        j1 = j + 1
-        assert j1 >= 0
-        res.append(value[j1:i+1])
-
-        # continue to look from the character before the space before the word
-        i = j - 1
-
-    res.reverse()
+    res = rsplit(value, maxsplit=maxsplit)
     return space.newlist_str(res)
 
 def str_rsplit__String_String_ANY(space, w_self, w_by, w_maxsplit=-1):

pypy/objspace/std/test/test_callmethod.py

     # 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):
 
 
 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([])

pypy/objspace/std/test/test_intobject.py

 
 class AppTestIntOptimizedAdd(AppTestInt):
     spaceconfig = {"objspace.std.optimized_int_add": True}
-
-class AppTestIntOptimizedComp(AppTestInt):
-    spaceconfig = {"objspace.std.optimized_comparison_op": True}

pypy/objspace/std/test/test_mapdict.py

 
 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
 
 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__

pypy/tool/pytest/apptest.py

         try:
             target(*args)
         except OperationError, e:
+            if self.config.option.verbose:
+                raise
             tb = sys.exc_info()[2]
             if e.match(space, space.w_KeyboardInterrupt):
                 raise KeyboardInterrupt, KeyboardInterrupt(), tb

rpython/annotator/argument.py

             return [Ellipsis]
         raise CallPatternTooComplex("'*' argument must be SomeTuple")
 
-    def is_true(self, s_tup):
+    def bool(self, s_tup):
         assert isinstance(s_tup, SomeTuple)
         return bool(s_tup.items)
 
             args_w = data_args_w[:need_cnt]
             for argname, w_arg in zip(argnames[need_cnt:], data_args_w[need_cnt:]):
                 unfiltered_kwds_w[argname] = w_arg
-            assert not space.is_true(data_w_stararg)
+            assert not space.bool(data_w_stararg)
         else:
             stararg_w = space.unpackiterable(data_w_stararg)
             args_w = data_args_w + stararg_w

rpython/annotator/binaryop.py

                 if pbc.isNone():
                     return %(classname)s(%(constructor_args)s)
                 else:
-                    return SomeObject()
+                    raise UnionError(pbc, obj)
 
         class __extend__(pairtype(SomePBC, %(classname)s)):
             def union((pbc, obj)):
                 if pbc.isNone():
                     return %(classname)s(%(constructor_args)s)
                 else:
-                    return SomeObject()
+                    raise UnionError(pbc, obj)
     """ % loc)
     exec source.compile() in glob
 

rpython/annotator/bookkeeper.py

         fn, block, i = self.position_key
         op = block.operations[i]
         if opname is not None:
-            assert op.opname == opname or op.opname in opname
+            assert op.opname == opname
         if arity is not None:
             assert len(op.args) == arity
         if pos is not None:

rpython/annotator/builtin.py

 
 
 def builtin_bool(s_obj):
-    return s_obj.is_true()
+    return s_obj.bool()
 
 def builtin_int(s_obj, s_base=None):
     if isinstance(s_obj, SomeInteger):

rpython/annotator/listdef.py

 from rpython.annotator.model import s_ImpossibleValue
 from rpython.annotator.model import SomeList, SomeString
-from rpython.annotator.model import unionof, TLS, UnionError
+from rpython.annotator.model import unionof, TLS, UnionError, AnnotatorError
 
 
-class TooLateForChange(Exception):
+class TooLateForChange(AnnotatorError):
     pass
 
-class ListChangeUnallowed(Exception):
+class ListChangeUnallowed(AnnotatorError):
     pass
 
 class ListItem(object):

rpython/annotator/signature.py

 from rpython.annotator.model import SomeBool, SomeInteger, SomeString,\
      SomeFloat, SomeList, SomeDict, s_None, \
      SomeObject, SomeInstance, SomeTuple, lltype_to_annotation,\
-     unionof, SomeUnicodeString, SomeType
+     unionof, SomeUnicodeString, SomeType, AnnotatorError
 from rpython.annotator.listdef import ListDef
 from rpython.annotator.dictdef import DictDef
 
             else:
                 args_s.append(annotation(argtype, bookkeeper=funcdesc.bookkeeper))
         if len(inputcells) != len(args_s):
-            raise Exception("%r: expected %d args, got %d" % (funcdesc,
+            raise SignatureError("%r: expected %d args, got %d" % (funcdesc,
                                                               len(args_s),
                                                               len(inputcells)))
         for i, (s_arg, s_input) in enumerate(zip(args_s, inputcells)):
             s_input = unionof(s_input, s_arg)
             if not s_arg.contains(s_input):
-                raise Exception("%r argument %d:\n"
+                raise SignatureError("%r argument %d:\n"
                                 "expected %s,\n"
                                 "     got %s" % (funcdesc, i+1,
                                              s_arg,
                                              s_input))
         inputcells[:] = args_s
 
+class SignatureError(AnnotatorError):
+    pass
+
 def finish_type(paramtype, bookkeeper, func):
     from rpython.rlib.types import SelfTypeMarker, AnyTypeMarker
     if isinstance(paramtype, SomeObject):
         return paramtype
     elif isinstance(paramtype, SelfTypeMarker):
-        raise Exception("%r argument declared as annotation.types.self(); class needs decorator rlib.signature.finishsigs()" % (func,))
+        raise SignatureError("%r argument declared as annotation.types.self(); class needs decorator rlib.signature.finishsigs()" % (func,))
     elif isinstance(paramtype, AnyTypeMarker):
         return None
     else:
         if s_param is None: # can be anything
             continue
         if not s_param.contains(s_actual):
-            raise Exception("%r argument %d:\n"
+            raise SignatureError("%r argument %d:\n"
                             "expected %s,\n"
                             "     got %s" % (funcdesc, i+1, s_param, s_actual))
     for i, s_param in enumerate(params_s):
 def enforce_signature_return(funcdesc, sigtype, inferredtype):
     s_sigret = finish_type(sigtype, funcdesc.bookkeeper, funcdesc.pyobj)
     if s_sigret is not None and not s_sigret.contains(inferredtype):
-        raise Exception("%r return value:\n"
+        raise SignatureError("%r return value:\n"
                         "expected %s,\n"
                         "     got %s" % (funcdesc, s_sigret, inferredtype))
     return s_sigret

rpython/annotator/specialize.py

             assert not s.can_be_None, "memo call: cannot mix None and PBCs"
             for desc in s.descriptions:
                 if desc.pyobj is None:
-                    raise Exception("memo call with a class or PBC that has no "
-                                   "corresponding Python object (%r)" % (desc,))
+                    raise annmodel.AnnotatorError(
+                        "memo call with a class or PBC that has no "
+                        "corresponding Python object (%r)" % (desc,))
                 values.append(desc.pyobj)
         elif isinstance(s, SomeImpossibleValue):
             return s    # we will probably get more possible args later
         elif isinstance(s, SomeBool):
             values = [False, True]
         else:
-            raise Exception("memo call: argument must be a class or a frozen "
-                            "PBC, got %r" % (s,))
+            raise annmodel.AnnotatorError("memo call: argument must be a class"
+                                          "or a frozen PBC, got %r" % (s,))
         argvalues.append(values)
     # the list of all possible tuples of arguments to give to the memo function
     possiblevalues = cartesian_product(argvalues)
     except KeyError:
         func = funcdesc.pyobj
         if func is None:
-            raise Exception("memo call: no Python function object to call "
-                            "(%r)" % (funcdesc,))
+            raise annmodel.AnnotatorError("memo call: no Python function object"
+                                          "to call (%r)" % (funcdesc,))
 
         def compute_one_result(args):
             value = func(*args)
             desc, = s.descriptions
             key.append(desc)
         else:
-            raise Exception("specialize:arg(%d): argument not constant: %r"
-                            % (i, s))
+            raise annmodel.AnnotatorError("specialize:arg(%d): argument not "
+                                          "constant: %r" % (i, s))
     key = tuple(key)
     return maybe_star_args(funcdesc, key, args_s)
 

rpython/annotator/test/test_annrpython.py

         s = a.build_types(snippet.prime, [int])
         assert s.knowntype == bool
 
-    def test_and_is_true_coalesce(self):
+    def test_and_bool_coalesce(self):
         def f(a,b,c,d,e):
             x = a and b
             if x:
         s = a.build_types(f, [int, str, a.bookkeeper.immutablevalue(1.0), a.bookkeeper.immutablevalue('d'), a.bookkeeper.immutablevalue('e')])
         assert s == annmodel.SomeTuple([annmodel.SomeChar(), a.bookkeeper.immutablevalue(1.0)])
 
-    def test_is_true_coalesce2(self):
+    def test_bool_coalesce2(self):
         def f(a,b,a1,b1,c,d,e):
             x = (a or  b) and (a1 or b1)
             if x:
         assert s == annmodel.SomeTuple([annmodel.SomeChar(),
                                         a.bookkeeper.immutablevalue(1.0)])
 
-    def test_is_true_coalesce_sanity(self):
+    def test_bool_coalesce_sanity(self):
         def f(a):
             while a:
                 pass

rpython/annotator/test/test_argument.py

     def newtuple(self, items):
         return tuple(items)
 
-    def is_true(self, obj):
+    def bool(self, obj):
         return bool(obj)
 
     def unpackiterable(self, it):

rpython/annotator/unaryop.py

 def immutablevalue(x):
     return getbookkeeper().immutablevalue(x)
 
-UNARY_OPERATIONS = set(['len', 'is_true', 'getattr', 'setattr', 'delattr',
+UNARY_OPERATIONS = set(['len', 'bool', 'getattr', 'setattr', 'delattr',
                         'simple_call', 'call_args', 'str', 'repr',
                         'iter', 'next', 'invert', 'type', 'issubtype',
-                        'pos', 'neg', 'nonzero', 'abs', 'hex', 'oct',
+                        'pos', 'neg', 'abs', 'hex', 'oct',
                         'ord', 'int', 'float', 'long',
                         'hash', 'id',    # <== not supported any more
                         'getslice', 'setslice', 'delslice',
     def len(obj):
         return SomeInteger(nonneg=True)
 
-    def is_true_behavior(obj, s):
+    def bool_behavior(obj, s):
         if obj.is_immutable_constant():
             s.const = bool(obj.const)
         else:
             if s_len.is_immutable_constant():
                 s.const = s_len.const > 0
 
-    def is_true(s_obj):
+    def bool(s_obj):
         r = SomeBool()
-        s_obj.is_true_behavior(r)
+        s_obj.bool_behavior(r)
 
         bk = getbookkeeper()
         knowntypedata = {}
-        op = bk._find_current_op(opname=("is_true", "nonzero"), arity=1)
+        op = bk._find_current_op(opname="bool", arity=1)
         arg = op.args[0]
         s_nonnone_obj = s_obj
         if s_obj.can_be_none():
         r.set_knowntypedata(knowntypedata)
         return r
 
-    def nonzero(obj):
-        return obj.is_true()
-
     def hash(obj):
         raise AnnotatorError("cannot use hash() in RPython")
 
 
     abs = neg
 
-    def is_true(self):
+    def bool(self):
         if self.is_immutable_constant():
             return getbookkeeper().immutablevalue(bool(self.const))
         return s_Bool
     abs_ovf = _clone(abs, [OverflowError])
 
 class __extend__(SomeBool):
-    def is_true(self):
+    def bool(self):
         return self
 
     def invert(self):
             # create or update the attribute in clsdef
             clsdef.generalize_attr(attr, s_value)
 
-    def is_true_behavior(ins, s):
+    def bool_behavior(ins, s):
         if not ins.can_be_None:
             s.const = True
 
         d = [desc.bind_under(classdef, name) for desc in pbc.descriptions]
         return SomePBC(d, can_be_None=pbc.can_be_None)
 
-    def is_true_behavior(pbc, s):
+    def bool_behavior(pbc, s):
         if pbc.isNone():
             s.const = False
         elif not pbc.can_be_None:
         v = p.ll_ptrtype._example()(*llargs)
         return ll_to_annotation(v)
 
-    def is_true(p):
+    def bool(p):
         return s_Bool
 
 class __extend__(SomeLLADTMeth):
             llmemory.supported_access_types[s_attr.const])
     getattr.can_only_throw = []
 
-    def is_true(s_addr):
+    def bool(s_addr):
         return s_Bool

rpython/flowspace/bytecode.py

 """
 from rpython.tool.stdlib_opcode import host_bytecode_spec
 from opcode import EXTENDED_ARG, HAVE_ARGUMENT
+import opcode
 from rpython.flowspace.argument import Signature
 from rpython.flowspace.flowcontext import BytecodeCorruption
 
         Returns (next_instr, opname, oparg).
         """
         co_code = self.co_code
-        opcode = ord(co_code[pos])
+        opnum = ord(co_code[pos])
         next_instr = pos + 1
 
-        if opcode >= HAVE_ARGUMENT:
+        if opnum >= HAVE_ARGUMENT:
             lo = ord(co_code[next_instr])
             hi = ord(co_code[next_instr+1])
             next_instr += 2
         else:
             oparg = 0
 
-        while opcode == EXTENDED_ARG:
-            opcode = ord(co_code[next_instr])
-            if opcode < HAVE_ARGUMENT:
+        while opnum == EXTENDED_ARG:
+            opnum = ord(co_code[next_instr])
+            if opnum < 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
 
-        opname = self.opnames[opcode]
+        if opnum in opcode.hasjrel:
+            oparg += next_instr
+        opname = self.opnames[opnum]
         return next_instr, opname, oparg
 
     @property

rpython/flowspace/flowcontext.py

 from rpython.tool.stdlib_opcode import host_bytecode_spec
 from rpython.flowspace.argument import CallSpec
 from rpython.flowspace.model import (Constant, Variable, Block, Link,
-    c_last_exception, SpaceOperation)
+    c_last_exception, SpaceOperation, const)
 from rpython.flowspace.framestate import (FrameState, recursively_unflatten,
     recursively_flatten)
 from rpython.flowspace.specialcase import (rpython_print_item,
     rpython_print_newline)
-from rpython.flowspace.operation import op
 
 
 class FlowingError(Exception):
     """ Signals invalid RPython in the function being analysed"""
-    def __init__(self, frame, msg):
-        super(FlowingError, self).__init__(msg)
-        self.frame = frame
+    frame = None
 
     def __str__(self):
         msg = ["\n"]
     def append(self, operation):
         raise NotImplementedError
 
-    def guessbool(self, frame, w_condition, **kwds):
+    def guessbool(self, frame, w_condition):
         raise AssertionError("cannot guessbool(%s)" % (w_condition,))
 
 
                       [str(s) for s in self.listtoreplay[self.index:]]))
         self.index += 1
 
-    def guessbool(self, frame, w_condition, **kwds):
+    def guessbool(self, frame, w_condition):
         assert self.index == len(self.listtoreplay)
         frame.recorder = self.nextreplayer
         return self.booloutcome
 
 def unsupportedoperation(OP