Carl Friedrich Bolz avatar Carl Friedrich Bolz committed 5225def Merge

merge

Comments (0)

Files changed (90)

 b590cf6de4190623aad9aa698694c22e614d67b9 release-1.5
 b48df0bf4e75b81d98f19ce89d4a7dc3e1dab5e5 benchmarked
 d8ac7d23d3ec5f9a0fa1264972f74a010dbfd07f release-1.6
-ff4af8f318821f7f5ca998613a60fca09aa137da release-1.7

lib_pypy/pyrepl/unix_console.py

                    e.args[4] == 'unexpected end of data':
                 pass
             else:
-                # was: "raise".  But it crashes pyrepl, and by extension the
-                # pypy currently running, in which we are e.g. in the middle
-                # of some debugging session.  Argh.  Instead just print an
-                # error message to stderr and continue running, for now.
-                self.partial_char = ''
-                sys.stderr.write('\n%s: %s\n' % (e.__class__.__name__, e))
+                raise
         else:
             self.partial_char = ''
             self.event_queue.push(c)

lib_pypy/syslog.py

 _setlogmask.argtypes = (c_int,)
 _setlogmask.restype = c_int
 
-_S_log_open = False
-_S_ident_o = None
-
-def _get_argv():
-    try:
-        import sys
-        script = sys.argv[0]
-        if isinstance(script, str):
-            return script[script.rfind('/')+1:] or None
-    except Exception:
-        pass
-    return None
-
 @builtinify
-def openlog(ident=None, logoption=0, facility=LOG_USER):
-    global _S_ident_o, _S_log_open
-    if ident is None:
-        ident = _get_argv()
-    _S_ident_o = c_char_p(ident)    # keepalive
-    _openlog(_S_ident_o, logoption, facility)
-    _S_log_open = True
+def openlog(ident, option, facility):
+    _openlog(ident, option, facility)
 
 @builtinify
 def syslog(arg1, arg2=None):
         priority, message = arg1, arg2
     else:
         priority, message = LOG_INFO, arg1
-    # if log is not opened, open it now
-    if not _S_log_open:
-        openlog()
     _syslog(priority, "%s", message)
 
 @builtinify
 def closelog():
-    global _S_log_open, S_ident_o
-    if _S_log_open:
-        _closelog()
-        _S_log_open = False
-        _S_ident_o = None
+    _closelog()
 
 @builtinify
 def setlogmask(mask):

pypy/doc/coding-guide.rst

   - *slicing*:
     the slice start must be within bounds. The stop doesn't need to, but it must
     not be smaller than the start.  All negative indexes are disallowed, except for
-    the [:-1] special case.  No step.  Slice deletion follows the same rules.
-    
-  - *slice assignment*:
-    only supports ``lst[x:y] = sublist``, if ``len(sublist) == y - x``.
-    In other words, slice assignment cannot change the total length of the list,
-    but just replace items.
+    the [:-1] special case.  No step.
 
   - *other operators*:
     ``+``, ``+=``, ``in``, ``*``, ``*=``, ``==``, ``!=`` work as expected.

pypy/doc/how-to-release.rst

+.. include:: needswork.txt
+
+.. needs work, it talks about svn. also, it is not really user documentation
 
 Making a PyPy Release
 =======================
 forgetting things. A set of todo files may also work.
 
 Check and prioritize all issues for the release, postpone some if necessary,
-create new  issues also as necessary. An important thing is to get
-the documentation into an up-to-date state!
+create new  issues also as necessary. A meeting (or meetings) should be
+organized to decide what things are priorities, should go in and work for
+the release. 
+
+An important thing is to get the documentation into an up-to-date state!
 
 Release Steps
 ----------------

pypy/doc/project-ideas.rst

 Numpy improvements
 ------------------
 
-The numpy is rapidly progressing in pypy, so feel free to come to IRC and
-ask for proposed topic. A not necesarilly up-to-date `list of topics`_
-is also available.
+This is more of a project-container than a single project. Possible ideas:
 
-.. _`list of topics`: https://bitbucket.org/pypy/extradoc/src/extradoc/planning/micronumpy.txt
+* experiment with auto-vectorization using SSE or implement vectorization
+  without automatically detecting it for array operations.
+
+* improve numpy, for example implement memory views.
+
+* interface with fortran/C libraries.
 
 Improving the jitviewer
 ------------------------

pypy/jit/backend/conftest.py

                     help="choose a fixed random seed")
     group.addoption('--backend', action="store",
                     default='llgraph',
-                    choices=['llgraph', 'cpu'],
+                    choices=['llgraph', 'x86'],
                     dest="backend",
                     help="select the backend to run the functions with")
     group.addoption('--block-length', action="store", type="int",

pypy/jit/backend/llgraph/llimpl.py

 from pypy.jit.backend.llgraph import symbolic
 from pypy.jit.codewriter import longlong
 
-from pypy.rlib import libffi
 from pypy.rlib.objectmodel import ComputedIntSymbolic, we_are_translated
 from pypy.rlib.rarithmetic import ovfcheck
 from pypy.rlib.rarithmetic import r_longlong, r_ulonglong, r_uint
     loop = _from_opaque(loop)
     loop.operations.append(Operation(opnum))
 
-def compile_add_descr(loop, ofs, type, arg_types, extrainfo, width):
+def compile_add_descr(loop, ofs, type, arg_types):
     from pypy.jit.backend.llgraph.runner import Descr
     loop = _from_opaque(loop)
     op = loop.operations[-1]
     assert isinstance(type, str) and len(type) == 1
-    op.descr = Descr(ofs, type, arg_types=arg_types, extrainfo=extrainfo, width=width)
+    op.descr = Descr(ofs, type, arg_types=arg_types)
 
 def compile_add_descr_arg(loop, ofs, type, arg_types):
     from pypy.jit.backend.llgraph.runner import Descr
         else:
             raise NotImplementedError
 
-    def op_getinteriorfield_raw(self, descr, array, index):
-        if descr.typeinfo == REF:
-            return do_getinteriorfield_raw_ptr(array, index, descr.width, descr.ofs)
-        elif descr.typeinfo == INT:
-            return do_getinteriorfield_raw_int(array, index, descr.width, descr.ofs)
-        elif descr.typeinfo == FLOAT:
-            return do_getinteriorfield_raw_float(array, index, descr.width, descr.ofs)
-        else:
-            raise NotImplementedError
-
     def op_setinteriorfield_gc(self, descr, array, index, newvalue):
         if descr.typeinfo == REF:
             return do_setinteriorfield_gc_ptr(array, index, descr.ofs,
         else:
             raise NotImplementedError
 
-    def op_setinteriorfield_raw(self, descr, array, index, newvalue):
-        if descr.typeinfo == REF:
-            return do_setinteriorfield_raw_ptr(array, index, newvalue, descr.width, descr.ofs)
-        elif descr.typeinfo == INT:
-            return do_setinteriorfield_raw_int(array, index, newvalue, descr.width, descr.ofs)
-        elif descr.typeinfo == FLOAT:
-            return do_setinteriorfield_raw_float(array, index, newvalue, descr.width, descr.ofs)
-        else:
-            raise NotImplementedError
-
     def op_setfield_gc(self, fielddescr, struct, newvalue):
         if fielddescr.typeinfo == REF:
             do_setfield_gc_ptr(struct, fielddescr.ofs, newvalue)
     struct = array._obj.container.getitem(index)
     return cast_to_ptr(_getinteriorfield_gc(struct, fieldnum))
 
-def _getinteriorfield_raw(ffitype, array, index, width, ofs):
-    addr = rffi.cast(rffi.VOIDP, array)
-    return libffi.array_getitem(ffitype, width, addr, index, ofs)
-
-def do_getinteriorfield_raw_int(array, index, width, ofs):
-    res = _getinteriorfield_raw(libffi.types.slong, array, index, width, ofs)
-    return res
-
 def _getfield_raw(struct, fieldnum):
     STRUCT, fieldname = symbolic.TokenToField[fieldnum]
     ptr = cast_from_int(lltype.Ptr(STRUCT), struct)
     return do_setinteriorfield_gc
 do_setinteriorfield_gc_int = new_setinteriorfield_gc(cast_from_int)
 do_setinteriorfield_gc_float = new_setinteriorfield_gc(cast_from_floatstorage)
-do_setinteriorfield_gc_ptr = new_setinteriorfield_gc(cast_from_ptr)
-
-def new_setinteriorfield_raw(ffitype):
-    def do_setinteriorfield_raw(array, index, newvalue, width, ofs):
-        addr = rffi.cast(rffi.VOIDP, array)
-        return libffi.array_setitem(ffitype, width, addr, index, ofs, newvalue)
-    return do_setinteriorfield_raw
-do_setinteriorfield_raw_int = new_setinteriorfield_raw(libffi.types.slong)
+do_setinteriorfield_gc_ptr = new_setinteriorfield_gc(cast_from_ptr)        
 
 def do_setfield_raw_int(struct, fieldnum, newvalue):
     STRUCT, fieldname = symbolic.TokenToField[fieldnum]

pypy/jit/backend/llgraph/runner.py

 class Descr(history.AbstractDescr):
 
     def __init__(self, ofs, typeinfo, extrainfo=None, name=None,
-                 arg_types=None, count_fields_if_immut=-1, ffi_flags=0, width=-1):
-
+                 arg_types=None, count_fields_if_immut=-1, ffi_flags=0):
         self.ofs = ofs
-        self.width = width
         self.typeinfo = typeinfo
         self.extrainfo = extrainfo
         self.name = name
         return False
 
     def getdescr(self, ofs, typeinfo='?', extrainfo=None, name=None,
-                 arg_types=None, count_fields_if_immut=-1, ffi_flags=0, width=-1):
+                 arg_types=None, count_fields_if_immut=-1, ffi_flags=0):
         key = (ofs, typeinfo, extrainfo, name, arg_types,
-               count_fields_if_immut, ffi_flags, width)
+               count_fields_if_immut, ffi_flags)
         try:
             return self._descrs[key]
         except KeyError:
             descr = Descr(ofs, typeinfo, extrainfo, name, arg_types,
-                          count_fields_if_immut, ffi_flags, width)
+                          count_fields_if_immut, ffi_flags)
             self._descrs[key] = descr
             return descr
 
             descr = op.getdescr()
             if isinstance(descr, Descr):
                 llimpl.compile_add_descr(c, descr.ofs, descr.typeinfo,
-                                         descr.arg_types, descr.extrainfo,
-                                         descr.width)
+                                         descr.arg_types)
             if (isinstance(descr, history.LoopToken) and
                 op.getopnum() != rop.JUMP):
                 llimpl.compile_add_loop_token(c, descr)
 
     def interiorfielddescrof(self, A, fieldname):
         S = A.OF
