| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Propagate the return type of ``_BINARY_OP_SUBSCR_TUPLE_INT`` in JIT. Patch | ||
| by Tomas Roun |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Expand Up | @@ -370,6 +370,27 @@ dummy_func(void) { | |||||||||||||||||||||||||||||||||||||||||||
| res = sym_new_type(ctx, &PyUnicode_Type); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| op(_BINARY_OP_SUBSCR_TUPLE_INT, (tuple_st, sub_st -- res)) { | ||||||||||||||||||||||||||||||||||||||||||||
| assert(sym_matches_type(tuple_st, &PyTuple_Type)); | ||||||||||||||||||||||||||||||||||||||||||||
| if (sym_is_const(ctx, sub_st)) { | ||||||||||||||||||||||||||||||||||||||||||||
| assert(PyLong_CheckExact(sym_get_const(ctx, sub_st))); | ||||||||||||||||||||||||||||||||||||||||||||
| long index = PyLong_AsLong(sym_get_const(ctx, sub_st)); | ||||||||||||||||||||||||||||||||||||||||||||
| assert(index >= 0); | ||||||||||||||||||||||||||||||||||||||||||||
| int tuple_length = sym_tuple_length(tuple_st); | ||||||||||||||||||||||||||||||||||||||||||||
| if (tuple_length == -1) { | ||||||||||||||||||||||||||||||||||||||||||||
| // Unknown length | ||||||||||||||||||||||||||||||||||||||||||||
| res = sym_new_not_null(ctx); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||||||||||||||||||||||
| assert(index < tuple_length); | ||||||||||||||||||||||||||||||||||||||||||||
| res = sym_tuple_getitem(ctx, tuple_st, index); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||||||||||||||||||||||
| res = sym_new_not_null(ctx); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment thread
Comment on lines
+375
to
+391
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality@tomasr8, this can be improved to handle abstract tuples that may not be constant (and it cleans things up, since it includes a length check):
Suggested change
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
@brandtbucher, I think this already handles abstract tuples? Assuming that abstract means those that have JIT_SYM_TUPLE_TAG rather than JIT_SYM_KNOWN_VALUE_TAG? For tuples that just have JIT_SYM_KNOWN_CLASS_TAG we don't know the length so there's nothing we can do I believe. But yeah, we can simplify the code since _Py_uop_sym_tuple_getitem can handle unknown length. The only difference is that it sets the type to unknown rather than non null as we do here. Is that a problem? Shouldn't _Py_uop_sym_tuple_getitem always return at least JIT_SYM_NON_NULL_TAG?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYour current code is gated on sym_is_const, which abstract tuples fail. The rest of your understanding is correct, though.
Sounds like you found your next PR. :)
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAh, I completely misunderstood, sorry. I thought you were checking whether the tuple was const, not the index. Disregard!
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityno worries :) I think we can still simplify the code a bit though!
Sorry, something went wrong.
All reactions
|
||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| op(_TO_BOOL, (value -- res)) { | ||||||||||||||||||||||||||||||||||||||||||||
| int already_bool = optimize_to_bool(this_instr, ctx, value, &res); | ||||||||||||||||||||||||||||||||||||||||||||
| if (!already_bool) { | ||||||||||||||||||||||||||||||||||||||||||||
| Expand Down | ||||||||||||||||||||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality@brandtbucher
Following the previous discussion, I'm wondering if it is correct to return sym_new_not_null here rather than sym_new_unknown?
We have an abstract tuple and we don't know its length so it is impossible to be sure that the index is not out of bounds for the tuple. Given that, I think it is incorrect to return sym_new_not_null here as regular Python code could raise an IndexError. Should we change this to sym_new_unknown?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.