GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-41463: Generate information about jumps from 'opcode.py' rather than duplicating it in 'compile.c' by markshannon · Pull Request #21714 · python/cpython

Conversation

@markshannon

@markshannon markshannon commented Aug 3, 2020 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

The motivation for this PR is to avoid errors when modifying compile.c.
Setting the i_jabs and i_jrel fields of every instruction is error prone and unnecessary.

https://bugs.python.org/issue41463

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@markshannon
Generate information about jumps from 'opcode.py' rather than duplica…
9728d21
…te it in 'compile.c'
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Aug 3, 2020
@bedevere-bot bedevere-bot added the awaiting core review label Aug 3, 2020
@markshannon markshannon added the skip news label Aug 3, 2020
@markshannon
markshannon requested a review from pablogsal August 4, 2020 10:01
pablogsal
pablogsal reviewed Aug 4, 2020
View reviewed changes
Comment thread Python/compile.c Outdated
int i_lineno;
};

static int

@pablogsal pablogsal Aug 4, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
static int
static inline int

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
pablogsal
pablogsal reviewed Aug 4, 2020
View reviewed changes
Comment thread Python/compile.c Outdated
return (_PyOpcode_RelativeJump[opcode>>5]>>(opcode&31))&1;
}

static int

@pablogsal pablogsal Aug 4, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
static int
static inline int

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
pablogsal
pablogsal reviewed Aug 4, 2020
View reviewed changes
Comment thread Python/compile.c Outdated
is_relative_jump(struct instr *i)
{
int opcode = i->i_opcode;
return (_PyOpcode_RelativeJump[opcode>>5]>>(opcode&31))&1;

@pablogsal pablogsal Aug 4, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can you define 5 and 31 as globals with a name (using #define or with static variables). That way this will read a bit better

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
pablogsal
pablogsal reviewed Aug 4, 2020
View reviewed changes

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Look great, I left some minor comments

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
pablogsal
pablogsal reviewed Aug 4, 2020
View reviewed changes
Comment thread Python/compile.c
int oparg = inst->i_oparg;
int nextop = i+1 < bb->b_iused ? bb->b_instr[i+1].i_opcode : 0;
if (inst->i_jabs || inst->i_jrel) {
if (is_jump(inst)) {

@pablogsal pablogsal Aug 4, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Great!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@markshannon
Minor clarifications.
210e582
pablogsal
pablogsal reviewed Aug 4, 2020
View reviewed changes
Comment thread Python/compile.c Outdated
static inline int
is_relative_jump(struct instr *i)
{
int opcode = i->i_opcode;

@pablogsal pablogsal Aug 4, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
pablogsal
pablogsal approved these changes Aug 4, 2020
View reviewed changes

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

I left a comment, feel free to address it before landing

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Aug 4, 2020
@markshannon
Clarify logic used to pick bit marking jumps.
5c6594c
pablogsal
pablogsal approved these changes Aug 4, 2020
View reviewed changes

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Perfect!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@markshannon
markshannon merged commit 582aaf1 into python:master Aug 4, 2020
@bedevere-bot bedevere-bot removed the awaiting merge label Aug 4, 2020
@markshannon
markshannon deleted the remove-i-fields branch August 4, 2020 22:05
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Aug 20, 2020
@markshannon @shihai1991
bpo-41463: Generate information about jumps from 'opcode.py' rather t…
fdaafe0
…han duplicating it in 'compile.c' (pythonGH-21714)

Generate information about jumps from 'opcode.py' rather than duplicate it in 'compile.c'
xzy3 pushed a commit to xzy3/cpython that referenced this pull request Oct 18, 2020
@markshannon @xzy3-cdc
bpo-41463: Generate information about jumps from 'opcode.py' rather t…
b47b85b
…han duplicating it in 'compile.c' (pythonGH-21714)

Generate information about jumps from 'opcode.py' rather than duplicate it in 'compile.c'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pablogsal pablogsal pablogsal approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@markshannon @pablogsal @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.