[pypy-commit] pypy default: merge win32-fixes5, which fixes own test failures in rpython/translator

mattip noreply at buildbot.pypy.org
Wed Oct 1 18:12:44 CEST 2014


Author: mattip <matti.picus at gmail.com>
Branch: 
Changeset: r73753:7c925baed944
Date: 2014-10-01 19:08 +0300
http://bitbucket.org/pypy/pypy/changeset/7c925baed944/

Log:	merge win32-fixes5, which fixes own test failures in
	rpython/translator and win32 now rounds to 4 on rffi memory size
	calculation

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -6,3 +6,9 @@
 .. this is a revision shortly after release-2.4.x
 .. startrev: 7026746cbb1b
 
+.. branch: win32-fixes5
+Fix c code generation for msvc so empty "{ }" are avoided in unions,
+Avoid re-opening files created with NamedTemporaryFile,
+Allocate by 4-byte chunks in rffi_platform,
+Skip testing objdump if it does not exist,
+and other small adjustments in own tests
diff --git a/pypy/tool/gdb_pypy.py b/pypy/tool/gdb_pypy.py
--- a/pypy/tool/gdb_pypy.py
+++ b/pypy/tool/gdb_pypy.py
@@ -123,11 +123,15 @@
         vname = 'pypy_g_rpython_memory_gctypelayout_GCData.gcd_inst_typeids_z'
         length = int(self.gdb.parse_and_eval('*(long*)%s' % vname))
         vstart = '(char*)(((long*)%s)+1)' % vname
-        with tempfile.NamedTemporaryFile('rb') as fobj:
+        fname = tempfile.mktemp()
+        try:
             self.gdb.execute('dump binary memory %s %s %s+%d' %
-                             (fobj.name, vstart, vstart, length))
-            data = fobj.read()
-        return TypeIdsMap(zlib.decompress(data).splitlines(True), self.gdb)
+                             (fname, vstart, vstart, length))
+            with open(fname, 'rt') as fobj:
+                data = fobj.read()
+            return TypeIdsMap(zlib.decompress(data).splitlines(True), self.gdb)
+        finally:
+            os.remove(fname)
 
 
 class TypeIdsMap(object):
diff --git a/rpython/rtyper/module/test/test_ll_os_stat.py b/rpython/rtyper/module/test/test_ll_os_stat.py
--- a/rpython/rtyper/module/test/test_ll_os_stat.py
+++ b/rpython/rtyper/module/test/test_ll_os_stat.py
@@ -22,10 +22,10 @@
         stat = ll_os_stat.make_win32_stat_impl('stat', ll_os.StringTraits())
         wstat = ll_os_stat.make_win32_stat_impl('stat', ll_os.UnicodeTraits())
         def check(f):
-            # msec resolution
+            # msec resolution, +- rounding error
             expected = int(os.stat(f).st_mtime*1000)
-            assert int(stat(f).st_mtime*1000) == expected
-            assert int(wstat(unicode(f)).st_mtime*1000) == expected
+            assert abs(int(stat(f).st_mtime*1000) - expected) < 2
+            assert abs(int(wstat(unicode(f)).st_mtime*1000) - expected) < 2
 
         check('c:/')
         check(os.environ['TEMP'])
diff --git a/rpython/rtyper/tool/rffi_platform.py b/rpython/rtyper/tool/rffi_platform.py
--- a/rpython/rtyper/tool/rffi_platform.py
+++ b/rpython/rtyper/tool/rffi_platform.py
@@ -107,15 +107,18 @@
     fields is properly aligned."""
     global _memory_alignment
     if _memory_alignment is None:
-        S = getstruct('struct memory_alignment_test', """
-           struct memory_alignment_test {
-               double d;
-               void* p;
-           };
-        """, [])
-        result = S._hints['align']
-        assert result & (result-1) == 0, "not a power of two??"
-        _memory_alignment = result
+        if sys.platform == 'win32':
+            _memory_alignment = 4
+        else:    
+            S = getstruct('struct memory_alignment_test', """
+               struct memory_alignment_test {
+                   double d;
+                   void* p;
+               };
+            """, [])
+            result = S._hints['align']
+            assert result & (result-1) == 0, "not a power of two??"
+            _memory_alignment = result
     return _memory_alignment
 _memory_alignment = None
 
diff --git a/rpython/tool/jitlogparser/test/test_parser.py b/rpython/tool/jitlogparser/test/test_parser.py
--- a/rpython/tool/jitlogparser/test/test_parser.py
+++ b/rpython/tool/jitlogparser/test/test_parser.py
@@ -5,6 +5,7 @@
 from rpython.tool.jitlogparser.storage import LoopStorage
 import py, sys
 from rpython.jit.backend.detect_cpu import autodetect
+from rpython.jit.backend.tool.viewcode import ObjdumpNotFound
 
 def parse(input, **kwds):
     return SimpleParser.parse_from_input(input, **kwds)
@@ -193,7 +194,8 @@
         py.test.skip('x86 only test')
     backend_dump = "554889E5534154415541564157488DA500000000488B042590C5540148C7042590C554010000000048898570FFFFFF488B042598C5540148C7042598C554010000000048898568FFFFFF488B0425A0C5540148C70425A0C554010000000048898560FFFFFF488B0425A8C5540148C70425A8C554010000000048898558FFFFFF4C8B3C2550525B0149BB30E06C96FC7F00004D8B334983C60149BB30E06C96FC7F00004D89334981FF102700000F8D000000004983C7014C8B342580F76A024983EE014C89342580F76A024983FE000F8C00000000E9AEFFFFFF488B042588F76A024829E0483B042580EC3C01760D49BB05F30894FC7F000041FFD3554889E5534154415541564157488DA550FFFFFF4889BD70FFFFFF4889B568FFFFFF48899560FFFFFF48898D58FFFFFF4D89C7E954FFFFFF49BB00F00894FC7F000041FFD34440484C3D030300000049BB00F00894FC7F000041FFD34440484C3D070304000000"
     dump_start = 0x7f3b0b2e63d5
-    loop = parse("""
+    try:
+        loop = parse("""
     # Loop 0 : loop with 19 ops
     [p0, p1, p2, p3, i4]
     debug_merge_point(0, 0, '<code object f. file 'x.py'. line 2> #15 COMPARE_OP')
@@ -212,6 +214,8 @@
     +218: --end of the loop--""", backend_dump=backend_dump,
                  dump_start=dump_start,
                  backend_tp='x86_64')
