]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-116202: Incorporate invalidation check into _START_EXECUTOR. (GH-118044)
authorMark Shannon <mark@hotpy.org>
Fri, 19 Apr 2024 08:26:42 +0000 (09:26 +0100)
committerGitHub <noreply@github.com>
Fri, 19 Apr 2024 08:26:42 +0000 (09:26 +0100)
Include/internal/pycore_uop_metadata.h
Python/bytecodes.c
Python/executor_cases.c.h
Python/optimizer.c
Python/optimizer_analysis.c

index 481d7415d19ad1d3f497f4792aa8454a5978a0ac..44ede3e77c68e1ee3525044c976005f3c6791063 100644 (file)
@@ -240,7 +240,7 @@ const uint16_t _PyUop_Flags[MAX_UOP_ID+1] = {
     [_CHECK_FUNCTION] = HAS_DEOPT_FLAG,
     [_INTERNAL_INCREMENT_OPT_COUNTER] = 0,
     [_COLD_EXIT] = HAS_ARG_FLAG | HAS_ESCAPES_FLAG,
-    [_START_EXECUTOR] = 0,
+    [_START_EXECUTOR] = HAS_DEOPT_FLAG,
     [_FATAL_ERROR] = HAS_ESCAPES_FLAG,
     [_CHECK_VALIDITY_AND_SET_IP] = HAS_DEOPT_FLAG,
     [_DEOPT] = 0,
index d6fb66a7be34acd647b1e21cb9984735b632e579..c34d702f06418e88348754443650298d9afb5d94 100644 (file)
@@ -4181,6 +4181,7 @@ dummy_func(
 #ifndef _Py_JIT
             current_executor = (_PyExecutorObject*)executor;
 #endif
+            DEOPT_IF(!((_PyExecutorObject *)executor)->vm_data.valid);
         }
 
         tier2 op(_FATAL_ERROR, (--)) {
index a3447da00477ca0e0cd03e876fd789051f28ac3e..fccff24a41858614a27954797713702e47cc9593 100644 (file)
             #ifndef _Py_JIT
             current_executor = (_PyExecutorObject*)executor;
             #endif
+            if (!((_PyExecutorObject *)executor)->vm_data.valid) {
+                UOP_STAT_INC(uopcode, miss);
+                JUMP_TO_JUMP_TARGET();
+            }
             break;
         }
 
index 5c69d9d5de92eb804d75aee6ef716806284ae90e..bb537c9111a51f302c205988feda0b36d6ac017b 100644 (file)
@@ -1109,8 +1109,6 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil
     assert(next_exit == -1);
     assert(dest == executor->trace);
     assert(dest->opcode == _START_EXECUTOR);
-    dest->oparg = 0;
-    dest->target = 0;
     _Py_ExecutorInit(executor, dependencies);
 #ifdef Py_DEBUG
     char *python_lltrace = Py_GETENV("PYTHON_LLTRACE");
@@ -1314,7 +1312,7 @@ counter_optimize(
     }
     _Py_CODEUNIT *target = instr + 1 + _PyOpcode_Caches[JUMP_BACKWARD] - oparg;
     _PyUOpInstruction buffer[5] = {
-        { .opcode = _START_EXECUTOR },
+        { .opcode = _START_EXECUTOR, .jump_target = 4, .format=UOP_FORMAT_JUMP },
         { .opcode = _LOAD_CONST_INLINE_BORROW, .operand = (uintptr_t)self },
         { .opcode = _INTERNAL_INCREMENT_OPT_COUNTER },
         { .opcode = _EXIT_TRACE, .jump_target = 4, .format=UOP_FORMAT_JUMP },
index efc5b3c39b6e761a11994d720c53428494e7a234..155f7026b041b0ac30d05023410d7ff1f70b26bf 100644 (file)
@@ -497,6 +497,9 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
     for (int pc = 0; pc < buffer_size; pc++) {
         int opcode = buffer[pc].opcode;
         switch (opcode) {
+            case _START_EXECUTOR:
+                may_have_escaped = false;
+                break;
             case _SET_IP:
                 buffer[pc].opcode = _NOP;
                 last_set_ip = pc;