[pypy-svn] pypy arm-backend-2: merge default

bivab commits-noreply at bitbucket.org
Wed Dec 22 14:27:09 CET 2010


Author: David Schneider <david.schneider at picle.org>
Branch: arm-backend-2
Changeset: r40183:cb5c50f82541
Date: 2010-12-20 13:34 +0100
http://bitbucket.org/pypy/pypy/changeset/cb5c50f82541/

Log:	merge default

diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -167,6 +167,9 @@
     if not we_are_translated():
         metainterp_sd.stats.compiled()
     metainterp_sd.log("compiled new bridge")
+    if metainterp_sd.warmrunnerdesc is not None:    # for tests
+        metainterp_sd.warmrunnerdesc.memory_manager.keep_loop_alive(
+            original_loop_token)
 
 # ____________________________________________________________
 

diff --git a/pypy/jit/backend/x86/test/test_ztranslation.py b/pypy/jit/backend/x86/test/test_ztranslation.py
--- a/pypy/jit/backend/x86/test/test_ztranslation.py
+++ b/pypy/jit/backend/x86/test/test_ztranslation.py
@@ -189,14 +189,14 @@
 
         @dont_look_inside
         def f(x, total):
-            if x <= 3:
+            if x <= 30:
                 raise ImDone(total * 10)
-            if x > 20:
+            if x > 200:
                 return 2
             raise ValueError
         @dont_look_inside
         def g(x):
-            if x > 15:
+            if x > 150:
                 raise ValueError
             return 2
         class Base:
@@ -207,7 +207,7 @@
                 return 1
         @dont_look_inside
         def h(x):
-            if x < 2000:
+            if x < 20000:
                 return Sub()
             else:
                 return Base()
@@ -238,8 +238,8 @@
         logfile = udir.join('test_ztranslation.log')
         os.environ['PYPYLOG'] = 'jit-log-opt:%s' % (logfile,)
         try:
-            res = self.meta_interp(main, [40])
-            assert res == main(40)
+            res = self.meta_interp(main, [400])
+            assert res == main(400)
         finally:
             del os.environ['PYPYLOG']
 
@@ -248,5 +248,7 @@
             if 'guard_class' in line:
                 guard_class += 1
         # if we get many more guard_classes, it means that we generate
