Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-91276: remove unused _PyOpcode_RelativeJump #103156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions 13 Include/internal/pycore_opcode.h

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

5 changes: 1 addition & 4 deletions 5 Include/internal/pycore_opcode_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif

#include "pycore_opcode.h" // _PyOpcode_RelativeJump
#include "pycore_opcode.h" // _PyOpcode_Jump


#define MAX_REAL_OPCODE 254
Expand Down Expand Up @@ -85,9 +85,6 @@ is_bit_set_in_table(const uint32_t *table, int bitindex) {
#undef LOG_BITS_PER_INT
#undef MASK_LOW_LOG_BITS

#define IS_RELATIVE_JUMP(opcode) (is_bit_set_in_table(_PyOpcode_RelativeJump, opcode))



#ifdef __cplusplus
}
Expand Down
34 changes: 11 additions & 23 deletions 34 Python/flowgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ is_block_push(cfg_instr *i)
return IS_BLOCK_PUSH_OPCODE(i->i_opcode);
}

static inline int
is_relative_jump(cfg_instr *i)
{
return IS_RELATIVE_JUMP(i->i_opcode);
}

static inline int
is_jump(cfg_instr *i)
{
Expand Down Expand Up @@ -199,8 +193,7 @@ blocksize(basicblock *b)
static void
dump_instr(cfg_instr *i)
{
const char *jrel = (is_relative_jump(i)) ? "jrel " : "";
const char *jabs = (is_jump(i) && !is_relative_jump(i))? "jabs " : "";
const char *jump = is_jump(i) ? "jump " : "";

char arg[128];

Expand All @@ -211,8 +204,8 @@ dump_instr(cfg_instr *i)
if (HAS_TARGET(i->i_opcode)) {
sprintf(arg, "target: %p [%d] ", i->i_target, i->i_oparg);
}
fprintf(stderr, "line: %d, opcode: %d %s%s%s\n",
i->i_loc.lineno, i->i_opcode, arg, jabs, jrel);
fprintf(stderr, "line: %d, opcode: %d %s%s\n",
i->i_loc.lineno, i->i_opcode, arg, jump);
}

static inline int
Expand Down Expand Up @@ -500,25 +493,20 @@ resolve_jump_offsets(basicblock *entryblock)
for (int i = 0; i < b->b_iused; i++) {
cfg_instr *instr = &b->b_instr[i];
int isize = _PyCfg_InstrSize(instr);
/* Relative jumps are computed relative to
the instruction pointer after fetching
the jump instruction.
*/
/* jump offsets are computed relative to
* the instruction pointer after fetching
* the jump instruction.
*/
bsize += isize;
if (is_jump(instr)) {
instr->i_oparg = instr->i_target->b_offset;
if (is_relative_jump(instr)) {
if (instr->i_oparg < bsize) {
assert(IS_BACKWARDS_JUMP_OPCODE(instr->i_opcode));
instr->i_oparg = bsize - instr->i_oparg;
}
else {
assert(!IS_BACKWARDS_JUMP_OPCODE(instr->i_opcode));
instr->i_oparg -= bsize;
}
if (instr->i_oparg < bsize) {
assert(IS_BACKWARDS_JUMP_OPCODE(instr->i_opcode));
instr->i_oparg = bsize - instr->i_oparg;
}
else {
assert(!IS_BACKWARDS_JUMP_OPCODE(instr->i_opcode));
instr->i_oparg -= bsize;
}
if (_PyCfg_InstrSize(instr) != isize) {
extended_arg_recompile = 1;
Expand Down
2 changes: 0 additions & 2 deletions 2 Tools/build/generate_opcode_h.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,10 @@ def main(opcode_py, outfile='Include/opcode.h', internaloutfile='Include/interna
for name, op in specialized_opmap.items():
fobj.write(DEFINE.format(name, op))

iobj.write("\nextern const uint32_t _PyOpcode_RelativeJump[9];\n")
iobj.write("\nextern const uint32_t _PyOpcode_Jump[9];\n")
iobj.write("\nextern const uint8_t _PyOpcode_Caches[256];\n")
iobj.write("\nextern const uint8_t _PyOpcode_Deopt[256];\n")
iobj.write("\n#ifdef NEED_OPCODE_TABLES\n")
write_int_array_from_ops("_PyOpcode_RelativeJump", opcode['hasjrel'], iobj)
write_int_array_from_ops("_PyOpcode_Jump", opcode['hasjrel'] + opcode['hasjabs'], iobj)

iobj.write("\nconst uint8_t _PyOpcode_Caches[256] = {\n")
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.