Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

gh-105481: add flags to each instr in the opcode metadata table, to replace opcode.hasarg/hasname/hasconst#105482

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
iritkatriel merged 10 commits intopython:mainfromiritkatriel:metadata
Jun 13, 2023

Conversation

iritkatriel
Copy link
Member

@iritkatrieliritkatriel commentedJun 7, 2023
edited
Loading

This is not yet working for pseudo instructions. Should we add them to bytecodes.c in some form?

Also, I needed to add a silly assert to YIELD_VALUE (which is irregular) to make it look to the code generator like it uses oparg. The bytecode doesn't use the oparg but oparg is set to the exception stack depth, so the opcode needs to be considered as HAS_ARG because there are assertions that oparg is 0 for instructions without args.

@gvanrossum
Copy link
Member

This is not yet working for pseudo instructions. Should we add them to bytecodes.c in some form?

I think so (unless all the flags are always false for all pseudo-ops, which I doubt is the case). In fact I think we should probably propose a solution for moving the canonical definition of the numeric opcode values before we move on this.

(Other than that, this approach seems fine.)

@iritkatriel
Copy link
MemberAuthor

Also I don’t know how to identify the jump opcodes in the generator. JUMPBY is used for caches so it’s no help. Maybe we could have a SKIP_CACHE macro and the a jumpby is really a jump?

@iritkatrieliritkatriel marked this pull request as draftJune 8, 2023 09:58
Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

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

Also I don’t know how to identify the jump opcodes in the generator. JUMPBY is used for caches so it’s no help. Maybe we could have a SKIP_CACHE macro and the a jumpby is really a jump?

Yeah, disambiguating these through their macro names sounds fine.

@gvanrossum
Copy link
Member

LG. Next steps?

@iritkatriel
Copy link
MemberAuthor

LG. Next steps?

next is to rebase and enable the assertions for pseudo ops. If that worksI'll check the diff, maybe this PR is done then.

gvanrossum reacted with thumbs up emoji

@iritkatriel
Copy link
MemberAuthor

Maybe we should make the parser or generator complain if you useframe->f_code->co_names orframe->f_code->co_consts in a bytecode definition?

@gvanrossum
Copy link
Member

Maybe we should make the parser or generator complain if you useframe->f_code->co_names orframe->f_code->co_consts in a bytecode definition?

How would it know? Maybe the original idea of looking for that sequence of tokens isn't so bad. Just don't fold it intovariable_used -- make it a separate helper function.

@iritkatriel
Copy link
MemberAuthor

Maybe we should make the parser or generator complain if you useframe->f_code->co_names orframe->f_code->co_consts in a bytecode definition?

How would it know? Maybe the original idea of looking for that sequence of tokens isn't so bad. Just don't fold it intovariable_used -- make it a separate helper function.

I didn't like thatframe->f_code->co_names means something different thencode = frame->f_code; code->co_names.
We could make it illegal to accessframe->f_code from the code, and add #defines for everything you might need from there.

@gvanrossum
Copy link
Member

I grepped and I see about a dozen places where frame->f_code is used to access something other than co_consts or co_names. So you'd need to review those.

@iritkatrieliritkatriel marked this pull request as ready for reviewJune 13, 2023 19:53
Copy link
Member

@gvanrossumgvanrossum left a comment
edited
Loading

Choose a reason for hiding this comment

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

Undraft, add skip news label, go!

[SEND] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG },
[SEND_GEN] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG },
[INSTRUMENTED_YIELD_VALUE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
[YIELD_VALUE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I just noticed that this PR changed the format ofYIELD_VALUE/INSTRUMENTED_YIELD_VALUE fromINSTR_FMT_IX toINSTR_FMT_IB. This is because we added the assertion that makes the generator identify it has HAS_ARG. I guess the new value is correct?

Copy link
Member

Choose a reason for hiding this comment

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

In opcode.py it is classified as having an arg (by being >= HAVE_ARGUMENT) so I think it's correct. The oparg is used elsewhere to indicate the stack depth.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gvanrossumgvanrossumgvanrossum approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@iritkatriel@gvanrossum@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp