Skip to content

Commit

Permalink
use constants
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel committed Oct 11, 2023
1 parent efa8eab commit 86cf45f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 27 deletions.
33 changes: 21 additions & 12 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ dummy_func(
new_frame->localsplus[1] = sub;
SKIP_OVER(INLINE_CACHE_ENTRIES_BINARY_SUBSCR);
frame->yield_offset = 0;
frame->next_instr_offset = next_instr - frame->instr_ptr;
assert(1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR == next_instr - frame->instr_ptr);
frame->next_instr_offset = 1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR;
DISPATCH_INLINED(new_frame);
}

Expand Down Expand Up @@ -985,8 +986,9 @@ dummy_func(
gen->gi_exc_state.previous_item = tstate->exc_info;
tstate->exc_info = &gen->gi_exc_state;
SKIP_OVER(INLINE_CACHE_ENTRIES_SEND);
frame->yield_offset = next_instr - frame->instr_ptr;
frame->next_instr_offset = next_instr - frame->instr_ptr + oparg;
assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - frame->instr_ptr);
frame->yield_offset = 1 + INLINE_CACHE_ENTRIES_SEND;
frame->next_instr_offset = 1 + INLINE_CACHE_ENTRIES_SEND + oparg;
DISPATCH_INLINED(gen_frame);
}
if (Py_IsNone(v) && PyIter_Check(receiver)) {
Expand Down Expand Up @@ -1024,8 +1026,9 @@ dummy_func(
gen->gi_exc_state.previous_item = tstate->exc_info;
tstate->exc_info = &gen->gi_exc_state;
SKIP_OVER(INLINE_CACHE_ENTRIES_SEND);
frame->yield_offset = next_instr - frame->instr_ptr;
frame->next_instr_offset = next_instr - frame->instr_ptr + oparg;
assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - frame->instr_ptr);
frame->yield_offset = 1 + INLINE_CACHE_ENTRIES_SEND;
frame->next_instr_offset = 1 + INLINE_CACHE_ENTRIES_SEND + oparg;
DISPATCH_INLINED(gen_frame);
}

Expand Down Expand Up @@ -2022,7 +2025,8 @@ dummy_func(
STACK_SHRINK(1);
new_frame->localsplus[0] = owner;
SKIP_OVER(INLINE_CACHE_ENTRIES_LOAD_ATTR);
frame->next_instr_offset = next_instr - frame->instr_ptr;
assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - frame->instr_ptr);
frame->next_instr_offset = 1 + INLINE_CACHE_ENTRIES_LOAD_ATTR;
DISPATCH_INLINED(new_frame);
}

Expand All @@ -2049,7 +2053,8 @@ dummy_func(
new_frame->localsplus[0] = owner;
new_frame->localsplus[1] = Py_NewRef(name);
SKIP_OVER(INLINE_CACHE_ENTRIES_LOAD_ATTR);
frame->next_instr_offset = next_instr - frame->instr_ptr;
assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - frame->instr_ptr);
frame->next_instr_offset = 1 + INLINE_CACHE_ENTRIES_LOAD_ATTR;
DISPATCH_INLINED(new_frame);
}

Expand Down Expand Up @@ -2685,8 +2690,9 @@ dummy_func(
SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
assert(next_instr[oparg].op.code == END_FOR ||
next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
frame->yield_offset = next_instr - frame->instr_ptr;
frame->next_instr_offset = oparg + next_instr - frame->instr_ptr;
assert(1 + INLINE_CACHE_ENTRIES_FOR_ITER == next_instr - frame->instr_ptr);
frame->yield_offset = 1 + INLINE_CACHE_ENTRIES_FOR_ITER;
frame->next_instr_offset = 1 + INLINE_CACHE_ENTRIES_FOR_ITER + oparg;
DISPATCH_INLINED(gen_frame);
}

Expand Down Expand Up @@ -2997,7 +3003,8 @@ dummy_func(
goto error;
}
SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
frame->next_instr_offset = next_instr - frame->instr_ptr;
assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - frame->instr_ptr);
frame->next_instr_offset = 1 + INLINE_CACHE_ENTRIES_CALL;
DISPATCH_INLINED(new_frame);
}
/* Callable is not a normal Python function */
Expand Down Expand Up @@ -3156,7 +3163,8 @@ dummy_func(
STACK_SHRINK(oparg + 2);
SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
frame->yield_offset = 0;
frame->next_instr_offset = next_instr - frame->instr_ptr;
assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - frame->instr_ptr);
frame->next_instr_offset = 1 + INLINE_CACHE_ENTRIES_CALL;
DISPATCH_INLINED(new_frame);
}

Expand Down Expand Up @@ -3234,7 +3242,8 @@ dummy_func(
}
SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
frame->yield_offset = 0;
frame->next_instr_offset = next_instr - frame->instr_ptr;
assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - frame->instr_ptr);
frame->next_instr_offset = 1 + INLINE_CACHE_ENTRIES_CALL;
STACK_SHRINK(oparg+2);
_PyFrame_SetStackPointer(frame, stack_pointer);
/* Link frames */
Expand Down
37 changes: 22 additions & 15 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 86cf45f

Please sign in to comment.