-        # guards that always fail
-        assert 0 < guard_class <= 4
+        # guards that always fail (the following assert's original purpose
+        # is to catch the following case: each GUARD_CLASS is misgenerated
+        # and always fails with "gcremovetypeptr")
+        assert 0 < guard_class < 10

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -193,7 +193,7 @@
       the API headers.
     """
     if error is _NOT_SPECIFIED:
-        if restype is PyObject:
+        if isinstance(restype, lltype.Ptr):
             error = lltype.nullptr(restype.TO)
         elif restype is lltype.Void:
             error = CANNOT_FAIL
@@ -308,7 +308,7 @@
     'PyModule_AddObject', 'PyModule_AddIntConstant', 'PyModule_AddStringConstant',
     'Py_BuildValue', 'Py_VaBuildValue', 'PyTuple_Pack',
 
-    'PyErr_Format', 'PyErr_NewException',
+    'PyErr_Format', 'PyErr_NewException', 'PyErr_NewExceptionWithDoc',
 
     'PyEval_CallFunction', 'PyEval_CallMethod', 'PyObject_CallFunction',
     'PyObject_CallMethod', 'PyObject_CallFunctionObjArgs', 'PyObject_CallMethodObjArgs',
@@ -320,6 +320,11 @@
     'PyCObject_GetDesc', 'PyCObject_Import', 'PyCObject_SetVoidPtr',
     'PyCObject_Type', 'init_pycobject',
 
+    'PyCapsule_New', 'PyCapsule_IsValid', 'PyCapsule_GetPointer',
+    'PyCapsule_GetName', 'PyCapsule_GetDestructor', 'PyCapsule_GetContext',
+    'PyCapsule_SetPointer', 'PyCapsule_SetName', 'PyCapsule_SetDestructor',
+    'PyCapsule_SetContext', 'PyCapsule_Import', 'PyCapsule_Type', 'init_capsule',
+
     'PyObject_AsReadBuffer', 'PyObject_AsWriteBuffer', 'PyObject_CheckReadBuffer',
 
     'PyStructSequence_InitType', 'PyStructSequence_New',
@@ -564,9 +569,11 @@
 def setup_init_functions(eci):
     init_buffer = rffi.llexternal('init_bufferobject', [], lltype.Void, compilation_info=eci)
     init_pycobject = rffi.llexternal('init_pycobject', [], lltype.Void, compilation_info=eci)
+    init_capsule = rffi.llexternal('init_capsule', [], lltype.Void, compilation_info=eci)
     INIT_FUNCTIONS.extend([
         lambda space: init_buffer(),
         lambda space: init_pycobject(),
+        lambda space: init_capsule(),
     ])
 
 def init_function(func):
@@ -657,6 +664,8 @@
     import ctypes
     bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL)
 
+    space.fromcache(State).install_dll(eci)
+
     # populate static data
     for name, (typ, expr) in GLOBALS.iteritems():
         from pypy.module import cpyext
@@ -746,6 +755,7 @@
         ("SIZEOF_LONG_LONG", rffi.LONGLONG),
         ("SIZEOF_VOID_P", rffi.VOIDP),
         ("SIZEOF_SIZE_T", rffi.SIZE_T),
+        ("SIZEOF_TIME_T", rffi.TIME_T),
         ("SIZEOF_LONG", rffi.LONG),
         ("SIZEOF_SHORT", rffi.SHORT),
         ("SIZEOF_INT", rffi.INT)
@@ -835,6 +845,25 @@
             structs.append('%s %s = NULL;' % (typ, name))
     struct_source = '\n'.join(structs)
 
+    separate_module_sources = [code, struct_source]
+
+    if sys.platform == 'win32':
+        get_pythonapi_source = '''
+        #include <windows.h>
+        HANDLE pypy_get_pythonapi_handle() {
+            MEMORY_BASIC_INFORMATION  mi;
+            memset(&mi, 0, sizeof(mi));
+
+            if( !VirtualQueryEx(GetCurrentProcess(), &pypy_get_pythonapi_handle,
+                                &mi, sizeof(mi)) )
+                return 0;
+
+            return (HMODULE)mi.AllocationBase;
+        }
+        '''
+        separate_module_sources.append(get_pythonapi_source)
+        export_symbols_eci.append('pypy_get_pythonapi_handle')
+
     eci = ExternalCompilationInfo(
         include_dirs=include_dirs,
         separate_module_files=[source_dir / "varargwrapper.c",
@@ -848,12 +877,14 @@
                                source_dir / "object.c",
                                source_dir / "cobject.c",
                                source_dir / "structseq.c",
+                               source_dir / "capsule.c",
                                ],
-        separate_module_sources = [code, struct_source],
+        separate_module_sources=separate_module_sources,
         export_symbols=export_symbols_eci,
         compile_extra=compile_extra,
         **kwds
         )
+
     return eci
 
 
@@ -872,6 +903,8 @@
 
     eci = build_eci(False, export_symbols, code)
 
+    space.fromcache(State).install_dll(eci)
+
     run_bootstrap_functions(space)
     setup_va_functions(eci)
 

diff --git a/pypy/module/cpyext/test/conftest.py b/pypy/module/cpyext/test/conftest.py
--- a/pypy/module/cpyext/test/conftest.py
+++ b/pypy/module/cpyext/test/conftest.py
@@ -9,7 +9,7 @@
     return False
 
 def pytest_funcarg__space(request):
-    return gettestobjspace(usemodules=['cpyext', 'thread'])
+    return gettestobjspace(usemodules=['cpyext', 'thread', '_rawffi'])
 
 def pytest_funcarg__api(request):
     return request.cls.api

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -778,6 +778,12 @@
         # CPython 2.5 adds an extra argument consumed by this opcode
         if self.pycode.magic >= 0xa0df294:
             w_flag = self.popvalue()
+            try:
+                if space.int_w(w_flag) == -1:
+                    w_flag = None
+            except OperationError, e:
+                if e.async(space):
+                    raise
         else:
             w_flag = None
 

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -555,6 +555,9 @@
 
     def setup_builtin_modules(self):
         "NOT_RPYTHON: only for initializing the space."
+        if self.config.objspace.usemodules.cpyext:
+            from pypy.module.cpyext.state import State
+            self.fromcache(State).build_api(self)
         self.getbuiltinmodule('sys')
         self.getbuiltinmodule('imp')
         self.getbuiltinmodule('__builtin__')

diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -35,7 +35,7 @@
 
 class AppTestApi:
     def setup_class(cls):
-        cls.space = gettestobjspace(usemodules=['cpyext', 'thread'])
+        cls.space = gettestobjspace(usemodules=['cpyext', 'thread', '_rawffi'])
         from pypy.rlib.libffi import get_libc_name
         cls.w_libc = cls.space.wrap(get_libc_name())
 
@@ -44,6 +44,17 @@
         raises(ImportError, cpyext.load_module, "missing.file", "foo")
         raises(ImportError, cpyext.load_module, self.libc, "invalid.function")
 
+    def test_dllhandle(self):
+        import sys
+        if sys.version_info < (2, 6):
+            skip("Python >= 2.6 only")
+        assert sys.dllhandle
+        assert sys.dllhandle.getaddressindll('PyPyErr_NewException')
+        import ctypes # slow
+        PyUnicode_GetDefaultEncoding = ctypes.pythonapi.PyPyUnicode_GetDefaultEncoding
+        PyUnicode_GetDefaultEncoding.restype = ctypes.c_char_p
+        assert PyUnicode_GetDefaultEncoding() == 'ascii'
+
 def compile_module(space, modname, **kwds):
     """
     Build an extension module and return the filename of the resulting native
@@ -147,7 +158,7 @@
 
 class AppTestCpythonExtensionBase(LeakCheckingTest):
     def setup_class(cls):
-        cls.space = gettestobjspace(usemodules=['cpyext', 'thread'])
+        cls.space = gettestobjspace(usemodules=['cpyext', 'thread', '_rawffi'])
         cls.space.getbuiltinmodule("cpyext")
         from pypy.module.imp.importing import importhook
         importhook(cls.space, "os") # warm up reference counts

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -1,51 +1,53 @@
-syntax:glob
+syntax: glob
 *.py[co]
 *.sw[po]
 *~
 
-testresult
-site-packages
-pypy/module/cpyext/src/*.o
-pypy/bin/pypy-c
-pypy/translator/jvm/src/pypy/*.class
-pypy/module/cpyext/test/*.errors
-pypy/doc/*.html
-pypy/doc/basicblock.asc
-pypy/doc/*.svninfo
-pypy/translator/jvm/.project
-pypy/translator/jvm/.classpath
-pypy/translator/jvm/eclipse-bin
-pypy/translator/benchmark/docutils
-pypy/translator/benchmark/templess
-pypy/translator/benchmark/gadfly
-pypy/translator/benchmark/mako
-pypy/translator/benchmark/bench-custom.benchmark_result
-pypy/translator/benchmark/shootout_benchmarks
-pypy/translator/goal/pypy-translation-snapshot
-pypy/translator/goal/pypy-c*
-pypy/translator/goal/*.exe
-pypy/translator/goal/target*-c
-pypy/_cache
-site-packages/*.egg
-site-packages/*.pth
-pypy/doc/statistic/*.html
-pypy/doc/statistic/*.eps
-pypy/doc/statistic/*.pdf
-pypy/translator/cli/src/pypylib.dll
-pypy/translator/cli/src/query.exe
-pypy/translator/cli/src/main.exe
-lib_pypy/ctypes_config_cache/_*_cache.py
-lib_pypy/ctypes_config_cache/_*_*_.py
-pypy/translator/cli/query-descriptions
-pypy/doc/discussion/*.html
-include/*.h
-include/*.inl
-pypy/doc/config/*.html
-pypy/doc/config/style.css
-pypy/doc/jit/*.html
-pypy/doc/jit/style.css
-pypy/doc/image/lattice1.png
-pypy/doc/image/lattice2.png
-pypy/doc/image/lattice3.png
-pypy/doc/image/stackless_informal.png
-pypy/doc/image/parsing_example*.png
+syntax: regexp
+^testresult$
+^site-packages$
+^pypy/module/cpyext/src/.+\.o$
+^pypy/bin/pypy-c
+^pypy/translator/jvm/src/pypy/.+\.class$
+^pypy/module/cpyext/test/.+\.errors$
+^pypy/module/cpyext/test/.+\.o$
+^pypy/doc/.+\.html$
+^pypy/doc/basicblock\.asc$
+^pypy/doc/.+\.svninfo$
+^pypy/translator/jvm/\.project$
+^pypy/translator/jvm/\.classpath$
+^pypy/translator/jvm/eclipse-bin$
+^pypy/translator/benchmark/docutils$
+^pypy/translator/benchmark/templess$
+^pypy/translator/benchmark/gadfly$
+^pypy/translator/benchmark/mako$
+^pypy/translator/benchmark/bench-custom\.benchmark_result$
+^pypy/translator/benchmark/shootout_benchmarks$
+^pypy/translator/goal/pypy-translation-snapshot$
+^pypy/translator/goal/pypy-c
+^pypy/translator/goal/.+\.exe$
+^pypy/translator/goal/target.+-c$
+^pypy/_cache$
+^site-packages/.+\.egg$
+^site-packages/.+\.pth$
+^pypy/doc/statistic/.+\.html$
+^pypy/doc/statistic/.+\.eps$
+^pypy/doc/statistic/.+\.pdf$
+^pypy/translator/cli/src/pypylib\.dll$
+^pypy/translator/cli/src/query\.exe$
+^pypy/translator/cli/src/main\.exe$
+^lib_pypy/ctypes_config_cache/_.+_cache\.py$
+^lib_pypy/ctypes_config_cache/_.+_.+_\.py$
+^pypy/translator/cli/query-descriptions$
+^pypy/doc/discussion/.+\.html$
+^include/.+\.h$
+^include/.+\.inl$
+^pypy/doc/config/.+\.html$
+^pypy/doc/config/style\.css$
+^pypy/doc/jit/.+\.html$
+^pypy/doc/jit/style\.css$
+^pypy/doc/image/lattice1\.png$
+^pypy/doc/image/lattice2\.png$
+^pypy/doc/image/lattice3\.png$
+^pypy/doc/image/stackless_informal\.png$
+^pypy/doc/image/parsing_example.+\.png$


More information about the Pypy-commit mailing list