Author: Matti Picus <[email protected]>
Branch: py3.5
Changeset: r96006:f468bb5ec141
Date: 2019-02-13 23:18 +0200
http://bitbucket.org/pypy/pypy/changeset/f468bb5ec141/

Log:    merge default into branch

diff --git a/pypy/doc/extending.rst b/pypy/doc/extending.rst
--- a/pypy/doc/extending.rst
+++ b/pypy/doc/extending.rst
@@ -45,16 +45,13 @@
 with the `CPython ctypes`_ version.  It works for large examples, such
 as pyglet.  PyPy's implementation is not strictly 100% compatible with
 CPython, but close enough for most cases.
-
-We also used to provide ``ctypes-configure`` for some API-level access.
-This is now viewed as a precursor of CFFI, which you should use instead.
 More (but older) information is available :doc:`here 
<discussion/ctypes-implementation>`.
 Also, ctypes' performance is not as good as CFFI's.
 
 .. _CPython ctypes: http://docs.python.org/library/ctypes.html
 
 PyPy implements ctypes as pure Python code around two built-in modules
-called ``_ffi`` and ``_rawffi``, which give a very low-level binding to
+called ``_rawffi`` and ``_rawffi.alt``, which give a very low-level binding to
 the C library libffi_.  Nowadays it is not recommended to use directly
 these two modules.
 
diff --git a/pypy/doc/index.rst b/pypy/doc/index.rst
--- a/pypy/doc/index.rst
+++ b/pypy/doc/index.rst
@@ -103,7 +103,7 @@
     the `development mailing list`_.
 
 .. _#pypy on irc.freenode.net: irc://irc.freenode.net/pypy
-.. _here: https://botbot.me/freenode/pypy/
+.. _here: https://quodlibet.duckdns.org/irc/pypy/latest.log.html#irc-end
 .. _Development mailing list: http://mail.python.org/mailman/listinfo/pypy-dev
 .. _Commit mailing list: http://mail.python.org/mailman/listinfo/pypy-commit
 .. _Development bug/feature tracker: https://bitbucket.org/pypy/pypy/issues
diff --git a/pypy/doc/release-v7.0.0.rst b/pypy/doc/release-v7.0.0.rst
--- a/pypy/doc/release-v7.0.0.rst
+++ b/pypy/doc/release-v7.0.0.rst
@@ -19,11 +19,12 @@
 Until we can work with downstream providers to distribute builds with PyPy, we
 have made packages for some common packages `available as wheels`_.
 
-The GC `hooks`_ , which can be used to gain more insights into its
+The `GC hooks`_ , which can be used to gain more insights into its
 performance, has been improved and it is now possible to manually manage the
 GC by using a combination of ``gc.disable`` and ``gc.collect_step``. See the
 `GC blog post`_.
 
+.. _`GC hooks`: 
http://doc.pypy.org/en/latest/gc_info.html#semi-manual-gc-management
 
 We updated the `cffi`_ module included in PyPy to version 1.12, and the
 `cppyy`_ backend to 1.4. Please use these to wrap your C and C++ code,
@@ -49,7 +50,7 @@
 
 We would also like to thank our contributors and encourage new people to join
 the project. PyPy has many layers and we need help with all of them: `PyPy`_
-and `RPython`_ documentation improvements, tweaking popular `modules`_ to run
+and `RPython`_ documentation improvements, tweaking popular modules to run
 on pypy, or general `help`_ with making RPython's JIT even better.
 
 .. _`PyPy`: index.html
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
@@ -25,6 +25,15 @@
 Improve performance of long operations where one of the operands fits into
 an int.
 
-.. branch: regalloc-playgrounds
+.. branch: regalloc-playground
 
 Improve register allocation in the JIT.
