]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix warnings in jit builds (GH-144817)
authorChris Eibl <138194463+chris-eibl@users.noreply.github.com>
Sat, 14 Feb 2026 17:39:10 +0000 (18:39 +0100)
committerGitHub <noreply@github.com>
Sat, 14 Feb 2026 17:39:10 +0000 (17:39 +0000)
Python/jit.c
Python/optimizer.c
Python/optimizer_analysis.c
Python/optimizer_bytecodes.c
Python/optimizer_cases.c.h

index 0791d042710efb0122c33893d81bb0777fa5ca16..3e0a0aa8bfcc81f9a0bde36dad85c7231b287691 100644 (file)
@@ -164,7 +164,7 @@ mark_executable(unsigned char *memory, size_t size)
         jit_error("unable to flush instruction cache");
         return -1;
     }
-    int old;
+    DWORD old;
     int failed = !VirtualProtect(memory, size, PAGE_EXECUTE_READ, &old);
 #else
     __builtin___clear_cache((char *)memory, (char *)memory + size);
index 12ef7c3fc0adf5de9b8592057fe3665c6428fb30..466729b158d3454f8eb89cc37390d0c1d18e19e2 100644 (file)
@@ -1044,7 +1044,7 @@ _PyJit_TryInitializeTracing(
     tracer->initial_state.func = (PyFunctionObject *)Py_NewRef(func);
     tracer->initial_state.executor = (_PyExecutorObject *)Py_XNewRef(current_executor);
     tracer->initial_state.exit = exit;
-    tracer->initial_state.stack_depth = stack_pointer - _PyFrame_Stackbase(frame);
+    tracer->initial_state.stack_depth = (int)(stack_pointer - _PyFrame_Stackbase(frame));
     tracer->initial_state.chain_depth = chain_depth;
     tracer->prev_state.dependencies_still_valid = true;
     tracer->prev_state.instr_code = (PyCodeObject *)Py_NewRef(_PyFrame_GetCode(frame));
@@ -1486,7 +1486,7 @@ stack_allocate(_PyUOpInstruction *buffer, _PyUOpInstruction *output, int length)
         write++;
         depth = _PyUop_Caching[uop].entries[depth].output;
     }
-    return write - output;
+    return (int)(write - output);
 }
 
 static int
@@ -2130,6 +2130,7 @@ executor_to_gv(_PyExecutorObject *executor, FILE *out)
             assert(inst->format == UOP_FORMAT_JUMP);
             _PyUOpInstruction const *exit_inst = &executor->trace[inst->jump_target];
             uint16_t base_exit_opcode = _PyUop_Uncached[exit_inst->opcode];
+            (void)base_exit_opcode;
             assert(base_exit_opcode == _EXIT_TRACE || base_exit_opcode == _DYNAMIC_EXIT);
             exit = (_PyExitData *)exit_inst->operand0;
         }
