diff options
author | Mark Shannon <mark@hotpy.org> | 2023-11-01 12:59:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-01 12:59:08 (GMT) |
commit | 5697fc2d4bff000b2b1dac493d45872ca648490b (patch) | |
tree | 18c70d5023a986637a134df3b6b4e13b2962f938 /Python/generated_cases.c.h | |
parent | b14e882428ceda1e5852a1c22772e7f88927bded (diff) | |
download | cpython-5697fc2d4bff000b2b1dac493d45872ca648490b.zip cpython-5697fc2d4bff000b2b1dac493d45872ca648490b.tar.gz cpython-5697fc2d4bff000b2b1dac493d45872ca648490b.tar.bz2 |
GH-111537: Avoid using `this_instr` in asserts. (GH-111600)
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r-- | Python/generated_cases.c.h | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 1c05e2d..cb773f3 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -935,8 +935,7 @@ STACK_SHRINK(2); new_frame->localsplus[0] = container; new_frame->localsplus[1] = sub; - assert(1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR == next_instr - this_instr); - frame->return_offset = 1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR; + frame->return_offset = (uint16_t)(next_instr - this_instr); DISPATCH_INLINED(new_frame); } @@ -1435,8 +1434,8 @@ gen->gi_frame_state = FRAME_EXECUTING; gen->gi_exc_state.previous_item = tstate->exc_info; tstate->exc_info = &gen->gi_exc_state; - assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - this_instr); - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_SEND + oparg); + assert(next_instr - this_instr + oparg <= UINT16_MAX); + frame->return_offset = (uint16_t)(next_instr - this_instr + oparg); DISPATCH_INLINED(gen_frame); } if (Py_IsNone(v) && PyIter_Check(receiver)) { @@ -1483,8 +1482,8 @@ gen->gi_frame_state = FRAME_EXECUTING; gen->gi_exc_state.previous_item = tstate->exc_info; tstate->exc_info = &gen->gi_exc_state; - assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - this_instr); - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_SEND + oparg); + assert(next_instr - this_instr + oparg <= UINT16_MAX); + frame->return_offset = (uint16_t)(next_instr - this_instr + oparg); DISPATCH_INLINED(gen_frame); } @@ -2970,8 +2969,7 @@ // Manipulate stack directly because we exit with DISPATCH_INLINED(). STACK_SHRINK(1); new_frame->localsplus[0] = owner; - assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - this_instr); - frame->return_offset = 1 + INLINE_CACHE_ENTRIES_LOAD_ATTR; + frame->return_offset = (uint16_t)(next_instr - this_instr); DISPATCH_INLINED(new_frame); } @@ -3005,8 +3003,7 @@ STACK_SHRINK(1); new_frame->localsplus[0] = owner; new_frame->localsplus[1] = Py_NewRef(name); - assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - this_instr); - frame->return_offset = 1 + INLINE_CACHE_ENTRIES_LOAD_ATTR; + frame->return_offset = (uint16_t)(next_instr - this_instr); DISPATCH_INLINED(new_frame); } @@ -3923,8 +3920,8 @@ tstate->exc_info = &gen->gi_exc_state; assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); - assert(1 + INLINE_CACHE_ENTRIES_FOR_ITER == next_instr - this_instr); - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_FOR_ITER + oparg); + assert(next_instr - this_instr + oparg <= UINT16_MAX); + frame->return_offset = (uint16_t)(next_instr - this_instr + oparg); DISPATCH_INLINED(gen_frame); } @@ -4346,8 +4343,7 @@ if (new_frame == NULL) { goto error; } - assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - this_instr); - frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL; + frame->return_offset = (uint16_t)(next_instr - this_instr); DISPATCH_INLINED(new_frame); } /* Callable is not a normal Python function */ @@ -4601,8 +4597,7 @@ } // Manipulate stack and cache directly since we leave using DISPATCH_INLINED(). STACK_SHRINK(oparg + 2); - assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - this_instr); - frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL; + frame->return_offset = (uint16_t)(next_instr - this_instr); DISPATCH_INLINED(new_frame); } @@ -4729,8 +4724,7 @@ for (int i = 0; i < oparg; i++) { init_frame->localsplus[i+1] = args[i]; } - assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - this_instr); - frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL; + frame->return_offset = (uint16_t)(next_instr - this_instr); STACK_SHRINK(oparg+2); _PyFrame_SetStackPointer(frame, stack_pointer); /* Link frames */ |