+
+.. branch: promote-unicode
+
+Implement rlib.jit.promote_unicode to complement promote_string
+
+.. branch: unicode-utf8
+
+Use utf8 internally to represent unicode, with the goal of never using 
rpython-level unicode
+
diff --git a/pypy/module/zlib/test/test_zlib.py 
b/pypy/module/zlib/test/test_zlib.py
--- a/pypy/module/zlib/test/test_zlib.py
+++ b/pypy/module/zlib/test/test_zlib.py
@@ -2,8 +2,8 @@
 Tests for the zlib module.
 """
 
+import pypy
 import py
-import pypy
 
 try:
     import zlib
@@ -15,7 +15,7 @@
     from pypy.module.zlib import interp_zlib
     from rpython.rlib import rzlib
 except ImportError:
-    import py; py.test.skip("no zlib C library on this machine")
+    py.test.skip("no zlib C library on this machine")
 
 
 class AppTestZlib(object):
@@ -403,6 +403,7 @@
 
         assert (d1 + from_copy) == (d1 + from_compressor)
 
+    @py.test.mark.skipif(rzlib.ZLIB_VERSION == '1.2.8', reason='does not error 
check')
     def test_cannot_copy_compressor_with_stream_in_inconsistent_state(self):
         if self.runappdirect: skip("can't run with -A")
         compressor = self.zlib.compressobj()
diff --git a/rpython/jit/backend/arm/regalloc.py 
b/rpython/jit/backend/arm/regalloc.py
--- a/rpython/jit/backend/arm/regalloc.py
+++ b/rpython/jit/backend/arm/regalloc.py
@@ -305,9 +305,8 @@
         operations = cpu.gc_ll_descr.rewrite_assembler(cpu, operations,
                                                        allgcrefs)
         # compute longevity of variables
-        longevity, last_real_usage = compute_vars_longevity(inputargs, 
operations)
+        longevity = compute_vars_longevity(inputargs, operations)
         self.longevity = longevity
-        self.last_real_usage = last_real_usage
         fm = self.frame_manager
         asm = self.assembler
         self.vfprm = VFPRegisterManager(longevity, fm, asm)
@@ -1062,7 +1061,7 @@
         position = self.rm.position
         for arg in inputargs:
             assert not isinstance(arg, Const)
-            if self.last_real_usage.get(arg, -1) <= position:
+            if self.longevity[arg].is_last_real_use_before(position):
                 self.force_spill_var(arg)
 
         #
diff --git a/rpython/jit/backend/llsupport/assembler.py 
b/rpython/jit/backend/llsupport/assembler.py
--- a/rpython/jit/backend/llsupport/assembler.py
+++ b/rpython/jit/backend/llsupport/assembler.py
@@ -77,6 +77,20 @@
         self._debug = False
         self.loop_run_counters = []
 
+        # XXX register allocation statistics to be removed later
+        self.num_moves_calls = 0
+        self.num_moves_jump = 0
+        self.num_spills = 0
+        self.num_spills_to_existing = 0
+        self.num_reloads = 0
+
+        self.preamble_num_moves_calls = 0
+        self.preamble_num_moves_jump = 0
+        self.preamble_num_spills = 0
+        self.preamble_num_spills_to_existing = 0
+        self.preamble_num_reloads = 0
+
+
     def stitch_bridge(self, faildescr, target):
         raise NotImplementedError
 
diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -90,19 +90,6 @@
         self.target_tokens_currently_compiling = {}
         self.frame_depth_to_patch = []
 
-        # XXX register allocation statistics to be removed later
-        self.num_moves_calls = 0
-        self.num_moves_jump = 0
-        self.num_spills = 0
-        self.num_spills_to_existing = 0
-        self.num_reloads = 0
-
-        self.preamble_num_moves_calls = 0
-        self.preamble_num_moves_jump = 0
-        self.preamble_num_spills = 0
-        self.preamble_num_spills_to_existing = 0
-        self.preamble_num_reloads = 0
-
 
     def teardown(self):
         self.pending_guard_tokens = None
diff --git a/rpython/jit/backend/x86/test/test_regalloc.py 
b/rpython/jit/backend/x86/test/test_regalloc.py
--- a/rpython/jit/backend/x86/test/test_regalloc.py
+++ b/rpython/jit/backend/x86/test/test_regalloc.py
@@ -419,4 +419,6 @@
         # 1 because lifetime of i172 does not end at the int_xor
         # 1 ptr to save before call
         # 3 for argument shuffling
-        assert len(self.filter_log_moves()) == 11
+
+        # XXX there is an additional mov, find out why!
+        assert len(self.filter_log_moves()) == 12
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
@@ -316,13 +316,13 @@
                 orig_var_even = reverse_mapping[even]
                 if orig_var_even in forbidden_vars:
                     continue # duh!
-                self._sync_var(orig_var_even)
+                self._sync_var_to_stack(orig_var_even)
                 del self.reg_bindings[orig_var_even]
             elif which_to_spill == SPILL_ODD:
                 orig_var_odd = reverse_mapping[odd]
                 if orig_var_odd in forbidden_vars:
                     continue # duh!
-                self._sync_var(orig_var_odd)
+                self._sync_var_to_stack(orig_var_odd)
                 del self.reg_bindings[orig_var_odd]
             
             # well, we got away with a single spill :)
@@ -344,10 +344,10 @@
                 continue
 
             if orig_var_even is not None:
-                self._sync_var(orig_var_even)
+                self._sync_var_to_stack(orig_var_even)
                 del self.reg_bindings[orig_var_even]
             if orig_var_odd is not None:
-                self._sync_var(orig_var_odd)
+                self._sync_var_to_stack(orig_var_odd)
                 del self.reg_bindings[orig_var_odd]
 
             self.reg_bindings[even_var] = even
@@ -371,7 +371,7 @@
                                                       forbidden_vars, odd)
                 else:
                     # old even var is not forbidden, sync it and be done with 
it
-                    self._sync_var(old_even_var)
+                    self._sync_var_to_stack(old_even_var)
                     del self.reg_bindings[old_even_var]
                     del reverse_mapping[odd]
             if old_odd_var:
@@ -379,7 +379,7 @@
                     self._relocate_forbidden_variable(odd, old_odd_var, 
reverse_mapping,
                                                       forbidden_vars, even)
                 else:
-                    self._sync_var(old_odd_var)
+                    self._sync_var_to_stack(old_odd_var)
                     del self.reg_bindings[old_odd_var]
                     del reverse_mapping[odd]
 
@@ -406,7 +406,7 @@
             candidate_var = reverse_mapping.get(candidate, None)
             if not candidate_var or candidate_var not in forbidden_vars:
                 if candidate_var is not None:
-                    self._sync_var(candidate_var)
+                    self._sync_var_to_stack(candidate_var)
                     del self.reg_bindings[candidate_var]
                     del reverse_mapping[candidate]
                 self.assembler.regalloc_mov(reg, candidate)
diff --git a/rpython/jit/codewriter/jtransform.py 
b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -596,6 +596,23 @@
             op1 = SpaceOperation('str_guard_value', [op.args[0], c, descr],
                                  op.result)
             return [SpaceOperation('-live-', [], None), op1, None]
+        if (hints.get('promote_unicode') and
+            op.args[0].concretetype is not lltype.Void):
+            U = lltype.Ptr(rstr.UNICODE)
+            assert op.args[0].concretetype == U
+            self._register_extra_helper(EffectInfo.OS_UNIEQ_NONNULL,
+                                        "str.eq_nonnull",
+                                        [U, U],
+                                        lltype.Signed,
+                                        EffectInfo.EF_ELIDABLE_CANNOT_RAISE)
+            descr, p = 
self.callcontrol.callinfocollection.callinfo_for_oopspec(
+                EffectInfo.OS_UNIEQ_NONNULL)
+            # XXX this is fairly ugly way of creating a constant,
+            #     however, callinfocollection has no better interface
+            c = Constant(p.adr.ptr, lltype.typeOf(p.adr.ptr))
+            op1 = SpaceOperation('str_guard_value', [op.args[0], c, descr],
+                                 op.result)
+            return [SpaceOperation('-live-', [], None), op1, None]
         if hints.get('force_virtualizable'):
             return SpaceOperation('hint_force_virtualizable', [op.args[0]], 
None)
         if hints.get('force_no_const'):   # for tests only
diff --git a/rpython/jit/codewriter/test/test_jtransform.py 
b/rpython/jit/codewriter/test/test_jtransform.py
--- a/rpython/jit/codewriter/test/test_jtransform.py
+++ b/rpython/jit/codewriter/test/test_jtransform.py
@@ -94,7 +94,7 @@
                 return True
         return False
     def callinfo_for_oopspec(self, oopspecindex):
-        assert oopspecindex == effectinfo.EffectInfo.OS_STREQ_NONNULL
+        # assert oopspecindex == effectinfo.EffectInfo.OS_STREQ_NONNULL
         class c:
             class adr:
                 ptr = 1
@@ -1129,6 +1129,21 @@
     assert op1.result == v2
     assert op0.opname == '-live-'
 
+def test_unicode_promote():
+    PUNICODE = lltype.Ptr(rstr.UNICODE)
+    v1 = varoftype(PUNICODE)
+    v2 = varoftype(PUNICODE)
+    op = SpaceOperation('hint',
+                        [v1, Constant({'promote_unicode': True}, lltype.Void)],
+                        v2)
+    tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
+    op0, op1, _ = tr.rewrite_operation(op)
+    assert op1.opname == 'str_guard_value'
+    assert op1.args[0] == v1
+    assert op1.args[2] == 'calldescr'
+    assert op1.result == v2
+    assert op0.opname == '-live-'
+
 def test_double_promote_str():
     PSTR = lltype.Ptr(rstr.STR)
     v1 = varoftype(PSTR)
diff --git a/rpython/jit/metainterp/test/test_string.py 
b/rpython/jit/metainterp/test/test_string.py
--- a/rpython/jit/metainterp/test/test_string.py
+++ b/rpython/jit/metainterp/test/test_string.py
@@ -3,7 +3,7 @@
 from rpython.jit.metainterp.test.support import LLJitMixin
 from rpython.rlib.debug import debug_print
 from rpython.rlib.jit import (JitDriver, dont_look_inside, we_are_jitted,
-    promote_string)
+    promote_string, promote_unicode)
 from rpython.rlib.rstring import StringBuilder, UnicodeBuilder
 
 
@@ -518,6 +518,19 @@
         self.meta_interp(f, [0])
         self.check_resops(call_r=2, call_i=5)
 
+    def test_promote_unicode(self):
+        driver = JitDriver(greens = [], reds = ['n'])
+
+        def f(n):
+            while n < 21:
+                driver.jit_merge_point(n=n)
+                promote_unicode(unicode(str(n % 3)))
+                n += 1
+            return 0
+
+        self.meta_interp(f, [0])
+        self.check_resops(call_r=4, call_i=5)
+
     def test_join_chars(self):
         jitdriver = JitDriver(reds=['a', 'b', 'c', 'i'], greens=[])
         _str = self._str
diff --git a/rpython/memory/gc/test/test_direct.py 
b/rpython/memory/gc/test/test_direct.py
--- a/rpython/memory/gc/test/test_direct.py
+++ b/rpython/memory/gc/test/test_direct.py
@@ -781,7 +781,7 @@
         def large_malloc():
             # malloc an object which is large enough to trigger a major 
collection
             threshold = self.gc.next_major_collection_threshold
-            self.malloc(VAR, int(threshold/8))
+            self.malloc(VAR, int(threshold/4))
             summary = debuglog.summary()
             debuglog.reset()
             return summary
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -84,6 +84,7 @@
 
     * promote - promote the argument from a variable into a constant
     * promote_string - same, but promote string by *value*
+    * promote_unicode - same, but promote unicode string by *value*
     * access_directly - directly access a virtualizable, as a structure
                         and don't treat it as a virtualizable
     * fresh_virtualizable - means that virtualizable was just allocated.
@@ -126,6 +127,9 @@
 def promote_string(x):
     return hint(x, promote_string=True)
 
+def promote_unicode(x):
+    return hint(x, promote_unicode=True)
+
 def dont_look_inside(func):
     """ Make sure the JIT does not trace inside decorated function
     (it becomes a call instead)
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -254,7 +254,7 @@
                 'sched.h',
                 'grp.h', 'dirent.h', 'sys/stat.h', 'fcntl.h',
                 'signal.h', 'sys/utsname.h', _ptyh]
-    if sys.platform.startswith('linux'):
+    if sys.platform.startswith('linux') or sys.platform.startswith('gnu'):
         includes.append('sys/sysmacros.h')
     if sys.platform.startswith('freebsd') or 
sys.platform.startswith('openbsd'):
         includes.append('sys/ttycom.h')
diff --git a/rpython/rlib/test/test_rzlib.py b/rpython/rlib/test/test_rzlib.py
--- a/rpython/rlib/test/test_rzlib.py
+++ b/rpython/rlib/test/test_rzlib.py
@@ -274,7 +274,7 @@
     rzlib.deflateEnd(copied)
     assert bytes1 + bytes_copy == compressed
 
-
[email protected](rzlib.ZLIB_VERSION == '1.2.8', reason='does not error 
check')
 def test_unsuccessful_compress_copy():
     """
     Errors during unsuccesful deflateCopy operations raise RZlibErrors.
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to