File: jitcrashers.py

package info (click to toggle)
pypy3 7.3.19%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212,236 kB
  • sloc: python: 2,098,316; ansic: 540,565; sh: 21,462; asm: 14,419; cpp: 4,451; makefile: 4,209; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 12; awk: 4
file content (103 lines) | stat: -rw-r--r-- 1,727 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from __future__ import print_function

def jit_simple_loop():
    print("simple loop")

    i = 0
    while i < 200:
        i = i + 3
    print(i)
    #assert i == 102

def jit_simple_inplace_add():
    print("simple loop with inplace_add")

    i = 0
    while i < 200:
        i += 3
    print(i)

def jit_range():
    print("range object, but outside the loop")

    s = 0
    for i in range(200):
        s = s + i
    print(s)

def jit_exceptions():
    try:
        i = 200
        while i > 0:
            if i == 10:
                raise IndexError
            i -= 1
    except IndexError:
        pass
    else:
        raise AssertionError

def jit_simple_bridge():
    s = 0
    for i in range(200):
        if i % 2:
            s += 1
        else:
            s += 2
    print(s)

def jit_tuple_indexing():
    t = (1, 2, 3)
    i = 0
    while i < 200:
        t = t[1], t[2], t[0]
        i += 1
    print(t)

def jit_nested_loop():
    print("Arbitrary test function.")
    n = 100
    i = 0
    x = 1
    while i<n:
        j = 0   #ZERO
        while j<=i:
            j = j + 1
            x = x + (i&j)
        i = i + 1
    print(x)
    return x

def jit_another_loop():
    n = "hello"
    i = 0
    while i < 150:
        i = i + 1
    print(n)

def jit_loop_with_call():
    i = 0
    k = 0
    while i < 20000:
        k += call(i)
        i += 1

def call(i):
    k = 0
    for j in range(i, i + 2):
        if j > i + 2:
            raise Exception("Explode")
        k += 1
    return k

def jit_importing_posixpath():
    import os
    import posixpath

def jit_importing_site():
    import site

def jit_unicode_formatting():
    d = []
    for i in range(1000):
        d[i] = u'\\xyz%d' % i