Author: Armin Rigo <ar...@tunes.org>
Branch: py3.5
Changeset: r88212:84f687b458a4
Date: 2016-11-08 13:36 +0100
http://bitbucket.org/pypy/pypy/changeset/84f687b458a4/

Log:    hg merge default

diff too long, truncating to 2000 out of 11118 lines

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -44,15 +44,15 @@
   Matti Picus
   Alex Gaynor
   Philip Jenvey
+  Ronan Lamy
   Brian Kearns
-  Ronan Lamy
+  Richard Plangger
   Michael Hudson
   Manuel Jacob
   David Schneider
   Holger Krekel
   Christian Tismer
   Hakan Ardo
-  Richard Plangger
   Benjamin Peterson
   Anders Chrigstrom
   Eric van Riet Paap
@@ -68,8 +68,8 @@
   Niklaus Haldimann
   Camillo Bruni
   Laura Creighton
+  Romain Guillebert
   Toon Verwaest
-  Romain Guillebert
   Leonardo Santagada
   Seo Sanghyeon
   Ronny Pfannschmidt
@@ -89,7 +89,9 @@
   Ludovic Aubry
   Jacob Hallen
   Jason Creighton
+  Mark Young
   Alex Martelli
+  Spenser Bauman
   Michal Bendowski
   stian
   Jan de Mooij
@@ -100,20 +102,21 @@
   Stefan Schwarzer
   Valentino Volonghi
   Tomek Meka
+  Stefano Rivera
   Patrick Maupin
+  Devin Jeanpierre
   Bob Ippolito
   Bruno Gola
   David Malcolm
   Jean-Paul Calderone
-  Mark Young
   Timo Paulssen
+  Edd Barrett
   Squeaky
-  Devin Jeanpierre
   Marius Gedminas
   Alexandre Fayolle
   Simon Burton
-  Stefano Rivera
   Martin Matusiak
+  Nicolas Truessel
   Konstantin Lopuhin
   Wenzhu Man
   John Witulski
@@ -123,14 +126,12 @@
   Dario Bertini
   Mark Pearse
   Simon Cross
-  Edd Barrett
+  Jeremy Thurgood
   Andreas St&#252;hrk
   Tobias Pape
   Jean-Philippe St. Pierre
   Guido van Rossum
   Pavel Vinogradov
-  Spenser Bauman
-  Jeremy Thurgood
   Pawe&#322; Piotr Przeradowski
   Paul deGrandis
   Ilya Osadchiy
@@ -141,7 +142,6 @@
   tav
   Taavi Burns
   Georg Brandl
-  Nicolas Truessel
   Bert Freudenberg
   Stian Andreassen
   Wanja Saatkamp
@@ -156,19 +156,20 @@
   Preston Timmons
   David Ripton
   Jeff Terrace
+  Tim Felgentreff
   Dusty Phillips
   Lukas Renggli
   Guenter Jantzen
   William Leslie
   Ned Batchelder
-  Tim Felgentreff
   Anton Gulenko
   Amit Regmi
   Ben Young
-  Sergey Matyunin
+  Jasper Schulz
   Nicolas Chauvat
   Andrew Durdin
   Andrew Chambers
+  Sergey Matyunin
   Michael Schneider
   Nicholas Riley
   Jason Chu
@@ -184,16 +185,16 @@
   Jared Grubb
   Karl Bartel
   Wouter van Heyst
-  Sebastian Pawlu&#347;
   Brian Dorsey
   Victor Stinner
   Andrews Medina
+  Sebastian Pawlu&#347;
   Stuart Williams
-  Jasper Schulz
-  Christian Hudon
+  Daniel Patrick
+  Aaron Iles
   Toby Watson
   Antoine Pitrou
-  Aaron Iles
+  Christian Hudon
   Michael Cheng
   Justas Sadzevicius
   Gasper Zejn
@@ -201,8 +202,8 @@
   Stanislaw Halik
   Mikael Sch&#246;nenberg
   Berkin Ilbeyi
+  Faye Zhao
   Elmo M&#228;ntynen
-  Faye Zhao
   Jonathan David Riehl
   Anders Qvist
   Corbin Simpson
@@ -211,11 +212,12 @@
   Alex Perry
   Vaibhav Sood
   Alan McIntyre
+  Reuben Cummings
   Alexander Sedov
   p_ziesch...@yahoo.de
   Attila Gobi
-  Jasper.Schulz
   Christopher Pope
+  Aaron Gallagher
   Florin Papa
   Christian Tismer 
   Marc Abramowitz
@@ -232,7 +234,6 @@
   Gabriel
   Lukas Vacek
   Kunal Grover
-  Aaron Gallagher
   Andrew Dalke
   Sylvain Thenault
   Jakub Stasiak
@@ -255,6 +256,7 @@
   Philipp Rustemeuer
   Henrik Vendelbo
   Richard Lancaster
+  Yasir Suhail
   Dan Buch
   Miguel de Val Borro
   Artur Lisiecki
@@ -267,6 +269,7 @@
   Catalin Gabriel Manciu
   Tomo Cocoa
   Kim Jin Su
+  rafalgalczyn...@gmail.com
   Toni Mattis
   Amber Brown
   Lucas Stadler
@@ -294,9 +297,7 @@
   Michael Hudson-Doyle
   Anders Sigfridsson
   Nikolay Zinov
-  Yasir Suhail
   Jason Michalski
-  rafalgalczyn...@gmail.com
   Floris Bruynooghe
   Laurens Van Houtven
   Akira Li
@@ -310,9 +311,10 @@
   James Lan
   Volodymyr Vladymyrov
   shoma hosaka
-  Daniel Neuh&#228;user
   Ben Mather
   Niclas Olofsson
+  Matthew Miller
+  Rodrigo Ara&#250;jo
   halgari
   Boglarka Vezer
   Chris Pressey
@@ -322,8 +324,9 @@
   Dinu Gherman
   Chris Lambacher
   coolbutusel...@gmail.com
+  Daniil Yarancev
   Jim Baker
-  Rodrigo Ara&#250;jo
+  Dan Crosta
   Nikolaos-Digenis Karagiannis
   James Robert
   Armin Ronacher
@@ -337,32 +340,31 @@
   Tomer Chachamu
   Christopher Groskopf
   Asmo Soinio
-  Stefan Marr
   jiaaro
   Mads Kiilerich
-  opassembler.py
   Antony Lee
   Jason Madden
+  Daniel Neuh&#65533;user
+  reub...@gmail.com
   Yaroslav Fedevych
   Jim Hunziker
   Markus Unterwaditzer
   Even Wiik Thomassen
   jbs
   squeaky
-  Zearin
   soareschen
   Jonas Pfannschmidt
   Kurt Griffiths
   Mike Bayer
-  Matthew Miller
+  Stefan Marr
   Flavio Percoco
   Kristoffer Kleine
-  yasirs
   Michael Chermside
   Anna Ravencroft
   pizi
+  remarkablerocket
   Andrey Churin
-  Dan Crosta
+  Zearin
   Eli Stevens
   Tobias Diaz
   Julien Phalip
diff --git a/lib-python/2.7/ctypes/test/test_bitfields.py 
b/lib-python/2.7/ctypes/test/test_bitfields.py
--- a/lib-python/2.7/ctypes/test/test_bitfields.py
+++ b/lib-python/2.7/ctypes/test/test_bitfields.py
@@ -2,6 +2,7 @@
 from ctypes.test import need_symbol, xfail
 import unittest
 import os
+import sys
 
 import ctypes
 import _ctypes_test
@@ -279,7 +280,6 @@
         x.c = 2
         self.assertEqual(b.tostring(), b'\xef\xcd\xab\x21')
 
-    @xfail
     @need_symbol('c_uint32')
     def test_uint32_swap_big_endian(self):
         # Issue #23319
@@ -295,5 +295,11 @@
         x.c = 2
         self.assertEqual(b.tostring(), b'\xab\xcd\xef\x12')
 
+    # see issue #1213, on big endian it fails for the little endian case
+    if sys.byteorder == 'little':
+        test_uint32_swap_big_endian = xfail(test_uint32_swap_big_endian)
+    elif sys.byteorder == 'big':
+        test_uint32_swap_little_endian = xfail(test_uint32_swap_little_endian)
+
 if __name__ == "__main__":
     unittest.main()
diff --git a/pypy/doc/contributor.rst b/pypy/doc/contributor.rst
--- a/pypy/doc/contributor.rst
+++ b/pypy/doc/contributor.rst
@@ -9,8 +9,8 @@
   Philip Jenvey
   Ronan Lamy
   Brian Kearns
+  Richard Plangger
   Michael Hudson
-  Richard Plangger
   Manuel Jacob
   David Schneider
   Holger Krekel
@@ -54,10 +54,10 @@
   Jason Creighton
   Mark Young
   Alex Martelli
+  Spenser Bauman
   Michal Bendowski
   stian
   Jan de Mooij
-  Spenser Bauman
   Tyler Wade
   Vincent Legoll
   Michael Foord
@@ -65,13 +65,13 @@
   Stefan Schwarzer
   Valentino Volonghi
   Tomek Meka
+  Stefano Rivera
   Patrick Maupin
   Devin Jeanpierre
   Bob Ippolito
   Bruno Gola
   David Malcolm
   Jean-Paul Calderone
-  Stefano Rivera
   Timo Paulssen
   Edd Barrett
   Squeaky
@@ -89,12 +89,12 @@
   Dario Bertini
   Mark Pearse
   Simon Cross
+  Jeremy Thurgood
   Andreas St&#252;hrk
   Tobias Pape
   Jean-Philippe St. Pierre
   Guido van Rossum
   Pavel Vinogradov
-  Jeremy Thurgood
   Pawe&#322; Piotr Przeradowski
   Paul deGrandis
   Ilya Osadchiy
@@ -128,10 +128,11 @@
   Anton Gulenko
   Amit Regmi
   Ben Young
-  Sergey Matyunin
+  Jasper Schulz
   Nicolas Chauvat
   Andrew Durdin
   Andrew Chambers
+  Sergey Matyunin
   Michael Schneider
   Nicholas Riley
   Jason Chu
@@ -147,17 +148,16 @@
   Jared Grubb
   Karl Bartel
   Wouter van Heyst
-  Sebastian Pawlu&#347;
   Brian Dorsey
   Victor Stinner
   Andrews Medina
+  Sebastian Pawlu&#347;
   Stuart Williams
   Daniel Patrick
-  Jasper Schulz
-  Christian Hudon
+  Aaron Iles
   Toby Watson
   Antoine Pitrou
-  Aaron Iles
+  Christian Hudon
   Michael Cheng
   Justas Sadzevicius
   Gasper Zejn
@@ -165,8 +165,8 @@
   Stanislaw Halik
   Mikael Sch&#246;nenberg
   Berkin Ilbeyi
+  Faye Zhao
   Elmo M&#228;ntynen
-  Faye Zhao
   Jonathan David Riehl
   Anders Qvist
   Corbin Simpson
@@ -175,11 +175,12 @@
   Alex Perry
   Vaibhav Sood
   Alan McIntyre
+  Reuben Cummings
   Alexander Sedov
   p_ziesch...@yahoo.de
   Attila Gobi
-  Jasper.Schulz
   Christopher Pope
+  Aaron Gallagher
   Florin Papa
   Christian Tismer 
   Marc Abramowitz
@@ -196,7 +197,6 @@
   Gabriel
   Lukas Vacek
   Kunal Grover
-  Aaron Gallagher
   Andrew Dalke
   Sylvain Thenault
   Jakub Stasiak
@@ -219,6 +219,7 @@
   Philipp Rustemeuer
   Henrik Vendelbo
   Richard Lancaster
+  Yasir Suhail
   Dan Buch
   Miguel de Val Borro
   Artur Lisiecki
@@ -231,6 +232,7 @@
   Catalin Gabriel Manciu
   Tomo Cocoa
   Kim Jin Su
+  rafalgalczyn...@gmail.com
   Toni Mattis
   Amber Brown
   Lucas Stadler
@@ -258,9 +260,7 @@
   Michael Hudson-Doyle
   Anders Sigfridsson
   Nikolay Zinov
-  Yasir Suhail
   Jason Michalski
-  rafalgalczyn...@gmail.com
   Floris Bruynooghe
   Laurens Van Houtven
   Akira Li
@@ -274,10 +274,10 @@
   James Lan
   Volodymyr Vladymyrov
   shoma hosaka
-  Daniel Neuh&#228;user
   Ben Mather
   Niclas Olofsson
-  "Aaron Gallagher
+  Matthew Miller
+  Rodrigo Ara&#250;jo
   halgari
   Boglarka Vezer
   Chris Pressey
@@ -287,8 +287,9 @@
   Dinu Gherman
   Chris Lambacher
   coolbutusel...@gmail.com
+  Daniil Yarancev
   Jim Baker
-  Rodrigo Ara&#250;jo
+  Dan Crosta
   Nikolaos-Digenis Karagiannis
   James Robert
   Armin Ronacher
@@ -302,13 +303,11 @@
   Tomer Chachamu
   Christopher Groskopf
   Asmo Soinio
-  Stefan Marr
   jiaaro
   Mads Kiilerich
-  opassembler.py
-  JohnDoe
   Antony Lee
   Jason Madden
+  Daniel Neuh&#65533;user
   reub...@gmail.com
   Yaroslav Fedevych
   Jim Hunziker
@@ -316,25 +315,24 @@
   Even Wiik Thomassen
   jbs
   squeaky
-  Zearin
   soareschen
   Jonas Pfannschmidt
   Kurt Griffiths
   Mike Bayer
-  Matthew Miller
+  Stefan Marr
   Flavio Percoco
   Kristoffer Kleine
-  yasirs
   Michael Chermside
   Anna Ravencroft
   pizi
   remarkablerocket
   Andrey Churin
-  Dan Crosta
+  Zearin
   Eli Stevens
   Tobias Diaz
   Julien Phalip
   Roman Podoliaka
   Dan Loewenherz
   werat
-  hgattic
+
+
diff --git a/pypy/doc/how-to-release.rst b/pypy/doc/how-to-release.rst
--- a/pypy/doc/how-to-release.rst
+++ b/pypy/doc/how-to-release.rst
@@ -1,4 +1,4 @@
-The PyPy Release Process
+PyPy's Release Process
 ========================
 
 Release Policy
@@ -39,41 +39,60 @@
   Some of the next updates may be done before or after branching; make
   sure things are ported back to the trunk and to the branch as
   necessary.
-* update pypy/doc/contributor.rst (and possibly LICENSE)
-  pypy/doc/tool/makecontributor.py generates the list of contributors
-* rename pypy/doc/whatsnew_head.rst to whatsnew_VERSION.rst
-  create a fresh whatsnew_head.rst after the release
-  and add the new file to  pypy/doc/index-of-whatsnew.rst
-* go to pypy/tool/release and run
-  ``force-builds.py <release branch>``
-  The following JIT binaries should be built, however, we need more buildbots
-  windows, linux-32, linux-64, osx64, armhf-raring, armhf-raspberrian, armel,
-  freebsd64 
 
-* wait for builds to complete, make sure there are no failures
-* download the builds, repackage binaries. Tag the release version
-  and download and repackage source from bitbucket. You may find it
-  convenient to use the ``repackage.sh`` script in pypy/tool/release to do 
this. 
+* Update and write documentation
 
-  Otherwise repackage and upload source "-src.tar.bz2" to bitbucket
-  and to cobra, as some packagers prefer a clearly labeled source package
-  ( download e.g.  https://bitbucket.org/pypy/pypy/get/release-2.5.x.tar.bz2,
-  unpack, rename the top-level directory to "pypy-2.5.0-src", repack, and 
upload)
+  * update pypy/doc/contributor.rst (and possibly LICENSE)
+    pypy/doc/tool/makecontributor.py generates the list of contributors
 
-* Upload binaries to https://bitbucket.org/pypy/pypy/downloads
+  * rename pypy/doc/whatsnew_head.rst to whatsnew_VERSION.rst
+    create a fresh whatsnew_head.rst after the release
+    and add the new file to  pypy/doc/index-of-whatsnew.rst
 
-* write release announcement pypy/doc/release-x.y(.z).txt
+  * write release announcement pypy/doc/release-VERSION.rst
+    The release announcement should contain a direct link to the download page
 
-  The release announcement should contain a direct link to the download page
+  * Add the new files to  pypy/doc/index-of-{whatsnew,release-notes}.rst
 
-* Add the new files to  pypy/doc/index-of-{whatsnew,release-notes}.rst
+* Build and upload the release tar-balls
 
-* update pypy.org (under extradoc/pypy.org), rebuild and commit
+  * go to pypy/tool/release and run
+    ``force-builds.py <release branch>``
+    The following JIT binaries should be built, however, we need more buildbots
+    windows, linux-32, linux-64, osx64, armhf-raring, armhf-raspberrian, armel,
+    freebsd64 
 
-* post announcement on morepypy.blogspot.com
-* send announcements to twitter.com, pypy-dev, python-list,
-  python-announce, python-dev ...
+  * wait for builds to complete, make sure there are no failures
 
-* add a tag on the pypy/jitviewer repo that corresponds to pypy release
-* add a tag on the codespeed web site that corresponds to pypy release
-* revise versioning at https://readthedocs.org/projects/pypy
+  * send out a mailing list message asking for people to test before uploading
+    to prevent having to upload more than once
+
+  * add a tag on the pypy/jitviewer repo that corresponds to pypy release, so
+    that the source tarball can be produced in the next steps
+
+  * download the builds, repackage binaries. Tag the release version
+    and download and repackage source from bitbucket. You may find it
+    convenient to use the ``repackage.sh`` script in pypy/tool/release to do 
this. 
+
+    Otherwise repackage and upload source "-src.tar.bz2" to bitbucket
+    and to cobra, as some packagers prefer a clearly labeled source package
+    ( download e.g.  https://bitbucket.org/pypy/pypy/get/release-2.5.x.tar.bz2,
+    unpack, rename the top-level directory to "pypy-2.5.0-src", repack, and 
upload)
+
+  * Upload binaries to https://bitbucket.org/pypy/pypy/downloads
+
+* Send out a mailing list message asking for last-minute comments and testing
+
+* RELEASE !  
+
+  * update pypy.org (under extradoc/pypy.org), rebuild and commit, using the
+    hashes produced from the ``repackage.sh`` script or by hand
+
+  * post announcement on morepypy.blogspot.com
+  * send announcements to twitter.com, pypy-dev, python-list,
+    python-announce, python-dev ...
+
+* If all is OK, document the released version
+
+  * add a tag on the codespeed web site that corresponds to pypy release
+  * revise versioning at https://readthedocs.org/projects/pypy
diff --git a/pypy/doc/index-of-release-notes.rst 
b/pypy/doc/index-of-release-notes.rst
--- a/pypy/doc/index-of-release-notes.rst
+++ b/pypy/doc/index-of-release-notes.rst
@@ -6,6 +6,7 @@
 
 .. toctree::
 
