Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b75c38

Browse files
committed
Factored out test for absolute jumps.
1 parent 6e5c179 commit 5b75c38

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Python/compile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ intern_strings(PyObject *tuple)
325325

326326
#define GETARG(arr, i) ((int)((arr[i+2]<<8) + arr[i+1]))
327327
#define UNCONDITIONAL_JUMP(op) (op==JUMP_ABSOLUTE || op==JUMP_FORWARD)
328-
#define GETJUMPTGT(arr, i) (GETARG(arr,i) + (arr[i]==JUMP_ABSOLUTE ? 0 : i+3))
328+
#define ABSOLUTE_JUMP(op) (op==JUMP_ABSOLUTE || op==CONTINUE_LOOP)
329+
#define GETJUMPTGT(arr, i) (GETARG(arr,i) + (ABSOLUTE_JUMP(arr[i]) ? 0 : i+3))
329330
#define SETARG(arr, i, val) arr[i+2] = val>>8; arr[i+1] = val & 255
330331

331332
static PyObject *
@@ -394,7 +395,7 @@ optimize_code(PyObject *code, PyObject* consts)
394395
tgttgt = GETJUMPTGT(codestr, tgt);
395396
if (opcode == JUMP_FORWARD) /* JMP_ABS can go backwards */
396397
opcode = JUMP_ABSOLUTE;
397-
if (opcode != JUMP_ABSOLUTE && opcode != CONTINUE_LOOP)
398+
if (!ABSOLUTE_JUMP(opcode))
398399
tgttgt -= i + 3; /* Calc relative jump addr */
399400
if (tgttgt < 0) /* No backward relative jumps */
400401
continue;

0 commit comments

Comments
 (0)