[pypy-commit] pypy py3.5: hg merge default

arigo pypy.commits at gmail.com
Sat Feb 25 09:38:14 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r90352:e0f57c4b95e8
Date: 2017-02-25 15:37 +0100
http://bitbucket.org/pypy/pypy/changeset/e0f57c4b95e8/

Log:	hg merge default

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
@@ -1245,6 +1245,17 @@
 
 def write_header(header_name, decls):
     lines = [
+        '''
+#ifdef _WIN64
+/* this check is for sanity, but also because the 'temporary fix'
+   below seems to become permanent and would cause unexpected
+   nonsense on Win64---but note that it's not the only reason for
+   why Win64 is not supported!  If you want to help, see
+   http://doc.pypy.org/en/latest/windows.html#what-is-missing-for-a-full-64-bit-translation
+   */
+#  error "PyPy does not support 64-bit on Windows.  Use Win32"
+#endif
+''',
         '#define Signed   long           /* xxx temporary fix */',
         '#define Unsigned unsigned long  /* xxx temporary fix */',
         '',] + decls + [
diff --git a/pypy/module/cpyext/include/Python.h b/pypy/module/cpyext/include/Python.h
--- a/pypy/module/cpyext/include/Python.h
+++ b/pypy/module/cpyext/include/Python.h
@@ -73,7 +73,7 @@
 
 #define Py_MEMCPY memcpy
 
-#include <pypy_macros.h>
+#include "pypy_macros.h"
 
 #define PyExc_EnvironmentError PyExc_OSError
 #define PyExc_IOError PyExc_OSError
@@ -144,7 +144,7 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-  #include <pypy_decl.h>
+  #include "pypy_decl.h"
 #ifdef __cplusplus
 }
 #endif
diff --git a/pypy/module/cpyext/include/_numpypy/numpy/ndarraytypes.h b/pypy/module/cpyext/include/_numpypy/numpy/ndarraytypes.h
--- a/pypy/module/cpyext/include/_numpypy/numpy/ndarraytypes.h
+++ b/pypy/module/cpyext/include/_numpypy/numpy/ndarraytypes.h
@@ -1,7 +1,7 @@
 #ifndef NDARRAYTYPES_H
 #define NDARRAYTYPES_H
 
-#include "numpy/npy_common.h"
+#include "npy_common.h"
 //#include "npy_endian.h"
 //#include "npy_cpu.h"
 //#include "utils.h"
diff --git a/pypy/module/cpyext/include/_numpypy/numpy/npy_3kcompat.h b/pypy/module/cpyext/include/_numpypy/numpy/npy_3kcompat.h
--- a/pypy/module/cpyext/include/_numpypy/numpy/npy_3kcompat.h
+++ b/pypy/module/cpyext/include/_numpypy/numpy/npy_3kcompat.h
@@ -10,7 +10,7 @@
 #ifndef _NPY_3KCOMPAT_H_
 #define _NPY_3KCOMPAT_H_
 
-#include <numpy/npy_common.h>
+#include "npy_common.h"
 
 #define npy_PyFile_Dup(file, mode) (NULL)
 #define npy_PyFile_DupClose(file, handle) (0)
