コード例 #1
0
ファイル: test_policy.py プロジェクト: Darriall/pypy
def test_contains_unsupported_variable_type():
    def f(x):
        return x
    graph = support.getgraph(f, [5])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                assert not contains_unsupported_variable_type(graph, sf,
                                                              sll, ssf)
    #
    graph = support.getgraph(f, [5.5])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                res = contains_unsupported_variable_type(graph, sf, sll, ssf)
                assert res is not sf
    #
    graph = support.getgraph(f, [r_singlefloat(5.5)])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                res = contains_unsupported_variable_type(graph, sf, sll, ssf)
                assert res == (not ssf)
    #
    graph = support.getgraph(f, [r_longlong(5)])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                res = contains_unsupported_variable_type(graph, sf, sll, ssf)
                assert res == (sys.maxint == 2147483647 and not sll)
コード例 #2
0
ファイル: test_policy.py プロジェクト: sota/pypy-old
def test_contains_unsupported_variable_type():
    def f(x):
        return x

    graph = support.getgraph(f, [5])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                assert not contains_unsupported_variable_type(
                    graph, sf, sll, ssf)
    #
    graph = support.getgraph(f, [5.5])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                res = contains_unsupported_variable_type(graph, sf, sll, ssf)
                assert res is not sf
    #
    graph = support.getgraph(f, [r_singlefloat(5.5)])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                res = contains_unsupported_variable_type(graph, sf, sll, ssf)
                assert res == (not ssf)
    #
    graph = support.getgraph(f, [r_longlong(5)])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                res = contains_unsupported_variable_type(graph, sf, sll, ssf)
                assert res == (sys.maxint == 2147483647 and not sll)
コード例 #3
0
ファイル: test_policy.py プロジェクト: Darriall/pypy
def test_look_inside():
    def h1(x):
        return x + 1
    @jit.look_inside    # force True, even if look_inside_function() thinks not
    def h2(x):
        return x + 2
    class MyPolicy(JitPolicy):
        def look_inside_function(self, func):
            return False
    graph1 = support.getgraph(h1, [5])
    graph2 = support.getgraph(h2, [5])
    assert not MyPolicy().look_inside_graph(graph1)
    assert MyPolicy().look_inside_graph(graph2)
コード例 #4
0
ファイル: test_policy.py プロジェクト: sota/pypy-old
def test_look_inside():
    def h1(x):
        return x + 1

    @jit.look_inside  # force True, even if look_inside_function() thinks not
    def h2(x):
        return x + 2

    class MyPolicy(JitPolicy):
        def look_inside_function(self, func):
            return False

    graph1 = support.getgraph(h1, [5])
    graph2 = support.getgraph(h2, [5])
    assert not MyPolicy().look_inside_graph(graph1)
    assert MyPolicy().look_inside_graph(graph2)
コード例 #5
0
ファイル: test_policy.py プロジェクト: sota/pypy-old
def test_dont_look_inside():
    @jit.dont_look_inside
    def h(x):
        return x + 3

    graph = support.getgraph(h, [5])
    assert not JitPolicy().look_inside_graph(graph)
コード例 #6
0
ファイル: test_policy.py プロジェクト: sota/pypy-old
def test_elidable():
    @jit.elidable
    def g(x):
        return x + 2

    graph = support.getgraph(g, [5])
    assert not JitPolicy().look_inside_graph(graph)
コード例 #7
0
ファイル: test_policy.py プロジェクト: sota/pypy-old
def test_without_floats():
    graph = support.getgraph(lambda x: x + 3.2, [5.4])
    policy = JitPolicy()
    policy.set_supports_floats(True)
    assert policy.look_inside_graph(graph)
    policy = JitPolicy()
    policy.set_supports_floats(False)
    assert not policy.look_inside_graph(graph)
コード例 #8
0
ファイル: test_policy.py プロジェクト: Darriall/pypy
def test_loops():
    def g(x):
        i = 0
        while i < x:
            i += 1
        return i
    graph = support.getgraph(g, [5])
    assert not JitPolicy().look_inside_graph(graph)
コード例 #9
0
ファイル: test_policy.py プロジェクト: Darriall/pypy
def test_without_floats():
    graph = support.getgraph(lambda x: x+3.2, [5.4])
    policy = JitPolicy()
    policy.set_supports_floats(True)
    assert policy.look_inside_graph(graph)
    policy = JitPolicy()
    policy.set_supports_floats(False)
    assert not policy.look_inside_graph(graph)
