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

Commit 21bea68

Browse filesBrowse files
authored
pythongh-91276: remove unused _PyOpcode_RelativeJump (python#103156)
1 parent 33822d0 commit 21bea68
Copy full SHA for 21bea68

File tree

4 files changed

+12
-42
lines changed
Filter options

4 files changed

+12
-42
lines changed

‎Include/internal/pycore_opcode.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_opcode.h
-13Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Include/internal/pycore_opcode_utils.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_opcode_utils.h
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
#include "pycore_opcode.h" // _PyOpcode_RelativeJump
11+
#include "pycore_opcode.h" // _PyOpcode_Jump
1212

1313

1414
#define MAX_REAL_OPCODE 254
@@ -85,9 +85,6 @@ is_bit_set_in_table(const uint32_t *table, int bitindex) {
8585
#undef LOG_BITS_PER_INT
8686
#undef MASK_LOW_LOG_BITS
8787

88-
#define IS_RELATIVE_JUMP(opcode) (is_bit_set_in_table(_PyOpcode_RelativeJump, opcode))
89-
90-
9188

9289
#ifdef __cplusplus
9390
}

‎Python/flowgraph.c

Copy file name to clipboardExpand all lines: Python/flowgraph.c
+11-23Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ is_block_push(cfg_instr *i)
4242
return IS_BLOCK_PUSH_OPCODE(i->i_opcode);
4343
}
4444

45-
static inline int
46-
is_relative_jump(cfg_instr *i)
47-
{
48-
return IS_RELATIVE_JUMP(i->i_opcode);
49-
}
50-
5145
static inline int
5246
is_jump(cfg_instr *i)
5347
{
@@ -199,8 +193,7 @@ blocksize(basicblock *b)
199193
static void
200194
dump_instr(cfg_instr *i)
201195
{
202-
const char *jrel = (is_relative_jump(i)) ? "jrel " : "";
203-
const char *jabs = (is_jump(i) && !is_relative_jump(i))? "jabs " : "";
196+
const char *jump = is_jump(i) ? "jump " : "";
204197

205198
char arg[128];
206199

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

218211
static inline int
@@ -500,25 +493,20 @@ resolve_jump_offsets(basicblock *entryblock)
500493
for (int i = 0; i < b->b_iused; i++) {
501494
cfg_instr *instr = &b->b_instr[i];
502495
int isize = _PyCfg_InstrSize(instr);
503-
/* Relative jumps are computed relative to
504-
the instruction pointer after fetching
505-
the jump instruction.
506-
*/
496+
/* jump offsets are computed relative to
497+
* the instruction pointer after fetching
498+
* the jump instruction.
499+
*/
507500
bsize += isize;
508501
if (is_jump(instr)) {
509502
instr->i_oparg = instr->i_target->b_offset;
510-
if (is_relative_jump(instr)) {
511-
if (instr->i_oparg < bsize) {
512-
assert(IS_BACKWARDS_JUMP_OPCODE(instr->i_opcode));
513-
instr->i_oparg = bsize - instr->i_oparg;
514-
}
515-
else {
516-
assert(!IS_BACKWARDS_JUMP_OPCODE(instr->i_opcode));
517-
instr->i_oparg -= bsize;
518-
}
503+
if (instr->i_oparg < bsize) {
504+
assert(IS_BACKWARDS_JUMP_OPCODE(instr->i_opcode));
505+
instr->i_oparg = bsize - instr->i_oparg;
519506
}
520507
else {
521508
assert(!IS_BACKWARDS_JUMP_OPCODE(instr->i_opcode));
509+
instr->i_oparg -= bsize;
522510
}
523511
if (_PyCfg_InstrSize(instr) != isize) {
524512
extended_arg_recompile = 1;

‎Tools/build/generate_opcode_h.py

Copy file name to clipboardExpand all lines: Tools/build/generate_opcode_h.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,10 @@ def main(opcode_py, outfile='Include/opcode.h', internaloutfile='Include/interna
130130
for name, op in specialized_opmap.items():
131131
fobj.write(DEFINE.format(name, op))
132132

133-
iobj.write("\nextern const uint32_t _PyOpcode_RelativeJump[9];\n")
134133
iobj.write("\nextern const uint32_t _PyOpcode_Jump[9];\n")
135134
iobj.write("\nextern const uint8_t _PyOpcode_Caches[256];\n")
136135
iobj.write("\nextern const uint8_t _PyOpcode_Deopt[256];\n")
137136
iobj.write("\n#ifdef NEED_OPCODE_TABLES\n")
138-
write_int_array_from_ops("_PyOpcode_RelativeJump", opcode['hasjrel'], iobj)
139137
write_int_array_from_ops("_PyOpcode_Jump", opcode['hasjrel'] + opcode['hasjabs'], iobj)
140138

141139
iobj.write("\nconst uint8_t _PyOpcode_Caches[256] = {\n")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.