[pypy-commit] pypy py3.6: merge default into py3.6

mattip pypy.commits at gmail.com
Mon Nov 18 06:37:38 EST 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: py3.6
Changeset: r98110:dde73a3a316b
Date: 2019-11-18 04:36 -0700
http://bitbucket.org/pypy/pypy/changeset/dde73a3a316b/

Log:	merge default into py3.6

diff --git a/pypy/module/_cffi_backend/newtype.py b/pypy/module/_cffi_backend/newtype.py
--- a/pypy/module/_cffi_backend/newtype.py
+++ b/pypy/module/_cffi_backend/newtype.py
@@ -267,7 +267,8 @@
 if sys.platform == 'win32':
     DEFAULT_SFLAGS_PLATFORM = SF_MSVC_BITFIELDS
 else:
-    if rffi_platform.getdefined('__arm__', ''):
+    if (rffi_platform.getdefined('__arm__', '') or
+        rffi_platform.getdefined('__aarch64__', '')):
         DEFAULT_SFLAGS_PLATFORM = SF_GCC_ARM_BITFIELDS
     else:
         DEFAULT_SFLAGS_PLATFORM = SF_GCC_X86_BITFIELDS
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -793,8 +793,10 @@
         # While this is a hack, cpython does it as well.
         w_metatype = space.w_type
 
-    w_obj = space.allocate_instance(W_PyCTypeObject, w_metatype)
-    track_reference(space, py_obj, w_obj)
+    w_obj = rawrefcount.to_obj(W_PyCTypeObject, py_obj)
+    if w_obj is None:
+        w_obj = space.allocate_instance(W_PyCTypeObject, w_metatype)
+        track_reference(space, py_obj, w_obj)
     # __init__ wraps all slotdefs functions from py_type via add_operators
     w_obj.__init__(space, py_type)
     w_obj.ready()
@@ -818,7 +820,7 @@
     Sets up tp_bases, necessary before creating the interpreter type.
     """
     base = pto.c_tp_base
-    base_pyo = rffi.cast(PyObject, pto.c_tp_base)
+    base_pyo = rffi.cast(PyObject, base)
     if base and not base.c_tp_flags & Py_TPFLAGS_READY:
         type_realize(space, base_pyo)
     if base and not pto.c_ob_type: # will be filled later
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
@@ -18,6 +18,20 @@
         return not detect_simd_z()
     return True
 
+def align_check(input):
+    if platform.machine().startswith('x86'):
+        return ""
+    if sys.maxsize > 2**32:
+        mask = 7
+    else:
+        mask = 3
+    return """
+        i10096 = int_and(%s, %d)
+        i10097 = int_is_zero(i10096)
+        guard_true(i10097, descr=...)
+    """ % (input, mask)
+
+
 @py.test.mark.skipif(True, reason='no _numpypy on pypy3')
 class TestMicroNumPy(BaseTestPyPyC):
 
@@ -144,8 +158,9 @@
             i9 = getfield_gc_i(p4, descr=<FieldU pypy.module.micronumpy.concrete.BaseConcreteArray.inst_storage \d+ pure>)
             i10 = getfield_gc_i(p6, descr=<FieldU pypy.module.micronumpy.descriptor.W_Dtype.inst_byteorder \d+ pure>)
             i12 = int_eq(i10, 61)
-            i14 = int_eq(i10, %d)
+            i14 = int_eq(i10, %(bit)d)
             i15 = int_or(i12, i14)
+            %(align_check)s
             f16 = raw_load_f(i9, i5, descr=<ArrayF \d+>)
             guard_true(i15, descr=...)
             guard_not_invalidated(descr=...)
@@ -177,7 +192,7 @@
             setfield_gc(p34, i30, descr=<FieldS pypy.module.micronumpy.iterators.IterState.inst_offset \d+>)
             }}}
             jump(..., descr=...)
-        """ % (bit,))
+        """ % {'align_check': align_check('i5'), 'bit': bit})
 
     def test_reduce_logical_and(self):
         def main():
@@ -190,6 +205,7 @@
         assert len(log.loops) == 1
         loop = log._filter(log.loops[0])
         loop.match("""
+            %(align_check)s
             f31 = raw_load_f(i9, i29, descr=<ArrayF 8>)
             guard_not_invalidated(descr=...)
             i32 = float_ne(f31, 0.000000)
@@ -199,7 +215,7 @@
             i38 = int_ge(i36, i30)
             guard_false(i38, descr=...)
             jump(..., descr=...)