コード例 #10
0
ファイル: test_policy.py プロジェクト: sota/pypy-old
def test_loops():
    def g(x):
        i = 0
        while i < x:
            i += 1
        return i

    graph = support.getgraph(g, [5])
    assert not JitPolicy().look_inside_graph(graph)
コード例 #11
0
ファイル: test_policy.py プロジェクト: Darriall/pypy
def test_unroll_safe():
    @jit.unroll_safe
    def h(x):
        i = 0
        while i < x:
            i += 1
        return i
    graph = support.getgraph(h, [5])
    assert JitPolicy().look_inside_graph(graph)
コード例 #12
0
ファイル: test_policy.py プロジェクト: sota/pypy-old
def test_unroll_safe():
    @jit.unroll_safe
    def h(x):
        i = 0
        while i < x:
            i += 1
        return i

    graph = support.getgraph(h, [5])
    assert JitPolicy().look_inside_graph(graph)
コード例 #13
0
ファイル: test_policy.py プロジェクト: Darriall/pypy
def test_unroll_safe_and_inline():
    @jit.unroll_safe
    def h(x):
        i = 0
        while i < x:
            i += 1
        return i
    h._always_inline_ = True

    def g(x):
        return h(x)

    graph = support.getgraph(h, [5])
    assert JitPolicy().look_inside_graph(graph)
コード例 #14
0
ファイル: test_policy.py プロジェクト: sota/pypy-old
def test_unroll_safe_and_inline():
    @jit.unroll_safe
    def h(x):
        i = 0
        while i < x:
            i += 1
        return i

    h._always_inline_ = True

    def g(x):
        return h(x)

    graph = support.getgraph(h, [5])
    assert JitPolicy().look_inside_graph(graph)
コード例 #15
0
ファイル: test_policy.py プロジェクト: sota/pypy-old
def test_str_join():
    def f(x, y):
        return "hello".join([str(x), str(y), "bye"])

    graph = support.getgraph(f, [5, 83])
    for block in graph.iterblocks():
        for op in block.operations:
            if op.opname == 'direct_call':
                funcptr = op.args[0].value
                called_graph = funcptr._obj.graph
                if JitPolicy().look_inside_graph(called_graph):
                    # the calls to join() and str() should be residual
                    mod = called_graph.func.__module__
                    assert (mod == 'rpython.rtyper.rlist'
                            or mod == 'rpython.rtyper.lltypesystem.rlist')
コード例 #16
0
ファイル: test_policy.py プロジェクト: Darriall/pypy
def test_str_join():
    def f(x, y):
        return "hello".join([str(x), str(y), "bye"])

    graph = support.getgraph(f, [5, 83])
    for block in graph.iterblocks():
        for op in block.operations:
            if op.opname == 'direct_call':
                funcptr = op.args[0].value
                called_graph = funcptr._obj.graph
                if JitPolicy().look_inside_graph(called_graph):
                    # the calls to join() and str() should be residual
                    mod = called_graph.func.__module__
                    assert (mod == 'rpython.rtyper.rlist' or
                            mod == 'rpython.rtyper.lltypesystem.rlist')
コード例 #17
0
ファイル: test_policy.py プロジェクト: sota/pypy-old
def test_regular_function():
    graph = support.getgraph(lambda x: x + 3, [5])
    assert JitPolicy().look_inside_graph(graph)
コード例 #18
0
ファイル: test_policy.py プロジェクト: Darriall/pypy
def test_dont_look_inside():
    @jit.dont_look_inside
    def h(x):
        return x + 3
    graph = support.getgraph(h, [5])
    assert not JitPolicy().look_inside_graph(graph)
コード例 #19
0
ファイル: test_policy.py プロジェクト: Darriall/pypy
def test_elidable():
    @jit.elidable
    def g(x):
        return x + 2
    graph = support.getgraph(g, [5])
    assert not JitPolicy().look_inside_graph(graph)
コード例 #20
0
ファイル: test_policy.py プロジェクト: Darriall/pypy
def test_regular_function():
    graph = support.getgraph(lambda x: x+3, [5])
    assert JitPolicy().look_inside_graph(graph)