-        width = symbolic.get_size(A)
+        ofs2 = symbolic.get_size(A)
         ofs, size = symbolic.get_field_token(S, fieldname)
         token = history.getkind(getattr(S, fieldname))
-        return self.getdescr(ofs, token[0], name=fieldname, width=width)
-
-    def interiorfielddescrof_dynamic(self, offset, width, fieldsize,
-        is_pointer, is_float, is_signed):
-
-        if is_pointer:
-            typeinfo = REF
-        elif is_float:
-            typeinfo = FLOAT
-        else:
-            typeinfo = INT
-        # we abuse the arg_types field to distinguish dynamic and static descrs
-        return Descr(offset, typeinfo, arg_types='dynamic', name='<dynamic interior field>', width=width)
+        return self.getdescr(ofs, token[0], name=fieldname, extrainfo=ofs2)
 
     def calldescrof(self, FUNC, ARGS, RESULT, extrainfo):
         arg_types = []

pypy/jit/backend/llsupport/descr.py

     def repr_of_descr(self):
         return '<%s %s %s>' % (self._clsname, self.name, self.offset)
 
-class DynamicFieldDescr(BaseFieldDescr):
-    def __init__(self, offset, fieldsize, is_pointer, is_float, is_signed):
-        self.offset = offset
-        self._fieldsize = fieldsize
-        self._is_pointer_field = is_pointer
-        self._is_float_field = is_float
-        self._is_field_signed = is_signed
-
-    def get_field_size(self, translate_support_code):
-        return self._fieldsize
 
 class NonGcPtrFieldDescr(BaseFieldDescr):
     _clsname = 'NonGcPtrFieldDescr'
     def repr_of_descr(self):
         return '<%s>' % self._clsname
 
-
 class NonGcPtrArrayDescr(BaseArrayDescr):
     _clsname = 'NonGcPtrArrayDescr'
     def get_item_size(self, translate_support_code):
     def get_ofs_length(self, translate_support_code):
         return -1
 
-class DynamicArrayNoLengthDescr(BaseArrayNoLengthDescr):
-    def __init__(self, itemsize):
-        self.itemsize = itemsize
-
-    def get_item_size(self, translate_support_code):
-        return self.itemsize
-
 class NonGcPtrArrayNoLengthDescr(BaseArrayNoLengthDescr):
     _clsname = 'NonGcPtrArrayNoLengthDescr'
     def get_item_size(self, translate_support_code):

pypy/jit/backend/llsupport/llmodel.py

 from pypy.jit.backend.llsupport import symbolic
 from pypy.jit.backend.llsupport.symbolic import WORD, unroll_basic_sizes
 from pypy.jit.backend.llsupport.descr import (get_size_descr,
-     get_field_descr, BaseFieldDescr, DynamicFieldDescr, get_array_descr,
-     BaseArrayDescr, DynamicArrayNoLengthDescr, get_call_descr,
-     BaseIntCallDescr, GcPtrCallDescr, FloatCallDescr, VoidCallDescr,
-     InteriorFieldDescr, get_interiorfield_descr)
+     get_field_descr, BaseFieldDescr, get_array_descr, BaseArrayDescr,
+     get_call_descr, BaseIntCallDescr, GcPtrCallDescr, FloatCallDescr,
+     VoidCallDescr, InteriorFieldDescr, get_interiorfield_descr)
 from pypy.jit.backend.llsupport.asmmemmgr import AsmMemoryManager
 
 
     def interiorfielddescrof(self, A, fieldname):
         return get_interiorfield_descr(self.gc_ll_descr, A, A.OF, fieldname)
 
-    def interiorfielddescrof_dynamic(self, offset, width, fieldsize,
-        is_pointer, is_float, is_signed):
-        arraydescr = DynamicArrayNoLengthDescr(width)
-        fielddescr = DynamicFieldDescr(offset, fieldsize, is_pointer, is_float, is_signed)
-        return InteriorFieldDescr(arraydescr, fielddescr)
-
     def unpack_arraydescr(self, arraydescr):
         assert isinstance(arraydescr, BaseArrayDescr)
         return arraydescr.get_base_size(self.translate_support_code)

pypy/jit/backend/llsupport/test/test_gc.py

         gcrootmap.put(retaddr, shapeaddr)
         assert gcrootmap._gcmap[0] == retaddr
         assert gcrootmap._gcmap[1] == shapeaddr
-        p = rffi.cast(rffi.LONGP, gcrootmap.gcmapstart())
+        p = rffi.cast(rffi.SIGNEDP, gcrootmap.gcmapstart())
         assert p[0] == retaddr
         assert (gcrootmap.gcmapend() ==
                 gcrootmap.gcmapstart() + rffi.sizeof(lltype.Signed) * 2)

pypy/jit/backend/model.py

             lst[n] = None
         self.fail_descr_free_list.extend(faildescr_indices)
 
-    def sizeof(self, S):
+    @staticmethod
+    def sizeof(S):
         raise NotImplementedError
 
-    def fielddescrof(self, S, fieldname):
+    @staticmethod
+    def fielddescrof(S, fieldname):
         """Return the Descr corresponding to field 'fieldname' on the
         structure 'S'.  It is important that this function (at least)
         caches the results."""
         raise NotImplementedError
 
-    def interiorfielddescrof(self, A, fieldname):
+    @staticmethod
+    def arraydescrof(A):
         raise NotImplementedError
 
-    def interiorfielddescrof_dynamic(self, offset, width, fieldsize, is_pointer,
-        is_float, is_signed):
-        raise NotImplementedError
-
-    def arraydescrof(self, A):
-        raise NotImplementedError
-
-    def calldescrof(self, FUNC, ARGS, RESULT):
+    @staticmethod
+    def calldescrof(FUNC, ARGS, RESULT):
         # FUNC is the original function type, but ARGS is a list of types
         # with Voids removed
         raise NotImplementedError
 
-    def methdescrof(self, SELFTYPE, methname):
+    @staticmethod
+    def methdescrof(SELFTYPE, methname):
         # must return a subclass of history.AbstractMethDescr
         raise NotImplementedError
 
