Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,9 @@ def test_guard_type_version_not_removed(self):

def thing(a):
x = 0
for i in range(100):
# 90 iterations with Foo.attr == 1, then 16 to invalidate, warm up
# again, and re-optimize with Foo.attr == 2:
for i in range(90 + 16):
x += a.attr
# for the first 90 iterations we set the attribute on this dummy function which shouldn't
# trigger the type watcher
Expand All @@ -1410,7 +1412,7 @@ class Bar:
opnames = list(iter_opnames(ex))

self.assertIsNotNone(ex)
self.assertEqual(res, 219)
self.assertEqual(res, 243)
guard_type_version_count = opnames.count("_GUARD_TYPE_VERSION")
self.assertEqual(guard_type_version_count, 2)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Require cold or invalidated code to "warm up" before being JIT compiled
again.
14 changes: 9 additions & 5 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2624,15 +2624,16 @@ dummy_func(
}
_PyExecutorObject *executor;
int optimized = _PyOptimizer_Optimize(frame, start, stack_pointer, &executor, 0);
ERROR_IF(optimized < 0, error);
if (optimized) {
if (optimized <= 0) {
this_instr[1].counter = restart_backoff_counter(counter);
ERROR_IF(optimized < 0, error);
}
else {
this_instr[1].counter = initial_jump_backoff_counter();
assert(tstate->previous_executor == NULL);
tstate->previous_executor = Py_None;
GOTO_TIER_TWO(executor);
}
else {
this_instr[1].counter = restart_backoff_counter(counter);
}
}
else {
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
Expand Down Expand Up @@ -4869,6 +4870,9 @@ dummy_func(
tstate->previous_executor = (PyObject *)current_executor;
GOTO_TIER_ONE(target);
}
else {
exit->temperature = initial_temperature_backoff_counter();
}
}
exit->executor = executor;
}
Expand Down
3 changes: 3 additions & 0 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading