Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r85023:2384df43b1dd
Date: 2016-06-08 09:29 +0200
http://bitbucket.org/pypy/pypy/changeset/2384df43b1dd/

Log:    merge heads

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -25,3 +25,4 @@
 80ef432a32d9baa4b3c5a54c215e8ebe499f6374 release-5.1.2
 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
+c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3
diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -164,13 +164,6 @@
 
     __multicall__.execute()
 
-def pytest_runtest_teardown(__multicall__, item):
-    __multicall__.execute()
-
-    if 'pygame' in sys.modules:
-        assert option.view, ("should not invoke Pygame "
-                             "if conftest.option.view is False")
-
 
 class PyPyClassCollector(py.test.collect.Class):
     # All pypy Test classes have a "space" member.
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
@@ -5,3 +5,17 @@
 .. this is a revision shortly after release-pypy2.7-v5.3
 .. startrev: 873218a739f1
 
+.. branch: fix-gen-dfa
+
+Resolves an issue with the generator script to build the dfa for Python syntax.
+
+.. branch: z196-support
+
+Fixes a critical issue in the register allocator and extends support on s390x.
+PyPy runs and translates on the s390x revisions z10 (released February 2008, 
experimental)
+and z196 (released August 2010) in addition to zEC12 and z13.
+To target e.g. z196 on a zEC12 machine supply CFLAGS="-march=z196" to your 
shell environment.
+
+.. branch: s390x-5.3-catchup
+
+Implement the backend related changes for s390x.
diff --git a/pypy/interpreter/pyparser/genpytokenize.py 
b/pypy/interpreter/pyparser/genpytokenize.py
--- a/pypy/interpreter/pyparser/genpytokenize.py
+++ b/pypy/interpreter/pyparser/genpytokenize.py
@@ -191,7 +191,7 @@
                               newArcPair(states, EMPTY),
                               pseudoExtras, number, funny, contStr, name))
     dfaStates, dfaAccepts = nfaToDfa(states, *pseudoToken)
-    return DFA(dfaStates, dfaAccepts)
+    return DFA(dfaStates, dfaAccepts), dfaStates
 
 # ______________________________________________________________________
 
@@ -205,7 +205,9 @@
                              newArcPair(states, DEFAULT),
                              any(states, notGroupStr(states, "'\\")))),
                    newArcPair(states, "'"))
-    singleDFA = DFA(*nfaToDfa(states, *single))
+    states, accepts = nfaToDfa(states, *single)
+    singleDFA = DFA(states, accepts)
+    states_singleDFA = states
     states = []
     double = chain(states,
                    any(states, notGroupStr(states, '"\\')),
@@ -215,7 +217,9 @@
                              newArcPair(states, DEFAULT),
                              any(states, notGroupStr(states, '"\\')))),
                    newArcPair(states, '"'))
-    doubleDFA = DFA(*nfaToDfa(states, *double))
+    states, accepts = nfaToDfa(states, *double)
+    doubleDFA = DFA(states, accepts)
+    states_doubleDFA = states
     states = []
     single3 = chain(states,
                     any(states, notGroupStr(states, "'\\")),
@@ -230,7 +234,9 @@
                                           notChainStr(states, "''"))),
                               any(states, notGroupStr(states, "'\\")))),
                     chainStr(states, "'''"))
-    single3DFA = NonGreedyDFA(*nfaToDfa(states, *single3))
+    states, accepts = nfaToDfa(states, *single3)
+    single3DFA = NonGreedyDFA(states, accepts)
+    states_single3DFA = states
     states = []
     double3 = chain(states,
                     any(states, notGroupStr(states, '"\\')),
@@ -245,9 +251,11 @@
                                           notChainStr(states, '""'))),
                               any(states, notGroupStr(states, '"\\')))),
                     chainStr(states, '"""'))