-            """)
+            """ % {'align_check': align_check('i29')})
         # vector version
         #assert loop.match("""
         #    guard_not_invalidated(descr=...)
@@ -311,6 +327,7 @@
             guard_not_invalidated(descr=...)
             i88 = int_ge(i87, i59)
             guard_false(i88, descr=...)
+            %(align_check)s
             f90 = raw_load_f(i67, i89, descr=<ArrayF 8>)
             i91 = int_add(i87, 1)
             i93 = int_add(i89, 8)
@@ -321,7 +338,7 @@
             i96 = int_lt(i95, 0)
             guard_false(i96, descr=...)
             jump(..., descr=...)
-        """)
+        """ % {"align_check": align_check('i89')})
 
     def test_array_flatiter_getitem_single(self):
         def main():
@@ -343,6 +360,7 @@
             guard_true(i126, descr=...)
             i128 = int_mul(i117, i59)
             i129 = int_add(i55, i128)
+            %(align_check)s
             f149 = raw_load_f(i100, i129, descr=<ArrayF 8>)
             i151 = int_add(i117, 1)
             setfield_gc(p156, i55, descr=<FieldS pypy.module.micronumpy.iterators.IterState.inst_offset .+>)
@@ -350,7 +368,7 @@
             setarrayitem_gc(p150, 0, 0, descr=<ArrayS .+>)
             --TICK--
             jump(..., descr=...)
-        """)
+        """ % {'align_check': align_check('i129')})
 
     def test_array_flatiter_setitem_single(self):
         def main():
@@ -373,6 +391,7 @@
             i131 = int_mul(i120, i57)
             i132 = int_add(i53, i131)
             guard_not_invalidated(descr=...)
+            %(align_check)s
             raw_store(i103, i132, 42.000000, descr=<ArrayF 8>)
             i153 = int_add(i120, 1)
             i154 = getfield_raw_i(#, descr=<FieldS pypysig_long_struct.c_value 0>)
@@ -382,7 +401,7 @@
             i157 = int_lt(i154, 0)
             guard_false(i157, descr=...)
             jump(..., descr=...)
-        """)
+        """ % {'align_check': align_check('i132')})
 
     def test_mixed_div(self):
         N = 1500
@@ -406,6 +425,7 @@
             guard_false(i94, descr=...)
             i96 = int_mul(i91, i58)
             i97 = int_add(i51, i96)
+            %(align_check)s
             f98 = raw_load_f(i63, i97, descr=<ArrayF 8>)
             guard_not_invalidated(descr=...)
             f100 = float_mul(f98, 0.500000)
@@ -423,4 +443,4 @@
             i107 = int_lt(i106, 0)
             guard_false(i107, descr=...)
             jump(..., descr=...)
-        """)
+        """ % {'align_check': align_check('i97')})
diff --git a/rpython/jit/backend/x86/rx86.py b/rpython/jit/backend/x86/rx86.py
--- a/rpython/jit/backend/x86/rx86.py
+++ b/rpython/jit/backend/x86/rx86.py
@@ -699,6 +699,9 @@
     TEST_ai = insn(rex_w, '\xF7', orbyte(0<<3), mem_reg_plus_scaled_reg_plus_const(1), immediate(2))
     TEST_mi = insn(rex_w, '\xF7', orbyte(0<<3), mem_reg_plus_const(1), immediate(2))
     TEST_ji = insn(rex_w, '\xF7', orbyte(0<<3), abs_(1), immediate(2))
+    TEST_ri = insn(rex_w, '\xF7', orbyte(0<<3), register(1), '\xC0', immediate(2))
+    TEST_bi = insn(rex_w, '\xF7', orbyte(0<<3), stack_bp(1), immediate(2))
+    TEST_br = insn(rex_w, '\x85', register(2,8), stack_bp(1))
 
     BTS_mr = insn(rex_w, '\x0F\xAB', register(2,8), mem_reg_plus_const(1))
     BTS_jr = insn(rex_w, '\x0F\xAB', register(2,8), abs_(1))
diff --git a/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py b/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py
--- a/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py
+++ b/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py
@@ -311,6 +311,8 @@
                 return []   # MOV AL, [immediate]: there is a special encoding
             if methname == 'MOV8_jr' and args[1] == rx86.R.al:
                 return []   # MOV [immediate], AL: there is a special encoding
+            if methname == 'TEST_ri' and args[0] == rx86.R.eax:
+                return []  # TEST EAX, constant: there is a special encoding
 
             return [args]
 


More information about the pypy-commit mailing list