diff --git a/pypy/module/cpyext/include/object.h b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -7,7 +7,7 @@
 extern "C" {
 #endif
 
-#include <cpyext_object.h>
+#include "cpyext_object.h"
 
 #define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
 #define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
diff --git a/pypy/module/cpyext/include/unicodeobject.h b/pypy/module/cpyext/include/unicodeobject.h
--- a/pypy/module/cpyext/include/unicodeobject.h
+++ b/pypy/module/cpyext/include/unicodeobject.h
@@ -5,7 +5,7 @@
 extern "C" {
 #endif
 
-#include <cpyext_unicodeobject.h>
+#include "cpyext_unicodeobject.h"
 
 /* Fast access macros */
 #ifndef Py_LIMITED_API
diff --git a/pypy/module/cpyext/parse/cpyext_object.h b/pypy/module/cpyext/parse/cpyext_object.h
--- a/pypy/module/cpyext/parse/cpyext_object.h
+++ b/pypy/module/cpyext/parse/cpyext_object.h
@@ -289,7 +289,7 @@
     destructor tp_finalize;
 } PyTypeObject;
 
-typedef struct {
+typedef struct _heaptypeobject {
     PyTypeObject ht_type;
     PyNumberMethods as_number;
     PyMappingMethods as_mapping;
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -4840,6 +4840,21 @@
         """
         self.optimize_strunicode_loop(ops, expected)
 
+    def test_nonvirtual_newstr_strlen(self):
+        ops = """
+        [p0]
+        p1 = call_r(0, p0, s"X", descr=strconcatdescr)
+        i0 = strlen(p1)
+        finish(i0)
+        """
+        expected = """
+        [p0]
+        i2 = strlen(p0)
+        i4 = int_add(i2, 1)
+        finish(i4)
+        """
+        self.optimize_strunicode_loop(ops, expected)
+
     def test_copy_long_string_to_virtual(self):
         ops = """
         []
diff --git a/rpython/jit/metainterp/optimizeopt/vstring.py b/rpython/jit/metainterp/optimizeopt/vstring.py
--- a/rpython/jit/metainterp/optimizeopt/vstring.py
+++ b/rpython/jit/metainterp/optimizeopt/vstring.py
@@ -60,7 +60,6 @@
         self.length = length
         self._is_virtual = is_virtual
         self.mode = mode
-        self.length = length
 
     def getlenbound(self, mode):
         from rpython.jit.metainterp.optimizeopt import intutils
@@ -110,12 +109,11 @@
         return self.string_copy_parts(op, string_optimizer, targetbox,
                                       offsetbox, mode)
 
-    def getstrlen(self, op, string_optimizer, mode, create_ops=True):
+    def getstrlen(self, op, string_optimizer, mode):
+        assert op is not None
         if self.lgtop is not None:
             return self.lgtop
         assert not self.is_virtual()
-        if not create_ops:
-            return None
         lengthop = ResOperation(mode.STRLEN, [op])
         lengthop.set_forwarded(self.getlenbound(mode))
         self.lgtop = lengthop
@@ -172,7 +170,8 @@
     def is_virtual(self):
         return self._is_virtual
 
-    def getstrlen(self, op, string_optimizer, mode, create_ops=True):
+    def getstrlen(self, op, string_optimizer, mode):
+        assert op is not None
         if self.lgtop is None:
             self.lgtop = ConstInt(len(self._chars))
         return self.lgtop
@@ -251,7 +250,8 @@
             return s1[start : start + length]
         return None
 
-    def getstrlen(self, op, string_optimizer, mode, create_ops=True):
+    def getstrlen(self, op, string_optimizer, mode):
+        assert op is not None
         return self.lgtop
 
     def _visitor_walk_recursive(self, instbox, visitor, optimizer):
@@ -280,20 +280,19 @@
     def is_virtual(self):
         return self._is_virtual
 
-    def getstrlen(self, op, string_optimizer, mode, create_ops=True):
+    def getstrlen(self, op, string_optimizer, mode):
+        assert op is not None
         if self.lgtop is not None:
             return self.lgtop
         lefti = string_optimizer.getptrinfo(self.vleft)
-        len1box = lefti.getstrlen(self.vleft, string_optimizer, mode,
-                                  create_ops)
+        len1box = lefti.getstrlen(self.vleft, string_optimizer, mode)
         if len1box is None:
             return None
         righti = string_optimizer.getptrinfo(self.vright)
-        len2box = righti.getstrlen(self.vright, string_optimizer, mode,
-                                   create_ops)
+        len2box = righti.getstrlen(self.vright, string_optimizer, mode)
         if len2box is None:
             return None
-        self.lgtop = _int_add(string_optimizer, len1box, len2box, create_ops)
+        self.lgtop = _int_add(string_optimizer, len1box, len2box)
             # ^^^ may still be None, if string_optimizer is None
         return self.lgtop
 
@@ -371,7 +370,7 @@
         offsetbox = nextoffsetbox
     return offsetbox
 
-def _int_add(string_optimizer, box1, box2, create_ops=True):
+def _int_add(string_optimizer, box1, box2):
     if isinstance(box1, ConstInt):
         if box1.value == 0:
             return box2
@@ -379,8 +378,6 @@
             return ConstInt(box1.value + box2.value)
     elif isinstance(box2, ConstInt) and box2.value == 0:
         return box1
-    if not create_ops:
-        return None
     op = ResOperation(rop.INT_ADD, [box1, box2])
     string_optimizer.send_extra_operation(op)
     return op
@@ -529,9 +526,10 @@
         return self._optimize_STRLEN(op, mode_unicode)
 
     def _optimize_STRLEN(self, op, mode):
-        opinfo = self.getptrinfo(op.getarg(0))
+        arg1 = self.get_box_replacement(op.getarg(0))
+        opinfo = self.getptrinfo(arg1)
         if opinfo:
-            lgtop = opinfo.getstrlen(op, self, mode, False)
+            lgtop = opinfo.getstrlen(arg1, self, mode)
             if lgtop is not None:
                 self.make_equal_to(op, lgtop)
                 return
@@ -700,11 +698,11 @@
         i2 = self.getptrinfo(arg2)
         #
         if i1:
-            l1box = i1.getstrlen(arg1, self, mode, create_ops=False)
+            l1box = i1.getstrlen(arg1, self, mode)
         else:
             l1box = None
         if i2:
-            l2box = i2.getstrlen(arg2, self, mode, create_ops=False)
+            l2box = i2.getstrlen(arg2, self, mode)
         else:
             l2box = None
         if (l1box is not None and l2box is not None and
@@ -742,7 +740,7 @@
         l2box = None
         l1box = None
         if i2:
-            l2box = i2.getstrlen(arg2, self, mode, create_ops=False)
+            l2box = i2.getstrlen(arg2, self, mode)
         if isinstance(l2box, ConstInt):
             if l2box.value == 0:
                 if i1 and i1.is_nonnull():
@@ -760,7 +758,7 @@
                     return True, None
             if l2box.value == 1:
                 if i1:
-                    l1box = i1.getstrlen(arg1, self, mode, False)
+                    l1box = i1.getstrlen(arg1, self, mode)
                 if isinstance(l1box, ConstInt) and l1box.value == 1:
                     # comparing two single chars
                     vchar1 = self.strgetitem(None, arg1, optimizer.CONST_0,
@@ -799,7 +797,7 @@
         i2 = self.getptrinfo(arg2)
         l2box = None
         if i2:
-            l2box = i2.getstrlen(arg1, self, mode, create_ops=False)
+            l2box = i2.getstrlen(arg1, self, mode)
         if l2box:
             l2info = self.getintbound(l2box)
             if l2info.is_constant():
@@ -822,12 +820,14 @@
         return False, None
 
     def opt_call_stroruni_STR_CMP(self, op, mode):
-        i1 = self.getptrinfo(op.getarg(1))
-        i2 = self.getptrinfo(op.getarg(2))
+        arg1 = self.get_box_replacement(op.getarg(1))
+        arg2 = self.get_box_replacement(op.getarg(2))
+        i1 = self.getptrinfo(arg1)
+        i2 = self.getptrinfo(arg2)
         if not i1 or not i2:
             return False, None
-        l1box = i1.getstrlen(None, self, mode, False)
-        l2box = i2.getstrlen(None, self, mode, False)
+        l1box = i1.getstrlen(arg1, self, mode)
+        l2box = i2.getstrlen(arg2, self, mode)
         if (l1box is not None and l2box is not None and
             isinstance(l1box, ConstInt) and
             isinstance(l2box, ConstInt) and
diff --git a/rpython/rlib/rvmprof/src/vmprof_main.h b/rpython/rlib/rvmprof/src/vmprof_main.h
--- a/rpython/rlib/rvmprof/src/vmprof_main.h
+++ b/rpython/rlib/rvmprof/src/vmprof_main.h
@@ -197,15 +197,30 @@
     return 0;
 }
 
+static int itimer_which = ITIMER_PROF;
+
 static int install_sigprof_timer(void)
 {
     struct itimerval timer;
     timer.it_interval.tv_sec = 0;
     timer.it_interval.tv_usec = profile_interval_usec;
     timer.it_value = timer.it_interval;
-    if (setitimer(ITIMER_PROF, &timer, NULL) != 0)
-        return -1;
-    return 0;
+    if (setitimer(itimer_which, &timer, NULL) == 0)
+        return 0;   /* normal path */
+
+    if (errno == EINVAL) {
+        /* on WSL, only ITIMER_REAL is supported */
+        if (setitimer(ITIMER_REAL, &timer, NULL) == 0) {
+            fprintf(stderr, "warning: setitimer(): ITIMER_PROF not "
+                            "available, using ITIMER_REAL instead. "
+                            "Multithreaded programs and programs "
+                            "doing a lot of I/O won't give correct "
+                            "results.\n");
+            itimer_which = ITIMER_REAL;
+            return 0;
+        }
+    }
+    return -1;
 }
 
 static int remove_sigprof_timer(void) {
@@ -214,7 +229,7 @@
     timer.it_interval.tv_usec = 0;
     timer.it_value.tv_sec = 0;
     timer.it_value.tv_usec = 0;
-    if (setitimer(ITIMER_PROF, &timer, NULL) != 0)
+    if (setitimer(itimer_which, &timer, NULL) != 0)
         return -1;
     return 0;
 }
diff --git a/rpython/translator/c/test/test_newgc.py b/rpython/translator/c/test/test_newgc.py
--- a/rpython/translator/c/test/test_newgc.py
+++ b/rpython/translator/c/test/test_newgc.py
@@ -1730,7 +1730,11 @@
                      (ulimitv, ' '.join(args),)]
             popen = subprocess.Popen(args1, stderr=subprocess.PIPE)
             _, child_stderr = popen.communicate()
-            assert popen.wait() == 134     # aborted
+            assert popen.wait() in (-6, 134)     # aborted
+            # note: it seems that on some systems we get 134 and on
+            # others we get -6.  Bash is supposed to translate the
+            # SIGABRT (signal 6) from the subprocess into the exit 
+            # code 128+6, but I guess it may not always do so.
             assert 'out of memory:' in child_stderr
             return '42'
         #


More information about the pypy-commit mailing list