Commits

Christian Rafael  committed 9b75e71 Draft Merge

Mesclado pypy/pypy em default

  • Participants
  • Parent commits bbc8261, a46161c

Comments (0)

Files changed (13)

File lib-python/2.7/distutils/command/install.py

 
     def select_scheme (self, name):
         # it's the caller's problem if they supply a bad name!
-        if hasattr(sys, 'pypy_version_info') and not (
-                name.endswith('_user') or name.endswith('_home')):
+        if (hasattr(sys, 'pypy_version_info') and
+            not name.endswith(('_user', '_home'))):
             name = 'pypy'
         scheme = INSTALL_SCHEMES[name]
         for key in SCHEME_KEYS:

File pypy/interpreter/app_main.py

 #! /usr/bin/env python
 # App-level version of py.py.
 # See test/test_app_main.
+
+# Missing vs CPython: -d, -OO, -t, -v, -x, -3
+"""\
+Options and arguments (and corresponding environment variables):
+-B     : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
+-c cmd : program passed in as string (terminates option list)
+-E     : ignore PYTHON* environment variables (such as PYTHONPATH)
+-h     : print this help message and exit (also --help)
+-i     : inspect interactively after running script; forces a prompt even
+         if stdin does not appear to be a terminal; also PYTHONINSPECT=x
+-m mod : run library module as a script (terminates option list)
+-O     : dummy optimization flag for compatibility with CPython
+-R     : ignored (see http://bugs.python.org/issue14621)
+-Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew
+-s     : don't add user site directory to sys.path; also PYTHONNOUSERSITE
+-S     : don't imply 'import site' on initialization
+-u     : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x
+-V     : print the Python version number and exit (also --version)
+-W arg : warning control; arg is action:message:category:module:lineno
+         also PYTHONWARNINGS=arg
+file   : program read from script file
+-      : program read from stdin (default; interactive mode if a tty)
+arg ...: arguments passed to program in sys.argv[1:]
+PyPy options and arguments:
+--info : print translation information about this PyPy executable
 """
