Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Minor clarifications.
  • Loading branch information
markshannon committed Aug 4, 2020
commit 210e5824773cdd5b43c3b3b0e6e5738b3aeecf0e
11 changes: 7 additions & 4 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,21 @@ struct instr {
int i_lineno;
};

static int
#define LOG_BITS_PER_INT 5
#define MASK_LOW_LOG_BITS 31

static inline int
is_relative_jump(struct instr *i)
{
int opcode = i->i_opcode;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for insisting a bit but it still took me a minute to parse the expression to follow how the function is determining if is a relative jump. I would suggest to maybe add a comment here briefly explaining the process as someone with less context will certainly struggle

return (_PyOpcode_RelativeJump[opcode>>5]>>(opcode&31))&1;
return (_PyOpcode_RelativeJump[opcode>>LOG_BITS_PER_INT]>>(opcode&MASK_LOW_LOG_BITS))&1;
}

static int
static inline int
is_jump(struct instr *i)
{
int opcode = i->i_opcode;
return (_PyOpcode_Jump[opcode>>5]>>(opcode&31))&1;
return (_PyOpcode_Jump[opcode>>LOG_BITS_PER_INT]>>(opcode&MASK_LOW_LOG_BITS))&1;
}

typedef struct basicblock_ {
Expand Down