[pypy-commit] pypy default: merge

fijal noreply at buildbot.pypy.org
Sun Jan 8 21:57:06 CET 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r51149:9835710fde04
Date: 2012-01-08 22:56 +0200
http://bitbucket.org/pypy/pypy/changeset/9835710fde04/

Log:	merge

diff --git a/pypy/jit/metainterp/optimizeopt/fficall.py b/pypy/jit/metainterp/optimizeopt/fficall.py
--- a/pypy/jit/metainterp/optimizeopt/fficall.py
+++ b/pypy/jit/metainterp/optimizeopt/fficall.py
@@ -234,11 +234,11 @@
             # longlongs are treated as floats, see
             # e.g. llsupport/descr.py:getDescrClass
             is_float = True
-        elif kind == 'u':
+        elif kind == 'u' or kind == 's':
             # they're all False
             pass
         else:
-            assert False, "unsupported ffitype or kind"
+            raise NotImplementedError("unsupported ffitype or kind: %s" % kind)
         #
         fieldsize = rffi.getintfield(ffitype, 'c_size')
         return self.optimizer.cpu.interiorfielddescrof_dynamic(
diff --git a/pypy/jit/metainterp/test/test_fficall.py b/pypy/jit/metainterp/test/test_fficall.py
--- a/pypy/jit/metainterp/test/test_fficall.py
+++ b/pypy/jit/metainterp/test/test_fficall.py
@@ -148,28 +148,38 @@
         self.check_resops({'jump': 1, 'int_lt': 2, 'setinteriorfield_raw': 4,
                            'getinteriorfield_raw': 8, 'int_add': 6, 'guard_true': 2})
 
-    def test_array_getitem_uint8(self):
+    def _test_getitem_type(self, TYPE, ffitype, COMPUTE_TYPE):
+        reds = ["n", "i", "s", "data"]
+        if COMPUTE_TYPE is lltype.Float:
+            # Move the float var to the back.
+            reds.remove("s")
+            reds.append("s")
         myjitdriver = JitDriver(
             greens = [],
-            reds = ["n", "i", "s", "data"],
+            reds = reds,
         )
         def f(data, n):
-            i = s = 0
+            i = 0
+            s = rffi.cast(COMPUTE_TYPE, 0)
             while i < n:
                 myjitdriver.jit_merge_point(n=n, i=i, s=s, data=data)
-                s += rffi.cast(lltype.Signed, array_getitem(types.uchar, 1, data, 0, 0))
+                s += rffi.cast(COMPUTE_TYPE, array_getitem(ffitype, rffi.sizeof(TYPE), data, 0, 0))
                 i += 1
             return s
+        def main(n):
+            with lltype.scoped_alloc(rffi.CArray(TYPE), 1) as data:
+                data[0] = rffi.cast(TYPE, 200)
+                return f(data, n)
+        assert self.meta_interp(main, [10]) == 2000
 
-        def main(n):
-            with lltype.scoped_alloc(rffi.CArray(rffi.UCHAR), 1) as data:
-                data[0] = rffi.cast(rffi.UCHAR, 200)
-                return f(data, n)
-
-        assert self.meta_interp(main, [10]) == 2000
+    def test_array_getitem_uint8(self):
+        self._test_getitem_type(rffi.UCHAR, types.uchar, lltype.Signed)
         self.check_resops({'jump': 1, 'int_lt': 2, 'getinteriorfield_raw': 2,
                            'guard_true': 2, 'int_add': 4})
 
+    def test_array_getitem_float(self):
+        self._test_getitem_type(rffi.FLOAT, types.float, lltype.Float)
+
 
 class TestFfiCall(FfiCallTests, LLJitMixin):
     supports_all = False
diff --git a/pypy/module/_lsprof/interp_lsprof.py b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -19,8 +19,9 @@
 # cpu affinity settings
 
 srcdir = py.path.local(pypydir).join('translator', 'c', 'src')
-eci = ExternalCompilationInfo(separate_module_files=
-                              [srcdir.join('profiling.c')])
+eci = ExternalCompilationInfo(
+    separate_module_files=[srcdir.join('profiling.c')],
+    export_symbols=['pypy_setup_profiling', 'pypy_teardown_profiling'])
                                                      
 c_setup_profiling = rffi.llexternal('pypy_setup_profiling',
                                   [], lltype.Void,
diff --git a/pypy/translator/c/src/profiling.c b/pypy/translator/c/src/profiling.c
--- a/pypy/translator/c/src/profiling.c
+++ b/pypy/translator/c/src/profiling.c
@@ -29,6 +29,35 @@
     profiling_setup = 0;
   }
 }
+
+#elif defined(_WIN32)
+#include <windows.h>
+
+DWORD_PTR base_affinity_mask;
+int profiling_setup = 0;
+
+void pypy_setup_profiling() { 
+    if (!profiling_setup) {
+        DWORD_PTR affinity_mask, system_affinity_mask;
+        GetProcessAffinityMask(GetCurrentProcess(),
+            &base_affinity_mask, &system_affinity_mask);
+        affinity_mask = 1;
+        /* Pick one cpu allowed by the system */
+        if (system_affinity_mask)
+            while ((affinity_mask & system_affinity_mask) == 0)
+                affinity_mask <<= 1;
+        SetProcessAffinityMask(GetCurrentProcess(), affinity_mask);
+        profiling_setup = 1;
+    }
+}
+
+void pypy_teardown_profiling() {
+    if (profiling_setup) {
+        SetProcessAffinityMask(GetCurrentProcess(), base_affinity_mask);
+        profiling_setup = 0;
+    }
+}
+
 #else
 void pypy_setup_profiling() { }
 void pypy_teardown_profiling() { }


More information about the pypy-commit mailing list