-    def typedescrof(self, TYPE):
+    @staticmethod
+    def typedescrof(TYPE):
+        raise NotImplementedError
+
+    @staticmethod
+    def interiorfielddescrof(A, fieldname):
         raise NotImplementedError
 
     # ---------- the backend-dependent operations ----------

pypy/jit/backend/test/test_random.py

     if pytest.config.option.backend == 'llgraph':
         from pypy.jit.backend.llgraph.runner import LLtypeCPU
         return LLtypeCPU(None)
-    elif pytest.config.option.backend == 'cpu':
-        from pypy.jit.backend.detect_cpu import getcpuclass
-        return getcpuclass()(None, None)
+    elif pytest.config.option.backend == 'x86':
+        from pypy.jit.backend.x86.runner import CPU386
+        return CPU386(None, None)
     else:
         assert 0, "unknown backend %r" % pytest.config.option.backend
 

pypy/jit/backend/x86/assembler.py

 from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.rpython.annlowlevel import llhelper
 from pypy.jit.backend.model import CompiledLoopToken
-from pypy.jit.backend.x86.regalloc import (RegAlloc, get_ebp_ofs, _get_scale,
-    gpr_reg_mgr_cls, _valid_addressing_size)
+from pypy.jit.backend.x86.regalloc import (RegAlloc, get_ebp_ofs,
+                                           _get_scale, gpr_reg_mgr_cls)
 
 from pypy.jit.backend.x86.arch import (FRAME_FIXED_SIZE, FORCE_INDEX_OFS, WORD,
                                        IS_X86_32, IS_X86_64)
             after()
 
     _NOARG_FUNC = lltype.Ptr(lltype.FuncType([], lltype.Void))
-    _CLOSESTACK_FUNC = lltype.Ptr(lltype.FuncType([rffi.LONGP],
+    _CLOSESTACK_FUNC = lltype.Ptr(lltype.FuncType([rffi.SIGNEDP],
                                                   lltype.Void))
 
     def _build_release_gil(self, gcrootmap):
         assert isinstance(itemsize_loc, ImmedLoc)
         if isinstance(index_loc, ImmedLoc):
             temp_loc = imm(index_loc.value * itemsize_loc.value)
-        elif _valid_addressing_size(itemsize_loc.value):
-            return AddressLoc(base_loc, index_loc, _get_scale(itemsize_loc.value), ofs_loc.value)
         else:
-            # XXX should not use IMUL in more cases, it can use a clever LEA
+            # XXX should not use IMUL in most cases
             assert isinstance(temp_loc, RegLoc)
             assert isinstance(index_loc, RegLoc)
             assert not temp_loc.is_xmm
                                                 ofs_loc)
         self.load_from_mem(resloc, src_addr, fieldsize_loc, sign_loc)
 
-    genop_getinteriorfield_raw = genop_getinteriorfield_gc
-
 
     def genop_discard_setfield_gc(self, op, arglocs):
         base_loc, ofs_loc, size_loc, value_loc = arglocs
                                                  ofs_loc)
         self.save_into_mem(dest_addr, value_loc, fieldsize_loc)
 
-    genop_discard_setinteriorfield_raw = genop_discard_setinteriorfield_gc
-
     def genop_discard_setarrayitem_gc(self, op, arglocs):
         base_loc, ofs_loc, value_loc, size_loc, baseofs = arglocs
         assert isinstance(baseofs, ImmedLoc)
                 kind = code & 3
                 code = (code - self.CODE_FROMSTACK) >> 2
                 stackloc = frame_addr + get_ebp_ofs(code)
-                value = rffi.cast(rffi.LONGP, stackloc)[0]
+                value = rffi.cast(rffi.SIGNEDP, stackloc)[0]
                 if kind == self.DESCR_FLOAT and WORD == 4:
                     value_hi = value
-                    value = rffi.cast(rffi.LONGP, stackloc - 4)[0]
+                    value = rffi.cast(rffi.SIGNEDP, stackloc - 4)[0]
             else:
                 # 'code' identifies a register: load its value
                 kind = code & 3
             elif kind == self.DESCR_FLOAT:
                 tgt = self.fail_boxes_float.get_addr_for_num(num)
                 if WORD == 4:
-                    rffi.cast(rffi.LONGP, tgt)[1] = value_hi
+                    rffi.cast(rffi.SIGNEDP, tgt)[1] = value_hi
             else:
                 assert 0, "bogus kind"
-            rffi.cast(rffi.LONGP, tgt)[0] = value
+            rffi.cast(rffi.SIGNEDP, tgt)[0] = value
             num += 1
         #
         if not we_are_translated():
         self.failure_recovery_func = failure_recovery_func
         self.failure_recovery_code = [0, 0, 0, 0]
 