+   release-pypy2.7-v5.6.0.rst
    release-pypy2.7-v5.4.1.rst
    release-pypy2.7-v5.4.0.rst
    release-pypy2.7-v5.3.1.rst
diff --git a/pypy/doc/index-of-whatsnew.rst b/pypy/doc/index-of-whatsnew.rst
--- a/pypy/doc/index-of-whatsnew.rst
+++ b/pypy/doc/index-of-whatsnew.rst
@@ -7,6 +7,7 @@
 .. toctree::
 
    whatsnew-head.rst
+   whatsnew-pypy2-5.6.0.rst
    whatsnew-pypy2-5.4.0.rst
    whatsnew-pypy2-5.3.1.rst
    whatsnew-pypy2-5.3.0.rst
diff --git a/pypy/doc/release-pypy2.7-v5.6.0.rst 
b/pypy/doc/release-pypy2.7-v5.6.0.rst
--- a/pypy/doc/release-pypy2.7-v5.6.0.rst
+++ b/pypy/doc/release-pypy2.7-v5.6.0.rst
@@ -6,7 +6,7 @@
 This new PyPy2.7 release includes the upstream stdlib version 2.7.12.
 
 We continue to make incremental improvements to our C-API
-compatability layer (cpyext). We pass all but a few of the tests in the
+compatibility layer (cpyext). We pass all but a few of the tests in the
 upstream numpy `test suite`_. 
 
 Work proceeds at a good pace on the PyPy3.5
@@ -16,10 +16,11 @@
 We changed ``timeit`` to now report average +- standard deviation, which is
 better than the misleading minimum value reported in CPython.
 
-We now support building PyPy with OpenSSL 1.1 in our built-in _sll module, as
+We now support building PyPy with OpenSSL 1.1 in our built-in _ssl module, as
 well as maintaining support for previous versions.
 
-XXX
+CFFI_ has been updated to 1.9, improving an already great package for
+interfacing with C.
 
 As always, this release fixed many issues and bugs raised by the
 growing community of PyPy users. We strongly recommend updating.
@@ -38,7 +39,7 @@
 with making RPython's JIT even better.
 
 .. _`test suite`: 
https://bitbucket.org/pypy/pypy/wiki/Adventures%20in%20cpyext%20compatibility
-.. _cffi: https://cffi.readthedocs.org
+.. _CFFI: https://cffi.readthedocs.io/en/latest/whatsnew.html
 .. _grant: 
https://morepypy.blogspot.com/2016/08/pypy-gets-funding-from-mozilla-for.html
 .. _`PyPy`: http://doc.pypy.org
 .. _`RPython`: https://rpython.readthedocs.org
@@ -73,6 +74,7 @@
 =========================================================
 
 * New features
+
   * Allow tests run with `-A` to find `libm.so` even if it is a script not a
     dynamically loadable file
   * Backport fixes to rposix on windows from py3.5
@@ -81,20 +83,20 @@
   * Support more attributes on ``super``
   * Issue #2386: non-latin1 unicode keys were ignored in 
``unicode.format(**d)``
   * Restore the ability to translate with CPython
-  * Update to CFFI 1.8.4
+  * Update to CFFI 1.9.0
   * Support the new buffer protocol in cpyext and numpypy
   * Add ``rposix.sync()``
   * Support full-precision nanosecond times in os.stat()
   * Add documentation about the assembler backends to RPYthon
   * Search for the stdlibs from the libpypy shared object rather than the 
pypy-c exe,
-    changes downstream packaging requirments
+    changes downstream packaging requirements
   * Add ``try_inline``, like ``always_inline`` and ``dont_inline`` to RPython
   * Reject ``'a'.strip(buffer(' '))`` like cpython (the argument to strip must
     be ``str`` or ``unicode``)
   * Allow ``warning.warn(('something', 1), Warning)`` like on CPython
   * Refactor ``rclock`` and add some more ``CLOCK_xxx`` constants on
     relevant platforms
-  * Backport the ``'faulthandler`` module from py3.5
+  * Backport the ``faulthandler`` module from py3.5
   * Improve the error message when trying to call a method where the ``self``
     parameter is missing in the definition
   * Implement ``rposix.cpu_count``
@@ -105,6 +107,7 @@
   * Support OpenSSL version 1.1 (in addition to version 1.0)
 
 * Bug Fixes
+
   * Tweak a float comparison with 0 in `backendopt.inline` to avoid rounding 
errors
   * Fix translation of the sandbox
   * Fix for an issue where `unicode.decode('utf8', 'custom_replace')` messed up
@@ -125,6 +128,7 @@
   * ``_numpypy.add.reduce`` returns a scalar now
 
 * Performance improvements:
+
   * Improve method calls on oldstyle classes
   * Clean and refactor code for testing cpyext to allow sharing with py3.5
   * Refactor a building the map of reflected ops in ``_numpypy``
diff --git a/pypy/doc/test/test_whatsnew.py b/pypy/doc/test/test_whatsnew.py
--- a/pypy/doc/test/test_whatsnew.py
+++ b/pypy/doc/test/test_whatsnew.py
@@ -111,4 +111,4 @@
         "hg log -r %s --template '{branch}'" % startrev)
     if errcode != 0:
         py.test.skip('no Mercurial repo')
-    assert wc_branch == 'default'
+    assert wc_branch in ('default', "'default'") # sometimes the ' leaks 
(windows)
diff --git a/pypy/doc/tool/makecontributor.py b/pypy/doc/tool/makecontributor.py
--- a/pypy/doc/tool/makecontributor.py
+++ b/pypy/doc/tool/makecontributor.py
@@ -32,7 +32,7 @@
     'Niklaus Haldimann': ['nik'],
     'Alexander Schremmer': ['xoraxax'],
     'Anders Hammarquist': ['iko'],
-    'David Edelsohn': ['edelsoh', 'edelsohn'],
+    'David Edelsohn': ['edelsoh', 'edelsohn','opassembler.py'],
     'Niko Matsakis': ['niko'],
     'Jakub Gustak': ['jlg'],
     'Guido Wesdorp': ['guido'],
@@ -75,6 +75,9 @@
     'Spenser Bauman':['Spenser Andrew Bauman'],
     'Raffael Tfirst':['raffael.tfi...@gmail.com'],
     'timo':['t...@eistee.fritz.box'],
+    'Jasper Schulz':['Jasper.Schulz'],
+    'Aaron Gallagher':['"Aaron Gallagher'],
+    'Yasir Suhail':['yasirs'],
     }
 
 alias_map = {}
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
@@ -1,9 +1,9 @@
 ==========================
-What's new in PyPy2.7 5.4+
+What's new in PyPy2.7 5.6+
 ==========================
 
-.. this is a revision shortly after release-pypy2.7-v5.4
-.. startrev: 522736f816dc
+.. this is a revision shortly after release-pypy2.7-v5.6
+.. startrev: 7e9787939641
 
 .. branch: mappingproxy
 .. branch: py3k-finish_time
@@ -14,92 +14,8 @@
 .. branch: rpython-resync
 Backport rpython changes made directly on the py3k and py3.5 branches.
 
-.. branch: buffer-interface
-Implement PyObject_GetBuffer, PyMemoryView_GET_BUFFER, and handles memoryviews
-in numpypy
+.. branch: rpython-error-to-systemerror
 
-.. branch: force-virtual-state
-Improve merging of virtual states in the JIT in order to avoid jumping to the
-preamble. Accomplished by allocating virtual objects where non-virtuals are
-expected.
-
-.. branch: conditional_call_value_3
-JIT residual calls: if the called function starts with a fast-path
-like "if x.foo != 0: return x.foo", then inline the check before
-doing the CALL.  For now, string hashing is about the only case.
-
-.. branch: search-path-from-libpypy
-
-The compiled pypy now looks for its lib-python/lib_pypy path starting
-from the location of the *libpypy-c* instead of the executable. This is
-arguably more consistent, and also it is what occurs anyway if you're
-embedding pypy.  Linux distribution packagers, take note!  At a minimum,
-the ``libpypy-c.so`` must really be inside the path containing
-``lib-python`` and ``lib_pypy``.  Of course, you can put a symlink to it
-from somewhere else.  You no longer have to do the same with the
-``pypy`` executable, as long as it finds its ``libpypy-c.so`` library.
-
-.. branch: _warnings
-
-CPython allows warning.warn(('something', 1), Warning), on PyPy this
-produced a "expected a readable buffer object" error. Test and fix.
-
-.. branch: stricter-strip
-
-CPython rejects 'a'.strip(buffer(' ')); only None, str or unicode are
-allowed as arguments. Test and fix for str and unicode
-
-.. branch: faulthandler
-
-Port the 'faulthandler' module to PyPy default.  This module is standard
-in Python 3.3 but can also be installed from CPython >= 2.6 from PyPI.
-
-.. branch: test-cpyext
-
-Refactor cpyext testing to be more pypy3-friendly.
-
-.. branch: better-error-missing-self
-
-Improve the error message when the user forgot the "self" argument of a method.
-
-
-.. fb6bb835369e
-Change the ``timeit`` module: it now prints the average time and the standard
-deviation over 7 runs by default, instead of the minimum. The minimum is often
-misleading.
-
-.. branch: unrecursive-opt
-
-Make optimiseopt iterative instead of recursive so it can be reasoned about
-more easily and debugging is faster.
-
-.. branch: Tiberiumk/fix-2412-1476011166874
-.. branch: redirect-assembler-jitlog
-
-
-
-.. branch: stdlib-2.7.12
-
-Update stdlib to version 2.7.12
-
-.. branch: buffer-interface2
-
-Improve support for new buffer interface in cpyext, bf_getbuffer on built-in
-types still missing
-
-.. branch: fix-struct-unpack-Q
-
-Improve compatibility with CPython in the ``struct`` module. In particular,
-``struct.unpack`` now returns an ``int`` whenever the returned value fits,
-while previously it always returned a ``long`` for certains format codes such
-as ``Q`` (and also ``I``, ``L`` and ``q`` on 32 bit)
-
-.. branch: newinitwarn
-
-Issue warnings for stricter handling of ``__new/init__`` args (that
-become TypeErrors in python 3)
-
-.. branch: openssl-1.1
-
-PyPy can now be translated on a machine where the newer OpenSSL 1.1 is
-installed.  Thanks tumbleweed!
+Any uncaught RPython exception (from a PyPy bug) is turned into an
+app-level SystemError.  This should improve the lot of users hitting an
+uncaught RPython error.
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-pypy2-5.6.0.rst
copy from pypy/doc/whatsnew-head.rst
copy to pypy/doc/whatsnew-pypy2-5.6.0.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-pypy2-5.6.0.rst
@@ -1,6 +1,6 @@
-==========================
-What's new in PyPy2.7 5.4+
-==========================
+=========================
+What's new in PyPy2.7 5.6
+=========================
 
 .. this is a revision shortly after release-pypy2.7-v5.4
 .. startrev: 522736f816dc
