23
23
raise unittest .SkipTest ("test crash randomly on ASAN/MSAN/UBSAN build" )
24
24
25
25
26
- def is_jit_build ():
27
- cflags = (sysconfig .get_config_var ("PY_CORE_CFLAGS" ) or '' )
28
- return "_Py_JIT" in cflags
29
-
30
-
31
- if is_jit_build ():
32
- raise unittest .SkipTest ("Perf support is not available in JIT builds" )
33
-
34
-
35
26
def supports_trampoline_profiling ():
36
27
perf_trampoline = sysconfig .get_config_var ("PY_HAVE_PERF_TRAMPOLINE" )
37
28
if not perf_trampoline :
@@ -58,12 +49,15 @@ def tearDown(self) -> None:
58
49
59
50
def test_trampoline_works (self ):
60
51
code = """if 1:
52
+ from test import support
53
+
61
54
def foo():
62
55
pass
63
56
64
57
def bar():
65
58
foo()
66
59
60
+ @support.without_optimizer
67
61
def baz():
68
62
bar()
69
63
@@ -110,6 +104,7 @@ def baz():
110
104
def test_trampoline_works_with_forks (self ):
111
105
code = """if 1:
112
106
import os, sys
107
+ from test import support
113
108
114
109
def foo_fork():
115
110
pass
@@ -132,6 +127,7 @@ def foo():
132
127
def bar():
133
128
foo()
134
129
130
+ @support.without_optimizer
135
131
def baz():
136
132
bar()
137
133
@@ -168,6 +164,8 @@ def baz():
168
164
def test_sys_api (self ):
169
165
code = """if 1:
170
166
import sys
167
+ from test import support
168
+
171
169
def foo():
172
170
pass
173
171
@@ -180,6 +178,7 @@ def bar():
180
178
sys.activate_stack_trampoline("perf")
181
179
spam()
182
180
181
+ @support.without_optimizer
183
182
def baz():
184
183
bar()
185
184
@@ -344,6 +343,8 @@ def run_perf(self, script_dir, perf_mode, script):
344
343
def test_python_calls_appear_in_the_stack_if_perf_activated (self ):
345
344
with temp_dir () as script_dir :
346
345
code = """if 1:
346
+ from test import support
347
+
347
348
def foo(n):
348
349
x = 0
349
350
for i in range(n):
@@ -352,6 +353,7 @@ def foo(n):
352
353
def bar(n):
353
354
foo(n)
354
355
356
+ @support.without_optimizer
355
357
def baz(n):
356
358
bar(n)
357
359
@@ -368,6 +370,8 @@ def baz(n):
368
370
def test_python_calls_do_not_appear_in_the_stack_if_perf_deactivated (self ):
369
371
with temp_dir () as script_dir :
370
372
code = """if 1:
373
+ from test import support
374
+
371
375
def foo(n):
372
376
x = 0
373
377
for i in range(n):
@@ -376,6 +380,7 @@ def foo(n):
376
380
def bar(n):
377
381
foo(n)
378
382
383
+ @support.without_optimizer
379
384
def baz(n):
380
385
bar(n)
381
386
@@ -428,12 +433,14 @@ def test_pre_fork_compile(self):
428
433
def foo_fork():
429
434
pass
430
435
436
+ @support.without_optimizer
431
437
def bar_fork():
432
438
foo_fork()
433
439
434
440
def foo():
435
441
import time; time.sleep(1)
436
442
443
+ @support.without_optimizer
437
444
def bar():
438
445
foo()
439
446
@@ -442,7 +449,6 @@ def compile_trampolines_for_all_functions():
442
449
for _, obj in globals().items():
443
450
if callable(obj) and hasattr(obj, '__code__'):
444
451
compile_perf_trampoline_entry(obj.__code__)
445
-
446
452
if __name__ == "__main__":
447
453
compile_trampolines_for_all_functions()
448
454
pid = os.fork()
0 commit comments