index 7bd6970e5fd2dcce3583c6866df30d24ce0ce800..c6a513ad220b636be019077acf3b5338affe1ab7 100644 (file)
@@ -398,7 +398,7 @@ get_test_bit_for_bools(void) {
     uintptr_t true_bits = (uintptr_t)&_Py_TrueStruct;
 #endif
     for (int i = 4; i < 8; i++) {
-        if ((true_bits ^ false_bits) & (1 << i)) {
+        if ((true_bits ^ false_bits) & (uintptr_t)(1 << i)) {
             return i;
         }
     }
@@ -412,8 +412,8 @@ test_bit_set_in_true(int bit) {
 #else
     uintptr_t true_bits = (uintptr_t)&_Py_TrueStruct;
 #endif
-    assert((true_bits ^ ((uintptr_t)&_Py_FalseStruct)) & (1 << bit));
-    return true_bits & (1 << bit);
+    assert((true_bits ^ ((uintptr_t)&_Py_FalseStruct)) & (uintptr_t)(1 << bit));
+    return true_bits & (uintptr_t)(1 << bit);
 }
 
 #ifdef Py_DEBUG
@@ -504,7 +504,7 @@ optimize_uops(
             stack_pointer = ctx->frame->stack_pointer;
         }
 
-        DUMP_UOP(ctx, "abs", this_instr - trace, this_instr, stack_pointer);
+        DUMP_UOP(ctx, "abs", (int)(this_instr - trace), this_instr, stack_pointer);
 
         _PyUOpInstruction *out_ptr = ctx->out_buffer.next;
 
index 7c928e6502a412ded07b6fdc00164b09ae1406f9..2b35628ad9999965755f807404d4e8f891197cc6 100644 (file)
@@ -109,11 +109,13 @@ dummy_func(void) {
     }
 
     op(_STORE_ATTR_INSTANCE_VALUE, (offset/1, value, owner -- o)) {
+        (void)offset;
         (void)value;
         o = owner;
     }
 
     op(_STORE_ATTR_WITH_HINT, (hint/1, value, owner -- o)) {
+        (void)hint;
         (void)value;
         o = owner;
     }
@@ -320,7 +322,8 @@ dummy_func(void) {
         r = right;
     }
 
-    op(_BINARY_OP_EXTEND, (left, right -- res, l, r)) {
+    op(_BINARY_OP_EXTEND, (descr/4, left, right -- res, l, r)) {
+        (void)descr;
         res = sym_new_not_null(ctx);
         l = left;
         r = right;
@@ -386,7 +389,7 @@ dummy_func(void) {
             assert(PyLong_CheckExact(sym_get_const(ctx, sub_st)));
             long index = PyLong_AsLong(sym_get_const(ctx, sub_st));
             assert(index >= 0);
-            int tuple_length = sym_tuple_length(tuple_st);
+            Py_ssize_t tuple_length = sym_tuple_length(tuple_st);
             if (tuple_length != -1 && index < tuple_length) {
                 ADD_OP(_NOP, 0, 0);
             }
@@ -951,7 +954,7 @@ dummy_func(void) {
             ctx->done = true;
             break;
         }
-        int returning_stacklevel = this_instr->operand1;
+        int returning_stacklevel = (int)this_instr->operand1;
         if (ctx->curr_frame_depth >= 2) {
             PyCodeObject *expected_code = ctx->frames[ctx->curr_frame_depth - 2].code;
             if (expected_code == returning_code) {
@@ -979,7 +982,7 @@ dummy_func(void) {
             break;
         }
         _Py_BloomFilter_Add(dependencies, returning_code);
-        int returning_stacklevel = this_instr->operand1;
+        int returning_stacklevel = (int)this_instr->operand1;
         if (frame_pop(ctx, returning_code, returning_stacklevel)) {
             break;
         }
@@ -1001,7 +1004,7 @@ dummy_func(void) {
             break;
         }
         _Py_BloomFilter_Add(dependencies, returning_code);
-        int returning_stacklevel = this_instr->operand1;
+        int returning_stacklevel = (int)this_instr->operand1;
         if (frame_pop(ctx, returning_code, returning_stacklevel)) {
             break;
         }
index 24ae511ebcde317a30023f78e20260fdba436019..7faa699a05824935b5f457f13d5b7a055155dbb1 100644 (file)
             right = stack_pointer[-1];
             left = stack_pointer[-2];
             PyObject *descr = (PyObject *)this_instr->operand0;
+            (void)descr;
             res = sym_new_not_null(ctx);
             l = left;
             r = right;
                 assert(PyLong_CheckExact(sym_get_const(ctx, sub_st)));
                 long index = PyLong_AsLong(sym_get_const(ctx, sub_st));
                 assert(index >= 0);
-                int tuple_length = sym_tuple_length(tuple_st);
+                Py_ssize_t tuple_length = sym_tuple_length(tuple_st);
                 if (tuple_length != -1 && index < tuple_length) {
                     ADD_OP(_NOP, 0, 0);
                 }
                 ctx->done = true;
                 break;
             }
-            int returning_stacklevel = this_instr->operand1;
+            int returning_stacklevel = (int)this_instr->operand1;
             if (ctx->curr_frame_depth >= 2) {
                 PyCodeObject *expected_code = ctx->frames[ctx->curr_frame_depth - 2].code;
                 if (expected_code == returning_code) {
                 break;
             }
             _Py_BloomFilter_Add(dependencies, returning_code);
-            int returning_stacklevel = this_instr->operand1;
+            int returning_stacklevel = (int)this_instr->operand1;
             if (frame_pop(ctx, returning_code, returning_stacklevel)) {
                 break;
             }
             owner = stack_pointer[-1];
             value = stack_pointer[-2];
             uint16_t offset = (uint16_t)this_instr->operand0;
+            (void)offset;
             (void)value;
             o = owner;
             CHECK_STACK_BOUNDS(-1);
             owner = stack_pointer[-1];
             value = stack_pointer[-2];
             uint16_t hint = (uint16_t)this_instr->operand0;
+            (void)hint;
             (void)value;
             o = owner;
             CHECK_STACK_BOUNDS(-1);
                 break;
             }
             _Py_BloomFilter_Add(dependencies, returning_code);
-            int returning_stacklevel = this_instr->operand1;
+            int returning_stacklevel = (int)this_instr->operand1;
             if (frame_pop(ctx, returning_code, returning_stacklevel)) {
                 break;
             }