-    double3DFA = NonGreedyDFA(*nfaToDfa(states, *double3))
-    map = {"'" : singleDFA,
-           '"' : doubleDFA,
+    states, accepts = nfaToDfa(states, *double3)
+    double3DFA = NonGreedyDFA(states, accepts)
+    states_double3DFA = states
+    map = {"'" : (singleDFA, states_singleDFA),
+           '"' : (doubleDFA, states_doubleDFA),
            "r" : None,
            "R" : None,
            "u" : None,
@@ -257,25 +265,30 @@
     for uniPrefix in ("", "u", "U", "b", "B", ):
         for rawPrefix in ("", "r", "R"):
             prefix = uniPrefix + rawPrefix
-            map[prefix + "'''"] = single3DFA
-            map[prefix + '"""'] = double3DFA
+            map[prefix + "'''"] = (single3DFA, states_single3DFA)
+            map[prefix + '"""'] = (double3DFA, states_double3DFA)
     return map
 
 # ______________________________________________________________________
 
-def output(name, dfa_class, dfa):
+def output(name, dfa_class, dfa, states):
     import textwrap
+    lines = []
     i = 0
     for line in textwrap.wrap(repr(dfa.accepts), width = 50):
         if i == 0:
-            print "accepts =", line
+            lines.append("accepts = ")
         else:
-            print "          ", line
+            lines.append("           ")
+        lines.append(line)
+        lines.append("\n")
         i += 1
     import StringIO
-    print "states = ["
-    for numstate, state in enumerate(dfa.states):
-        print "    #", numstate
+    lines.append("states = [\n")
+    for numstate, state in enumerate(states):
+        lines.append("    # ")
+        lines.append(str(numstate))
+        lines.append('\n')
         s = StringIO.StringIO()
         i = 0
         for k, v in sorted(state.items()):
@@ -298,22 +311,28 @@
         for line in text:
             line = line.replace('::', ': ')
             if i == 0:
-                print '    {' + line
+                lines.append('    {')
             else:
-                print '     ' + line
+                lines.append('     ')
+            lines.append(line)
+            lines.append('\n')
             i += 1
-    print "    ]"
-    print "%s = automata.%s(states, accepts)" % (name, dfa_class)
-    print
+    lines.append("    ]\n")
+    lines.append("%s = automata.%s(states, accepts)\n" % (name, dfa_class))
+    return ''.join(lines)
 
 def main ():
-    pseudoDFA = makePyPseudoDFA()
-    output("pseudoDFA", "DFA", pseudoDFA)
+    pseudoDFA, states_pseudoDFA = makePyPseudoDFA()
+    print output("pseudoDFA", "DFA", pseudoDFA, states_pseudoDFA)
     endDFAMap = makePyEndDFAMap()
-    output("double3DFA", "NonGreedyDFA", endDFAMap['"""'])
-    output("single3DFA", "NonGreedyDFA", endDFAMap["'''"])
-    output("singleDFA", "DFA", endDFAMap["'"])
-    output("doubleDFA", "DFA", endDFAMap['"'])
+    dfa, states = endDFAMap['"""']
+    print output("double3DFA", "NonGreedyDFA", dfa, states)
+    dfa, states = endDFAMap["'''"]
+    print output("single3DFA", "NonGreedyDFA", dfa, states)
+    dfa, states = endDFAMap["'"]
+    print output("singleDFA", "DFA", dfa, states)
+    dfa, states = endDFAMap["\""]
+    print output("doubleDFA", "DFA", dfa, states)
 
 # ______________________________________________________________________
 
diff --git a/pypy/interpreter/pyparser/test/test_gendfa.py 
b/pypy/interpreter/pyparser/test/test_gendfa.py
new file mode 100644
--- /dev/null
+++ b/pypy/interpreter/pyparser/test/test_gendfa.py
@@ -0,0 +1,16 @@
+from pypy.interpreter.pyparser.automata import DFA, DEFAULT
+from pypy.interpreter.pyparser.genpytokenize import output
+
+def test_states():
+    states = [{"\x00": 1}, {"\x01": 0}]
+    d = DFA(states[:], [False, True])
+    assert output('test', DFA, d, states) == """\
+accepts = [False, True]
+states = [
+    # 0
+    {'\\x00': 1},
+    # 1
+    {'\\x01': 0},
+    ]
+test = automata.pypy.interpreter.pyparser.automata.DFA(states, accepts)
+"""
diff --git a/pypy/interpreter/test/test_pyframe.py 
b/pypy/interpreter/test/test_pyframe.py
--- a/pypy/interpreter/test/test_pyframe.py
+++ b/pypy/interpreter/test/test_pyframe.py
@@ -1,5 +1,5 @@
-import pytest
 from rpython.tool import udir
+from pypy.conftest import option
 from pypy.interpreter.gateway import interp2app
 
 def check_no_w_locals(space, w_frame):
@@ -11,7 +11,7 @@
         space = cls.space
         cls.w_udir = cls.space.wrap(str(udir.udir))
         cls.w_tempfile1 = cls.space.wrap(str(udir.udir.join('tempfile1')))
-        if not pytest.config.option.runappdirect:
+        if not option.runappdirect:
             w_call_further = cls.space.appexec([], """():
                 def call_further(f):
                     return f()
diff --git a/pypy/interpreter/test/test_zzpickle_and_slow.py 
b/pypy/interpreter/test/test_zzpickle_and_slow.py
--- a/pypy/interpreter/test/test_zzpickle_and_slow.py
+++ b/pypy/interpreter/test/test_zzpickle_and_slow.py
@@ -1,4 +1,5 @@
 import py
+from pypy import conftest
 from pypy.interpreter import gateway
 from rpython.rlib.jit import non_virtual_ref, vref_None
 
diff --git a/pypy/module/_continuation/test/test_translated.py 
b/pypy/module/_continuation/test/test_translated.py
--- a/pypy/module/_continuation/test/test_translated.py
+++ b/pypy/module/_continuation/test/test_translated.py
@@ -89,7 +89,8 @@
 class AppTestWrapper:
     def setup_class(cls):
         "Run test_various_depths() when we are run with 'pypy py.test -A'."
-        if not py.test.config.option.runappdirect:
+        from pypy.conftest import option
+        if not option.runappdirect:
             py.test.skip("meant only for -A run")
 
 def _setup():
diff --git a/pypy/module/_file/test/test_file.py 
b/pypy/module/_file/test/test_file.py
--- a/pypy/module/_file/test/test_file.py
+++ b/pypy/module/_file/test/test_file.py
@@ -516,11 +516,12 @@
             assert s == 'bar\n'
 
 def test_flush_at_exit():
+    from pypy import conftest
     from pypy.tool.option import make_config, make_objspace
     from rpython.tool.udir import udir
 
     tmpfile = udir.join('test_flush_at_exit')
-    config = make_config(py.test.config.option)
+    config = make_config(conftest.option)
     space = make_objspace(config)
     space.appexec([space.wrap(str(tmpfile))], """(tmpfile):
         f = open(tmpfile, 'w')
diff --git a/pypy/module/_io/test/test_fileio.py 
b/pypy/module/_io/test/test_fileio.py
--- a/pypy/module/_io/test/test_fileio.py
+++ b/pypy/module/_io/test/test_fileio.py
@@ -222,10 +222,14 @@
         assert not closed[0]  # flush() called before file closed
         os.close(fd)
 
-def test_flush_at_exit(space):
+def test_flush_at_exit():
+    from pypy import conftest
+    from pypy.tool.option import make_config, make_objspace
     from rpython.tool.udir import udir
 
     tmpfile = udir.join('test_flush_at_exit')
+    config = make_config(conftest.option)
+    space = make_objspace(config)
     space.appexec([space.wrap(str(tmpfile))], """(tmpfile):
         import io
         f = io.open(tmpfile, 'w', encoding='ascii')
@@ -237,7 +241,12 @@
     assert tmpfile.read() == '42'
 
 
-def test_flush_at_exit_IOError_and_ValueError(space):
+def test_flush_at_exit_IOError_and_ValueError():
+    from pypy import conftest
+    from pypy.tool.option import make_config, make_objspace
+
+    config = make_config(conftest.option)
+    space = make_objspace(config)
     space.appexec([], """():
         import io
         class MyStream(io.IOBase):
diff --git a/pypy/module/_rawffi/test/test_tracker.py 
b/pypy/module/_rawffi/test/test_tracker.py
--- a/pypy/module/_rawffi/test/test_tracker.py
+++ b/pypy/module/_rawffi/test/test_tracker.py
@@ -1,5 +1,5 @@
 import py
-from pytest import option
+from pypy.conftest import option
 from pypy.module._rawffi.tracker import Tracker
 
 
@@ -44,3 +44,4 @@
 
     def teardown_class(cls):
         Tracker.DO_TRACING = False
+
diff --git a/pypy/module/cpyext/object.py b/pypy/module/cpyext/object.py
--- a/pypy/module/cpyext/object.py
+++ b/pypy/module/cpyext/object.py
@@ -1,7 +1,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from pypy.module.cpyext.api import (
     cpython_api, generic_cpy_call, CANNOT_FAIL, Py_ssize_t, Py_ssize_tP,
-    PyVarObject, Py_buffer,
+    PyVarObject, Py_buffer, size_t,
     Py_TPFLAGS_HEAPTYPE, Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT,
     Py_GE, CONST_STRING, FILEP, fwrite)
 from pypy.module.cpyext.pyobject import (
@@ -14,14 +14,14 @@
 import pypy.module.__builtin__.operation as operation
 
 
-@cpython_api([Py_ssize_t], rffi.VOIDP)
+@cpython_api([size_t], rffi.VOIDP)
 def PyObject_Malloc(space, size):
     # returns non-zero-initialized memory, like CPython
     return lltype.malloc(rffi.VOIDP.TO, size,
                          flavor='raw',
                          add_memory_pressure=True)
 
-@cpython_api([rffi.VOIDP, Py_ssize_t], rffi.VOIDP)
+@cpython_api([rffi.VOIDP, size_t], rffi.VOIDP)
 def PyObject_Realloc(space, ptr, size):
     if not lltype.cast_ptr_to_int(ptr):
         return lltype.malloc(rffi.VOIDP.TO, size,
diff --git a/pypy/module/gc/test/test_referents.py 
b/pypy/module/gc/test/test_referents.py
--- a/pypy/module/gc/test/test_referents.py
+++ b/pypy/module/gc/test/test_referents.py
@@ -1,4 +1,4 @@
-from pytest import option
+from pypy.conftest import option
 
 
 class AppTestReferents(object):
diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -13,7 +13,7 @@
 
 from pypy.module.imp import importing
 
-from pytest import config
+from pypy import conftest
 
 def setuppkg(pkgname, **entries):
     p = udir.join('impsubdir')
@@ -106,7 +106,7 @@
 
     # create compiled/x.py and a corresponding pyc file
     p = setuppkg("compiled", x = "x = 84")
-    if config.option.runappdirect:
+    if conftest.option.runappdirect:
         import marshal, stat, struct, os, imp
         code = py.code.Source(p.join("x.py").read()).compile()
         s3 = marshal.dumps(code)
@@ -168,7 +168,7 @@
     }
 
     def setup_class(cls):
-        cls.w_runappdirect = cls.space.wrap(config.option.runappdirect)
+        cls.w_runappdirect = cls.space.wrap(conftest.option.runappdirect)
         cls.saved_modules = _setup(cls.space)
         #XXX Compile class
 
@@ -1494,6 +1494,8 @@
     spaceconfig = dict(usemodules=['thread', 'time'])
 
     def setup_class(cls):
+        #if not conftest.option.runappdirect:
+        #    py.test.skip("meant as an -A test")
         tmpfile = udir.join('test_multithreaded_imp.py')
         tmpfile.write('''if 1:
             x = 666
diff --git a/pypy/module/micronumpy/test/test_base.py 
b/pypy/module/micronumpy/test/test_base.py
--- a/pypy/module/micronumpy/test/test_base.py
+++ b/pypy/module/micronumpy/test/test_base.py
@@ -1,4 +1,4 @@
-from pytest import config
+from pypy.conftest import option
 from pypy.module.micronumpy import constants as NPY
 
 
@@ -7,7 +7,7 @@
 
     @classmethod
     def setup_class(cls):
-        if config.option.runappdirect:
+        if option.runappdirect:
             import sys
             if '__pypy__' not in sys.builtin_module_names:
                 import numpy
diff --git a/pypy/module/micronumpy/test/test_complex.py 
b/pypy/module/micronumpy/test/test_complex.py
--- a/pypy/module/micronumpy/test/test_complex.py
+++ b/pypy/module/micronumpy/test/test_complex.py
@@ -2,6 +2,7 @@
 
 import sys
 
+from pypy.conftest import option
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.gateway import interp2app
 from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
@@ -22,13 +23,13 @@
     # special values testing
     if isnan(a):
         if isnan(b):
-            return True, ''
+            return True,''
         raise AssertionError(msg + '%r should be nan' % (b,))
 
     if isinf(a):
         if a == b:
-            return True, ''
-        raise AssertionError(msg + 'finite result where infinity expected: '
+            return True,''
+        raise AssertionError(msg + 'finite result where infinity expected: '+ \
                           'expected %r, got %r' % (a, b))
 
     # if both a and b are zero, check whether they have the same sign
@@ -38,7 +39,7 @@
     if not a and not b:
         # only check it if we are running on top of CPython >= 2.6
         if sys.version_info >= (2, 6) and copysign(1., a) != copysign(1., b):
-            raise AssertionError(msg +
+            raise AssertionError( msg + \
                     'zero has wrong sign: expected %r, got %r' % (a, b))
 
     # if a-b overflows, or b is infinite, return False.  Again, in
@@ -95,6 +96,7 @@
         cls.w_testcases128 = cls.space.wrap(list(parse_testfile(fname128)))
         cls.w_testcases64 = cls.space.wrap(list(parse_testfile(fname64)))
 
+        cls.w_runAppDirect = cls.space.wrap(option.runappdirect)
         cls.w_isWindows = cls.space.wrap(os.name == 'nt')
 
         if cls.runappdirect:
diff --git a/pypy/module/micronumpy/test/test_dtypes.py 
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -1,11 +1,11 @@
-from pytest import config
+from pypy.conftest import option
 from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
 from pypy.interpreter.gateway import interp2app
 
 class BaseAppTestDtypes(BaseNumpyAppTest):
     def setup_class(cls):
         BaseNumpyAppTest.setup_class.im_func(cls)
-        if config.option.runappdirect:
+        if option.runappdirect:
             import platform
             bits, linkage = platform.architecture()
             ptr_size = int(bits[:-3]) // 8
@@ -1088,7 +1088,7 @@
     spaceconfig = dict(usemodules=["micronumpy", "struct", "binascii"])
     def setup_class(cls):
         BaseNumpyAppTest.setup_class.im_func(cls)
-        if config.option.runappdirect:
+        if option.runappdirect:
             cls.w_test_for_core_internal = cls.space.wrap(True)
         else:
             cls.w_test_for_core_internal = cls.space.wrap(False)
@@ -1515,7 +1515,7 @@
             else:
                 assert stor2[1] == '\x01'
                 assert stor2[0] == '\x00'
-        if config.option.runappdirect:
+        if option.runappdirect:
             cls.w_check_non_native = lambda *args : None
         else:
             cls.w_check_non_native = 
cls.space.wrap(interp2app(check_non_native))
diff --git a/pypy/module/micronumpy/test/test_ndarray.py 
b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -2,7 +2,7 @@
 import py
 import sys
 
-from pytest import config
+from pypy.conftest import option
 from pypy.module.micronumpy.appbridge import get_appbridge_cache
 from pypy.module.micronumpy.strides import Chunk, new_view, EllipsisChunk
 from pypy.module.micronumpy.ndarray import W_NDimArray
@@ -3850,7 +3850,7 @@
 
 class AppTestRepr(BaseNumpyAppTest):
     def setup_class(cls):
-        if config.option.runappdirect:
+        if option.runappdirect:
             py.test.skip("Can't be run directly.")
         BaseNumpyAppTest.setup_class.im_func(cls)
         cache = get_appbridge_cache(cls.space)
@@ -3867,7 +3867,7 @@
         assert repr(array(1.5).real) == "array(1.5)"
 
     def teardown_class(cls):
-        if config.option.runappdirect:
+        if option.runappdirect:
             return
         cache = get_appbridge_cache(cls.space)
         cache.w_array_repr = cls.old_array_repr
@@ -4343,7 +4343,7 @@
 
 class AppTestPyPy(BaseNumpyAppTest):
     def setup_class(cls):
-        if config.option.runappdirect and '__pypy__' not in 
sys.builtin_module_names:
+        if option.runappdirect and '__pypy__' not in sys.builtin_module_names:
             py.test.skip("pypy only test")
         BaseNumpyAppTest.setup_class.im_func(cls)
 
diff --git a/pypy/module/micronumpy/test/test_object_arrays.py 
b/pypy/module/micronumpy/test/test_object_arrays.py
--- a/pypy/module/micronumpy/test/test_object_arrays.py
+++ b/pypy/module/micronumpy/test/test_object_arrays.py
@@ -1,9 +1,14 @@
 from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
+from pypy.conftest import option
 
 
 class AppTestObjectDtypes(BaseNumpyAppTest):
     spaceconfig = dict(usemodules=["micronumpy", "struct", "binascii"])
 
+    def setup_class(cls):
+        BaseNumpyAppTest.setup_class.im_func(cls)
+        cls.w_runappdirect = cls.space.wrap(option.runappdirect)
+
     def test_scalar_from_object(self):
         from numpy import array
         import sys
diff --git a/pypy/module/micronumpy/test/test_support_app.py 
b/pypy/module/micronumpy/test/test_support_app.py
--- a/pypy/module/micronumpy/test/test_support_app.py
+++ b/pypy/module/micronumpy/test/test_support_app.py
@@ -3,12 +3,11 @@
 import py
 
 from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
-from pytest import config
+from pypy.conftest import option
 
 class AppTestSupport(BaseNumpyAppTest):
     def setup_class(cls):
-        if (config.option.runappdirect and
-                '__pypy__' not in sys.builtin_module_names):
+        if option.runappdirect and '__pypy__' not in sys.builtin_module_names:
             py.test.skip("pypy only test")
         BaseNumpyAppTest.setup_class.im_func(cls)
 
diff --git a/pypy/module/select/test/test_epoll.py 
b/pypy/module/select/test/test_epoll.py
--- a/pypy/module/select/test/test_epoll.py
+++ b/pypy/module/select/test/test_epoll.py
@@ -20,6 +20,10 @@
         self.w_sockets = self.space.wrap([])
         if platform.machine().startswith('arm'):
             self.w_timeout = self.space.wrap(0.06)
+        if platform.machine().startswith('s390x'):
+            # s390x is not slow, but it seems there is one case when epoll
+            # modify method is called that takes longer on s390x
+            self.w_timeout = self.space.wrap(0.06)
         else:
             self.w_timeout = self.space.wrap(0.02)
 
diff --git a/pypy/module/test_lib_pypy/support.py 
b/pypy/module/test_lib_pypy/support.py
--- a/pypy/module/test_lib_pypy/support.py
+++ b/pypy/module/test_lib_pypy/support.py
@@ -1,6 +1,6 @@
 import py
 
-from pytest import config
+from pypy.conftest import option
 from pypy.interpreter.error import OperationError
 
 def import_lib_pypy(space, name, skipmsg=None):
@@ -9,7 +9,7 @@
 
     Raises a pytest Skip on ImportError if a skip message was specified.
     """
-    if config.option.runappdirect:
+    if option.runappdirect:
         try:
             mod = __import__('lib_pypy.' + name)
         except ImportError as e:
diff --git a/pypy/objspace/std/test/test_bytearrayobject.py 
b/pypy/objspace/std/test/test_bytearrayobject.py
--- a/pypy/objspace/std/test/test_bytearrayobject.py
+++ b/pypy/objspace/std/test/test_bytearrayobject.py
@@ -1,9 +1,9 @@
-from pytest import config
+from pypy import conftest
 
 
 class AppTestBytesArray:
     def setup_class(cls):
-        cls.w_runappdirect = cls.space.wrap(config.option.runappdirect)
+        cls.w_runappdirect = cls.space.wrap(conftest.option.runappdirect)
 
     def test_basics(self):
         b = bytearray()
diff --git a/pypy/objspace/std/test/test_obj.py 
b/pypy/objspace/std/test/test_obj.py
--- a/pypy/objspace/std/test/test_obj.py
+++ b/pypy/objspace/std/test/test_obj.py
@@ -1,4 +1,5 @@
-from pytest import config
+from __future__ import with_statement
+from pypy.conftest import option
 
 class AppTestObject:
 
@@ -6,13 +7,13 @@
         from pypy.interpreter import gateway
         import sys
 
-        cpython_behavior = (not config.option.runappdirect
+        cpython_behavior = (not option.runappdirect
                             or not hasattr(sys, 'pypy_translation_info'))
 
         space = cls.space
         cls.w_cpython_behavior = space.wrap(cpython_behavior)
         cls.w_cpython_version = space.wrap(tuple(sys.version_info))
-        cls.w_appdirect = space.wrap(config.option.runappdirect)
+        cls.w_appdirect = space.wrap(option.runappdirect)
         cls.w_cpython_apptest = space.wrap(option.runappdirect and not 
hasattr(sys, 'pypy_translation_info'))
 
         def w_unwrap_wrap_unicode(space, w_obj):
diff --git a/pypy/objspace/std/test/test_proxy_usercreated.py 
b/pypy/objspace/std/test/test_proxy_usercreated.py
--- a/pypy/objspace/std/test/test_proxy_usercreated.py
+++ b/pypy/objspace/std/test/test_proxy_usercreated.py
@@ -5,7 +5,7 @@
 from pypy.interpreter.typedef import TypeDef
 from pypy.interpreter.gateway import interp2app
 from pypy.objspace.std.transparent import register_proxyable
-from pytest import config
+from pypy.conftest import option
 
 
 class W_Wrapped(W_Root):
@@ -25,7 +25,7 @@
 
 class AppTestProxyNewtype(AppProxy):
     def setup_class(cls):
-        if config.option.runappdirect:
+        if option.runappdirect:
             py.test.skip("Impossible to run on appdirect")
         AppProxy.setup_class.im_func(cls)
         cls.w_wrapped = cls.space.wrap(W_Wrapped())
diff --git a/pypy/objspace/test/test_binop_overriding.py 
b/pypy/objspace/test/test_binop_overriding.py
--- a/pypy/objspace/test/test_binop_overriding.py
+++ b/pypy/objspace/test/test_binop_overriding.py
@@ -1,5 +1,5 @@
 # test about the binop operation rule, see issue 412
-from pytest import config
+from pypy.conftest import option
 
 class AppTestBinopCombinations:
 
@@ -83,7 +83,7 @@
     return Base, do_test
 """)
         cls.w_helpers = w_helpers
-        cls.w_appdirect = cls.space.wrap(config.option.runappdirect)
+        cls.w_appdirect = cls.space.wrap(option.runappdirect)
 
     def test_overriding_base_binop_explict(self):
         class MulBase(object):
diff --git a/pypy/tool/pytest/appsupport.py b/pypy/tool/pytest/appsupport.py
--- a/pypy/tool/pytest/appsupport.py
+++ b/pypy/tool/pytest/appsupport.py
@@ -184,6 +184,7 @@
                 source = str(source).strip()
             except py.error.ENOENT:
                 source = None
+            from pypy import conftest
             if source and py.test.config._assertstate.mode != "off":
                 msg = interpret(source, runner, should_fail=True)
                 space.setattr(w_self, space.wrap('args'),
diff --git a/pypy/tool/pytest/objspace.py b/pypy/tool/pytest/objspace.py
--- a/pypy/tool/pytest/objspace.py
+++ b/pypy/tool/pytest/objspace.py
@@ -3,13 +3,14 @@
 from rpython.config.config import ConflictConfigError
 from pypy.tool.option import make_config, make_objspace
 from pypy.tool.pytest import appsupport
+from pypy.conftest import option
 
 _SPACECACHE={}
 def gettestobjspace(**kwds):
     """ helper for instantiating and caching space's for testing.
     """
     try:
-        config = make_config(py.test.config.option,**kwds)
+        config = make_config(option,**kwds)
     except ConflictConfigError as e:
         # this exception is typically only raised if a module is not available.
         # in this case the test should be skipped
@@ -18,7 +19,7 @@
     try:
         return _SPACECACHE[key]
     except KeyError:
-        if getattr(py.test.config.option, 'runappdirect', None):
+        if getattr(option, 'runappdirect', None):
             return TinyObjSpace(**kwds)
         space = maketestobjspace(config)
         _SPACECACHE[key] = space
@@ -26,7 +27,7 @@
 
 def maketestobjspace(config=None):
     if config is None:
-        config = make_config(py.test.config.option)
+        config = make_config(option)
     if config.objspace.usemodules.thread:
         config.translation.thread = True
     space = make_objspace(config)
diff --git a/rpython/doc/arch/index.rst b/rpython/doc/arch/index.rst
new file mode 100644
--- /dev/null
+++ b/rpython/doc/arch/index.rst
@@ -0,0 +1,11 @@
+.. _arch_index:
+
+Architecture specific notes
+===========================
+
+Here you can find some architecture specific notes.
+
+.. toctree::
+    :maxdepth: 1
+
+    s390x
diff --git a/rpython/doc/arch/s390x.rst b/rpython/doc/arch/s390x.rst
new file mode 100644
--- /dev/null
+++ b/rpython/doc/arch/s390x.rst
@@ -0,0 +1,34 @@
+.. _s390x:
+
+IBM Mainframe S390X
+===================
+
+Our JIT implements the 64 bit version of the IBM Mainframe called s390x.
+Note that this architecture is big endian.
+
+Currently supported ISAs:
+
+* z13 (released January 2015)
+* zEC12 (released September 2012)
+* z196 (released August 2010)
+* z10 (released February 2008)
+
+To check if all the necessary CPU facilities are installed
+on the subject machine, please run the test using a copy of the pypy
+source code::
+
+    $ ./pytest.py rpython/jit/backend/zarch/test/test_assembler -v -k 
'test_facility'
+
+In addition you can run the auto encoding test to check if your Linux GCC tool 
chain
+is able to compile all instructions used in the JIT backend::
+
+    $ ./pytest.py rpython/jit/backend/zarch/test/test_auto_encoding.py -v
+
+Translating
+-----------
+
+Specifically check for these two dependencies. On old versions of some
+Linux distributions ship older versions.
+
+* libffi (version should do > 3.0.+).
+* CPython 2.7.+.
diff --git a/rpython/doc/index.rst b/rpython/doc/index.rst
--- a/rpython/doc/index.rst
+++ b/rpython/doc/index.rst
@@ -37,7 +37,6 @@
 
    arm
    logging
-   s390x
 
 
 Writing your own interpreter in RPython
@@ -61,6 +60,7 @@
    getting-started
    dir-reference
    jit/index
+   arch/index
    translation
    rtyper
    garbage_collection
diff --git a/rpython/doc/s390x.rst b/rpython/doc/s390x.rst
deleted file mode 100644
--- a/rpython/doc/s390x.rst
+++ /dev/null
@@ -1,20 +0,0 @@
-.. _s390x:
-
-S390X JIT Backend
-=================
-
-Our JIT implements the 64 bit version of the IBM Mainframe called s390x.
-Note that this architecture is big endian.
-
-The following facilities need to be installed to operate
-correctly (all of the machines used for development these where installed):
-
-* General-Instructions-Extension
-* Long-Displacement
-* Binary Floating Point (IEEE)
-
-Translating
------------
-
-Ensure that libffi is installed (version should do > 3.0.+).
-CPython should be version 2.7.+.
diff --git a/rpython/jit/backend/ppc/regalloc.py 
b/rpython/jit/backend/ppc/regalloc.py
--- a/rpython/jit/backend/ppc/regalloc.py
+++ b/rpython/jit/backend/ppc/regalloc.py
@@ -439,7 +439,7 @@
     prepare_int_lshift = helper.prepare_binary_op
     prepare_int_rshift = helper.prepare_binary_op
     prepare_uint_rshift = helper.prepare_binary_op
-    prepare_uint_mul_high = helper.prepare_binary_op
+    prepare_uint_mul_high = helper.prepare_int_mul_ovf
 
     prepare_int_add_ovf = helper.prepare_binary_op
     prepare_int_sub_ovf = helper.prepare_binary_op
diff --git a/rpython/jit/backend/zarch/instructions.py 
b/rpython/jit/backend/zarch/instructions.py
--- a/rpython/jit/backend/zarch/instructions.py
+++ b/rpython/jit/backend/zarch/instructions.py
@@ -29,6 +29,7 @@
     'MGHI':    ('ri',    ['\xA7','\x0D']),
     'MSGFI':   ('ril',   ['\xC2','\x00']),
     'MLGR':    ('rre',   ['\xB9','\x86'], 'eo,r'),
+    'MLG':     ('rxy',   ['\xE3','\x86'], 'eo,bid'),
     # div/mod
     'DSGR':    ('rre',   ['\xB9','\x0D'], 'eo,r'),
     'DSG':     ('rxy',   ['\xE3','\x0D'], 'eo,bidl'),
@@ -44,7 +45,6 @@
 
     # rotating
     'RISBG':   ('rie_f',   ['\xEC','\x55']),
-    'RISBGN':  ('rie_f',   ['\xEC','\x59']),
 
     # invert & negative & absolute
     'LPGR':    ('rre',   ['\xB9','\x00']),
diff --git a/rpython/jit/backend/zarch/opassembler.py 
b/rpython/jit/backend/zarch/opassembler.py
--- a/rpython/jit/backend/zarch/opassembler.py
+++ b/rpython/jit/backend/zarch/opassembler.py
@@ -160,11 +160,15 @@
         omc.BRC(c.ANY, l.imm(label_end - jmp_neither_lqlr_overflow))
         omc.overwrite()
 
-    emit_int_floordiv = gen_emit_div_mod('DSGR', 'DSG')
-    emit_uint_floordiv = gen_emit_div_mod('DLGR', 'DLG')
-    # NOTE division sets one register with the modulo value, thus
-    # the regalloc ensures the right register survives.
-    emit_int_mod = gen_emit_div_mod('DSGR', 'DSG')
+    def emit_uint_mul_high(self, op, arglocs, regalloc):
+        r0, _, a1 = arglocs
+        # _ carries the value, contents of r0 are ignored
+        assert not r0.is_imm()
+        assert not a1.is_imm()
+        if a1.is_core_reg():
+            self.mc.MLGR(r0, a1)
+        else:
+            self.mc.MLG(r0, a1)
 
     def emit_int_invert(self, op, arglocs, regalloc):
         l0, = arglocs
diff --git a/rpython/jit/backend/zarch/regalloc.py 
b/rpython/jit/backend/zarch/regalloc.py
--- a/rpython/jit/backend/zarch/regalloc.py
+++ b/rpython/jit/backend/zarch/regalloc.py
@@ -733,9 +733,6 @@
     prepare_int_sub_ovf = helper.prepare_int_sub
     prepare_int_mul = helper.prepare_int_mul
     prepare_int_mul_ovf = helper.prepare_int_mul_ovf
-    prepare_int_floordiv = helper.prepare_int_div
-    prepare_uint_floordiv = helper.prepare_int_div
-    prepare_int_mod = helper.prepare_int_mod
     prepare_nursery_ptr_increment = prepare_int_add
 
     prepare_int_and = helper.prepare_int_logic
@@ -746,6 +743,18 @@
     prepare_int_lshift  = helper.prepare_int_shift
     prepare_uint_rshift = helper.prepare_int_shift
 
+    def prepare_uint_mul_high(self, op):
+        a0 = op.getarg(0)
+        a1 = op.getarg(1)
+        if a0.is_constant():
+            a0, a1 = a1, a0
+        if helper.check_imm32(a1):
+            l1 = self.ensure_reg(a1)
+        else:
+            l1 = self.ensure_reg_or_pool(a1)
+        lr,lq = self.rm.ensure_even_odd_pair(a0, op, bind_first=True)
+        return [lr, lq, l1]
+
     prepare_int_le = helper.generate_cmp_op()
     prepare_int_lt = helper.generate_cmp_op()
     prepare_int_ge = helper.generate_cmp_op()
diff --git a/rpython/jit/backend/zarch/test/test_assembler.py 
b/rpython/jit/backend/zarch/test/test_assembler.py
--- a/rpython/jit/backend/zarch/test/test_assembler.py
+++ b/rpython/jit/backend/zarch/test/test_assembler.py
@@ -155,7 +155,15 @@
         s64 = bin(fac_data[1])[2:]
         print(f64)
         print(s64)
+        for i,c in enumerate(f64):
+            print('index: %d is set? %s' % (i,c))
+
+        assert f64[1] == '1' # The z/Architecture architectural mode is 
installed.
+        assert f64[2] == '1' # The z/Architecture architectural mode is active.
         assert f64[18] == '1' # long displacement facility
+        assert f64[21] == '1' # extended immediate facility
+        assert f64[34] == '1' # general instruction facility
+        assert f64[41] == '1' # floating-point-support-enhancement
 
     def test_load_byte_zero_extend(self):
         adr = self.a.datablockwrapper.malloc_aligned(16, 16)
@@ -189,7 +197,7 @@
     @py.test.mark.parametrize('p', 
[2**32,2**32+1,2**63-1,2**63-2,0,1,2,3,4,5,6,7,8,10001])
     def test_align_withroll(self, p):
         self.a.mc.load_imm(r.r2, p & 0xffffFFFFffffFFFF)
-        self.a.mc.RISBGN(r.r2, r.r2, loc.imm(0), loc.imm(0x80 | 60), 
loc.imm(0))
+        self.a.mc.RISBG(r.r2, r.r2, loc.imm(0), loc.imm(0x80 | 60), loc.imm(0))
         self.a.mc.BCR(con.ANY, r.r14)
         assert run_asm(self.a) == rffi.cast(rffi.ULONG,p) & ~(7)
 
@@ -214,7 +222,7 @@
         n = 13
         l = loc
         self.a.mc.load_imm(r.r2, 7<<n)
-        self.a.mc.RISBGN(r.r2, r.r2, l.imm(61), l.imm(0x80 | 63), l.imm(64-n))
+        self.a.mc.RISBG(r.r2, r.r2, l.imm(61), l.imm(0x80 | 63), l.imm(64-n))
         self.a.mc.BCR(con.ANY, r.r14)
         assert run_asm(self.a) == 7
 
@@ -222,7 +230,7 @@
         n = 16
         l = loc
         self.a.mc.load_imm(r.r2, 0xffFFffFF)
-        self.a.mc.RISBGN(r.r2, r.r2, l.imm(60), l.imm(0x80 | 63), l.imm(64-n))
+        self.a.mc.RISBG(r.r2, r.r2, l.imm(60), l.imm(0x80 | 63), l.imm(64-n))
         self.a.mc.BCR(con.ANY, r.r14)
         assert run_asm(self.a) == 15
 
diff --git a/rpython/jit/backend/zarch/test/test_auto_encoding.py 
b/rpython/jit/backend/zarch/test/test_auto_encoding.py
--- a/rpython/jit/backend/zarch/test/test_auto_encoding.py
+++ b/rpython/jit/backend/zarch/test/test_auto_encoding.py
@@ -204,7 +204,7 @@
                 g.write('%s\n' % op)
                 oplist.append(op)
             g.write('\t.string "%s"\n' % END_TAG)
-        proc = subprocess.Popen(['as', '-m64', '-mzarch', '-march=zEC12',
+        proc = subprocess.Popen(['as', '-m64', '-mzarch', '-march=z196',
                                  inputname, '-o', filename],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
diff --git a/rpython/jit/backend/zarch/test/test_int.py 
b/rpython/jit/backend/zarch/test/test_int.py
--- a/rpython/jit/backend/zarch/test/test_int.py
+++ b/rpython/jit/backend/zarch/test/test_int.py
@@ -35,41 +35,13 @@
         fail = self.cpu.get_latest_descr(deadframe)
         assert fail == finishdescr # ensures that guard is not taken!
 
-    def test_double_evenodd_pair(self):
-        code = """
-        [i0]
-        i1 = int_floordiv(i0, 2)
-        i2 = int_floordiv(i0, 3)
-        i3 = int_floordiv(i0, 4)
-        i4 = int_floordiv(i0, 5)
-        i5 = int_floordiv(i0, 6)
-        i6 = int_floordiv(i0, 7)
-        i7 = int_floordiv(i0, 8)
-        i8 = int_le(i1, 0)
-        guard_true(i8) [i1,i2,i3,i4,i5,i6,i7]
-        finish(i0, descr=faildescr)
-        """
-        # the guard forces 3 spills because after 4 divisions
-        # all even slots of the managed registers are full
-        loop = parse(code, namespace={'faildescr': BasicFinalDescr(1)})
-        looptoken = JitCellToken()
-        self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
-        deadframe = self.cpu.execute_token(looptoken, 100)
-        fail = self.cpu.get_latest_descr(deadframe)
-        for i in range(2,9):
-            assert self.cpu.get_int_value(deadframe, i-2) == 100//i
-
-
-
     @py.test.mark.parametrize('value', [2,3,15,2**16])
     def test_evenodd_pair_extensive(self, value):
         instrs = []
         failargs = []
         values = []
         j = 0
-        mapping = (('int_floordiv',lambda x,y: x // y),
-                   ('int_mod', lambda x,y: x % y),
-                   ('int_mul_ovf', lambda x,y: x * y))
+        mapping = (('int_mul_ovf', lambda x,y: x * y),)
         for i in range(20):
             name, func = mapping[j]
             instrs.append("i{d} = {i}(i0, {d})".format(d=i+1, i=name))
diff --git a/rpython/jit/backend/zarch/test/test_regalloc.py 
b/rpython/jit/backend/zarch/test/test_regalloc.py
--- a/rpython/jit/backend/zarch/test/test_regalloc.py
+++ b/rpython/jit/backend/zarch/test/test_regalloc.py
@@ -146,128 +146,3 @@
     assert cpu.get_int_value(deadframe, 0) == 0
     assert cpu.get_int_value(deadframe, 1) == -1000
 
-def test_bug_0():
-    cpu, deadframe = run([-13, 10, 10, 8, -8, -16, -18, 46, -12, 26], '''
-    [i1, i2, i3, i4, i5, i6, i7, i8, i9, i10]
-    i11 = uint_gt(i3, -48)
-    i12 = int_xor(i8, i1)
-    i13 = int_gt(i6, -9)
-    i14 = int_le(i13, i2)
-    i15 = int_le(i11, i5)
-    i16 = uint_ge(i13, i13)
-    i17 = int_or(i9, -23)
-    i18 = int_lt(i10, i13)
-    i19 = int_or(i15, i5)
-    i20 = int_xor(i17, 54)
-    i21 = int_mul(i8, i10)
-    i22 = int_or(i3, i9)
-    i41 = int_and(i11, -4)
-    i42 = int_or(i41, 1)
-    i23 = int_mod(i12, i42)
-    i24 = int_is_true(i6)
-    i25 = uint_rshift(i15, 6)
-    i26 = int_or(-4, i25)
-    i27 = int_invert(i8)
-    i28 = int_sub(-113, i11)
-    i29 = int_neg(i7)
-    i30 = int_neg(i24)
-    i31 = int_floordiv(i3, 53)
-    i32 = int_mul(i28, i27)
-    i43 = int_and(i18, -4)
-    i44 = int_or(i43, 1)
-    i33 = int_mod(i26, i44)
-    i34 = int_or(i27, i19)
-    i35 = uint_lt(i13, 1)
-    i45 = int_and(i21, 31)
-    i36 = int_rshift(i21, i45)
-    i46 = int_and(i20, 31)
-    i37 = uint_rshift(i4, i46)
-    i38 = uint_gt(i33, -11)
-    i39 = int_neg(i7)
-    i40 = int_gt(i24, i32)
-    i99 = same_as_i(0)
-    guard_true(i99) [i40, i36, i37, i31, i16, i34, i35, i23, i22, i29, i14, 
i39, i30, i38]
-    finish(42)
-    ''')
-    assert cpu.get_int_value(deadframe, 0) == 0
-    assert cpu.get_int_value(deadframe, 1) == 0
-    assert cpu.get_int_value(deadframe, 2) == 0
-    assert cpu.get_int_value(deadframe, 3) == 0
-    assert cpu.get_int_value(deadframe, 4) == 1
-    assert cpu.get_int_value(deadframe, 5) == -7
-    assert cpu.get_int_value(deadframe, 6) == 1
-    assert cpu.get_int_value(deadframe, 7) == 0
-    assert cpu.get_int_value(deadframe, 8) == -2
-    assert cpu.get_int_value(deadframe, 9) == 18
-    assert cpu.get_int_value(deadframe, 10) == 1
-    assert cpu.get_int_value(deadframe, 11) == 18
-    assert cpu.get_int_value(deadframe, 12) == -1
-    assert cpu.get_int_value(deadframe, 13) == 0
-
-def test_bug_1():
-    cpu, deadframe = run([17, -20, -6, 6, 1, 13, 13, 9, 49, 8], '''
-    [i1, i2, i3, i4, i5, i6, i7, i8, i9, i10]
-    i11 = uint_lt(i6, 0)
-    i41 = int_and(i3, 31)
-    i12 = int_rshift(i3, i41)
-    i13 = int_neg(i2)
-    i14 = int_add(i11, i7)
-    i15 = int_or(i3, i2)
-    i16 = int_or(i12, i12)
-    i17 = int_ne(i2, i5)
-    i42 = int_and(i5, 31)
-    i18 = uint_rshift(i14, i42)
-    i43 = int_and(i14, 31)
-    i19 = int_lshift(7, i43)
-    i20 = int_neg(i19)
-    i21 = int_mod(i3, 1)
-    i22 = uint_ge(i15, i1)
-    i44 = int_and(i16, 31)
-    i23 = int_lshift(i8, i44)
-    i24 = int_is_true(i17)
-    i45 = int_and(i5, 31)
-    i25 = int_lshift(i14, i45)
-    i26 = int_lshift(i5, 17)
-    i27 = int_eq(i9, i15)
-    i28 = int_ge(0, i6)
-    i29 = int_neg(i15)
-    i30 = int_neg(i22)
-    i31 = int_add(i7, i16)
-    i32 = uint_lt(i19, i19)
-    i33 = int_add(i2, 1)
-    i34 = int_neg(i5)
-    i35 = int_add(i17, i24)
-    i36 = uint_lt(2, i16)
-    i37 = int_neg(i9)
-    i38 = int_gt(i4, i11)
-    i39 = int_lt(i27, i22)
-    i40 = int_neg(i27)
-    i99 = same_as_i(0)
-    guard_true(i99) [i40, i10, i36, i26, i13, i30, i21, i33, i18, i25, i31, 
i32, i28, i29, i35, i38, i20, i39, i34, i23, i37]
-    finish(-42)
-    ''')
-    assert cpu.get_int_value(deadframe, 0) == 0
-    assert cpu.get_int_value(deadframe, 1) == 8
-    assert cpu.get_int_value(deadframe, 2) == 1
-    assert cpu.get_int_value(deadframe, 3) == 131072
-    assert cpu.get_int_value(deadframe, 4) == 20
-    assert cpu.get_int_value(deadframe, 5) == -1
-    assert cpu.get_int_value(deadframe, 6) == 0
-    assert cpu.get_int_value(deadframe, 7) == -19
-    assert cpu.get_int_value(deadframe, 8) == 6
-    assert cpu.get_int_value(deadframe, 9) == 26
-    assert cpu.get_int_value(deadframe, 10) == 12
-    assert cpu.get_int_value(deadframe, 11) == 0
-    assert cpu.get_int_value(deadframe, 12) == 0
-    assert cpu.get_int_value(deadframe, 13) == 2
-    assert cpu.get_int_value(deadframe, 14) == 2
-    assert cpu.get_int_value(deadframe, 15) == 1
-    assert cpu.get_int_value(deadframe, 16) == -57344
-    assert cpu.get_int_value(deadframe, 17) == 1
-    assert cpu.get_int_value(deadframe, 18) == -1
-    if WORD == 4:
-        assert cpu.get_int_value(deadframe, 19) == -2147483648
-    elif WORD == 8:
-        assert cpu.get_int_value(deadframe, 19) == 19327352832
-    assert cpu.get_int_value(deadframe, 20) == -49
-
diff --git a/rpython/translator/platform/arch/__init__.py 
b/rpython/translator/platform/arch/__init__.py
new file mode 100644
diff --git a/rpython/translator/platform/arch/s390x.py 
b/rpython/translator/platform/arch/s390x.py
new file mode 100644
--- /dev/null
+++ b/rpython/translator/platform/arch/s390x.py
@@ -0,0 +1,86 @@
+import re
+
+def extract_s390x_cpu_ids(lines):
+    """ NOT_RPYTHON """
+    ids = []
+
+    re_number = re.compile("processor (\d+):")
+    re_version = re.compile("version = ([0-9A-Fa-f]+)")
+    re_id = re.compile("identification = ([0-9A-Fa-f]+)")
+    re_machine = re.compile("machine = ([0-9A-Fa-f]+)")
+    for line in lines:
+        number = -1
+        version = None
+        ident = None
+        machine = 0
+
+        match = re_number.match(line)
+        if not match:
+            continue
+        number = int(match.group(1))
+
+        match = re_version.search(line)
+        if match:
+            version = match.group(1)
+
+        match = re_version.search(line)
+        if match:
+            version = match.group(1)
+
+        match = re_id.search(line)
+        if match:
+            ident = match.group(1)
+
+        match = re_machine.search(line)
+        if match:
+            machine = int(match.group(1), 16)
+
+        ids.append((number, version, ident, machine))
+
+    return ids
+
+
+def s390x_cpu_revision():
+    """ NOT_RPYTHON """
+    # linux kernel does the same classification
+    # 
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20131028/193311.html
+
+    with open("/proc/cpuinfo", "rb") as fd:
+        lines = fd.read().splitlines()
+        cpu_ids = extract_s390x_cpu_ids(lines)
+    machine = -1
+    for number, version, id, m in cpu_ids:
+        if machine != -1:
+            assert machine == m
+        machine = m
+
+    if machine == 0x2097 or machine == 0x2098:
+        return "z10"
+    if machine == 0x2817 or machine == 0x2818:
+        return "z196"
+    if machine == 0x2827 or machine == 0x2828:
+        return "zEC12"
+    if machine == 0x2964:
+        return "z13"
+
+    # well all others are unsupported!
+    return "unknown"
+
+def update_cflags(cflags):
+    """ NOT_RPYTHON """
+    # force the right target arch for s390x
+    for cflag in cflags:
+        if cflag.startswith('-march='):
+            break
+    else:
+        # the default cpu architecture that is supported
+        # older versions are not supported
+        revision = s390x_cpu_revision()
+        if revision == 'z13':
+            # gcc does not recognize z13 as a compiler flag!
+            revision = 'zEC12'
+
+        assert revision != 'unknown'
+        cflags += ('-march='+revision,)
+    cflags += ('-m64','-mzarch')
+    return cflags
diff --git a/rpython/translator/platform/arch/test/test_s390x.py 
b/rpython/translator/platform/arch/test/test_s390x.py
new file mode 100644
--- /dev/null
+++ b/rpython/translator/platform/arch/test/test_s390x.py
@@ -0,0 +1,22 @@
+import py
+import platform
+from rpython.translator.platform.arch.s390x import (s390x_cpu_revision,
+        extract_s390x_cpu_ids)
+
+if platform.machine() != 's390x':
+    py.test.skip("s390x tests only")
+
+def test_cpuid_s390x():
+    revision = s390x_cpu_revision()
+    assert revision != 'unknown', 'the model you are running on might be too 
old'
+
+def test_read_processor_info():
+    ids = extract_s390x_cpu_ids("""
+processor 0: machine = 12345
+processor 1: version = FF, identification = AF
+    """.splitlines())
+    assert ids == [(0, None, None, 0x12345),
+                   (1, 'FF', 'AF', 0),
+                  ]
+
+
diff --git a/rpython/translator/platform/linux.py 
b/rpython/translator/platform/linux.py
--- a/rpython/translator/platform/linux.py
+++ b/rpython/translator/platform/linux.py
@@ -22,8 +22,8 @@
     so_prefixes = ('lib', '')
 
     if platform.machine() == 's390x':
-        # force the right target arch for s390x
-        cflags = ('-march=zEC12','-m64','-mzarch') + cflags
+        from rpython.translator.platform.arch import s390x
+        cflags = s390x.update_cflags(cflags)
 
     def _args_for_shared(self, args):
         return ['-shared'] + args
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to