@@ -87,6 +87,7 @@
 Improve support for new buffer interface in cpyext, bf_getbuffer on built-in
 types still missing
 
+
 .. branch: fix-struct-unpack-Q
 
 Improve compatibility with CPython in the ``struct`` module. In particular,
@@ -94,12 +95,19 @@
 while previously it always returned a ``long`` for certains format codes such
 as ``Q`` (and also ``I``, ``L`` and ``q`` on 32 bit)
 
+.. branch: zarch-simd-support
+
+s390x implementation for vector operations used in VecOpt
+
+.. branch: ppc-vsx-support
+
+PowerPC implementation for vector operations used in VecOpt
+
 .. branch: newinitwarn
 
-Issue warnings for stricter handling of ``__new/init__`` args (that
-become TypeErrors in python 3)
+Match CPython's stricter handling of __new/init__ arguments
 
 .. branch: openssl-1.1
 
-PyPy can now be translated on a machine where the newer OpenSSL 1.1 is
-installed.  Thanks tumbleweed!
+Support for OpenSSL version 1.1 (in addition to version 1.0).
+Tested on Linux (1.1, 1.0), on Win32, and Mac (1.0 only)
diff --git a/pypy/doc/windows.rst b/pypy/doc/windows.rst
--- a/pypy/doc/windows.rst
+++ b/pypy/doc/windows.rst
@@ -20,6 +20,22 @@
 
 .. _our downloads: http://pypy.org/download.html
 
+Installing Visual Compiler v9 (for Python 2.7)
+----------------------------------------------
+
+This compiler, while the standard one for Python 2.7, is depricated. Microsoft 
has
+made it available as the `Microsoft Visual C++ Compiler for Python 2.7`_ (the 
link
+was checked in Nov 2016). Note that the compiler suite will be installed in
+``C:\Users\<user name>\AppData\Local\Programs\Common\Microsoft\Visual C++ for 
Python``.
+Using a current version of ``setuptools`` will be able to find it there. For
+Windows 10, you must right-click the download, and under ``Properties`` ->
+``Compatibility`` mark it as ``Run run this program in comatibility mode for``
+``Previous version...``. Also, you must download and install the ``.Net 
Framework 3.5``,
+otherwise ``mt.exe`` will silently fail. Installation will begin automatically
+by running the mt.exe command by hand from a DOS window (that is how the author
+discovered the problem).
+
+.. _Microsoft Visual C++ Compiler for Python 2.7: 
https://www.microsoft.com/en-us/download/details.aspx?id=44266
 
 Translating PyPy with Visual Studio
 -----------------------------------
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -7,6 +7,7 @@
 
 from rpython.rlib import jit
 from rpython.rlib.objectmodel import we_are_translated, specialize
+from rpython.rlib import rstackovf
 
 from pypy.interpreter import debug
 
@@ -65,10 +66,14 @@
     def __str__(self):
         "NOT_RPYTHON: Convenience for tracebacks."
         s = self._w_value
-        if self.__class__ is not OperationError and s is None:
-            space = getattr(self.w_type, 'space')
-            if space is not None:
+        space = getattr(self.w_type, 'space', None)
+        if space is not None:
+            if self.__class__ is not OperationError and s is None:
                 s = self._compute_value(space)
+            try:
+                s = space.str_w(s)
+            except Exception:
+                pass
         return '[%s: %s]' % (self.w_type, s)
 
     def __repr__(self):
@@ -632,3 +637,55 @@
 def raise_import_error(space, w_msg, w_name, w_path):
     w_exc = new_import_error(space, w_msg, w_name, w_path)
     raise OperationError(space.w_ImportError, w_exc)
+
+def _convert_unexpected_exception_extra(space, e):
+    "NOT_RPYTHON"
+    if e.__class__.__name__ in (
+        'Skipped',     # list of exception class names that are ok
+        ):             # to get during ==untranslated tests== only
+        raise
+    # include the RPython-level traceback
+    exc = sys.exc_info()
+    import traceback, cStringIO
+    f = cStringIO.StringIO()
+    print >> f, "\nTraceback (interpreter-level):"
+    traceback.print_tb(exc[2], file=f)
+    return f.getvalue()
+
+@jit.dont_look_inside
+def get_converted_unexpected_exception(space, e):
+    """This is used in two places when we get an non-OperationError
+    RPython exception: from gateway.py when calling an interp-level
+    function raises; and from pyopcode.py when we're exiting the
+    interpretation of the frame with an exception.  Note that it
+    *cannot* be used in pyopcode.py: that place gets a
+    ContinueRunningNormally exception from the JIT, which must not end
+    up here!
+    """
+    try:
+        if not we_are_translated():
+            raise
+        raise e
+    except KeyboardInterrupt:
+        return OperationError(space.w_KeyboardInterrupt, space.w_None)
+    except MemoryError:
+        return OperationError(space.w_MemoryError, space.w_None)
+    except NotImplementedError:   # not on top of pypy! tests only
+        return OperationError(space.w_SystemError,
+                              space.wrap("NotImplementedError"))
+    except rstackovf.StackOverflow as e:
+        rstackovf.check_stack_overflow()
+        return oefmt(space.w_RecursionError,
+                     "maximum recursion depth exceeded")
+    except RuntimeError:   # not on top of py.py
+        return OperationError(space.w_RuntimeError, space.w_None)
+    except:
+        if we_are_translated():
+            from rpython.rlib.debug import debug_print_traceback
+            debug_print_traceback()
+            extra = '; internal traceback was dumped to stderr'
+        else:
+            extra = _convert_unexpected_exception_extra(space, e)
+        return OperationError(space.w_SystemError, space.wrap(
+            "unexpected internal exception (please report a bug): %r%s" %
+            (e, extra)))
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -23,7 +23,6 @@
     DescrMismatch)
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.function import ClassMethod, FunctionWithFixedCode
-from rpython.rlib import rstackovf
 from rpython.rlib.objectmodel import we_are_translated
 from rpython.rlib.rarithmetic import r_longlong, r_int, r_ulonglong, r_uint
 from rpython.tool.sourcetools import func_with_new_name, compile2
@@ -756,16 +755,11 @@
             if not we_are_translated():
                 raise
             raise e
-        except KeyboardInterrupt:
-            raise OperationError(space.w_KeyboardInterrupt, space.w_None)
-        except MemoryError:
-            raise OperationError(space.w_MemoryError, space.w_None)
-        except rstackovf.StackOverflow as e:
-            rstackovf.check_stack_overflow()
-            raise oefmt(space.w_RecursionError,
-                        "maximum recursion depth exceeded")
-        except RuntimeError:   # not on top of py.py
-            raise OperationError(space.w_RuntimeError, space.w_None)
+        except OperationError:
+            raise
+        except Exception as e:      # general fall-back
+            from pypy.interpreter import error
+            raise error.get_converted_unexpected_exception(space, e)
 
 # (verbose) performance hack below
 
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -1,6 +1,7 @@
 """ PyFrame class implementation with the interpreter main loop.
 """
 
+import sys
 from rpython.rlib import jit, rweakref
 from rpython.rlib.debug import make_sure_not_resized, check_nonneg
 from rpython.rlib.jit import hint
@@ -319,6 +320,12 @@
                 else:
                     w_exitvalue = self.dispatch(self.pycode, next_instr,
                                                 executioncontext)
+            except OperationError:
+                raise
+            except Exception as e:      # general fall-back
+                raise self._convert_unexpected_exception(e)
+                w_exitvalue = self.dispatch(self.pycode, next_instr,
+                                            executioncontext)
             finally:
                 executioncontext.return_trace(self, w_exitvalue)
             # it used to say self.last_exception = None
@@ -958,6 +965,14 @@
             self.locals_cells_stack_w[i] = None
         self.valuestackdepth = 0
 
+    def _convert_unexpected_exception(self, e):
+        from pypy.interpreter import error
+
+        operr = error.get_converted_unexpected_exception(self.space, e)
+        pytraceback.record_application_traceback(
+            self.space, operr, self, self.last_instr)
+        raise operr
+
 # ____________________________________________________________
 
 def get_block_class(opname):
diff --git a/pypy/interpreter/test/test_executioncontext.py 
b/pypy/interpreter/test/test_executioncontext.py
--- a/pypy/interpreter/test/test_executioncontext.py
+++ b/pypy/interpreter/test/test_executioncontext.py
@@ -1,8 +1,10 @@
 import py
 from pypy.interpreter import executioncontext
+from pypy.interpreter.error import OperationError
 
-class Finished(Exception):
-    pass
+class Finished(OperationError):
+    def __init__(self):
+        OperationError.__init__(self, "exception_class", "exception_value")
 
 
 class TestExecutionContext:
diff --git a/pypy/interpreter/test/test_gateway.py 
b/pypy/interpreter/test/test_gateway.py
--- a/pypy/interpreter/test/test_gateway.py
+++ b/pypy/interpreter/test/test_gateway.py
@@ -4,6 +4,7 @@
 from pypy.interpreter import gateway, argument
 from pypy.interpreter.gateway import ObjSpace, W_Root, WrappedDefault
 from pypy.interpreter.signature import Signature
+from pypy.interpreter.error import OperationError
 import py
 import sys
 
@@ -789,6 +790,38 @@
         w_g = space.wrap(gateway.interp2app_temp(g, doc='bar'))
         assert space.unwrap(space.getattr(w_g, space.wrap('__doc__'))) == 'bar'
 
+    def test_system_error(self):
+        class UnexpectedException(Exception):
+            pass
+        space = self.space
+        def g(space):
+            raise UnexpectedException
+        w_g = space.wrap(gateway.interp2app_temp(g))
+        e = py.test.raises(OperationError, space.appexec, [w_g], """(my_g):
+            my_g()
+        """)
+        err = str(e.value)
+        assert 'SystemError' in err
+        assert ('unexpected internal exception (please '
+                'report a bug): UnexpectedException') in err
+
+    def test_system_error_2(self):
+        class UnexpectedException(Exception):
+            pass
+        space = self.space
+        def g(space):
+            raise UnexpectedException
+        w_g = space.wrap(gateway.interp2app_temp(g))
+        w_msg = space.appexec([w_g], """(my_g):
+            try:
+                my_g()
+            except SystemError as e:
+                return str(e)
+        """)
+        err = space.str_w(w_msg)
+        assert ('unexpected internal exception (please '
+                'report a bug): UnexpectedException') in err
+
     def test_unwrap_spec_default_bytes(self):
         space = self.space
         @gateway.unwrap_spec(s='bufferstr')
diff --git a/pypy/module/__pypy__/interp_magic.py 
b/pypy/module/__pypy__/interp_magic.py
--- a/pypy/module/__pypy__/interp_magic.py
+++ b/pypy/module/__pypy__/interp_magic.py
@@ -76,7 +76,9 @@
         return space.w_None
     return space.get(w_descr, w_obj)
 
-def do_what_I_mean(space):
+def do_what_I_mean(space, w_crash=None):
+    if not space.is_none(w_crash):
+        raise ValueError    # RPython-level, uncaught
     return space.wrap(42)
 
 
diff --git a/pypy/module/__pypy__/test/test_special.py 
b/pypy/module/__pypy__/test/test_special.py
--- a/pypy/module/__pypy__/test/test_special.py
+++ b/pypy/module/__pypy__/test/test_special.py
@@ -73,6 +73,7 @@
         from __pypy__ import do_what_I_mean
         x = do_what_I_mean()
         assert x == 42
+        raises(SystemError, do_what_I_mean, 1)
 
     def test_list_strategy(self):
         from __pypy__ import strategy
diff --git a/pypy/module/_rawffi/alt/interp_funcptr.py 
b/pypy/module/_rawffi/alt/interp_funcptr.py
--- a/pypy/module/_rawffi/alt/interp_funcptr.py
+++ b/pypy/module/_rawffi/alt/interp_funcptr.py
@@ -325,6 +325,8 @@
             self.cdll = libffi.CDLL(name, mode)
         except DLOpenError as e:
             raise wrap_dlopenerror(space, e, self.name)
+        except OSError as e:
+            raise wrap_oserror(space, e)
 
     def getfunc(self, space, w_name, w_argtypes, w_restype):
         return _getfunc(space, self, w_name, w_argtypes, w_restype)
@@ -339,6 +341,9 @@
                         "No symbol %s found in library %s", name, self.name)
         return space.wrap(address_as_uint)
 
+    def getidentifier(self, space):
+        return space.wrap(self.cdll.getidentifier())
+
 @unwrap_spec(name='str_or_None', mode=int)
 def descr_new_cdll(space, w_type, name, mode=-1):
     return space.wrap(W_CDLL(space, name, mode))
@@ -349,6 +354,8 @@
     __new__     = interp2app(descr_new_cdll),
     getfunc     = interp2app(W_CDLL.getfunc),
     getaddressindll = interp2app(W_CDLL.getaddressindll),
+    __int__     = interp2app(W_CDLL.getidentifier),
+    __long__    = interp2app(W_CDLL.getidentifier),
     )
 
 class W_WinDLL(W_CDLL):
@@ -366,13 +373,11 @@
     __new__     = interp2app(descr_new_windll),
     getfunc     = interp2app(W_WinDLL.getfunc),
     getaddressindll = interp2app(W_WinDLL.getaddressindll),
+    __int__     = interp2app(W_CDLL.getidentifier),
+    __long__    = interp2app(W_CDLL.getidentifier),
     )
 
 # ========================================================================
 
 def get_libc(space):
-    try:
-        return space.wrap(W_CDLL(space, get_libc_name(), -1))
-    except OSError as e:
-        raise wrap_oserror(space, e)
-
+    return space.wrap(W_CDLL(space, get_libc_name(), -1))
diff --git a/pypy/module/_rawffi/alt/test/test_funcptr.py 
b/pypy/module/_rawffi/alt/test/test_funcptr.py
--- a/pypy/module/_rawffi/alt/test/test_funcptr.py
+++ b/pypy/module/_rawffi/alt/test/test_funcptr.py
@@ -645,3 +645,21 @@
         f_name = libfoo.getfunc('AAA_first_ordinal_function', [], types.sint)
         f_ordinal = libfoo.getfunc(1, [], types.sint)
         assert f_name.getaddr() == f_ordinal.getaddr()
+
+    def test_cdll_as_integer(self):
+        import _rawffi
+        from _rawffi.alt import CDLL
+        libfoo = CDLL(self.libfoo_name)
+        A = _rawffi.Array('i')
+        a = A(1, autofree=True)
+        a[0] = libfoo      # should cast libfoo to int/long automatically
+
+    def test_windll_as_integer(self):
+        if not self.iswin32:
+            skip("windows specific")
+        import _rawffi
+        from _rawffi.alt import WinDLL
+        libm = WinDLL(self.libm_name)
+        A = _rawffi.Array('i')
+        a = A(1, autofree=True)
+        a[0] = libm        # should cast libm to int/long automatically
diff --git a/pypy/module/_rawffi/interp_rawffi.py 
b/pypy/module/_rawffi/interp_rawffi.py
--- a/pypy/module/_rawffi/interp_rawffi.py
+++ b/pypy/module/_rawffi/interp_rawffi.py
@@ -231,14 +231,17 @@
             raise oefmt(space.w_ValueError, "Cannot find symbol %s", name)
         return space.wrap(address_as_uint)
 
+def open_cdll(space, name):
+    try:
+        return CDLL(name)
+    except DLOpenError as e:
+        raise wrap_dlopenerror(space, e, name or "<None>")
+    except OSError as e:
+        raise wrap_oserror(space, e)
+
 @unwrap_spec(name='str_or_None')
 def descr_new_cdll(space, w_type, name):