-    _FAILURE_RECOVERY_FUNC = lltype.Ptr(lltype.FuncType([rffi.LONGP],
+    _FAILURE_RECOVERY_FUNC = lltype.Ptr(lltype.FuncType([rffi.SIGNEDP],
                                                         lltype.Signed))
 
     def _build_failure_recovery(self, exc, withfloats=False):

pypy/jit/backend/x86/codebuf.py

         if self.relocations is not None:
             for reloc in self.relocations:
                 p = addr + reloc
-                adr = rffi.cast(rffi.LONGP, p - WORD)
+                adr = rffi.cast(rffi.SIGNEDP, p - WORD)
                 adr[0] = intmask(adr[0] - p)
         valgrind.discard_translations(addr, self.get_relative_pos())
         self._dump(addr, "jit-backend-dump", backend_name)

pypy/jit/backend/x86/regalloc.py

         self.PerformDiscard(op, [base_loc, ofs, itemsize, fieldsize,
                                  index_loc, temp_loc, value_loc])
 
-    consider_setinteriorfield_raw = consider_setinteriorfield_gc
-
     def consider_strsetitem(self, op):
         args = op.getarglist()
         base_loc = self.rm.make_sure_var_in_reg(op.getarg(0), args)
         self.Perform(op, [base_loc, ofs, itemsize, fieldsize,
                           index_loc, temp_loc, sign_loc], result_loc)
 
-    consider_getinteriorfield_raw = consider_getinteriorfield_gc
-
     def consider_int_is_true(self, op, guard_op):
         # doesn't need arg to be in a register
         argloc = self.loc(op.getarg(0))
     # i.e. the n'th word beyond the fixed frame size.
     return -WORD * (FRAME_FIXED_SIZE + position)
 
-def _valid_addressing_size(size):
-    return size == 1 or size == 2 or size == 4 or size == 8
-
 def _get_scale(size):
-    assert _valid_addressing_size(size)
+    assert size == 1 or size == 2 or size == 4 or size == 8
     if size < 4:
         return size - 1         # 1, 2 => 0, 1
     else:

pypy/jit/backend/x86/runner.py

     cast_ptr_to_int._annspecialcase_ = 'specialize:arglltype(0)'
     cast_ptr_to_int = staticmethod(cast_ptr_to_int)
 
-    all_null_registers = lltype.malloc(rffi.LONGP.TO, 24,
+    all_null_registers = lltype.malloc(rffi.SIGNEDP.TO, 24,
                                        flavor='raw', zero=True,
                                        immortal=True)
 

pypy/jit/backend/x86/test/test_assembler.py

         assert withfloats
         value = random.random() - 0.5
         # make sure it fits into 64 bits
-        tmp = lltype.malloc(rffi.LONGP.TO, 2, flavor='raw',
+        tmp = lltype.malloc(rffi.SIGNEDP.TO, 2, flavor='raw',
                             track_allocation=False)
         rffi.cast(rffi.DOUBLEP, tmp)[0] = value
         return rffi.cast(rffi.DOUBLEP, tmp)[0], tmp[0], tmp[1]
 
     # prepare the expected target arrays, the descr_bytecode,
     # the 'registers' and the 'stack' arrays according to 'content'
-    xmmregisters = lltype.malloc(rffi.LONGP.TO, 16+ACTUAL_CPU.NUM_REGS+1,
+    xmmregisters = lltype.malloc(rffi.SIGNEDP.TO, 16+ACTUAL_CPU.NUM_REGS+1,
                                  flavor='raw', immortal=True)
     registers = rffi.ptradd(xmmregisters, 16)
     stacklen = baseloc + 30
-    stack = lltype.malloc(rffi.LONGP.TO, stacklen, flavor='raw',
+    stack = lltype.malloc(rffi.SIGNEDP.TO, stacklen, flavor='raw',
                           immortal=True)
     expected_ints = [0] * len(content)
     expected_ptrs = [lltype.nullptr(llmemory.GCREF.TO)] * len(content)

pypy/jit/backend/x86/test/test_ztranslation.py

 import py, os, sys
 from pypy.tool.udir import udir
-from pypy.rlib.jit import JitDriver, unroll_parameters, set_param
+from pypy.rlib.jit import JitDriver, unroll_parameters
 from pypy.rlib.jit import PARAMETERS, dont_look_inside
 from pypy.rlib.jit import promote
 from pypy.jit.metainterp.jitprof import Profiler
         def f(i, j):
             for param, _ in unroll_parameters:
                 defl = PARAMETERS[param]
-                set_param(jitdriver, param, defl)
-            set_param(jitdriver, "threshold", 3)
-            set_param(jitdriver, "trace_eagerness", 2)
+                jitdriver.set_param(param, defl)
+            jitdriver.set_param("threshold", 3)
+            jitdriver.set_param("trace_eagerness", 2)
             total = 0
             frame = Frame(i)
             while frame.i > 3:
             else:
                 return Base()
         def myportal(i):
-            set_param(jitdriver, "threshold", 3)
-            set_param(jitdriver, "trace_eagerness", 2)
+            jitdriver.set_param("threshold", 3)
+            jitdriver.set_param("trace_eagerness", 2)
             total = 0
             n = i
             while True:

pypy/jit/codewriter/codewriter.py

         else:
             name = 'unnamed' % id(ssarepr)
         i = 1
-        # escape <lambda> names for windows
-        name = name.replace('<lambda>', '_(lambda)_')
         extra = ''
         while name+extra in self._seen_files:
             i += 1

pypy/jit/codewriter/effectinfo.py

     OS_LIBFFI_PREPARE           = 60
     OS_LIBFFI_PUSH_ARG          = 61
     OS_LIBFFI_CALL              = 62
-    OS_LIBFFI_GETARRAYITEM      = 63
-    OS_LIBFFI_SETARRAYITEM      = 64
     #
     OS_LLONG_INVERT             = 69
     OS_LLONG_ADD                = 70

pypy/jit/codewriter/jtransform.py

         elif oopspec_name.startswith('libffi_call_'):
             oopspecindex = EffectInfo.OS_LIBFFI_CALL
             extraeffect = EffectInfo.EF_RANDOM_EFFECTS
-        elif oopspec_name == 'libffi_array_getitem':
-            oopspecindex = EffectInfo.OS_LIBFFI_GETARRAYITEM
-            extraeffect = EffectInfo.EF_CANNOT_RAISE
-        elif oopspec_name == 'libffi_array_setitem':
-            oopspecindex = EffectInfo.OS_LIBFFI_SETARRAYITEM
-            extraeffect = EffectInfo.EF_CANNOT_RAISE
         else:
             assert False, 'unsupported oopspec: %s' % oopspec_name
         return self._handle_oopspec_call(op, args, oopspecindex, extraeffect)

pypy/jit/metainterp/executor.py

                          rop.DEBUG_MERGE_POINT,
                          rop.JIT_DEBUG,
                          rop.SETARRAYITEM_RAW,
-                         rop.GETINTERIORFIELD_RAW,
-                         rop.SETINTERIORFIELD_RAW,
                          rop.CALL_RELEASE_GIL,
                          rop.QUASIIMMUT_FIELD,
                          ):      # list of opcodes never executed by pyjitpl

pypy/jit/metainterp/optimizeopt/fficall.py

+from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
+from pypy.rlib.objectmodel import we_are_translated
+from pypy.rlib.libffi import Func
+from pypy.rlib.debug import debug_print
 from pypy.jit.codewriter.effectinfo import EffectInfo
+from pypy.jit.metainterp.resoperation import rop, ResOperation
+from pypy.jit.metainterp.optimizeopt.util import make_dispatcher_method
 from pypy.jit.metainterp.optimizeopt.optimizer import Optimization
-from pypy.jit.metainterp.optimizeopt.util import make_dispatcher_method
-from pypy.jit.metainterp.resoperation import rop, ResOperation
-from pypy.rlib import clibffi, libffi
-from pypy.rlib.debug import debug_print
-from pypy.rlib.libffi import Func
-from pypy.rlib.objectmodel import we_are_translated
-from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
-from pypy.rpython.lltypesystem import llmemory
 
 
 class FuncInfo(object):
 
     def new(self):
         return OptFfiCall()
-
+    
     def begin_optimization(self, funcval, op):
         self.rollback_maybe('begin_optimization', op)
         self.funcinfo = FuncInfo(funcval, self.optimizer.cpu, op)
             ops = self.do_push_arg(op)
         elif oopspec == EffectInfo.OS_LIBFFI_CALL:
             ops = self.do_call(op)
-        elif (oopspec == EffectInfo.OS_LIBFFI_GETARRAYITEM or
-            oopspec == EffectInfo.OS_LIBFFI_SETARRAYITEM):
-            ops = self.do_getsetarrayitem(op, oopspec)
         #
         for op in ops:
             self.emit_operation(op)
         ops.append(newop)
         return ops
 
-    def do_getsetarrayitem(self, op, oopspec):
-        ffitypeval = self.getvalue(op.getarg(1))
-        widthval = self.getvalue(op.getarg(2))
-        offsetval = self.getvalue(op.getarg(5))
-        if not ffitypeval.is_constant() or not widthval.is_constant() or not offsetval.is_constant():
-            return [op]
-
-        ffitypeaddr = ffitypeval.box.getaddr()
-        ffitype = llmemory.cast_adr_to_ptr(ffitypeaddr, clibffi.FFI_TYPE_P)
-        offset = offsetval.box.getint()
-        width = widthval.box.getint()
-        descr = self._get_interior_descr(ffitype, width, offset)
-
-        arglist = [
-            self.getvalue(op.getarg(3)).force_box(self.optimizer),
-            self.getvalue(op.getarg(4)).force_box(self.optimizer),
-        ]
-        if oopspec == EffectInfo.OS_LIBFFI_GETARRAYITEM:
-            opnum = rop.GETINTERIORFIELD_RAW
-        elif oopspec == EffectInfo.OS_LIBFFI_SETARRAYITEM:
-            opnum = rop.SETINTERIORFIELD_RAW
-            arglist.append(self.getvalue(op.getarg(6)).force_box(self.optimizer))
-        else:
-            assert False
-        return [
-            ResOperation(opnum, arglist, op.result, descr=descr),
-        ]
-
-    def _get_interior_descr(self, ffitype, width, offset):
-        kind = libffi.types.getkind(ffitype)
-        is_pointer = is_float = is_signed = False
-        if ffitype is libffi.types.pointer:
-            is_pointer = True
-        elif kind == 'i':
-            is_signed = True
-        elif kind == 'f' or kind == 'I' or kind == 'U':
-            # longlongs are treated as floats, see
-            # e.g. llsupport/descr.py:getDescrClass
-            is_float = True
-        else:
-            assert False, "unsupported ffitype or kind"
-        #
-        fieldsize = ffitype.c_size
-        return self.optimizer.cpu.interiorfielddescrof_dynamic(
-            offset, width, fieldsize, is_pointer, is_float, is_signed
-        )
-
     def propagate_forward(self, op):
         if self.logops is not None:
             debug_print(self.logops.repr_of_resop(op))

pypy/jit/metainterp/resoperation.py

     'GETARRAYITEM_GC/2d',
     'GETARRAYITEM_RAW/2d',
     'GETINTERIORFIELD_GC/2d',
-    'GETINTERIORFIELD_RAW/2d',
     'GETFIELD_GC/1d',
     'GETFIELD_RAW/1d',
     '_MALLOC_FIRST',
     'SETARRAYITEM_GC/3d',
     'SETARRAYITEM_RAW/3d',
     'SETINTERIORFIELD_GC/3d',
-    'SETINTERIORFIELD_RAW/3d',
     'SETFIELD_GC/2d',
     'SETFIELD_RAW/2d',
     'STRSETITEM/3',

pypy/jit/metainterp/test/test_ajit.py

 from pypy.rlib.jit import (JitDriver, we_are_jitted, hint, dont_look_inside,
     loop_invariant, elidable, promote, jit_debug, assert_green,
     AssertGreenFailed, unroll_safe, current_trace_length, look_inside_iff,
-    isconstant, isvirtual, promote_string, set_param)
+    isconstant, isvirtual, promote_string)
 from pypy.rlib.rarithmetic import ovfcheck
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi
 from pypy.rpython.ootypesystem import ootype
                 n -= 1
                 x += n
             return x
-        def f(n, threshold, arg):
-            if arg:
-                set_param(myjitdriver, 'threshold', threshold)
-            else:
-                set_param(None, 'threshold', threshold)
+        def f(n, threshold):
+            myjitdriver.set_param('threshold', threshold)
             return g(n)
 
-        res = self.meta_interp(f, [10, 3, 1])
+        res = self.meta_interp(f, [10, 3])
         assert res == 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0
         self.check_tree_loop_count(2)
 
-        res = self.meta_interp(f, [10, 13, 0])
+        res = self.meta_interp(f, [10, 13])
         assert res == 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0
         self.check_tree_loop_count(0)
 
                                 get_printable_location=get_printable_location)
         bytecode = "0j10jc20a3"
         def f():
-            set_param(myjitdriver, 'threshold', 7)
-            set_param(myjitdriver, 'trace_eagerness', 1)
+            myjitdriver.set_param('threshold', 7)
+            myjitdriver.set_param('trace_eagerness', 1)
             i = j = c = a = 1
             while True:
                 myjitdriver.jit_merge_point(i=i, j=j, c=c, a=a)
         myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa', 'a'])
 
         def f(n, limit):
-            set_param(myjitdriver, 'retrace_limit', limit)
+            myjitdriver.set_param('retrace_limit', limit)
             sa = i = a = 0
             while i < n:
                 myjitdriver.jit_merge_point(n=n, i=i, sa=sa, a=a)
         myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa', 'a'])
 
         def f(n, limit):
-            set_param(myjitdriver, 'retrace_limit', 3)
-            set_param(myjitdriver, 'max_retrace_guards', limit)
+            myjitdriver.set_param('retrace_limit', 3)
+            myjitdriver.set_param('max_retrace_guards', limit)
             sa = i = a = 0
             while i < n:
                 myjitdriver.jit_merge_point(n=n, i=i, sa=sa, a=a)
         myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa', 'a',
                                                      'node'])
         def f(n, limit):
-            set_param(myjitdriver, 'retrace_limit', limit)
+            myjitdriver.set_param('retrace_limit', limit)
             sa = i = a = 0
             node = [1, 2, 3]
             node[1] = n
         myjitdriver = JitDriver(greens = ['pc'], reds = ['n', 'i', 'sa'])
         bytecode = "0+sI0+SI"
         def f(n):
-            set_param(None, 'threshold', 3)
-            set_param(None, 'trace_eagerness', 1)
-            set_param(None, 'retrace_limit', 5)
-            set_param(None, 'function_threshold', -1)
+            myjitdriver.set_param('threshold', 3)
+            myjitdriver.set_param('trace_eagerness', 1)
+            myjitdriver.set_param('retrace_limit', 5)
+            myjitdriver.set_param('function_threshold', -1)
             pc = sa = i = 0
             while pc < len(bytecode):
                 myjitdriver.jit_merge_point(pc=pc, n=n, sa=sa, i=i)
         myjitdriver = JitDriver(greens = ['pc'], reds = ['n', 'a', 'i', 'j', 'sa'])
         bytecode = "ij+Jj+JI"
         def f(n, a):
-            set_param(None, 'threshold', 5)
-            set_param(None, 'trace_eagerness', 1)
-            set_param(None, 'retrace_limit', 2)
+            myjitdriver.set_param('threshold', 5)
+            myjitdriver.set_param('trace_eagerness', 1)
+            myjitdriver.set_param('retrace_limit', 2)
             pc = sa = i = j = 0
             while pc < len(bytecode):
                 myjitdriver.jit_merge_point(pc=pc, n=n, sa=sa, i=i, j=j, a=a)
                 return B(self.val + 1)
         myjitdriver = JitDriver(greens = [], reds = ['sa', 'a'])
         def f():
-            set_param(None, 'threshold', 3)
-            set_param(None, 'trace_eagerness', 2)
+            myjitdriver.set_param('threshold', 3)
+            myjitdriver.set_param('trace_eagerness', 2)
             a = A(0)
             sa = 0
             while a.val < 8:
                 return B(self.val + 1)
         myjitdriver = JitDriver(greens = [], reds = ['sa', 'b', 'a'])
         def f(b):
-            set_param(None, 'threshold', 6)
-            set_param(None, 'trace_eagerness', 4)
+            myjitdriver.set_param('threshold', 6)
+            myjitdriver.set_param('trace_eagerness', 4)
             a = A(0)
             sa = 0
             while a.val < 15:
         myjitdriver = JitDriver(greens = ['pc'], reds = ['n', 'i', 'sa'])
         bytecode = "0+sI0+SI"
         def f(n):
-            set_param(None, 'threshold', 3)
-            set_param(None, 'trace_eagerness', 1)
-            set_param(None, 'retrace_limit', 5)
-            set_param(None, 'function_threshold', -1)
+            myjitdriver.set_param('threshold', 3)
+            myjitdriver.set_param('trace_eagerness', 1)
+            myjitdriver.set_param('retrace_limit', 5)
+            myjitdriver.set_param('function_threshold', -1)
             pc = sa = i = 0
             while pc < len(bytecode):
                 myjitdriver.jit_merge_point(pc=pc, n=n, sa=sa, i=i)

pypy/jit/metainterp/test/test_fficall.py

+
 import py
+from pypy.rlib.rarithmetic import r_singlefloat, r_longlong, r_ulonglong
+from pypy.rlib.jit import JitDriver, promote, dont_look_inside
+from pypy.rlib.unroll import unrolling_iterable
+from pypy.rlib.libffi import ArgChain
+from pypy.rlib.libffi import IS_32_BIT
+from pypy.rlib.test.test_libffi import TestLibffiCall as _TestLibffiCall
+from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rlib.objectmodel import specialize
+from pypy.tool.sourcetools import func_with_new_name
+from pypy.jit.metainterp.test.support import LLJitMixin
 
-from pypy.jit.metainterp.test.support import LLJitMixin
-from pypy.rlib.jit import JitDriver, promote, dont_look_inside
-from pypy.rlib.libffi import (ArgChain, IS_32_BIT, array_getitem, array_setitem,
-    types)
-from pypy.rlib.objectmodel import specialize
-from pypy.rlib.rarithmetic import r_singlefloat, r_longlong, r_ulonglong
-from pypy.rlib.test.test_libffi import TestLibffiCall as _TestLibffiCall
-from pypy.rlib.unroll import unrolling_iterable
-from pypy.rpython.lltypesystem import lltype, rffi
-from pypy.tool.sourcetools import func_with_new_name
+class TestFfiCall(LLJitMixin, _TestLibffiCall):
+    supports_all = False     # supports_{floats,longlong,singlefloats}
 
-
-class FfiCallTests(_TestLibffiCall):
     # ===> ../../../rlib/test/test_libffi.py
 
     def call(self, funcspec, args, RESULT, is_struct=False, jitif=[]):
     test_byval_result.__doc__ = _TestLibffiCall.test_byval_result.__doc__
     test_byval_result.dont_track_allocations = True
 
-class FfiLookupTests(object):
-    def test_array_fields(self):
-        myjitdriver = JitDriver(
-            greens = [],
-            reds = ["n", "i", "points", "result_point"],
-        )
 
-        POINT = lltype.Struct("POINT",
-            ("x", lltype.Signed),
-            ("y", lltype.Signed),
-        )
-        def f(points, result_point, n):
-            i = 0
-            while i < n:
-                myjitdriver.jit_merge_point(i=i, points=points, n=n,
-                                            result_point=result_point)
-                x = array_getitem(
-                    types.slong, rffi.sizeof(lltype.Signed) * 2, points, i, 0
-                )
-                y = array_getitem(
-                    types.slong, rffi.sizeof(lltype.Signed) * 2, points, i, rffi.sizeof(lltype.Signed)
-                )
-
-                cur_x = array_getitem(
-                    types.slong, rffi.sizeof(lltype.Signed) * 2, result_point, 0, 0
-                )
-                cur_y = array_getitem(
-                    types.slong, rffi.sizeof(lltype.Signed) * 2, result_point, 0, rffi.sizeof(lltype.Signed)
-                )
-
-                array_setitem(
-                    types.slong, rffi.sizeof(lltype.Signed) * 2, result_point, 0, 0, cur_x + x
-                )
-                array_setitem(
-                    types.slong, rffi.sizeof(lltype.Signed) * 2, result_point, 0, rffi.sizeof(lltype.Signed), cur_y + y
-                )
-                i += 1
-
-        def main(n):
-            with lltype.scoped_alloc(rffi.CArray(POINT), n) as points:
-                with lltype.scoped_alloc(rffi.CArray(POINT), 1) as result_point:
-                    for i in xrange(n):
-                        points[i].x = i * 2
-                        points[i].y = i * 2 + 1
-                    points = rffi.cast(rffi.CArrayPtr(lltype.Char), points)
-                    result_point[0].x = 0
-                    result_point[0].y = 0
-                    result_point = rffi.cast(rffi.CArrayPtr(lltype.Char), result_point)
-                    f(points, result_point, n)
-                    result_point = rffi.cast(rffi.CArrayPtr(POINT), result_point)
-                    return result_point[0].x * result_point[0].y
-
-        assert self.meta_interp(main, [10]) == main(10) == 9000
-        self.check_loops({"int_add": 3, "jump": 1, "int_lt": 1, "guard_true": 1,
-                          "getinteriorfield_raw": 4, "setinteriorfield_raw": 2
-        })
-
-
-class TestFfiCall(FfiCallTests, LLJitMixin):
-    supports_all = False
-
-class TestFfiCallSupportAll(FfiCallTests, LLJitMixin):
+class TestFfiCallSupportAll(TestFfiCall):
     supports_all = True     # supports_{floats,longlong,singlefloats}
-
-class TestFfiLookup(FfiLookupTests, LLJitMixin):
-    pass

pypy/jit/metainterp/test/test_jitdriver.py

 """Tests for multiple JitDrivers."""
-from pypy.rlib.jit import JitDriver, unroll_safe, set_param
+from pypy.rlib.jit import JitDriver, unroll_safe
 from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.jit.metainterp.warmspot import get_stats
 
             return n
         #
         def loop2(g, r):
-            set_param(None, 'function_threshold', 0)
+            myjitdriver1.set_param('function_threshold', 0)
             while r > 0:
                 myjitdriver2.can_enter_jit(g=g, r=r)
                 myjitdriver2.jit_merge_point(g=g, r=r)

pypy/jit/metainterp/test/test_loop.py

 import py
-from pypy.rlib.jit import JitDriver, hint, set_param
+from pypy.rlib.jit import JitDriver, hint
 from pypy.rlib.objectmodel import compute_hash
 from pypy.jit.metainterp.warmspot import ll_meta_interp, get_stats
 from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
         myjitdriver = JitDriver(greens = ['pos'], reds = ['i', 'j', 'n', 'x'])
         bytecode = "IzJxji"
         def f(n, threshold):
-            set_param(myjitdriver, 'threshold', threshold)        
+            myjitdriver.set_param('threshold', threshold)        
             i = j = x = 0
             pos = 0
             op = '-'
         myjitdriver = JitDriver(greens = ['pos'], reds = ['i', 'j', 'n', 'x'])
         bytecode = "IzJxji"
         def f(nval, threshold):
-            set_param(myjitdriver, 'threshold', threshold)        
+            myjitdriver.set_param('threshold', threshold)        
             i, j, x = A(0), A(0), A(0)
             n = A(nval)
             pos = 0

pypy/jit/metainterp/test/test_recursive.py

 import py
-from pypy.rlib.jit import JitDriver, hint, set_param
+from pypy.rlib.jit import JitDriver, we_are_jitted, hint
 from pypy.rlib.jit import unroll_safe, dont_look_inside, promote
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.debug import fatalerror
                 pc += 1
             return n
         def main(n):
-            set_param(None, 'threshold', 3)
-            set_param(None, 'trace_eagerness', 5)            
+            myjitdriver.set_param('threshold', 3)
+            myjitdriver.set_param('trace_eagerness', 5)            
             return f("c-l", n)
         expected = main(100)
         res = self.meta_interp(main, [100], enable_opts='', inline=True)
                 return recursive(n - 1) + 1
             return 0
         def loop(n):            
-            set_param(myjitdriver, "threshold", 10)
+            myjitdriver.set_param("threshold", 10)
             pc = 0
             while n:
                 myjitdriver.can_enter_jit(n=n)
             return 0
         myjitdriver = JitDriver(greens=[], reds=['n'])
         def loop(n):
-            set_param(None, "threshold", 4)
-            set_param(None, "trace_eagerness", 2)
+            myjitdriver.set_param("threshold", 4)
+            myjitdriver.set_param("trace_eagerness", 2)
             while n:
                 myjitdriver.can_enter_jit(n=n)
                 myjitdriver.jit_merge_point(n=n)
         TRACE_LIMIT = 66
  
         def main(inline):
-            set_param(None, "threshold", 10)
-            set_param(None, 'function_threshold', 60)
+            myjitdriver.set_param("threshold", 10)
+            myjitdriver.set_param('function_threshold', 60)
             if inline:
-                set_param(None, 'inlining', True)
+                myjitdriver.set_param('inlining', True)
             else:
-                set_param(None, 'inlining', False)
+                myjitdriver.set_param('inlining', False)
             return loop(100)
 
         res = self.meta_interp(main, [0], enable_opts='', trace_limit=TRACE_LIMIT)
                 pc += 1
             return n
         def g(m):
-            set_param(None, 'inlining', True)
+            myjitdriver.set_param('inlining', True)
             # carefully chosen threshold to make sure that the inner function
             # cannot be inlined, but the inner function on its own is small
             # enough
-            set_param(None, 'trace_limit', 40)
+            myjitdriver.set_param('trace_limit', 40)
             if m > 1000000:
                 f('', 0)
             result = 0
                     driver.can_enter_jit(c=c, i=i, v=v)
                 break
 
-        def main(c, i, _set_param, v):
-            if _set_param:
-                set_param(driver, 'function_threshold', 0)
+        def main(c, i, set_param, v):
+            if set_param:
+                driver.set_param('function_threshold', 0)
             portal(c, i, v)
 
         self.meta_interp(main, [10, 10, False, False], inline=True)

pypy/jit/metainterp/test/test_warmspot.py

 import py
+from pypy.jit.metainterp.warmspot import ll_meta_interp
 from pypy.jit.metainterp.warmspot import get_stats
-from pypy.rlib.jit import JitDriver, set_param, unroll_safe
+from pypy.rlib.jit import JitDriver
+from pypy.rlib.jit import unroll_safe
 from pypy.jit.backend.llgraph import runner
+from pypy.jit.metainterp.history import BoxInt
 
 from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.jit.metainterp.optimizeopt import ALL_OPTS_NAMES
                 n = A().m(n)
             return n
         def f(n, enable_opts):
-            set_param(None, 'enable_opts', hlstr(enable_opts))
+            myjitdriver.set_param('enable_opts', hlstr(enable_opts))
             return g(n)
 
         # check that the set_param will override the default

pypy/jit/metainterp/test/test_ztranslation.py

 import py
 from pypy.jit.metainterp.warmspot import rpython_ll_meta_interp, ll_meta_interp
 from pypy.jit.backend.llgraph import runner
-from pypy.rlib.jit import JitDriver, unroll_parameters, set_param
+from pypy.rlib.jit import JitDriver, unroll_parameters
 from pypy.rlib.jit import PARAMETERS, dont_look_inside, hint
 from pypy.jit.metainterp.jitprof import Profiler
 from pypy.rpython.lltypesystem import lltype, llmemory
                               get_printable_location=get_printable_location)
         def f(i):
             for param, defl in unroll_parameters:
