Esempio n. 1
0
# skip-if: '-O' in EXTRA_JIT_ARGS
# statcheck: 4 <= noninit_count('num_deopt') < 50
# statcheck: 1 <= stats["num_osr_exits"] <= 2

try:
    import __pyston__
    __pyston__.setOption("OSR_THRESHOLD_BASELINE", 50)
    __pyston__.setOption("REOPT_THRESHOLD_BASELINE", 50)
    __pyston__.setOption("OSR_THRESHOLD_INTERPRETER", 50)
    __pyston__.setOption("REOPT_THRESHOLD_INTERPRETER", 50)
    __pyston__.setOption("SPECULATION_THRESHOLD", 10)
except ImportError:
    pass

# This test makes sure that the boxedLocals survive a deopt.
# TODO Write a test case to make sure exc_info survives the deopt.

def f_with_name_scoping(o):
    print "starting f"

    exec "k = 5"
    l = 6

    try:
        print o.a
        if o.b:
            raise Exception('')
    except Exception, e:
        print o.c
        print e
    print o.d
Esempio n. 2
0
try:
    import __pyston__
    __pyston__.setOption("OSR_THRESHOLD_BASELINE", 50)
except ImportError:
    pass

def f1(x):
    exec """
for i in xrange(x):
    pass
print x
"""

f1(200)

def f3():
    exec """
def f2(x):
    def inner():
        return x
    return inner
"""

    g = f2(200)
    for i in xrange(200):
        g()
    print g()
f3()
Esempio n. 3
0
try:
    import __pyston__
    __pyston__.setOption("LAZY_SCOPING_ANALYSIS", 0)
except ImportError:
    pass

cases = [
    """
# should fail
def f():
    a = 0
    def g():
        print a
    del a
""", """
# should fail
def f():
    def g():
        print a
    del a
""", """
def f():
    global a
    a = 0
    def g():
        print a
    del a
""", """
def f():
    a = 0
    def g():
Esempio n. 4
0
# I would have expected this to be valid, but cPython and pypy err out saying "name 'x' is local and global"

try:
    import __pyston__
    __pyston__.setOption("LAZY_SCOPING_ANALYSIS", 0)
except ImportError:
    pass

try:
    exec """
x = 1
def f(x):
    global x

print "calling"
f(2)
print x
"""
except SyntaxError as e:
    print e.message

try:
    exec """
x = 1
def f((x, y)):
    global x

print "calling"
f(2)
print x
"""
Esempio n. 5
0
# This is the same as incremental_tb_bjit.py but tests the baseline JIT.
try:
    import __pyston__
    __pyston__.setOption("REOPT_THRESHOLD_INTERPRETER", 1)
except:
    pass

import incremental_tb
Esempio n. 6
0
# statcheck: '-L' in EXTRA_JIT_ARGS or 1 <= stats['num_osr_exits'] <= 5

# "big osr" in terms of lots of live variables needing to be passed through:

try:
    import __pyston__
    __pyston__.setOption("OSR_THRESHOLD_INTERPRETER", 5)
    __pyston__.setOption("OSR_THRESHOLD_BASELINE", 5)
except ImportError:
    pass


def outer(quit):
    if quit:
        return

    a = 1
    b = 2
    c = 3
    d = 4
    e = 5
    f = 6
    g = 7
    h = 8
    i = 9
    l = []

    n = 10000
    while n:
        n = n - 1
        a = a + 1
Esempio n. 7
0
try:
    import __pyston__
    __pyston__.setOption("OSR_THRESHOLD_BASELINE", 50)
except ImportError:
    pass


def f1(x):
    exec """
for i in xrange(x):
    pass
print x
"""


f1(200)


def f3():
    exec """
def f2(x):
    def inner():
        return x
    return inner
"""

    g = f2(200)
    for i in xrange(200):
        g()
    print g()
Esempio n. 8
0
# statcheck: '-O' in EXTRA_JIT_ARGS or 1 <= stats['num_osr_exits'] <= 5

# "big osr" in terms of lots of live variables needing to be passed through:

try:
    import __pyston__
    __pyston__.setOption("OSR_THRESHOLD_INTERPRETER", 5)
    __pyston__.setOption("OSR_THRESHOLD_BASELINE", 5)
except ImportError:
    pass

def outer(quit):
    if quit:
        return

    a = 1
    b = 2
    c = 3
    d = 4
    e = 5
    f = 6
    g = 7
    h = 8
    i = 9
    l = []

    n = 10000
    while n:
        n = n - 1
        a = a + 1
        b = b + 1