+    except ObjdumpNotFound:
+        py.test.skip('no objdump found on path')
     cmp = loop.operations[1]
     assert 'jge' in cmp.asm
     assert '0x2710' in cmp.asm
@@ -276,8 +280,11 @@
         py.test.skip('x86 only test')
     _, loops = import_log(str(py.path.local(__file__).join('..',
                                                            'logtest.log')))
-    for loop in loops:
-        loop.force_asm()
+    try:
+        for loop in loops:
+            loop.force_asm()
+    except ObjdumpNotFound:
+        py.test.skip('no objdump found on path')
     assert 'jge' in loops[0].operations[3].asm
 
 def test_import_log_2():
@@ -285,8 +292,11 @@
         py.test.skip('x86 only test')
     _, loops = import_log(str(py.path.local(__file__).join('..',
                                                            'logtest2.log')))
-    for loop in loops:
-        loop.force_asm()
+    try:
+        for loop in loops:
+            loop.force_asm()
+    except ObjdumpNotFound:
+        py.test.skip('no objdump found on path')
     assert 'cmp' in loops[1].operations[2].asm
 
 def test_Op_repr_is_pure():
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -302,8 +302,11 @@
 
     def has_profopt(self):
         profbased = self.getprofbased()
-        return (profbased and isinstance(profbased, tuple)
+        retval = (profbased and isinstance(profbased, tuple)
                 and profbased[0] is ProfOpt)
+        if retval and self.translator.platform.name == 'msvc':
+            raise ValueError('Cannot do profile based optimization on MSVC,'
+                    'it is not supported in free compiler version')
 
     def getentrypointptr(self):
         # XXX check that the entrypoint has the correct
diff --git a/rpython/translator/c/node.py b/rpython/translator/c/node.py
--- a/rpython/translator/c/node.py
+++ b/rpython/translator/c/node.py
@@ -521,12 +521,16 @@
             return []
         lines = list(self.initializationexpr())
         type, name = self.get_declaration()
-        if name != self.name:
-            lines[0] = '{ ' + lines[0]    # extra braces around the 'a' part
-            lines[-1] += ' }'             # of the union
-        lines[0] = '%s = %s' % (
-            cdecl(type, name, self.is_thread_local()),
-            lines[0])
+        if name != self.name and len(lines) < 2:
+            # a union with length 0
+            lines[0] = cdecl(type, name, self.is_thread_local())
+        else:
+            if name != self.name:
+                lines[0] = '{ ' + lines[0]    # extra braces around the 'a' part
+                lines[-1] += ' }'             # of the union
+            lines[0] = '%s = %s' % (
+                cdecl(type, name, self.is_thread_local()),
+                lines[0])
         lines[-1] += ';'
         return lines
 
@@ -563,7 +567,6 @@
     def initializationexpr(self, decoration=''):
         T = self.getTYPE()
         is_empty = True
-        yield '{'
         defnode = self.db.gettypedefnode(T)
 
         data = []
@@ -592,7 +595,13 @@
             padding_drop = T._hints['get_padding_drop'](d)
         else:
             padding_drop = []
+        type, name = self.get_declaration()
+        if name != self.name and self.getvarlength() < 1 and len(data) < 2:
+            # an empty union
+            yield ''
+            return
 
+        yield '{'
         for name, value in data:
             if name in padding_drop:
                 continue
diff --git a/rpython/translator/c/test/test_standalone.py b/rpython/translator/c/test/test_standalone.py
--- a/rpython/translator/c/test/test_standalone.py
+++ b/rpython/translator/c/test/test_standalone.py
@@ -187,6 +187,8 @@
         assert map(float, data.split()) == [0.0, 0.0]
 
     def test_profopt(self):
+        if sys.platform == 'win32':
+            py.test.skip("no profopt on win32")
         def add(a,b):
             return a + b - b + b - b + b - b + b - b + b - b + b - b + b
         def entry_point(argv):
diff --git a/rpython/translator/tool/stdoutcapture.py b/rpython/translator/tool/stdoutcapture.py
--- a/rpython/translator/tool/stdoutcapture.py
+++ b/rpython/translator/tool/stdoutcapture.py
@@ -9,7 +9,8 @@
     
     def __init__(self, mixed_out_err = False):
         "Start capture of the Unix-level stdout and stderr."
-        if (not hasattr(os, 'tmpfile') or
+        if (sys.platform == 'win32' or # os.tmpfile fails, cpython issue #2232
+            not hasattr(os, 'tmpfile') or
             not hasattr(os, 'dup') or
             not hasattr(os, 'dup2') or
             not hasattr(os, 'fdopen')):


More information about the pypy-commit mailing list