diff options
author | Tomas R. <tomas.roun8@gmail.com> | 2024-10-29 17:25:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-29 17:25:05 (GMT) |
commit | aab58a93efd09185e3622572d2624a31e0fe405b (patch) | |
tree | 893178c0fa545041d8b77ec0fa1f5b45999aadca /Python | |
parent | b2eaa75b176e07730215d76d8dce4d63fb493391 (diff) | |
download | cpython-aab58a93efd09185e3622572d2624a31e0fe405b.zip cpython-aab58a93efd09185e3622572d2624a31e0fe405b.tar.gz cpython-aab58a93efd09185e3622572d2624a31e0fe405b.tar.bz2 |
gh-118423: Add `INSTRUCTION_SIZE` macro to code generator (GH-125467)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bytecodes.c | 22 | ||||
-rw-r--r-- | Python/executor_cases.c.h | 10 | ||||
-rw-r--r-- | Python/generated_cases.c.h | 24 |
3 files changed, 28 insertions, 28 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index b7469c2..fa98af1 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -859,7 +859,7 @@ dummy_func( new_frame->localsplus[0] = container; new_frame->localsplus[1] = sub; INPUTS_DEAD(); - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR); + frame->return_offset = INSTRUCTION_SIZE; } macro(BINARY_SUBSCR_GETITEM) = @@ -1111,8 +1111,8 @@ dummy_func( gen->gi_frame_state = FRAME_EXECUTING; gen->gi_exc_state.previous_item = tstate->exc_info; tstate->exc_info = &gen->gi_exc_state; - assert(next_instr - this_instr + oparg <= UINT16_MAX); - frame->return_offset = (uint16_t)(next_instr - this_instr + oparg); + assert(INSTRUCTION_SIZE + oparg <= UINT16_MAX); + frame->return_offset = (uint16_t)(INSTRUCTION_SIZE + oparg); assert(gen_frame->previous == NULL); gen_frame->previous = frame; DISPATCH_INLINED(gen_frame); @@ -1157,8 +1157,8 @@ dummy_func( 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 + oparg <= UINT16_MAX); - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_SEND + oparg); + assert(INSTRUCTION_SIZE + oparg <= UINT16_MAX); + frame->return_offset = (uint16_t)(INSTRUCTION_SIZE + oparg); gen_frame->previous = frame; } @@ -2265,7 +2265,7 @@ dummy_func( new_frame->localsplus[0] = owner; DEAD(owner); new_frame->localsplus[1] = PyStackRef_FromPyObjectNew(name); - frame->return_offset = (uint16_t)(next_instr - this_instr); + frame->return_offset = INSTRUCTION_SIZE; DISPATCH_INLINED(new_frame); } @@ -3062,7 +3062,7 @@ dummy_func( tstate->exc_info = &gen->gi_exc_state; gen_frame->previous = frame; // oparg is the return offset from the next instruction. - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_FOR_ITER + oparg); + frame->return_offset = (uint16_t)(INSTRUCTION_SIZE + oparg); } macro(FOR_ITER_GEN) = @@ -3341,7 +3341,7 @@ dummy_func( if (new_frame == NULL) { ERROR_NO_POP(); } - frame->return_offset = (uint16_t)(next_instr - this_instr); + frame->return_offset = INSTRUCTION_SIZE; DISPATCH_INLINED(new_frame); } /* Callable is not a normal Python function */ @@ -4205,8 +4205,8 @@ dummy_func( if (new_frame == NULL) { ERROR_NO_POP(); } - assert(next_instr - this_instr == 1 + INLINE_CACHE_ENTRIES_CALL_KW); - frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL_KW; + assert(INSTRUCTION_SIZE == 1 + INLINE_CACHE_ENTRIES_CALL_KW); + frame->return_offset = INSTRUCTION_SIZE; DISPATCH_INLINED(new_frame); } /* Callable is not a normal Python function */ @@ -4472,7 +4472,7 @@ dummy_func( if (new_frame == NULL) { ERROR_NO_POP(); } - assert(next_instr - this_instr == 1); + assert(INSTRUCTION_SIZE == 1); frame->return_offset = 1; DISPATCH_INLINED(new_frame); } diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 27b7e32..ff4a0a5 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -1147,7 +1147,7 @@ new_frame = _PyFrame_PushUnchecked(tstate, PyStackRef_FromPyObjectNew(getitem), 2, frame); new_frame->localsplus[0] = container; new_frame->localsplus[1] = sub; - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR); + frame->return_offset = 2 ; stack_pointer[-2].bits = (uintptr_t)new_frame; stack_pointer += -1; assert(WITHIN_STACK_BOUNDS()); @@ -1454,8 +1454,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 + oparg <= UINT16_MAX); - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_SEND + oparg); + assert( 2 + oparg <= UINT16_MAX); + frame->return_offset = (uint16_t)( 2 + oparg); gen_frame->previous = frame; stack_pointer[-1].bits = (uintptr_t)gen_frame; break; @@ -2826,7 +2826,7 @@ break; } - /* _LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN is not a viable micro-op for tier 2 because it uses the 'this_instr' variable */ + /* _LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN is not a viable micro-op for tier 2 because it has unused cache entries */ case _GUARD_DORV_NO_DICT: { _PyStackRef owner; @@ -3644,7 +3644,7 @@ tstate->exc_info = &gen->gi_exc_state; gen_frame->previous = frame; // oparg is the return offset from the next instruction. - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_FOR_ITER + oparg); + frame->return_offset = (uint16_t)( 2 + oparg); stack_pointer[0].bits = (uintptr_t)gen_frame; stack_pointer += 1; assert(WITHIN_STACK_BOUNDS()); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index a615f65..632cbc7 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -539,7 +539,7 @@ new_frame = _PyFrame_PushUnchecked(tstate, PyStackRef_FromPyObjectNew(getitem), 2, frame); new_frame->localsplus[0] = container; new_frame->localsplus[1] = sub; - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR); + frame->return_offset = 2 ; } // _PUSH_FRAME { @@ -935,7 +935,7 @@ if (new_frame == NULL) { goto error; } - frame->return_offset = (uint16_t)(next_instr - this_instr); + frame->return_offset = 4 ; DISPATCH_INLINED(new_frame); } /* Callable is not a normal Python function */ @@ -1737,7 +1737,7 @@ if (new_frame == NULL) { goto error; } - assert(next_instr - this_instr == 1); + assert( 1 == 1); frame->return_offset = 1; DISPATCH_INLINED(new_frame); } @@ -1958,8 +1958,8 @@ if (new_frame == NULL) { goto error; } - assert(next_instr - this_instr == 1 + INLINE_CACHE_ENTRIES_CALL_KW); - frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL_KW; + assert( 4 == 1 + INLINE_CACHE_ENTRIES_CALL_KW); + frame->return_offset = 4 ; DISPATCH_INLINED(new_frame); } /* Callable is not a normal Python function */ @@ -3986,7 +3986,7 @@ tstate->exc_info = &gen->gi_exc_state; gen_frame->previous = frame; // oparg is the return offset from the next instruction. - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_FOR_ITER + oparg); + frame->return_offset = (uint16_t)( 2 + oparg); } // _PUSH_FRAME { @@ -4448,7 +4448,7 @@ if (new_frame == NULL) { goto error; } - frame->return_offset = (uint16_t)(next_instr - this_instr); + frame->return_offset = 4 ; DISPATCH_INLINED(new_frame); } /* Callable is not a normal Python function */ @@ -5352,7 +5352,7 @@ STACK_SHRINK(1); new_frame->localsplus[0] = owner; new_frame->localsplus[1] = PyStackRef_FromPyObjectNew(name); - frame->return_offset = (uint16_t)(next_instr - this_instr); + frame->return_offset = 10 ; DISPATCH_INLINED(new_frame); } @@ -7035,8 +7035,8 @@ gen->gi_frame_state = FRAME_EXECUTING; gen->gi_exc_state.previous_item = tstate->exc_info; tstate->exc_info = &gen->gi_exc_state; - assert(next_instr - this_instr + oparg <= UINT16_MAX); - frame->return_offset = (uint16_t)(next_instr - this_instr + oparg); + assert( 2 + oparg <= UINT16_MAX); + frame->return_offset = (uint16_t)( 2 + oparg); assert(gen_frame->previous == NULL); gen_frame->previous = frame; DISPATCH_INLINED(gen_frame); @@ -7108,8 +7108,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 + oparg <= UINT16_MAX); - frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_SEND + oparg); + assert( 2 + oparg <= UINT16_MAX); + frame->return_offset = (uint16_t)( 2 + oparg); gen_frame->previous = frame; } // _PUSH_FRAME |