-options:
-  -i             inspect interactively after running script
-  -O             dummy optimization flag for compatibility with C Python
-  -c cmd         program passed in as CMD (terminates option list)
-  -S             do not 'import site' on initialization
-  -u             unbuffered binary stdout and stderr
-  -h, --help     show this help message and exit
-  -m mod         library module to be run as a script (terminates option list)
-  -W arg         warning control (arg is action:message:category:module:lineno)
-  -E             ignore environment variables (such as PYTHONPATH)
-  -R             ignored (see http://bugs.python.org/issue14621)
-  --version      print the PyPy version
-  --info         print translation information about this PyPy executable
+USAGE1 = __doc__
+# Missing vs CPython: PYTHONHOME, PYTHONCASEOK
+USAGE2 = """
+Other environment variables:
+PYTHONSTARTUP: file executed on interactive startup (no default)
+PYTHONPATH   : %r-separated list of directories prefixed to the
+               default module search path.  The result is sys.path.
+PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.
 """
 
 import sys
     raise SystemExit
 
 def print_help(*args):
-    print 'usage: %s [options] [-c cmd|-m mod|file.py|-] [arg...]' % (
+    import os
+    print 'usage: %s [option] ... [-c cmd | -m mod | file | -] [arg] ...' % (
         sys.executable,)
-    print __doc__.rstrip()
+    print USAGE1,
     if 'pypyjit' in sys.builtin_module_names:
-        print "  --jit OPTIONS  advanced JIT options: try 'off' or 'help'"
-    print
+        print "--jit options: advanced JIT options: try 'off' or 'help'"
+    print (USAGE2 % (os.pathsep,)),
     raise SystemExit
 
 def _print_jit_help():

File pypy/interpreter/test2/test_app_main.py

         # test that -h prints the usage, including the name of the executable
         # which should be /full/path/to/app_main.py in this case
         child = self.spawn(['-h'])
-        child.expect(r'usage: .*app_main.py \[options\]')
+        child.expect(r'usage: .*app_main.py \[option\]')
+        child.expect('PyPy options and arguments:')
 
     def test_run_script(self):
         child = self.spawn([demo_script])

File pypy/module/__builtin__/app_functional.py

 Return a list of tuples, where each tuple contains the i-th element
 from each of the argument sequences.  The returned list is truncated
 in length to the length of the shortest argument sequence."""
-    if not sequences:
+    l = len(sequences)
+    if l == 2:
+        # This is functionally the same as the code below, but more
+        # efficient because it unrolls the loops over 'sequences'.
+        # Only for two arguments, which is the most common case.
+        seq0 = sequences[0]
+        seq1 = sequences[1]
+        iter0 = iter(seq0)
+        iter1 = iter(seq1)
+        hint = min(100000000,   # max 100M
+                   operator._length_hint(seq0, 0),
+                   operator._length_hint(seq1, 0))
+
+        with _ManagedNewlistHint(hint) as result:
+            while True:
+                try:
+                    item0 = next(iter0)
+                    item1 = next(iter1)
+                except StopIteration:
+                    return result
+                result.append((item0, item1))
+
+    if l == 0:
         return []
 
     # Gather the iterators and guess the result length (the min of the

File pypy/module/__builtin__/test/test_zip.py

     def test_one_list(self):
         assert zip([1, 2, 3]) == [(1,), (2,), (3,)]
 
+    def test_two_lists(self):
+        # uses a different code path
+        assert zip([1, 2, 3], [3, 4, 5]) == [(1, 3), (2, 4), (3, 5)]
+        assert zip([1, 2, 3], [3, 4]) == [(1, 3), (2, 4)]
+        assert zip([1, 2], [3, 4, 5]) == [(1, 3), (2, 4)]
+
     def test_three_lists_same_size(self):
         assert zip([1, 2, 3], [3, 4, 5], [6, 7, 8]) == (
                           [(1, 3, 6), (2, 4, 7), (3, 5, 8)])

File pypy/objspace/std/bytearrayobject.py

+"""The builtin bytearray implementation"""
+
+from pypy.interpreter.buffer import RWBuffer
 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.objspace.std.model import registerimplementation, W_Object
-from pypy.objspace.std.register_all import register_all
+from pypy.interpreter.signature import Signature
+from pypy.objspace.std import stringobject
+from pypy.objspace.std.bytearraytype import (
+    getbytevalue, makebytearraydata_w, new_bytearray)
+from pypy.objspace.std.intobject import W_IntObject
 from pypy.objspace.std.inttype import wrapint
+from pypy.objspace.std.listobject import get_list_index, get_positive_index
+from pypy.objspace.std.model import W_Object, registerimplementation
 from pypy.objspace.std.multimethod import FailedToImplement
 from pypy.objspace.std.noneobject import W_NoneObject
-from rpython.rlib.rarithmetic import intmask
-from rpython.rlib.rstring import StringBuilder
-from rpython.rlib.debug import check_annotation
-from pypy.objspace.std import stringobject
-from pypy.objspace.std.intobject import W_IntObject
-from pypy.objspace.std.listobject import get_positive_index, get_list_index
+from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
 from pypy.objspace.std.stringobject import W_StringObject
-from pypy.objspace.std.strutil import ParseStringError
-from pypy.objspace.std.strutil import string_to_float
 from pypy.objspace.std.tupleobject import W_TupleObject
 from pypy.objspace.std.unicodeobject import W_UnicodeObject
-from pypy.objspace.std import slicetype
-from pypy.interpreter import gateway
-from pypy.interpreter.buffer import RWBuffer
-from pypy.interpreter.signature import Signature
-from pypy.objspace.std.bytearraytype import (
-    makebytearraydata_w, getbytevalue,
-    new_bytearray
-)
-from rpython.tool.sourcetools import func_with_new_name
+from rpython.rlib.rstring import StringBuilder
 
 
 class W_BytearrayObject(W_Object):

File pypy/objspace/std/stringobject.py

-from pypy.objspace.std.model import registerimplementation, W_Object
+"""The builtin str implementation"""
+
+from pypy.interpreter.buffer import StringBuffer
+from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.objspace.std import newformat, slicetype
+from pypy.objspace.std.formatting import mod_format
+from pypy.objspace.std.inttype import wrapint
+from pypy.objspace.std.model import W_Object, registerimplementation
+from pypy.objspace.std.multimethod import FailedToImplement
+from pypy.objspace.std.noneobject import W_NoneObject
 from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.multimethod import FailedToImplement
-from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter import gateway
+from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
+from pypy.objspace.std.stringtype import (
+    joined2, sliced, stringendswith, stringstartswith, wrapchar, wrapstr)
+from pypy.objspace.std.tupleobject import W_TupleObject
+from rpython.rlib import jit
+from rpython.rlib.objectmodel import (
+    compute_hash, compute_unique_id, specialize)
 from rpython.rlib.rarithmetic import ovfcheck
-from rpython.rlib.objectmodel import we_are_translated, compute_hash, specialize
-from rpython.rlib.objectmodel import compute_unique_id
-from pypy.objspace.std.inttype import wrapint
-from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
-from pypy.objspace.std import slicetype, newformat
-from pypy.objspace.std.listobject import W_ListObject
-from pypy.objspace.std.noneobject import W_NoneObject
-from pypy.objspace.std.tupleobject import W_TupleObject
 from rpython.rlib.rstring import StringBuilder, split
-from pypy.interpreter.buffer import StringBuffer
-from rpython.rlib import jit
 
-from pypy.objspace.std.stringtype import sliced, wrapstr, wrapchar, \
-     stringendswith, stringstartswith, joined2
-
-from pypy.objspace.std.formatting import mod_format
 
 class W_AbstractStringObject(W_Object):
     __slots__ = ()

File pypy/objspace/std/unicodeobject.py

-from pypy.objspace.std.model import registerimplementation, W_Object
-from pypy.objspace.std.register_all import register_all
+"""The builtin unicode implementation"""
+
+from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.module.unicodedata import unicodedb
+from pypy.objspace.std import newformat, slicetype
+from pypy.objspace.std.formatting import mod_format
+from pypy.objspace.std.model import W_Object, registerimplementation
 from pypy.objspace.std.multimethod import FailedToImplement
-from pypy.interpreter import gateway
-from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.objspace.std.stringobject import W_StringObject, make_rsplit_with_delim
 from pypy.objspace.std.noneobject import W_NoneObject
 from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
-from pypy.objspace.std import slicetype, newformat
+from pypy.objspace.std.stringobject import (
+    W_StringObject, make_rsplit_with_delim)
+from pypy.objspace.std.stringtype import stringendswith, stringstartswith
+from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.tupleobject import W_TupleObject
-from rpython.rlib.rarithmetic import intmask, ovfcheck
-from rpython.rlib.objectmodel import compute_hash, specialize
-from rpython.rlib.objectmodel import compute_unique_id
+from rpython.rlib import jit
+from rpython.rlib.rarithmetic import ovfcheck
+from rpython.rlib.objectmodel import (
+    compute_hash, compute_unique_id, specialize)
 from rpython.rlib.rstring import UnicodeBuilder
 from rpython.rlib.runicode import make_unicode_escape_function
-from pypy.module.unicodedata import unicodedb
 from rpython.tool.sourcetools import func_with_new_name
-from rpython.rlib import jit
 
-from pypy.objspace.std.formatting import mod_format
-from pypy.objspace.std.stringtype import stringstartswith, stringendswith
 
 class W_AbstractUnicodeObject(W_Object):
     __slots__ = ()

File rpython/jit/backend/arm/assembler.py

File contents unchanged.

File rpython/jit/backend/arm/codebuilder.py

             instr = self._encode_reg_list(cond << 28 | 0x92D << 16, regs)
         self.write32(instr)
 
+    def STM(self, base, regs, write_back=False, cond=cond.AL):
+        assert len(regs) > 0
+        instr = (cond << 28
+                | 0x11 << 23
+                | (1 if write_back else 0) << 21
+                | (base & 0xF) << 16)
+        instr = self._encode_reg_list(instr, regs)
+        self.write32(instr)
+
+    def LDM(self, base, regs, write_back=False, cond=cond.AL):
+        assert len(regs) > 0
+        instr = (cond << 28
+                | 0x11 << 23
+                | (1 if write_back else 0) << 21
+                | 1 << 20
+                | (base & 0xF) << 16)
+        instr = self._encode_reg_list(instr, regs)
+        self.write32(instr)
+
+    def VSTM(self, base, regs, write_back=False, cond=cond.AL):
+        # encoding T1
+        P = 0
+        U = 1
+        nregs = len(regs)
+        assert nregs > 0 and nregs <= 16
+        freg = regs[0]
+        D = (freg & 0x10) >> 4
+        Dd = (freg & 0xF)
+        nregs *= 2
+        instr = (cond << 28
+                | 3 << 26
+                | P << 24
+                | U << 23
+                | D << 22
+                | (1 if write_back else 0) << 21
+                | (base & 0xF) << 16
+                | Dd << 12
+                | 0xB << 8
+                | nregs)
+        self.write32(instr)
+
+    def VLDM(self, base, regs, write_back=False, cond=cond.AL):
+        # encoding T1
+        P = 0
+        U = 1
+        nregs = len(regs)
+        assert nregs > 0 and nregs <= 16
+        freg = regs[0]
+        D = (freg & 0x10) >> 4
+        Dd = (freg & 0xF)
+        nregs *= 2
+        instr = (cond << 28
+                | 3 << 26
+                | P << 24
+                | U << 23
+                | D << 22
+                | (1 if write_back else 0) << 21
+                | 1 << 20
+                | (base & 0xF) << 16
+                | Dd << 12
+                | 0xB << 8
+                | nregs)
+        self.write32(instr)
+
     def VPUSH(self, regs, cond=cond.AL):
         nregs = len(regs)
         assert nregs > 0 and nregs <= 16

File rpython/jit/backend/arm/test/test_assembler.py

 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.jit.metainterp.history import JitCellToken
 from rpython.jit.backend.model import CompiledLoopToken
+from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
+from rpython.rtyper.annlowlevel import llhelper
+from rpython.rlib.objectmodel import specialize
+from rpython.rlib.debug import ll_assert
 
 CPU = getcpuclass()
 
         self.a.mc.ADD_ri(r.sp.value, r.sp.value, 8)
         self.a.gen_func_epilog()
         assert run_asm(self.a) == x
+    
+    def test_stm(self):
+        container = lltype.malloc(lltype.Array(lltype.Signed, hints={'nolength': True}), 10, flavor='raw')
+        self.a.gen_func_prolog()
+        self.a.mc.gen_load_int(r.ip.value, rffi.cast(lltype.Signed, container))
+        for x in range(10):
+            self.a.mc.gen_load_int(x, x)
+        self.a.mc.STM(r.ip.value, [x for x in range(10)])
+        self.a.gen_func_epilog()
+        run_asm(self.a)
+        for x in range(10):
+            assert container[x] == x
+        lltype.free(container, flavor='raw')
 
+    def test_ldm(self):
+        container = lltype.malloc(lltype.Array(lltype.Signed, hints={'nolength': True}), 10, flavor='raw')
+        for x in range(10):
+            container[x] = x
+        self.a.gen_func_prolog()
+        self.a.mc.gen_load_int(r.ip.value, rffi.cast(lltype.Signed, container))
+        self.a.mc.LDM(r.ip.value, [x for x in range(10)])
+        for x in range(1, 10):
+            self.a.mc.ADD_ri(0, 0, x)
+        self.a.gen_func_epilog()
+        res = run_asm(self.a) 
+        assert res == sum(range(10))
+        lltype.free(container, flavor='raw')
 
 def callme(inp):
     i = inp + 10

File rpython/jit/backend/arm/test/test_instr_codebuilder.py

     def test_push_raises_sp(self):
         assert py.test.raises(AssertionError, 'self.cb.PUSH([r.sp.value])')
 
+    def test_stm(self):
+        self.cb.STM(r.fp.value, [reg.value for reg in r.caller_resp], cond=conditions.AL)
+        self.assert_equal('STM fp, {r0, r1, r2, r3}')
+
+    def test_ldm(self):
+        self.cb.LDM(r.fp.value, [reg.value for reg in r.caller_resp], cond=conditions.AL)
+        self.assert_equal('LDM fp, {r0, r1, r2, r3}')
+
+    def test_vstm(self):
+        self.cb.VSTM(r.fp.value, [reg.value for reg in r.caller_vfp_resp], cond=conditions.AL)
+        self.assert_equal('VSTM fp, {d0, d1, d2, d3, d4, d5, d6, d7}')
+
+    def test_vldm(self):
+        self.cb.VLDM(r.fp.value, [reg.value for reg in r.caller_vfp_resp], cond=conditions.AL)
+        self.assert_equal('VLDM fp, {d0, d1, d2, d3, d4, d5, d6, d7}')
+
     def test_pop(self):
         self.cb.POP([reg.value for reg in r.caller_resp], cond=conditions.AL)
         self.assert_equal('POP {r0, r1, r2, r3}')

File rpython/translator/platform/arm.py

 class ARM(Linux):
     name = "arm"
 
-    available_librarydirs = [SB2 + '/usr/lib/arm-linux-gnueabi/',
+    available_librarydirs = [SB2 + '/lib/arm-linux-gnueabi/',
+                             SB2 + '/lib/arm-linux-gnueabihf/',
+                             SB2 + '/usr/lib/arm-linux-gnueabi/',
                              SB2 + '/usr/lib/arm-linux-gnueabihf/']
+
     available_includedirs = [SB2 + '/usr/include/arm-linux-gnueabi/',
                              SB2 + '/usr/include/arm-linux-gnueabihf/']
     copied_cache = {}