Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r88643:27b352d10c03 Date: 2016-11-24 17:58 +0100 http://bitbucket.org/pypy/pypy/changeset/27b352d10c03/
Log: Test and fix: try harder to propagate 'can_be_None=False' information diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py --- a/rpython/rlib/jit.py +++ b/rpython/rlib/jit.py @@ -1243,7 +1243,13 @@ args_s[1], args_s[2:]) if self.instance == _jit_conditional_call_value: from rpython.annotator import model as annmodel - return annmodel.unionof(s_res, args_s[0]) + # the result is either s_res, i.e. the function result, or + # it is args_s[0]-but-not-none. The "not-none" part is + # only useful for pointer-like types, but it means that + # args_s[0] could be NULL without the result of the whole + # conditional_call_elidable() necessarily returning a result + # that can be NULL. + return annmodel.unionof(s_res, args_s[0].nonnoneify()) def specialize_call(self, hop): from rpython.rtyper.lltypesystem import lltype diff --git a/rpython/rlib/test/test_jit.py b/rpython/rlib/test/test_jit.py --- a/rpython/rlib/test/test_jit.py +++ b/rpython/rlib/test/test_jit.py @@ -314,6 +314,24 @@ res = self.interpret(f, [-42, 1000, 100]) assert res == -42 + def test_conditional_call_elidable_annotates_nonnull(self): + class X: + pass + def g(n): + return X() # non-null + def f(x, n): + y = conditional_call_elidable(x, g, n) + return y # now, y is known to be non-null, even if x can be + def main(n): + if n > 100: + x = X() + else: + x = None + return f(x, n) + t = TranslationContext() + s = t.buildannotator().build_types(main, [int]) + assert s.can_be_None is False + def test_enter_leave_portal_frame(self): from rpython.translator.interactive import Translation def g(): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit