8000 GH-117066: Tier 2 optimizer: Don't throw away good traces if we can't… · python/cpython@63289b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 63289b9

Browse files
authored
GH-117066: Tier 2 optimizer: Don't throw away good traces if we can't optimize them perfectly. (GH-117067)
1 parent dcaf33a commit 63289b9

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

Python/optimizer_analysis.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,24 +406,28 @@ optimize_uops(
406406
out_of_space:
407407
DPRINTF(3, "\n");
408408
DPRINTF(1, "Out of space in abstract interpreter\n");
409-
_Py_uop_abstractcontext_fini(ctx);
410-
return 0;
411-
409+
goto done;
412410
error:
413411
DPRINTF(3, "\n");
414412
DPRINTF(1, "Encountered error in abstract interpreter\n");
415413
_Py_uop_abstractcontext_fini(ctx);
416-
return 0;
414+
return -1;
417415

418416
hit_bottom:
419417
// Attempted to push a "bottom" (contradition) symbol onto the stack.
420418
// This means that the abstract interpreter has hit unreachable code.
421-
// We *could* generate an _EXIT_TRACE or _FATAL_ERROR here, but it's
422-
// simpler to just admit failure and not create the executor.
419+
// We *could* generate an _EXIT_TRACE or _FATAL_ERROR here, but hitting
420+
// bottom indicates type instability, so we are probably better off
421+
// retrying later.
423422
DPRINTF(3, "\n");
424423
DPRINTF(1, "Hit bottom in abstract interpreter\n");
425424
_Py_uop_abstractcontext_fini(ctx);
426425
return 0;
426+
done:
427+
/* Cannot optimize further, but there would be no benefit
428+
* in retrying later */
429+
_Py_uop_abstractcontext_fini(ctx);
430+
return 1;
427431
}
428432

429433

Python/optimizer_bytecodes.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,9 @@ dummy_func(void) {
546546
PyFunctionObject *func = (PyFunctionObject *)(this_instr + 2)->operand;
547547
DPRINTF(3, "func: %p ", func);
548548
if (func == NULL) {
549-
goto error;
549+
DPRINTF(3, "\n");
550+
DPRINTF(1, "Missing function\n");
551+
goto done;
550552
}
551553
PyCodeObject *co = (PyCodeObject *)func->func_code;
552554

Python/optimizer_cases.c.h

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0