summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-04-19 08:26:42 (GMT)
committerGitHub <noreply@github.com>2024-04-19 08:26:42 (GMT)
commit7e6fa5fceddc3f4721c036116c7a11533c8b23b3 (patch)
tree8684f0f2bc1f25c197cbb0c70249f9f04de65464
parentd3bd6b5f3f48731715e21fe132b8e65a4e5f6ce8 (diff)
downloadcpython-7e6fa5fceddc3f4721c036116c7a11533c8b23b3.zip
cpython-7e6fa5fceddc3f4721c036116c7a11533c8b23b3.tar.gz
cpython-7e6fa5fceddc3f4721c036116c7a11533c8b23b3.tar.bz2
GH-116202: Incorporate invalidation check into _START_EXECUTOR. (GH-118044)
-rw-r--r--Include/internal/pycore_uop_metadata.h2
-rw-r--r--Python/bytecodes.c1
-rw-r--r--Python/executor_cases.c.h4
-rw-r--r--Python/optimizer.c4
-rw-r--r--Python/optimizer_analysis.c3
5 files changed, 10 insertions, 4 deletions
diff --git a/Include/internal/pycore_uop_metadata.h b/Include/internal/pycore_uop_metadata.h
index 481d741..44ede3e 100644
--- a/Include/internal/pycore_uop_metadata.h
+++ b/Include/internal/pycore_uop_metadata.h
@@ -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,
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index d6fb66a..c34d702 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -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, (--)) {
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index a3447da..fccff24 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -4137,6 +4137,10 @@
#ifndef _Py_JIT
current_executor = (_PyExecutorObject*)executor;
#endif
+ if (!((_PyExecutorObject *)executor)->vm_data.valid) {
+ UOP_STAT_INC(uopcode, miss);
+ JUMP_TO_JUMP_TARGET();
+ }
break;
}
diff --git a/Python/optimizer.c b/Python/optimizer.c
index 5c69d9d..bb537c9 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -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 },
diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c
index efc5b3c..155f702 100644
--- a/Python/optimizer_analysis.c
+++ b/Python/optimizer_analysis.c
@@ -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;