summaryrefslogtreecommitdiffstats
path: root/Python/optimizer.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2023-11-17 19:49:42 (GMT)
committerGitHub <noreply@github.com>2023-11-17 19:49:42 (GMT)
commitbe0bd54c6b3b2382d03f2073070353c8b946902b (patch)
treec92d1dacbfd1fe3e7e9bf538538cf48b66c5a4d3 /Python/optimizer.c
parentb4144979934d7b8448f80c1fbee65dc3bfbce005 (diff)
downloadcpython-be0bd54c6b3b2382d03f2073070353c8b946902b.zip
cpython-be0bd54c6b3b2382d03f2073070353c8b946902b.tar.gz
cpython-be0bd54c6b3b2382d03f2073070353c8b946902b.tar.bz2
gh-106529: Cleanups split off gh-112134 (#112214)
- Double max trace size to 256 - Add a dependency on executor_cases.c.h for ceval.o - Mark `_SPECIALIZE_UNPACK_SEQUENCE` as `TIER_ONE_ONLY` - Add debug output back showing the optimized trace - Bunch of cleanups to Tools/cases_generator/
Diffstat (limited to 'Python/optimizer.c')
-rw-r--r--Python/optimizer.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c
index e14ad89..5d1ef8a 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -325,7 +325,8 @@ uop_dealloc(_PyUOpExecutorObject *self) {
}
static const char *
-uop_name(int index) {
+uop_name(int index)
+{
if (index <= MAX_REAL_OPCODE) {
return _PyOpcode_OpName[index];
}
@@ -832,6 +833,24 @@ make_executor_from_uops(_PyUOpInstruction *buffer, _PyBloomFilter *dependencies)
assert(dest == -1);
executor->base.execute = _PyUopExecute;
_Py_ExecutorInit((_PyExecutorObject *)executor, dependencies);
+#ifdef Py_DEBUG
+ char *python_lltrace = Py_GETENV("PYTHON_LLTRACE");
+ int lltrace = 0;
+ if (python_lltrace != NULL && *python_lltrace >= '0') {
+ lltrace = *python_lltrace - '0'; // TODO: Parse an int and all that
+ }
+ if (lltrace >= 2) {
+ printf("Optimized executor (length %d):\n", length);
+ for (int i = 0; i < length; i++) {
+ printf("%4d %s(%d, %d, %" PRIu64 ")\n",
+ i,
+ uop_name(executor->trace[i].opcode),
+ executor->trace[i].oparg,
+ executor->trace[i].target,
+ executor->trace[i].operand);
+ }
+ }
+#endif
return (_PyExecutorObject *)executor;
}