-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
gh-131798: Add MATCH_SEQUENCE/MAPPING to the JIT optimizer
#148124
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
16f6ab0
c366767
a405ca7
e167770
ba91a21
bd2a9d8
e178f70
1e25f00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2595,6 +2595,30 @@ dummy_func(void) { | |
| n = names; | ||
| } | ||
|
|
||
| op(_MATCH_MAPPING, (subject -- subject, res)) { | ||
| PyTypeObject *type = sym_get_type(subject); | ||
| if (type != NULL) { | ||
| int match = type->tp_flags & Py_TPFLAGS_MAPPING; | ||
| REPLACE_OP(this_instr, _LOAD_COMMON_CONSTANT, match? CONSTANT_TRUE : CONSTANT_FALSE, 0); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you need to assign to res here as well
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added, sorry for the wait |
||
| res = sym_new_const(ctx, match? Py_True : Py_False); | ||
| } | ||
| else { | ||
| res = sym_new_type(ctx, &PyBool_Type); | ||
| } | ||
| } | ||
|
|
||
| op(_MATCH_SEQUENCE, (subject -- subject, res)) { | ||
| PyTypeObject *type = sym_get_type(subject); | ||
| if (type != NULL) { | ||
| int match = type->tp_flags & Py_TPFLAGS_SEQUENCE; | ||
| REPLACE_OP(this_instr, _LOAD_COMMON_CONSTANT, match? CONSTANT_TRUE : CONSTANT_FALSE, 0); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In other places, |
||
| res = sym_new_const(ctx, match? Py_True : Py_False); | ||
| } | ||
| else { | ||
| res = sym_new_type(ctx, &PyBool_Type); | ||
| } | ||
| } | ||
|
|
||
| op(_DICT_UPDATE, (dict, unused[oparg - 1], update -- dict, unused[oparg - 1], upd)) { | ||
| (void)dict; | ||
| upd = update; | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
I also wonder if this logic will be broken by abc.register.
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.
Hmm I'm not too sure either. I'll try to see if I can find out more
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.
abc.registerwill change thetp_flagsbut don't update thetype version, so JIT won't invalid the old traceThere 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.
@Fidget-Spinner Do we need call
assign_version_tagwhen useabc.register?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.
Why? ABC never changes the actual type flags.
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.
That sounds like a bug in abc.register. We should fix abc.register as that might affect the specializing interpreter as well.
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.
Oh, I thought it already did invalidation, so yes this is a bug.
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.
@cocolato do you mind opening an issue for
abc.registerseparately please?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.
Sure, i will try to create the issue and solve this :)
Uh oh!
There was an error while loading. Please reload this page.
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.
You don't have to solve it (unless you want to of course), but just opening an issue is fine :). Thank you