[pypy-dev] [pypy-commit] pypy faster-nested-scopes: fix tests. no clue where the extra arraylen comes from?

Hakan Ardo hakan at debian.org
Sat Aug 27 08:41:37 CEST 2011


If a getarrayitem is moved into the short_preamble we also need guards
on the array len as it might be out of bound at the end of some future
bridge. After jit-short_from_state the jump of the loop is produced by
inlining the short preamble there (that approach does not crash if the
optimizers introduces new boxes). It is typically optimized out
entierly. In case of an array len check the guard is optimized out
while the arraylen remains. It should be killed by the backend though
as it's result is never used.

On Fri, Aug 26, 2011 at 11:19 PM, cfbolz <noreply at buildbot.pypy.org> wrote:
> Author: Carl Friedrich Bolz <cfbolz at gmx.de>
> Branch: faster-nested-scopes
> Changeset: r46806:77b0daebad60
> Date: 2011-08-26 23:25 +0200
> http://bitbucket.org/pypy/pypy/changeset/77b0daebad60/
>
> Log:    fix tests. no clue where the extra arraylen comes from?
>
> diff --git a/pypy/module/pypyjit/test_pypy_c/test_call.py b/pypy/module/pypyjit/test_pypy_c/test_call.py
> --- a/pypy/module/pypyjit/test_pypy_c/test_call.py
> +++ b/pypy/module/pypyjit/test_pypy_c/test_call.py
> @@ -67,24 +67,17 @@
>         assert log.opnames(ops) == ["guard_value",
>                                     "getfield_gc", "guard_value",
>                                     "getfield_gc", "guard_value",
> -                                    "getfield_gc", "guard_nonnull_class"]
> -        # LOAD_GLOBAL of OFFSET but in different function partially folded
> +                                    "guard_not_invalidated"]
> +        # LOAD_GLOBAL of OFFSET but in different function folded
>         # away
> -        # XXX could be improved
>         ops = entry_bridge.ops_by_id('add', opcode='LOAD_GLOBAL')
> -        assert log.opnames(ops) == ["guard_value", "getfield_gc", "guard_value"]
> +        assert log.opnames(ops) == ["guard_not_invalidated"]
>         #
>         # two LOAD_GLOBAL of f, the second is folded away
>         ops = entry_bridge.ops_by_id('call', opcode='LOAD_GLOBAL')
> -        assert log.opnames(ops) == ["getfield_gc", "guard_nonnull_class"]
> +        assert log.opnames(ops) == []
>         #
>         assert entry_bridge.match_by_id('call', """
> -            p29 = getfield_gc(ConstPtr(ptr28), descr=<GcPtrFieldDescr pypy.objspace.std.celldict.ModuleCell.inst_w_value .*>)
> -            guard_nonnull_class(p29, ConstClass(Function), descr=...)
> -            p33 = getfield_gc(p29, descr=<GcPtrFieldDescr pypy.interpreter.function.Function.inst_code .*>)
> -            guard_value(p33, ConstPtr(ptr34), descr=...)
> -            p35 = getfield_gc(p29, descr=<GcPtrFieldDescr pypy.interpreter.function.Function.inst_w_func_globals .*>)
> -            p36 = getfield_gc(p29, descr=<GcPtrFieldDescr pypy.interpreter.function.Function.inst_closure .*>)
>             p38 = call(ConstClass(getexecutioncontext), descr=<GcPtrCallDescr>)
>             p39 = getfield_gc(p38, descr=<GcPtrFieldDescr pypy.interpreter.executioncontext.ExecutionContext.inst_topframeref .*>)
>             i40 = force_token()
> @@ -100,19 +93,16 @@
>         # -----------------------------
>         loop, = log.loops_by_id('call')
>         assert loop.match("""
> -            i12 = int_lt(i5, i6)
> -            guard_true(i12, descr=...)
> +            guard_not_invalidated(descr=...)
> +            i9 = int_lt(i5, i6)
> +            guard_true(i9, descr=...)
> +            i10 = force_token()
> +            i12 = int_add(i5, 1)
>             i13 = force_token()
> -            i15 = int_add(i5, 1)
> -            i16 = int_add_ovf(i15, i7)
> -            guard_no_overflow(descr=...)
> -            i18 = force_token()
> -            i20 = int_add_ovf(i16, 1)
> -            guard_no_overflow(descr=...)
> -            i21 = int_add_ovf(i20, i7)
> +            i15 = int_add_ovf(i12, 1)
>             guard_no_overflow(descr=...)
>             --TICK--
> -            jump(p0, p1, p2, p3, p4, i21, i6, i7, p8, p9, p10, p11, descr=<Loop0>)
> +            jump(p0, p1, p2, p3, p4, i15, i6, i7, p8, descr=<Loop0>)
>         """)
>
>     def test_method_call(self):
> diff --git a/pypy/module/pypyjit/test_pypy_c/test_globals.py b/pypy/module/pypyjit/test_pypy_c/test_globals.py
> --- a/pypy/module/pypyjit/test_pypy_c/test_globals.py
> +++ b/pypy/module/pypyjit/test_pypy_c/test_globals.py
> @@ -20,11 +20,9 @@
>             guard_value(p10, ConstPtr(ptr11), descr=...)
>             p12 = getfield_gc(p10, descr=<GcPtrFieldDescr .*W_DictMultiObject.inst_strategy .*>)
>             guard_value(p12, ConstPtr(ptr13), descr=...)
> -            p15 = getfield_gc(ConstPtr(ptr14), descr=<GcPtrFieldDescr .*ModuleCell.inst_w_value .*>)
> -            guard_isnull(p15, descr=...)
>             guard_not_invalidated(descr=...)
>             p19 = getfield_gc(ConstPtr(p17), descr=<GcPtrFieldDescr .*W_DictMultiObject.inst_strategy .*>)
>             guard_value(p19, ConstPtr(ptr20), descr=...)
>             p22 = getfield_gc(ConstPtr(ptr21), descr=<GcPtrFieldDescr .*ModuleCell.inst_w_value .*>)
>             guard_nonnull(p22, descr=...)
> -        """)
> \ No newline at end of file
> +        """)
> diff --git a/pypy/module/pypyjit/test_pypy_c/test_instance.py b/pypy/module/pypyjit/test_pypy_c/test_instance.py
> --- a/pypy/module/pypyjit/test_pypy_c/test_instance.py
> +++ b/pypy/module/pypyjit/test_pypy_c/test_instance.py
> @@ -52,7 +52,7 @@
>             i10 = int_add_ovf(i5, i7)
>             guard_no_overflow(descr=...)
>             --TICK--
> -            jump(p0, p1, p2, p3, p4, i10, i6, p7, i7, p8, descr=<Loop0>)
> +            jump(p0, p1, p2, p3, p4, i10, i6, i7, p8, descr=<Loop0>)
>         """)
>
>     def test_getattr_with_dynamic_attribute(self):
> @@ -151,6 +151,7 @@
>         assert loop.match_by_id('loadattr',
>         '''
>         guard_not_invalidated(descr=...)
> +        i16 = arraylen_gc(p10, descr=<GcPtrArrayDescr>)
>         i19 = call(ConstClass(ll_dict_lookup), _, _, _, descr=...)
>         guard_no_exception(descr=...)
>         i21 = int_and(i19, _)
> diff --git a/pypy/module/pypyjit/test_pypy_c/test_math.py b/pypy/module/pypyjit/test_pypy_c/test_math.py
> --- a/pypy/module/pypyjit/test_pypy_c/test_math.py
> +++ b/pypy/module/pypyjit/test_pypy_c/test_math.py
> @@ -47,6 +47,7 @@
>         assert loop.match("""
>             i2 = int_lt(i0, i1)
>             guard_true(i2, descr=...)
> +            guard_not_invalidated(descr=...)
>             f1 = cast_int_to_float(i0)
>             i3 = float_eq(f1, inf)
>             i4 = float_eq(f1, -inf)
> @@ -60,4 +61,4 @@
>             i7 = int_add(i0, f1)
>             --TICK--
>             jump(..., descr=)
> -        """)
> \ No newline at end of file
> +        """)
> diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py b/pypy/module/pypyjit/test_pypy_c/test_string.py
> --- a/pypy/module/pypyjit/test_pypy_c/test_string.py
> +++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
> @@ -105,5 +105,5 @@
>             i58 = int_add_ovf(i6, i57)
>             guard_no_overflow(descr=...)
>             --TICK--
> -            jump(p0, p1, p2, p3, p4, p5, i58, i7, i8, p9, p10, descr=<Loop4>)
> +            jump(p0, p1, p2, p3, p4, p5, i58, i7, descr=<Loop4>)
>         """)
> _______________________________________________
> pypy-commit mailing list
> pypy-commit at python.org
> http://mail.python.org/mailman/listinfo/pypy-commit
>



-- 
Håkan Ardö


More information about the pypy-dev mailing list