-                set_param(jitdriver, param, defl)
-            set_param(jitdriver, "threshold", 3)
-            set_param(jitdriver, "trace_eagerness", 2)
+                jitdriver.set_param(param, defl)
+            jitdriver.set_param("threshold", 3)
+            jitdriver.set_param("trace_eagerness", 2)
             total = 0
             frame = Frame(i)
             while frame.l[0] > 3:
                 raise ValueError
             return 2
         def main(i):
-            set_param(jitdriver, "threshold", 3)
-            set_param(jitdriver, "trace_eagerness", 2)
+            jitdriver.set_param("threshold", 3)
+            jitdriver.set_param("trace_eagerness", 2)
             total = 0
             n = i
             while n > 3:

pypy/jit/metainterp/warmspot.py

                 op = block.operations[i]
                 if (op.opname == 'jit_marker' and
                     op.args[0].value == marker_name and
-                    (op.args[1].value is None or
-                    op.args[1].value.active)):   # the jitdriver
+                    op.args[1].value.active):   # the jitdriver
                     results.append((graph, block, i))
     return results
 
         _, PTR_SET_PARAM_STR_FUNCTYPE = self.cpu.ts.get_FuncType(
             [lltype.Ptr(STR)], lltype.Void)
         def make_closure(jd, fullfuncname, is_string):
