Commits

mattip committed e22c2ae Merge

merge default into branch

Comments (0)

Files changed (14)

pypy/bin/translatorshell.py

-#!/usr/bin/env python 
-
-
-"""PyPy Translator Frontend
-
-Glue script putting together the various pieces of the translator.
-Can be used for interactive testing of the translator.
-
-Example:
-
-    t = Translation(func, [int])       # pass the list of args types
-    t.view()                           # control flow graph
-
-    t.annotate()
-    t.view()                           # graph + annotations under the mouse
-
-    t.rtype()                          # use low level operations 
-    f = t.compile_c()                  # C compilation
-    assert f(arg) == func(arg)         # sanity check (for C)
-    
-
-Some functions are provided for the benefit of interactive testing.
-Try dir(snippet) for list of current snippets.
-"""
-
-import os, sys
-
-from rpython.translator.interactive import Translation
-from rpython.rtyper.rtyper import *
-from rpython.rlib.rarithmetic import *
-
-import py
-
-def setup_readline():
-    import readline
-    try:
-        import rlcompleter2
-        rlcompleter2.setup()
-    except ImportError:
-        import rlcompleter
-        readline.parse_and_bind("tab: complete")
-    import os
-    histfile = os.path.join(os.environ["HOME"], ".pypytrhist")
-    try:
-        getattr(readline, "clear_history", lambda : None)()
-        readline.read_history_file(histfile)
-    except IOError:
-        pass
-    import atexit
-    atexit.register(readline.write_history_file, histfile)
-
-if __name__ == '__main__':
-    try:
-        setup_readline()
-    except ImportError, err:
-        print "Disabling readline support (%s)" % err
-    from rpython.translator.test import snippet
-    from rpython.rtyper.rtyper import RPythonTyper
-
-    if (os.getcwd() not in sys.path and
-        os.path.curdir not in sys.path):
-        sys.path.insert(0, os.getcwd())
-
-    print __doc__
-
-    import os
-    os.putenv("PYTHONINSPECT", "1")
-
-
   export SB2=/srv/chroot/precise_arm
   export SB2OPT='-t ARM'
 
-Once this is set, you can call the translator 
-
-::
-
-  pypy ~/path_to_pypy_checkout/pypy/translator/goal/translate.py -O1 --platform=arm target.py
-
-If everything worked correctly this should yield an ARM binary. Running this binary in the ARM chroot or on an ARM device should produce the output ``"Hello World"``.
-
-.. _`this`:
+Once this is set, you can call the translator. For example save this file 
 
 ::
 
 
   def target(*args):
       return main, None
+
+and call the translator
+
+::
+
+  pypy ~/path_to_pypy_checkout/pypy/translator/goal/translate.py -O1 --platform=arm target.py
+
+If everything worked correctly this should yield an ARM binary. Running this binary in the ARM chroot or on an ARM device should produce the output ``"Hello World"``.
+
+To translate the full python pypy interpreter with a jit, you can cd into pypy/goal and call      
+
+::
+
+  pypy <path to rpython>/rpython/translator/goal/translate.py -Ojit --platform=arm --gcrootfinder=shadowstack --jit-backend=arm targetpypystandalone.py
+
+The gcrootfinder option is needed to work around `issue 1377`_ and the jit-backend works around `issue 1376`_
+
+.. _`issue 1377`: https://bugs.pypy.org/issue1377
+.. _`issue 1376`: https://bugs.pypy.org/issue1376

pypy/interpreter/astcompiler/codegen.py

 
     def visit_Set(self, s):
         self.update_position(s.lineno)
+        elt_count = len(s.elts) if s.elts is not None else 0
         self.visit_sequence(s.elts)
-        self.emit_op_arg(ops.BUILD_SET, len(s.elts))
+        self.emit_op_arg(ops.BUILD_SET, elt_count)
 
     def visit_Name(self, name):
         self.update_position(name.lineno)

pypy/module/_ast/test/test_ast.py

         ])
         exec compile(body, '<string>', 'exec')
 
+    def test_empty_set(self):
+        import ast
+        m = ast.Module(body=[ast.Expr(value=ast.Set(elts=[]))])
+        ast.fix_missing_locations(m)
+        compile(m, "<test>", "exec")
+
     def test_invalid_sum(self):
         import _ast as ast
         pos = dict(lineno=2, col_offset=3)

pypy/module/cpyext/classobject.py

         w_result.setdict(space, w_dict)
     return w_result
 
+@cpython_api([PyObject, PyObject, PyObject], PyObject)
+def PyInstance_New(space, w_cls, w_arg, w_kw):
+    """Create a new instance of a specific class.  The parameters arg and kw are
+    used as the positional and keyword parameters to the object's constructor."""
+    return space.call(w_cls, w_arg, w_kw)
+
 @cpython_api([PyObject, PyObject], PyObject, error=CANNOT_FAIL)
 def _PyInstance_Lookup(space, w_instance, w_name):
     name = space.str_w(w_name)

pypy/module/cpyext/include/ceval.h

+/* empty */

pypy/module/cpyext/stubs.py

     """Return true if klass is a subclass of base. Return false in all other cases."""
     raise NotImplementedError
 
