Skip to content

Commit caac966

Browse files
authored
fix warnings in jit builds (GH-144817)
1 parent 14cbd0e commit caac966

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

Python/jit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ mark_executable(unsigned char *memory, size_t size)
164164
jit_error("unable to flush instruction cache");
165165
return -1;
166166
}
167-
int old;
167+
DWORD old;
168168
int failed = !VirtualProtect(memory, size, PAGE_EXECUTE_READ, &old);
169169
#else
170170
__builtin___clear_cache((char *)memory, (char *)memory + size);

Python/optimizer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ _PyJit_TryInitializeTracing(
10441044
tracer->initial_state.func = (PyFunctionObject *)Py_NewRef(func);
10451045
tracer->initial_state.executor = (_PyExecutorObject *)Py_XNewRef(current_executor);
10461046
tracer->initial_state.exit = exit;
1047-
tracer->initial_state.stack_depth = stack_pointer - _PyFrame_Stackbase(frame);
1047+
tracer->initial_state.stack_depth = (int)(stack_pointer - _PyFrame_Stackbase(frame));
10481048
tracer->initial_state.chain_depth = chain_depth;
10491049
tracer->prev_state.dependencies_still_valid = true;
10501050
tracer->prev_state.instr_code = (PyCodeObject *)Py_NewRef(_PyFrame_GetCode(frame));
@@ -1486,7 +1486,7 @@ stack_allocate(_PyUOpInstruction *buffer, _PyUOpInstruction *output, int length)
14861486
write++;
14871487
depth = _PyUop_Caching[uop].entries[depth].output;
14881488
}
1489-
return write - output;
1489+
return (int)(write - output);
14901490
}
14911491

14921492
static int
@@ -2130,6 +2130,7 @@ executor_to_gv(_PyExecutorObject *executor, FILE *out)
21302130
assert(inst->format == UOP_FORMAT_JUMP);
21312131
_PyUOpInstruction const *exit_inst = &executor->trace[inst->jump_target];
21322132
uint16_t base_exit_opcode = _PyUop_Uncached[exit_inst->opcode];
2133+
(void)base_exit_opcode;
21332134
assert(base_exit_opcode == _EXIT_TRACE || base_exit_opcode == _DYNAMIC_EXIT);
21342135
exit = (_PyExitData *)exit_inst->operand0;
21352136
}

Python/optimizer_analysis.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ get_test_bit_for_bools(void) {
398398
uintptr_t true_bits = (uintptr_t)&_Py_TrueStruct;
399399
#endif
400400
for (int i = 4; i < 8; i++) {
401-
if ((true_bits ^ false_bits) & (1 << i)) {
401+
if ((true_bits ^ false_bits) & (uintptr_t)(1 << i)) {
402402
return i;
403403
}
404404
}
@@ -412,8 +412,8 @@ test_bit_set_in_true(int bit) {
412412
#else
413413
uintptr_t true_bits = (uintptr_t)&_Py_TrueStruct;
414414
#endif
415-
assert((true_bits ^ ((uintptr_t)&_Py_FalseStruct)) & (1 << bit));
416-
return true_bits & (1 << bit);
415+
assert((true_bits ^ ((uintptr_t)&_Py_FalseStruct)) & (uintptr_t)(1 << bit));
416+
return true_bits & (uintptr_t)(1 << bit);
417417
}
418418

419419
#ifdef Py_DEBUG
@@ -504,7 +504,7 @@ optimize_uops(
504504
stack_pointer = ctx->frame->stack_pointer;
505505
}
506506

507-
DUMP_UOP(ctx, "abs", this_instr - trace, this_instr, stack_pointer);
507+
DUMP_UOP(ctx, "abs", (int)(this_instr - trace), this_instr, stack_pointer);
508508

509509
_PyUOpInstruction *out_ptr = ctx->out_buffer.next;
510510

Python/optimizer_bytecodes.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ dummy_func(void) {
109109
}
110110

111111
op(_STORE_ATTR_INSTANCE_VALUE, (offset/1, value, owner -- o)) {
112+
(void)offset;
112113
(void)value;
113114
o = owner;
114115
}
115116

116117
op(_STORE_ATTR_WITH_HINT, (hint/1, value, owner -- o)) {
118+
(void)hint;
117119
(void)value;
118120
o = owner;
119121
}
@@ -320,7 +322,8 @@ dummy_func(void) {
320322
r = right;
321323
}
322324

323-
op(_BINARY_OP_EXTEND, (left, right -- res, l, r)) {
325+
op(_BINARY_OP_EXTEND, (descr/4, left, right -- res, l, r)) {
326+
(void)descr;
324327
res = sym_new_not_null(ctx);
325328
l = left;
326329
r = right;
@@ -386,7 +389,7 @@ dummy_func(void) {
386389
assert(PyLong_CheckExact(sym_get_const(ctx, sub_st)));
387390
long index = PyLong_AsLong(sym_get_const(ctx, sub_st));
388391
assert(index >= 0);
389-
int tuple_length = sym_tuple_length(tuple_st);
392+
Py_ssize_t tuple_length = sym_tuple_length(tuple_st);
390393
if (tuple_length != -1 && index < tuple_length) {
391394
ADD_OP(_NOP, 0, 0);
392395
}
@@ -951,7 +954,7 @@ dummy_func(void) {
951954
ctx->done = true;
952955
break;
953956
}
954-
int returning_stacklevel = this_instr->operand1;
957+
int returning_stacklevel = (int)this_instr->operand1;
955958
if (ctx->curr_frame_depth >= 2) {
956959
PyCodeObject *expected_code = ctx->frames[ctx->curr_frame_depth - 2].code;
957960
if (expected_code == returning_code) {
@@ -979,7 +982,7 @@ dummy_func(void) {
979982
break;
980983
}
981984
_Py_BloomFilter_Add(dependencies, returning_code);
982-
int returning_stacklevel = this_instr->operand1;
985+
int returning_stacklevel = (int)this_instr->operand1;
983986
if (frame_pop(ctx, returning_code, returning_stacklevel)) {
984987
break;
985988
}
@@ -1001,7 +1004,7 @@ dummy_func(void) {
10011004
break;
10021005
}
10031006
_Py_BloomFilter_Add(dependencies, returning_code);
1004-
int returning_stacklevel = this_instr->operand1;
1007+
int returning_stacklevel = (int)this_instr->operand1;
10051008
if (frame_pop(ctx, returning_code, returning_stacklevel)) {
10061009
break;
10071010
}

Python/optimizer_cases.c.h

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)