Skip to content

Commit d444dec

Browse files
authored
Fix debug output for optimized executor (#116337)
This adjusts `length` rather than using `length+1` all over the place.
1 parent e7ba6e9 commit d444dec

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Python/optimizer.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,8 @@ make_executor_from_uops(_PyUOpInstruction *buffer, const _PyBloomFilter *depende
899899
uint32_t used[(UOP_MAX_TRACE_LENGTH + 31)/32] = { 0 };
900900
int exit_count;
901901
int length = compute_used(buffer, used, &exit_count);
902-
_PyExecutorObject *executor = allocate_executor(exit_count, length+1);
902+
length += 1; // For _START_EXECUTOR
903+
_PyExecutorObject *executor = allocate_executor(exit_count, length);
903904
if (executor == NULL) {
904905
return NULL;
905906
}
@@ -909,7 +910,7 @@ make_executor_from_uops(_PyUOpInstruction *buffer, const _PyBloomFilter *depende
909910
executor->exits[i].temperature = 0;
910911
}
911912
int next_exit = exit_count-1;
912-
_PyUOpInstruction *dest = (_PyUOpInstruction *)&executor->trace[length];
913+
_PyUOpInstruction *dest = (_PyUOpInstruction *)&executor->trace[length-1];
913914
/* Scan backwards, so that we see the destinations of jumps before the jumps themselves. */
914915
for (int i = UOP_MAX_TRACE_LENGTH-1; i >= 0; i--) {
915916
if (!BIT_IS_SET(used, i)) {
@@ -957,7 +958,7 @@ make_executor_from_uops(_PyUOpInstruction *buffer, const _PyBloomFilter *depende
957958
#ifdef _Py_JIT
958959
executor->jit_code = NULL;
959960
executor->jit_size = 0;
960-
if (_PyJIT_Compile(executor, executor->trace, length+1)) {
961+
if (_PyJIT_Compile(executor, executor->trace, length)) {
961962
Py_DECREF(executor);
962963
return NULL;
963964
}

0 commit comments

Comments
 (0)