-    try:
-        cdll = CDLL(name)
-    except DLOpenError as e:
-        raise wrap_dlopenerror(space, e, name)
-    except OSError as e:
-        raise wrap_oserror(space, e)
+    cdll = open_cdll(space, name)
     return space.wrap(W_CDLL(space, name, cdll))
 
 W_CDLL.typedef = TypeDef(
@@ -623,10 +626,7 @@
 
 def get_libc(space):
     name = get_libc_name()
-    try:
-        cdll = CDLL(name)
-    except OSError as e:
-        raise wrap_oserror(space, e)
+    cdll = open_cdll(space, name)
     return space.wrap(W_CDLL(space, name, cdll))
 
 def get_errno(space):
diff --git a/pypy/module/_vmprof/test/test__vmprof.py 
b/pypy/module/_vmprof/test/test__vmprof.py
--- a/pypy/module/_vmprof/test/test__vmprof.py
+++ b/pypy/module/_vmprof/test/test__vmprof.py
@@ -1,4 +1,3 @@
-
 from rpython.tool.udir import udir
 from pypy.tool.pytest.objspace import gettestobjspace
 
diff --git a/pypy/module/cpyext/test/test_eval.py 
b/pypy/module/cpyext/test/test_eval.py
--- a/pypy/module/cpyext/test/test_eval.py
+++ b/pypy/module/cpyext/test/test_eval.py
@@ -3,7 +3,8 @@
 from pypy.module.cpyext.test.test_api import BaseApiTest
 from pypy.module.cpyext.eval import (
     Py_single_input, Py_file_input, Py_eval_input, PyCompilerFlags)
-from pypy.module.cpyext.api import c_fopen, c_fclose, c_fileno, Py_ssize_tP
+from pypy.module.cpyext.api import (c_fopen, c_fclose, c_fileno, 
+                Py_ssize_tP, is_valid_fd)
 from pypy.interpreter.gateway import interp2app
 from pypy.interpreter.astcompiler import consts
 from rpython.tool.udir import udir
@@ -142,7 +143,8 @@
         fp = c_fopen(str(filepath), "rb")
         os.close(c_fileno(fp))
         api.PyRun_File(fp, filename, Py_file_input, w_globals, w_locals)
-        c_fclose(fp)
+        if is_valid_fd(c_fileno(fp)):
+            c_fclose(fp)
         assert api.PyErr_Occurred() is space.w_IOError
         api.PyErr_Clear()
 
diff --git a/pypy/module/faulthandler/test/test_faulthander.py 
b/pypy/module/faulthandler/test/test_faulthander.py
--- a/pypy/module/faulthandler/test/test_faulthander.py
+++ b/pypy/module/faulthandler/test/test_faulthander.py
@@ -1,4 +1,3 @@
-
 class AppTestFaultHandler:
     spaceconfig = {
         "usemodules": ["faulthandler", "_vmprof"]
diff --git a/pypy/module/gc/test/test_app_referents.py 
b/pypy/module/gc/test/test_app_referents.py
--- a/pypy/module/gc/test/test_app_referents.py
+++ b/pypy/module/gc/test/test_app_referents.py
@@ -4,12 +4,13 @@
 
 def test_interface_to_dump_rpy_heap_str(space):
     filename = str(udir.join('dump_rpy_heap.str'))
-    try:
-        space.appexec([space.wrap(filename)], """(filename):
-            import gc
-            gc.dump_rpy_heap(filename)""")
-    except NotImplementedError:
-        pass
+    space.appexec([space.wrap(filename)], """(filename):
+        import gc
+        try:
+            gc.dump_rpy_heap(filename)
+        except SystemError:
+            pass
+    """)
     assert os.path.exists(filename)
 
 def test_interface_to_dump_rpy_heap_file(space):
@@ -20,20 +21,22 @@
             f.write(b'X')
             return f""")
     assert os.path.getsize(filename) == 0   # the 'X' was not flushed yet
-    try:
-        space.appexec([w_f], """(f):
-            import gc
-            gc.dump_rpy_heap(f)""")
-    except NotImplementedError:
-        pass
+    space.appexec([w_f], """(f):
+        import gc
+        try:
+            gc.dump_rpy_heap(f)
+        except SystemError:
+            pass
+    """)
     assert os.path.getsize(filename) == 1   # the 'X' was flushed here
 
 def test_interface_to_dump_rpy_heap_fd(space):
     filename = str(udir.join('dump_rpy_heap.fd'))
     f = open(filename, 'wb')
-    try:
-        space.appexec([space.wrap(f.fileno())], """(fd):
-            import gc
-            gc.dump_rpy_heap(fd)""")
-    except NotImplementedError:
-        pass
+    space.appexec([space.wrap(f.fileno())], """(fd):
+        import gc
+        try:
+            gc.dump_rpy_heap(fd)
+        except SystemError:
+            pass
+    """)
diff --git a/pypy/module/micronumpy/test/test_zjit.py 
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -16,7 +16,7 @@
 from rpython.jit.backend.detect_cpu import getcpuclass
 
 CPU = getcpuclass()
-if not CPU.vector_extension:
+if not CPU.vector_ext:
     py.test.skip("this cpu %s has no implemented vector backend" % CPU)
 
 def get_profiler():
@@ -29,7 +29,7 @@
     interp = None
 
     def setup_method(self, method):
-        if not self.CPUClass.vector_extension:
+        if not self.CPUClass.vector_ext:
             py.test.skip("needs vector extension to run (for now)")
 
     def assert_float_equal(self, f1, f2, delta=0.0001):
@@ -418,9 +418,7 @@
     def test_sum_float_to_int16(self):
         result = self.run("sum_float_to_int16")
         assert result == sum(range(30))
-        # one can argue that this is not desired,
-        # but unpacking exactly hits savings = 0
-        self.check_vectorized(1, 1)
+
     def define_sum_float_to_int32():
         return """
         a = |30|
@@ -429,7 +427,6 @@
     def test_sum_float_to_int32(self):
         result = self.run("sum_float_to_int32")
         assert result == sum(range(30))
-        self.check_vectorized(1, 1)
 
     def define_sum_float_to_float32():
         return """
diff --git a/pypy/module/posix/test/test_posix2.py 
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -1009,7 +1009,8 @@
             pid1, status1 = os.waitpid(pid, 0)
             assert pid1 == pid
             assert os.WIFEXITED(status1)
-            assert os.WEXITSTATUS(status1) == myprio + 3
+            expected = min(myprio + 3, 19)
+            assert os.WEXITSTATUS(status1) == expected
 
     if hasattr(os, 'symlink'):
         def test_symlink(self):
diff --git a/pypy/module/pypyjit/test_pypy_c/test_ffi.py 
b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
--- a/pypy/module/pypyjit/test_pypy_c/test_ffi.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
@@ -418,7 +418,7 @@
         guard_no_exception(descr=...)
         i112 = int_signext(i160, 2)
         setfield_gc(p167, ConstPtr(ptr85), descr=<FieldP 
pypy.module._cffi_backend.cdataobj.W_CData.inst_ctype .+>)
-        setfield_gc(p167, -1, descr=<FieldS 
pypy.module._cffi_backend.cdataobj.W_CDataNewOwning.inst_length .+>)
+        setfield_gc(p167, -1, descr=<FieldS 
pypy.module._cffi_backend.cdataobj.W_CDataNewOwning.inst_allocated_length .+>)
         i114 = int_ne(i160, i112)
         guard_false(i114, descr=...)
         --TICK--
diff --git a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py 
b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
--- a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
@@ -3,23 +3,35 @@
 from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
 from rpython.rlib.rawstorage import misaligned_is_fine
 
+def no_vector_backend():
+    import platform
+    if platform.machine().startswith('x86'):
+        from rpython.jit.backend.x86.detect_feature import detect_sse4_2
+        return not detect_sse4_2()
+    if platform.machine().startswith('ppc'):
+        from rpython.jit.backend.ppc.detect_feature import detect_vsx
+        return not detect_vsx()
+    if platform.machine() == "s390x":
+        from rpython.jit.backend.zarch.detect_feature import detect_simd_z
+        return not detect_simd_z()
+    return True
 
 class TestMicroNumPy(BaseTestPyPyC):
 
     arith_comb = [('+','float','float', 4*3427,   3427, 1.0,3.0),
-             ('+','float','int',   9*7843,   7843, 4.0,5.0),
-             ('+','int','float',   8*2571,   2571, 9.0,-1.0),
-             ('+','float','int',   -18*2653,   2653, 4.0,-22.0),
-             ('+','int','int',     -1*1499,   1499, 24.0,-25.0),
-             ('-','float','float', -2*5523,  5523, 1.0,3.0),
-             ('*','float','float', 3*2999,   2999, 1.0,3.0),
-             ('/','float','float', 3*7632,   7632, 3.0,1.0),
-             ('/','float','float', 1.5*7632, 7632, 3.0,2.0),
-             ('&','int','int',     0,        1500, 1,0),
-             ('&','int','int',     1500,     1500, 1,1),
-             ('|','int','int',     1500,     1500, 0,1),
-             ('|','int','int',     0,        1500, 0,0),
-            ]
+                  ('+','float','int',   9*7843,   7843, 4.0,5.0),
+                  ('+','int','float',   8*2571,   2571, 9.0,-1.0),
+                  ('+','float','int',   -18*2653,   2653, 4.0,-22.0),
+                  ('+','int','int',     -1*1499,   1499, 24.0,-25.0),
+                  ('-','float','float', -2*5523,  5523, 1.0,3.0),
+                  ('*','float','float', 3*2999,   2999, 1.0,3.0),
+                  ('/','float','float', 3*7632,   7632, 3.0,1.0),
+                  ('/','float','float', 1.5*7632, 7632, 3.0,2.0),
+                  ('&','int','int',     0,        1500, 1,0),
+                  ('&','int','int',     1500,     1500, 1,1),
+                  ('|','int','int',     1500,     1500, 0,1),
+                  ('|','int','int',     0,        1500, 0,0),
+                 ]
     type_permuated = []
     types = { 'int': ['int32','int64','int8','int16'],
               'float': ['float32', 'float64']
@@ -36,6 +48,7 @@
                 type_permuated.append(t)
 
     @py.test.mark.parametrize("op,adtype,bdtype,result,count,a,b", 
type_permuated)
+    @py.test.mark.skipif('no_vector_backend()')
     def test_vector_call2(self, op, adtype, bdtype, result, count, a, b):
         source = """
         def main():
@@ -51,6 +64,13 @@
         log = self.run(main, [], vec=0)
         assert log.result == vlog.result
         assert log.result == result
+        assert log.jit_summary.vecopt_tried == 0
+        assert log.jit_summary.vecopt_success == 0
+        assert vlog.jit_summary.vecopt_tried > 0
+        if adtype in ('int64','float64') and bdtype in ('int64','float64'):
+            assert vlog.jit_summary.vecopt_success > 0
+        else:
+            assert vlog.jit_summary.vecopt_success >= 0
 
 
     arith_comb = [
@@ -58,7 +78,7 @@
         ('sum','float', 2581, 2581, 1),
         ('prod','float', 1, 3178, 1),
         ('prod','int', 1, 3178, 1),
-        ('any','int', 1, 1239, 1),
+        ('any','int', 1, 2239, 1),
         ('any','int', 0, 4912, 0),
         ('all','int', 0, 3420, 0),
         ('all','int', 1, 6757, 1),
@@ -76,6 +96,7 @@
             type_permuated.append(t)
 
     @py.test.mark.parametrize("op,dtype,result,count,a", type_permuated)
+    @py.test.mark.skipif('no_vector_backend()')
     def test_reduce_generic(self,op,dtype,result,count,a):
         source = """
         def main():
@@ -84,10 +105,19 @@
             return a.{method}()
         """.format(method=op, dtype=dtype, count=count, a=a)
         exec py.code.Source(source).compile()
+        log = self.run(main, [], vec=0)
         vlog = self.run(main, [], vec=1)
-        log = self.run(main, [], vec=0)
         assert log.result == vlog.result
         assert log.result == result
+        if not log.jit_summary:
+            return
+        assert log.jit_summary.vecopt_tried == 0
+        assert log.jit_summary.vecopt_success == 0
+        assert vlog.jit_summary.vecopt_tried > 0
+        if dtype in ('int64','float64') and (dtype != 'int64' and op != 
'prod'):
+            assert vlog.jit_summary.vecopt_success > 0
+        else:
+            assert vlog.jit_summary.vecopt_success >= 0
 
     def test_reduce_logical_xor(self):
         def main():
@@ -158,7 +188,7 @@
         assert log.result is True
         assert len(log.loops) == 1
         loop = log._filter(log.loops[0])
-        assert loop.match("""
+        loop.match("""
             f31 = raw_load_f(i9, i29, descr=<ArrayF 8>)
             guard_not_invalidated(descr=...)
             i32 = float_ne(f31, 0.000000)
@@ -168,7 +198,20 @@
             i38 = int_ge(i36, i30)
             guard_false(i38, descr=...)
             jump(..., descr=...)
-        """)
+            """)
+        # vector version
+        #assert loop.match("""
+        #    guard_not_invalidated(descr=...)
+        #    i38 = int_add(i25, 2)
+        #    i39 = int_ge(i38, i33)
+        #    guard_false(i39, descr=...)
+        #    v42 = vec_load_f(i9, i32, 1, 0, descr=<ArrayF 8>)
+        #    v43 = vec_float_ne(v42, v36)
+        #    f46 = vec_unpack_f(v42, 0, 1)
+        #    vec_guard_true(v43, descr=...)
+        #    i48 = int_add(i32, 16)
+        #    i50 = int_add(i25, 2)
+        #    jump(..., descr=...)""")
 
     def test_array_getitem_basic(self):
         def main():
diff --git a/pypy/module/signal/interp_signal.py 
b/pypy/module/signal/interp_signal.py
--- a/pypy/module/signal/interp_signal.py
+++ b/pypy/module/signal/interp_signal.py
@@ -179,11 +179,19 @@
 @jit.dont_look_inside
 @unwrap_spec(timeout=int)
 def alarm(space, timeout):
+    """alarm(seconds)
+
+    Arrange for SIGALRM to arrive after the given number of seconds.
+    """
     return space.wrap(c_alarm(timeout))
 
 
 @jit.dont_look_inside
 def pause(space):
+    """pause()
+
+    Wait until a signal arrives.
+    """
     c_pause()
     return space.w_None
 
@@ -258,6 +266,12 @@
 @jit.dont_look_inside
 @unwrap_spec(signum=int, flag=int)
 def siginterrupt(space, signum, flag):
+    """siginterrupt(sig, flag) -> None
+
+    change system call restart behaviour: if flag is False, system calls
+    will be restarted when interrupted by signal sig, else system calls
+    will be interrupted.
+    """
     check_signum_in_range(space, signum)
     if rffi.cast(lltype.Signed, c_siginterrupt(signum, flag)) < 0:
         raise exception_from_saved_errno(space, space.w_OSError)
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -829,65 +829,83 @@
     new_obj = map.materialize_r_dict(space, obj, dict_w)
     obj._set_mapdict_storage_and_map(new_obj.storage, new_obj.map)
 
+
+class IteratorMixin(object):
+
+    def _init(self, strategy, w_dict):
+        w_obj = strategy.unerase(w_dict.dstorage)
+        self.w_obj = w_obj
+        self.orig_map = curr_map = w_obj._get_mapdict_map()
+        # We enumerate non-lazily the attributes, and store them in the
+        # 'attrs' list.  We then walk that list in opposite order.  This
+        # gives an ordering that is more natural (roughly corresponding
+        # to oldest-first) than the one we get in the direct algorithm
+        # (from leaves to root, looks like backward order).  See issue
+        # #2426: it should improve the performance of code like
+        # copy.copy().
+        attrs = []
+        while True:
+            curr_map = curr_map.search(DICT)
+            if curr_map is None:
+                break
+            attrs.append(curr_map.name)
+            curr_map = curr_map.back
+        self.attrs = attrs
+
+
 class MapDictIteratorKeys(BaseKeyIterator):
+    objectmodel.import_from_mixin(IteratorMixin)
+
     def __init__(self, space, strategy, w_dict):
         BaseKeyIterator.__init__(self, space, strategy, w_dict)
-        w_obj = strategy.unerase(w_dict.dstorage)
-        self.w_obj = w_obj
-        self.orig_map = self.curr_map = w_obj._get_mapdict_map()
+        self._init(strategy, w_dict)
 
     def next_key_entry(self):
         assert isinstance(self.w_dict.get_strategy(), MapDictStrategy)
         if self.orig_map is not self.w_obj._get_mapdict_map():
             return None
-        if self.curr_map:
-            curr_map = self.curr_map.search(DICT)
-            if curr_map:
-                self.curr_map = curr_map.back
-                attr = curr_map.name
-                w_attr = self.space.wrap(attr.decode('utf-8'))
-                return w_attr
+        attrs = self.attrs
+        if len(attrs) > 0:
+            attr = attrs.pop()
+            w_attr = self.space.wrap(attr.decode('utf-8'))
+            return w_attr
         return None
 
 
 class MapDictIteratorValues(BaseValueIterator):
+    objectmodel.import_from_mixin(IteratorMixin)
+
     def __init__(self, space, strategy, w_dict):
         BaseValueIterator.__init__(self, space, strategy, w_dict)
-        w_obj = strategy.unerase(w_dict.dstorage)
-        self.w_obj = w_obj
-        self.orig_map = self.curr_map = w_obj._get_mapdict_map()
+        self._init(strategy, w_dict)
 
     def next_value_entry(self):
         assert isinstance(self.w_dict.get_strategy(), MapDictStrategy)
         if self.orig_map is not self.w_obj._get_mapdict_map():
             return None
-        if self.curr_map:
-            curr_map = self.curr_map.search(DICT)
-            if curr_map:
-                self.curr_map = curr_map.back
-                attr = curr_map.name
-                return self.w_obj.getdictvalue(self.space, attr)
+        attrs = self.attrs
+        if len(attrs) > 0:
+            attr = attrs.pop()
+            return self.w_obj.getdictvalue(self.space, attr)
         return None
 
 
 class MapDictIteratorItems(BaseItemIterator):
+    objectmodel.import_from_mixin(IteratorMixin)
+
     def __init__(self, space, strategy, w_dict):
         BaseItemIterator.__init__(self, space, strategy, w_dict)
-        w_obj = strategy.unerase(w_dict.dstorage)
-        self.w_obj = w_obj
-        self.orig_map = self.curr_map = w_obj._get_mapdict_map()
+        self._init(strategy, w_dict)
 
     def next_item_entry(self):
         assert isinstance(self.w_dict.get_strategy(), MapDictStrategy)
         if self.orig_map is not self.w_obj._get_mapdict_map():
             return None, None
-        if self.curr_map:
-            curr_map = self.curr_map.search(DICT)
-            if curr_map:
-                self.curr_map = curr_map.back
-                attr = curr_map.name
-                w_attr = self.space.wrap(attr.decode('utf-8'))
-                return w_attr, self.w_obj.getdictvalue(self.space, attr)
+        attrs = self.attrs
+        if len(attrs) > 0:
+            attr = attrs.pop()
+            w_attr = self.space.wrap(attr.decode('utf-8'))
+            return w_attr, self.w_obj.getdictvalue(self.space, attr)
         return None, None
 
 
diff --git a/pypy/objspace/std/test/test_mapdict.py 
b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -1204,6 +1204,20 @@
         got = a.method()
         assert got == 43
 
+    def test_dict_order(self):
+        # the __dict__ order is not strictly enforced, but in
+        # simple cases like that, we want to follow the order of
+        # creation of the attributes
+        class A(object):
+            pass
+        a = A()
+        a.x = 5
+        a.z = 6
+        a.y = 7
+        assert list(a.__dict__) == ['x', 'z', 'y']
+        assert a.__dict__.values() == [5, 6, 7]
+        assert list(a.__dict__.iteritems()) == [('x', 5), ('z', 6), ('y', 7)]
+
     def test_bug_method_change(self):
         class A(object):
             def method(self):
diff --git a/pypy/tool/cpyext/extbuild.py b/pypy/tool/cpyext/extbuild.py
--- a/pypy/tool/cpyext/extbuild.py
+++ b/pypy/tool/cpyext/extbuild.py
@@ -194,6 +194,13 @@
 
 def _build(cfilenames, outputfilename, compile_extra, link_extra,
         include_dirs, libraries, library_dirs):
+    try:
+        # monkeypatch distutils for some versions of msvc compiler
+        import setuptools
+    except ImportError:
+        # XXX if this fails and is required, 
+        #     we must call pypy -mensurepip after translation
+        pass
     from distutils.ccompiler import new_compiler
     from distutils import sysconfig
     compiler = new_compiler(force=1)
diff --git a/rpython/annotator/test/test_annrpython.py 
b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -146,6 +146,27 @@
         # result should be an integer
         assert s.knowntype == int
 
+    def test_not_rpython(self):
+        def g(x):
+            """ NOT_RPYTHON """
+            return eval(x)
+        def f(x):
+            return g(str(x))
+        a = self.RPythonAnnotator()
+        with py.test.raises(ValueError):
+            a.build_types(f, [int])
+
+    def test_not_rpython_decorator(self):
+        from rpython.rlib.objectmodel import not_rpython
+        @not_rpython
+        def g(x):
+            return eval(x)
+        def f(x):
+            return g(str(x))
+        a = self.RPythonAnnotator()
+        with py.test.raises(ValueError):
+            a.build_types(f, [int])
+
     def test_lists(self):
         a = self.RPythonAnnotator()
         end_cell = a.build_types(snippet.poor_man_rev_range, [int])
diff --git a/rpython/doc/faq.rst b/rpython/doc/faq.rst
--- a/rpython/doc/faq.rst
+++ b/rpython/doc/faq.rst
@@ -80,6 +80,9 @@
 stops and reports this as an error. You can therefore mark functions as
 "NOT_RPYTHON" to make sure that they are never analyzed.
 
+This method of marking a function as not RPython is outdated. For new code,
+please use the ``@objectmodel.not_rpython`` decorator instead.
+
 
 Couldn't we simply take a Python syntax tree and turn it into Lisp?
 -------------------------------------------------------------------
@@ -143,7 +146,7 @@
   attempt to point newcomers at existing alternatives, which are more
   mainstream and where they will get help from many people.*
 
-  *If anybody seriously wants to promote RPython anyway, he is welcome
+  *If anybody seriously wants to promote RPython anyway, they are welcome
   to: we won't actively resist such a plan.  There are a lot of things
   that could be done to make RPython a better Java-ish language for
   example, starting with supporting non-GIL-based multithreading, but we
@@ -182,8 +185,8 @@
 patch the generated machine code.
 
 So the position of the core PyPy developers is that if anyone wants to
-make an N+1'th attempt with LLVM, he is welcome, and he will receive a
-bit of help on the IRC channel, but he is left with the burden of proof
+make an N+1'th attempt with LLVM, they are welcome, and they will receive a
+bit of help on the IRC channel, but they are left with the burden of proof
 that it works.
 
 
diff --git a/rpython/doc/jit/vectorization.rst 
b/rpython/doc/jit/vectorization.rst
--- a/rpython/doc/jit/vectorization.rst
+++ b/rpython/doc/jit/vectorization.rst
@@ -13,11 +13,6 @@
   (e.g. those in the NumPyPy module).
 * --jit vec_all=1: turns on the vectorization for any jit driver. See 
parameters for
   the filtering heuristics of traces.
-* --jit vec_ratio=2: A number from 0 to 10 that represents a real number 
(vec_ratio / 10).
-  This filters traces if vec_all is enabled. N is the trace count then the 
number of
-  vector transformable operations (add_int -> vec_add_int) M, the following 
must hold:
-  M / N >= (vec_ratio / 10)
-* --jit vec_length=60: The maximum number of trace instructions the vectorizer 
filters for.
 
 Features
 --------
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -18,6 +18,8 @@
     except AttributeError:
         raise ValueError("%r is not RPython: it is likely an unexpected "
                          "built-in function or type" % (func,))
+    if getattr(func, "_not_rpython_", False):
+        raise ValueError("%r is tagged as @not_rpython" % (func,))
     if func.func_doc and func.func_doc.lstrip().startswith('NOT_RPYTHON'):
         raise ValueError("%r is tagged as NOT_RPYTHON" % (func,))
     if func.func_code.co_cellvars:
diff --git a/rpython/jit/backend/detect_cpu.py 
b/rpython/jit/backend/detect_cpu.py
--- a/rpython/jit/backend/detect_cpu.py
+++ b/rpython/jit/backend/detect_cpu.py
@@ -13,7 +13,6 @@
 MODEL_X86         = 'x86'
 MODEL_X86_NO_SSE2 = 'x86-without-sse2'
 MODEL_X86_64      = 'x86-64'
-MODEL_X86_64_SSE4 = 'x86-64-sse4'
 MODEL_ARM         = 'arm'
 MODEL_PPC_64      = 'ppc-64'
 MODEL_S390_64     = 's390x'
@@ -81,9 +80,6 @@
         from rpython.jit.backend.x86 import detect_feature as feature
         if sys.maxint == 2**63-1:
             result = MODEL_X86_64
-            # has sse 2 at least
-            if feature.detect_sse4_1():
-                result = MODEL_X86_64_SSE4
         else:
             assert sys.maxint == 2**31-1
             if feature.detect_sse2():
@@ -120,8 +116,6 @@
         return "rpython.jit.backend.x86.runner", "CPU386_NO_SSE2"
     elif backend_name == MODEL_X86_64:
         return "rpython.jit.backend.x86.runner", "CPU_X86_64"
-    elif backend_name == MODEL_X86_64_SSE4:
-        return "rpython.jit.backend.x86.runner", "CPU_X86_64_SSE4"
     elif backend_name == MODEL_ARM:
         return "rpython.jit.backend.arm.runner", "CPU_ARM"
     elif backend_name == MODEL_PPC_64:
@@ -145,7 +139,6 @@
         MODEL_X86: ['floats', 'singlefloats', 'longlong'],
         MODEL_X86_NO_SSE2: ['longlong'],
         MODEL_X86_64: ['floats', 'singlefloats'],
-        MODEL_X86_64_SSE4: ['floats', 'singlefloats'],
         MODEL_ARM: ['floats', 'singlefloats', 'longlong'],
         MODEL_PPC_64: ['floats'],
         MODEL_S390_64: ['floats'],
diff --git a/rpython/jit/backend/llgraph/runner.py 
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -2,6 +2,7 @@
 from rpython.jit.backend import model
 from rpython.jit.backend.llgraph import support
 from rpython.jit.backend.llsupport import symbolic
+from rpython.jit.backend.llsupport.vector_ext import VectorExt
 from rpython.jit.metainterp.history import AbstractDescr
 from rpython.jit.metainterp.history import Const, getkind
 from rpython.jit.metainterp.history import INT, REF, FLOAT, VOID
@@ -328,10 +329,11 @@
     supports_cond_call_value = True
     translate_support_code = False
     is_llgraph = True
-    vector_extension = True
-    vector_register_size = 16 # in bytes
-    vector_horizontal_operations = True
-    vector_pack_slots = True
+    vector_ext = VectorExt()
+    vector_ext.enable(16, accum=True)
+    vector_ext.setup_once = lambda asm: asm
+    load_supported_factors = (1,2,4,8)
+    assembler = None
 
     def __init__(self, rtyper, stats=None, *ignored_args, **kwds):
         model.AbstractCPU.__init__(self)
@@ -877,6 +879,9 @@
     def bh_vec_int_xor(self, vx, vy, count):
         return [int(x) ^ int(y) for x,y in zip(vx,vy)]
 
+    def bh_vec_float_xor(self, vx, vy, count):
+        return [0.0 for x,y in zip(vx,vy)] # just used for clearing the vector 
register
+
     def bh_vec_cast_float_to_singlefloat(self, vx, count):
         from rpython.rlib.rarithmetic import r_singlefloat
         return 
[longlong.singlefloat2int(r_singlefloat(longlong.getrealfloat(v)))
@@ -928,50 +933,32 @@
     def bh_vec_int_signext(self, vx, ext, count):
         return [heaptracker.int_signext(_vx, ext) for _vx in vx]
 
-    def build_getarrayitem(func):
-        def method(self, struct, offset, descr, _count):
+    def build_load(func):
+        def method(self, struct, offset, scale, disp, descr, _count):
             values = []
-            count = self.vector_register_size // descr.get_item_size_in_bytes()
+            count = self.vector_ext.vec_size() // 
descr.get_item_size_in_bytes()
             assert _count == count
             assert count > 0
+            adr = struct + (offset * scale + disp)
+            a = support.cast_arg(lltype.Ptr(descr.A), adr)
+            array = a._obj
             for i in range(count):
-                val = func(self, struct, offset + i, descr)
+                val = support.cast_result(descr.A.OF, array.getitem(i))
                 values.append(val)
             return values
         return method
 
-    bh_vec_getarrayitem_gc_i = build_getarrayitem(bh_getarrayitem_gc)
-    bh_vec_getarrayitem_gc_f = build_getarrayitem(bh_getarrayitem_gc)
-    bh_vec_getarrayitem_raw_i = build_getarrayitem(bh_getarrayitem_raw)
-    bh_vec_getarrayitem_raw_f = build_getarrayitem(bh_getarrayitem_raw)
-    del build_getarrayitem
+    bh_vec_load_i = build_load(bh_getarrayitem_raw)
+    bh_vec_load_f = build_load(bh_getarrayitem_raw)
+    del build_load
 
-    def _bh_vec_raw_load(self, struct, offset, descr, _count):
-        values = []
+    def bh_vec_store(self, struct, offset, newvalues, scale, disp, descr, 
count):
         stride = descr.get_item_size_in_bytes()
-        count = self.vector_register_size // descr.get_item_size_in_bytes()
-        assert _count == count
-        assert count > 0
-        for i in range(count):
-            val = self.bh_raw_load(struct, offset + i*stride, descr)
-            values.append(val)
-        return values
-
-    bh_vec_raw_load_i = _bh_vec_raw_load
-    bh_vec_raw_load_f = _bh_vec_raw_load
-
-    def bh_vec_raw_store(self, struct, offset, newvalues, descr, count):
-        stride = descr.get_item_size_in_bytes()
+        adr = struct + (offset * scale + disp)
+        a = support.cast_arg(lltype.Ptr(descr.A), adr)
+        array = a._obj
         for i,n in enumerate(newvalues):
-            self.bh_raw_store(struct, offset + i*stride, n, descr)
-
-    def bh_vec_setarrayitem_raw(self, struct, offset, newvalues, descr, count):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to