-            if jd is None:
-                def closure(i):
-                    if is_string:
-                        i = hlstr(i)
-                    for jd in self.jitdrivers_sd:
-                        getattr(jd.warmstate, fullfuncname)(i)
-            else:
-                state = jd.warmstate
-                def closure(i):
-                    if is_string:
-                        i = hlstr(i)
-                    getattr(state, fullfuncname)(i)
+            state = jd.warmstate
+            def closure(i):
+                if is_string:
+                    i = hlstr(i)
+                getattr(state, fullfuncname)(i)
             if is_string:
                 TP = PTR_SET_PARAM_STR_FUNCTYPE
             else:
             return Constant(funcptr, TP)
         #
         for graph, block, i in find_set_param(graphs):
-            
             op = block.operations[i]
-            if op.args[1].value is not None:
-                for jd in self.jitdrivers_sd:
-                    if jd.jitdriver is op.args[1].value:
-                        break
-                else:
-                    assert 0, "jitdriver of set_param() not found"
+            for jd in self.jitdrivers_sd:
+                if jd.jitdriver is op.args[1].value:
+                    break
             else:
-                jd = None
+                assert 0, "jitdriver of set_param() not found"
             funcname = op.args[2].value
             key = jd, funcname
             if key not in closures:

pypy/module/cpyext/include/modsupport.h

 /*
  * This is from pyport.h.  Perhaps it belongs elsewhere.
  */