-@cpython_api([PyObject, PyObject, PyObject], PyObject)
-def PyInstance_New(space, cls, arg, kw):
-    """Create a new instance of a specific class.  The parameters arg and kw are
-    used as the positional and keyword parameters to the object's constructor."""
-    raise NotImplementedError
-
 @cpython_api([PyObject], rffi.INT_real, error=-1)
 def PyCodec_Register(space, search_function):
     """Register a new codec search function.

pypy/module/cpyext/test/conftest.py

 import py
 import pytest
 
+def pytest_configure(config):
+    from pypy.tool.pytest.objspace import gettestobjspace
+    # For some reason (probably a ll2ctypes cache issue on linux64)
+    # it's necessary to run "import time" at least once before any
+    # other cpyext test, otherwise the same statement will fail in
+    # test_datetime.py.
+    space = gettestobjspace(usemodules=['rctime'])
+    space.getbuiltinmodule("time")
+
 def pytest_ignore_collect(path, config):
     if config.option.runappdirect:
         return True # "cannot be run by py.test -A"

pypy/module/cpyext/test/test_classobject.py

         w_class = space.appexec([], """():
             class C:
                 x = None
-                def __init__(self):
+                def __init__(self, *args, **kwargs):
                     self.x = 1
+                    self.args = args
+                    self.__dict__.update(kwargs)
             return C
         """)
 
         assert space.getattr(w_instance, space.wrap('x')) is space.w_None
         assert space.unwrap(space.getattr(w_instance, space.wrap('a'))) == 3
 
+        w_instance = api.PyInstance_New(w_class,
+                                        space.wrap((3,)), space.wrap(dict(y=2)))
+        assert space.unwrap(space.getattr(w_instance, space.wrap('x'))) == 1
+        assert space.unwrap(space.getattr(w_instance, space.wrap('y'))) == 2
+        assert space.unwrap(space.getattr(w_instance, space.wrap('args'))) == (3,)
+        
+
     def test_lookup(self, space, api):
         w_instance = space.appexec([], """():
             class C:

pypy/pytest-A.cfg

 cherrypick = ['interpreter', 'objspace/test', 'objspace/std', 'module']
 
-interp = ['translator/goal/pypy-c']
+interp = ['goal/pypy-c']
 test_driver = ['test_all.py', '-A']
 
     if len(sys.argv) == 1 and os.path.dirname(sys.argv[0]) in '.':
         print >> sys.stderr, __doc__
         sys.exit(2)
-
+    #Add toplevel repository dir to sys.path
+    sys.path.insert(0,os.path.dirname(os.path.dirname(__file__)))
     import pytest
     import pytest_cov
     sys.exit(pytest.main(plugins=[pytest_cov]))

pypy/tool/release/package.py

 
 import shutil
 import sys
+import os
+#Add toplevel repository dir to sys.path
+sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
 import py
-import os
 import fnmatch
 from rpython.tool.udir import udir
 

rpython/bin/translatorshell.py

+#!/usr/bin/env python 
+
+
+"""PyPy Translator Frontend
+
+Glue script putting together the various pieces of the translator.
+Can be used for interactive testing of the translator.
+
+Example:
+
+    t = Translation(func, [int])       # pass the list of args types
+    t.view()                           # control flow graph
+
+    t.annotate()
+    t.view()                           # graph + annotations under the mouse
+
+    t.rtype()                          # use low level operations 
+    f = t.compile_c()                  # C compilation
+    assert f(arg) == func(arg)         # sanity check (for C)
+    
+
+Some functions are provided for the benefit of interactive testing.
+Try dir(snippet) for list of current snippets.
+"""
+
+import os, sys
+
+from rpython.translator.interactive import Translation
+from rpython.rtyper.rtyper import *
+from rpython.rlib.rarithmetic import *
+
+import py
+
+def setup_readline():
+    import readline
+    try:
+        import rlcompleter2
+        rlcompleter2.setup()
+    except ImportError:
+        import rlcompleter
+        readline.parse_and_bind("tab: complete")
+    import os
+    histfile = os.path.join(os.environ["HOME"], ".pypytrhist")
+    try:
+        getattr(readline, "clear_history", lambda : None)()
+        readline.read_history_file(histfile)
+    except IOError:
+        pass
+    import atexit
+    atexit.register(readline.write_history_file, histfile)
+
+if __name__ == '__main__':
+    try:
+        setup_readline()
+    except ImportError, err:
+        print "Disabling readline support (%s)" % err
+    from rpython.translator.test import snippet
+    from rpython.rtyper.rtyper import RPythonTyper
+
+    if (os.getcwd() not in sys.path and
+        os.path.curdir not in sys.path):
+        sys.path.insert(0, os.getcwd())
+
+    print __doc__
+
+    import os
+    os.putenv("PYTHONINSPECT", "1")
+
+

rpython/jit/backend/arm/test/support.py

     def check_jumps(self, maxcount):
         pass
 
+if not getattr(os, 'uname', None):
+    pytest.skip('cannot run arm tests on non-posix platform')
+
 if os.uname()[1] == 'llaima.local':
     AS = '~/Code/arm-jit/android/android-ndk-r4b//build/prebuilt/darwin-x86/arm-eabi-4.4.0/arm-eabi/bin/as'
 else:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.