https://github.com/python/cpython/commit/94dbce13979ea1b302ba12be8769175c50639b30
commit: 94dbce13979ea1b302ba12be8769175c50639b30
branch: main
author: Hai Zhu <[email protected]>
committer: markshannon <[email protected]>
date: 2026-01-14T10:27:33Z
summary:

gh-138050: Use cold flag instead of warm flag in `MAKE_WARM` (GH-143827)

files:
M Include/internal/pycore_optimizer.h
M Python/bytecodes.c
M Python/executor_cases.c.h
M Python/optimizer.c
M Python/pystate.c

diff --git a/Include/internal/pycore_optimizer.h 
b/Include/internal/pycore_optimizer.h
index a2d9d2d4dfc86f..80a22e6bd12c64 100644
--- a/Include/internal/pycore_optimizer.h
+++ b/Include/internal/pycore_optimizer.h
@@ -27,7 +27,7 @@ typedef struct {
     uint8_t oparg;
     uint8_t valid;
     uint8_t chain_depth;  // Must be big enough for MAX_CHAIN_DEPTH - 1.
-    bool warm;
+    bool cold;
     uint8_t pending_deletion;
     int32_t index;           // Index of ENTER_EXECUTOR (if code isn't NULL, 
below).
     _PyBloomFilter bloom;
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index fda97dc07932fb..273865bd366935 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -5474,7 +5474,7 @@ dummy_func(
         }
 
         tier2 op(_MAKE_WARM, (--)) {
-            current_executor->vm_data.warm = true;
+            current_executor->vm_data.cold = false;
         }
 
         tier2 op(_FATAL_ERROR, (--)) {
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index 26385e3a32f472..42cca042022fc1 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -18511,7 +18511,7 @@
         case _MAKE_WARM_r00: {
             CHECK_CURRENT_CACHED_VALUES(0);
             assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
-            current_executor->vm_data.warm = true;
+            current_executor->vm_data.cold = false;
             SET_CURRENT_CACHED_VALUES(0);
             assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
             break;
@@ -18521,7 +18521,7 @@
             CHECK_CURRENT_CACHED_VALUES(1);
             assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
             _PyStackRef _stack_item_0 = _tos_cache0;
-            current_executor->vm_data.warm = true;
+            current_executor->vm_data.cold = false;
             _tos_cache0 = _stack_item_0;
             SET_CURRENT_CACHED_VALUES(1);
             assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
@@ -18533,7 +18533,7 @@
             assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
             _PyStackRef _stack_item_0 = _tos_cache0;
             _PyStackRef _stack_item_1 = _tos_cache1;
-            current_executor->vm_data.warm = true;
+            current_executor->vm_data.cold = false;
             _tos_cache1 = _stack_item_1;
             _tos_cache0 = _stack_item_0;
             SET_CURRENT_CACHED_VALUES(2);
@@ -18547,7 +18547,7 @@
             _PyStackRef _stack_item_0 = _tos_cache0;
             _PyStackRef _stack_item_1 = _tos_cache1;
             _PyStackRef _stack_item_2 = _tos_cache2;
-            current_executor->vm_data.warm = true;
+            current_executor->vm_data.cold = false;
             _tos_cache2 = _stack_item_2;
             _tos_cache1 = _stack_item_1;
             _tos_cache0 = _stack_item_0;
diff --git a/Python/optimizer.c b/Python/optimizer.c
index 79ac179d0b710a..5ef4a5c4fa513c 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -1408,9 +1408,9 @@ make_executor_from_uops(_PyThreadStateImpl *tstate, 
_PyUOpInstruction *buffer, i
 #ifdef _Py_JIT
     executor->jit_code = NULL;
     executor->jit_size = 0;
-    // This is initialized to true so we can prevent the executor
+    // This is initialized to false so we can prevent the executor
     // from being immediately detected as cold and invalidated.
-    executor->vm_data.warm = true;
+    executor->vm_data.cold = false;
     if (_PyJIT_Compile(executor, executor->trace, length)) {
         Py_DECREF(executor);
         return NULL;
@@ -1698,9 +1698,9 @@ make_cold_executor(uint16_t opcode)
         Py_FatalError("Cannot allocate core JIT code");
     }
     ((_PyUOpInstruction *)cold->trace)->opcode = opcode;
-    // This is initialized to true so we can prevent the executor
+    // This is initialized to false so we can prevent the executor
     // from being immediately detected as cold and invalidated.
-    cold->vm_data.warm = true;
+    cold->vm_data.cold = false;
 #ifdef _Py_JIT
     cold->jit_code = NULL;
     cold->jit_size = 0;
@@ -1895,11 +1895,11 @@ _Py_Executors_InvalidateCold(PyInterpreterState *interp)
         assert(exec->vm_data.valid);
         _PyExecutorObject *next = exec->vm_data.links.next;
 
-        if (!exec->vm_data.warm && PyList_Append(invalidate, (PyObject *)exec) 
< 0) {
+        if (exec->vm_data.cold && PyList_Append(invalidate, (PyObject *)exec) 
< 0) {
             goto error;
         }
         else {
-            exec->vm_data.warm = false;
+            exec->vm_data.cold = true;
         }
 
         exec = next;
diff --git a/Python/pystate.c b/Python/pystate.c
index b3d375a7feabb0..ebe56b8f32c06b 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -820,7 +820,7 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState 
*tstate)
     if (cold != NULL) {
         interp->cold_executor = NULL;
         assert(cold->vm_data.valid);
-        assert(cold->vm_data.warm);
+        assert(!cold->vm_data.cold);
         _PyExecutor_Free(cold);
     }
 
@@ -828,7 +828,7 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState 
*tstate)
     if (cold_dynamic != NULL) {
         interp->cold_dynamic_executor = NULL;
         assert(cold_dynamic->vm_data.valid);
-        assert(cold_dynamic->vm_data.warm);
+        assert(!cold_dynamic->vm_data.cold);
         _PyExecutor_Free(cold_dynamic);
     }
     /* We don't clear sysdict and builtins until the end of this function.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to