-#ifdef __cplusplus
-#define PyMODINIT_FUNC extern "C" void
-#else
 #define PyMODINIT_FUNC void
-#endif
 
 
 #ifdef __cplusplus

pypy/module/cpyext/presetup.py

 patch_distutils()
 
 del sys.argv[0]
-execfile(sys.argv[0], {'__file__': sys.argv[0], '__name__': '__main__'})
+execfile(sys.argv[0], {'__file__': sys.argv[0]})

pypy/module/cpyext/slotdefs.py

     unaryfunc, wrapperfunc, ternaryfunc, PyTypeObjectPtr, binaryfunc,
     getattrfunc, getattrofunc, setattrofunc, lenfunc, ssizeargfunc,
     ssizessizeargfunc, ssizeobjargproc, iternextfunc, initproc, richcmpfunc,
-    cmpfunc, hashfunc, descrgetfunc, descrsetfunc, objobjproc, objobjargproc,
-    readbufferproc)
+    cmpfunc, hashfunc, descrgetfunc, descrsetfunc, objobjproc, readbufferproc)
 from pypy.module.cpyext.pyobject import from_ref
 from pypy.module.cpyext.pyerrors import PyErr_Occurred
 from pypy.module.cpyext.state import State
         space.fromcache(State).check_and_raise_exception(always=True)
     return space.wrap(res)
 
-def wrap_objobjargproc(space, w_self, w_args, func):
-    func_target = rffi.cast(objobjargproc, func)
-    check_num_args(space, w_args, 2)
-    w_key, w_value = space.fixedview(w_args)
-    res = generic_cpy_call(space, func_target, w_self, w_key, w_value)
-    if rffi.cast(lltype.Signed, res) == -1:
-        space.fromcache(State).check_and_raise_exception(always=True)
-    return space.wrap(res)
-
 def wrap_ssizessizeargfunc(space, w_self, w_args, func):
     func_target = rffi.cast(ssizessizeargfunc, func)
     check_num_args(space, w_args, 2)

pypy/module/cpyext/test/test_typeobject.py

             def __str__(self):
                 return "text"
         assert module.tp_str(C()) == "text"
-
-    def test_mp_ass_subscript(self):
-        module = self.import_extension('foo', [
-           ("new_obj", "METH_NOARGS",
-            '''
-                PyObject *obj;
-                Foo_Type.tp_as_mapping = &tp_as_mapping;
-                tp_as_mapping.mp_ass_subscript = mp_ass_subscript;
-                if (PyType_Ready(&Foo_Type) < 0) return NULL;
-                obj = PyObject_New(PyObject, &Foo_Type);
-                return obj;
-            '''
-            )],
-            '''
-            static int
-            mp_ass_subscript(PyObject *self, PyObject *key, PyObject *value)
-            {
-                PyErr_SetNone(PyExc_ZeroDivisionError);
-                return -1;
-            }
-            PyMappingMethods tp_as_mapping;
-            static PyTypeObject Foo_Type = {
-                PyVarObject_HEAD_INIT(NULL, 0)
-                "foo.foo",
-            };
-            ''')
-        obj = module.new_obj()
-        raises(ZeroDivisionError, obj.__setitem__, 5, None)

pypy/module/micronumpy/__init__.py

 
 
 class Module(MixedModule):
-    applevel_name = 'numpypy'
+    applevel_name = 'numpy'
 
     interpleveldefs = {
         'array': 'interp_numarray.SingleDimArray',

pypy/module/micronumpy/app_numpy.py

 import math
 
-import numpypy
+import numpy
 
 
 inf = float("inf")
 
 def mean(a):
     if not hasattr(a, "mean"):
-        a = numpypy.array(a)
+        a = numpy.array(a)
     return a.mean()

pypy/module/micronumpy/bench/add.py

 
-try:
-    import numpypy as numpy
-except:
-    import numpy
+import numpy
 
 def f():
     a = numpy.zeros(10000000)

pypy/module/micronumpy/bench/iterate.py

 
-try:
-    import numpypy as numpy
-except:
-    import numpy
+import numpy
 
 def f():
     sum = 0

pypy/module/micronumpy/test/test_dtypes.py

 
 class AppTestDtypes(BaseNumpyAppTest):
     def test_dtype(self):
-        from numpypy import dtype
+        from numpy import dtype
 
         d = dtype('?')
         assert d.num == 0
         raises(TypeError, dtype, 1042)
 
     def test_dtype_with_types(self):
-        from numpypy import dtype
+        from numpy import dtype
 
         assert dtype(bool).num == 0
         assert dtype(int).num == 7
         assert dtype(float).num == 12
 
     def test_array_dtype_attr(self):
-        from numpypy import array, dtype
+        from numpy import array, dtype
 
         a = array(range(5), long)
         assert a.dtype is dtype(long)
 
     def test_repr_str(self):
-        from numpypy import dtype
+        from numpy import dtype
 
         assert repr(dtype) == "<type 'numpy.dtype'>"
         d = dtype('?')
         assert str(d) == "bool"
 
     def test_bool_array(self):
-        from numpypy import array, False_, True_
+        import numpy
 
-        a = array([0, 1, 2, 2.5], dtype='?')
-        assert a[0] is False_
+        a = numpy.array([0, 1, 2, 2.5], dtype='?')
+        assert a[0] is numpy.False_
         for i in xrange(1, 4):
-            assert a[i] is True_
+            assert a[i] is numpy.True_
 
     def test_copy_array_with_dtype(self):
-        from numpypy import array, False_, True_
+        import numpy
 
-        a = array([0, 1, 2, 3], dtype=long)
+        a = numpy.array([0, 1, 2, 3], dtype=long)
         # int on 64-bit, long in 32-bit
         assert isinstance(a[0], (int, long))
         b = a.copy()
         assert isinstance(b[0], (int, long))
 
-        a = array([0, 1, 2, 3], dtype=bool)
-        assert a[0] is False_
+        a = numpy.array([0, 1, 2, 3], dtype=bool)
+        assert a[0] is numpy.False_
         b = a.copy()
-        assert b[0] is False_
+        assert b[0] is numpy.False_
 
     def test_zeros_bool(self):
-        from numpypy import zeros, False_
+        import numpy
 
-        a = zeros(10, dtype=bool)
+        a = numpy.zeros(10, dtype=bool)
         for i in range(10):
-            assert a[i] is False_
+            assert a[i] is numpy.False_
 
     def test_ones_bool(self):
-        from numpypy import ones, True_
+        import numpy
 
-        a = ones(10, dtype=bool)
+        a = numpy.ones(10, dtype=bool)
         for i in range(10):
-            assert a[i] is True_
+            assert a[i] is numpy.True_
 
     def test_zeros_long(self):
-        from numpypy import zeros
+        from numpy import zeros
         a = zeros(10, dtype=long)
         for i in range(10):
             assert isinstance(a[i], (int, long))
             assert a[1] == 0
 
     def test_ones_long(self):
-        from numpypy import ones
+        from numpy import ones
         a = ones(10, dtype=long)
         for i in range(10):
             assert isinstance(a[i], (int, long))
             assert a[1] == 1
 
     def test_overflow(self):
-        from numpypy import array, dtype
+        from numpy import array, dtype
         assert array([128], 'b')[0] == -128
         assert array([256], 'B')[0] == 0
         assert array([32768], 'h')[0] == -32768
         raises(OverflowError, "array([2**64], 'Q')")
 
     def test_bool_binop_types(self):
-        from numpypy import array, dtype
+        from numpy import array, dtype
         types = [
             '?', 'b', 'B', 'h', 'H', 'i', 'I', 'l', 'L', 'q', 'Q', 'f', 'd'
         ]
             assert (a + array([0], t)).dtype is dtype(t)
 
     def test_binop_types(self):
-        from numpypy import array, dtype
+        from numpy import array, dtype
         tests = [('b','B','h'), ('b','h','h'), ('b','H','i'), ('b','i','i'),
                  ('b','l','l'), ('b','q','q'), ('b','Q','d'), ('B','h','h'),
                  ('B','H','H'), ('B','i','i'), ('B','I','I'), ('B','l','l'),
             assert (array([1], d1) + array([1], d2)).dtype is dtype(dout)
 
     def test_add_int8(self):
-        from numpypy import array, dtype
+        from numpy import array, dtype
 
         a = array(range(5), dtype="int8")
         b = a + a
             assert b[i] == i * 2
 
     def test_add_int16(self):
-        from numpypy import array, dtype
+        from numpy import array, dtype
 
         a = array(range(5), dtype="int16")
         b = a + a
             assert b[i] == i * 2
 
     def test_add_uint32(self):
-        from numpypy import array, dtype
+        from numpy import array, dtype
 
         a = array(range(5), dtype="I")
         b = a + a
             assert b[i] == i * 2
 
     def test_shape(self):
-        from numpypy import dtype
+        from numpy import dtype
 
         assert dtype(long).shape == ()
 
     def test_cant_subclass(self):
-        from numpypy import dtype
+        from numpy import dtype
 
         # You can't subclass dtype
         raises(TypeError, type, "Foo", (dtype,), {})

pypy/module/micronumpy/test/test_module.py

 
 class AppTestNumPyModule(BaseNumpyAppTest):
     def test_mean(self):
-        from numpypy import array, mean
+        from numpy import array, mean
         assert mean(array(range(5))) == 2.0
         assert mean(range(5)) == 2.0
 
     def test_average(self):
-        from numpypy import array, average
+        from numpy import array, average
         assert average(range(10)) == 4.5
         assert average(array(range(10))) == 4.5
 
     def test_constants(self):
         import math
-        from numpypy import inf, e
+        from numpy import inf, e
         assert type(inf) is float
         assert inf == float("inf")
         assert e == math.e
-        assert type(e) is float
+        assert type(e) is float

pypy/module/micronumpy/test/test_numarray.py

 
 class AppTestNumArray(BaseNumpyAppTest):
     def test_type(self):
-        from numpypy import array
+        from numpy import array
         ar = array(range(5))
         assert type(ar) is type(ar + ar)
 
     def test_init(self):
-        from numpypy import zeros
+        from numpy import zeros
         a = zeros(15)
         # Check that storage was actually zero'd.
         assert a[10] == 0.0
         assert a[13] == 5.3
 
     def test_size(self):
-        from numpypy import array
+        from numpy import array
         # XXX fixed on multidim branch
         #assert array(3).size == 1
         a = array([1, 2, 3])
         Test that empty() works.
         """
 
-        from numpypy import empty
+        from numpy import empty
         a = empty(2)
         a[1] = 1.0
         assert a[1] == 1.0
 
     def test_ones(self):
-        from numpypy import ones
+        from numpy import ones
         a = ones(3)
         assert len(a) == 3
         assert a[0] == 1
         assert a[2] == 4
 
     def test_copy(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         b = a.copy()
         for i in xrange(5):
             assert b[i] == a[i]
 
     def test_iterator_init(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         assert a[3] == 3
 
     def test_repr(self):
-        from numpypy import array, zeros
+        from numpy import array, zeros
         a = array(range(5), float)
         assert repr(a) == "array([0.0, 1.0, 2.0, 3.0, 4.0])"
         a = array([], float)
         assert repr(a) == "array([True, False, True, False], dtype=bool)"
 
     def test_repr_slice(self):
-        from numpypy import array, zeros
+        from numpy import array, zeros
         a = array(range(5), float)
         b = a[1::2]
         assert repr(b) == "array([1.0, 3.0])"
         assert repr(b) == "array([0.0, 0.0, 0.0, ..., 0.0, 0.0, 0.0])"
 
     def test_str(self):
-        from numpypy import array, zeros
+        from numpy import array, zeros
         a = array(range(5), float)
         assert str(a) == "[0.0 1.0 2.0 3.0 4.0]"
         assert str((2*a)[:]) == "[0.0 2.0 4.0 6.0 8.0]"
         assert str(a) == "[0 1 2 3 4]"
 
     def test_str_slice(self):
-        from numpypy import array, zeros
+        from numpy import array, zeros
         a = array(range(5), float)
         b = a[1::2]
         assert str(b) == "[1.0 3.0]"
         assert str(b) == "[0.0 0.0 0.0 ..., 0.0 0.0 0.0]"
 
     def test_getitem(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         raises(IndexError, "a[5]")
         a = a + a
         raises(IndexError, "a[-6]")
 
     def test_getitem_tuple(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         raises(IndexError, "a[(1,2)]")
         for i in xrange(5):
             assert a[i] == b[i]
 
     def test_setitem(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         a[-1] = 5.0
         assert a[4] == 5.0
         raises(IndexError, "a[-6] = 3.0")
 
     def test_setitem_tuple(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         raises(IndexError, "a[(1,2)] = [0,1]")
         for i in xrange(5):
             assert a[i] == i
 
     def test_setslice_array(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         b = array(range(2))
         a[1:4:2] = b
         assert b[1] == 0.
 
     def test_setslice_of_slice_array(self):
-        from numpypy import array, zeros
+        from numpy import array, zeros
         a = zeros(5)
         a[::2] = array([9., 10., 11.])
         assert a[0] == 9.
         assert a[0] == 3.
 
     def test_setslice_list(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5), float)
         b = [0., 1.]
         a[1:4:2] = b
         assert a[3] == 1.
 
     def test_setslice_constant(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5), float)
         a[1:4:2] = 0.
         assert a[1] == 0.
         assert a[3] == 0.
 
     def test_len(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         assert len(a) == 5
         assert len(a + a) == 5
 
     def test_shape(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         assert a.shape == (5,)
         b = a + a
         assert c.shape == (3,)
 
     def test_add(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         b = a + a
         for i in range(5):
             assert c[i] == bool(a[i] + b[i])
 
     def test_add_other(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         b = array(range(4, -1, -1))
         c = a + b
             assert c[i] == 4
 
     def test_add_constant(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         b = a + 5
         for i in range(5):
             assert b[i] == i + 5
 
     def test_radd(self):
-        from numpypy import array
+        from numpy import array
         r = 3 + array(range(3))
         for i in range(3):
             assert r[i] == i + 3
 
     def test_add_list(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         b = list(reversed(range(5)))
         c = a + b
             assert c[i] == 4
 
     def test_subtract(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         b = a - a
         for i in range(5):
             assert b[i] == 0
 
     def test_subtract_other(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         b = array([1, 1, 1, 1, 1])
         c = a - b
             assert c[i] == i - 1
 
     def test_subtract_constant(self):
-        from numpypy import array
+        from numpy import array
         a = array(range(5))
         b = a - 5
         for i in range(5):
             assert b[i] == i - 5
 
     def test_mul(self):
-        import numpypy
+        import numpy
 
-        a = numpypy.array(range(5))