Uh oh!
There was an error while loading. Please reload this page.
gh-115685: Type/values propagate for TO_BOOL in tier 2 - #115686
Conversation
markshannon
left a comment
There was a problem hiding this comment.
All the res = sym_new_... assignments need to wrapped in OUT_OF_SPACE_IF_NULL
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
When you're done making the requested changes, leave the comment: And if you don't make the requested changes, you will be poked with soft cushions! |
gvanrossum
commented
Feb 21, 2024
Hey @Fidget-Spinner did you make the requested changes? You need to do the dance to make Bedevere happy. :-) |
Fidget-Spinner
commented
Feb 21, 2024
I have made the requested changes; please review again. |
gvanrossum
commented
Feb 21, 2024
Odd. That test is still failing?! |
markshannon
left a comment
There was a problem hiding this comment.
Looks good in general.
There are a few optimizations that have been missed, and beware the side effects of C API calls.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| assert(PyLong_CheckExact(get_const(right))); | ||
| PyObject *temp = _PyLong_Add((PyLongObject *)get_const(left), | ||
| (PyLongObject *)get_const(right)); |
There was a problem hiding this comment.
Maybe there should be s get_long_const() helper which returns (PyLongObject *)get_const(x) and also includes the assert(PyLong_CheckExact()) call, to make code like this more compact. (Same for float.)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| pure op (_POP_TOP_LOAD_CONST_INLINE_BORROW, (ptr/4, pop -- value)) { | ||
| TIER_TWO_ONLY; | ||
| DECREF_INPUTS(); | ||
| value = ptr; | ||
| } |
There was a problem hiding this comment.
Maybe there could be an even more specialized opcode that doesn't DECREF its input? That would be handy for the case where you introduced this -- the input is known to be None, so we don't really need to bother with the DECREF of the immortal value.
There was a problem hiding this comment.
The expectation is that the _POP_TOP part will be removed in a later pass.LOAD_CONST ; _POP_TOP_LOAD_CONST_INLINE_BORROW -> _LOAD_CONST_INLINE_BORROW
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
gvanrossum
left a comment
There was a problem hiding this comment.
LGTM, let's see if @markshannon agrees.
| { | ||
| sym_set_type(sym, Py_TYPE(const_val)); | ||
| sym_set_flag(sym, TRUE_CONST | KNOWN | NOT_NULL); | ||
| Py_XSETREF(sym->const_val, Py_NewRef(const_val)); |
There was a problem hiding this comment.
This is temporary, just ignore this for now. I will remove it in #115817.
| op(_TO_BOOL_NONE, (value -- res)) { | ||
| if (sym_get_const(value) == Py_None) { | ||
| if (sym_is_const(value) && (sym_get_const(value) == Py_None)) { |
There was a problem hiding this comment.
Why is this necessary? Shouldn't sym_get_const return NULL for anything that isn't a constant?
It does seem rather verbose to have to prefix every sys_get_const with a sys_is_const.
There was a problem hiding this comment.
In the code:
staticinlinePyObject*sym_get_const(_Py_UOpsSymType*sym)
{
assert(sym_is_const(sym));
assert(sym->const_val);
returnsym->const_val;
}So we assume there is always something there when there's sym_get_const. I think I can just change the contract to return NULL on non constants though.
There was a problem hiding this comment.
The new sym_get_const() indeed returns NULL in this case.
gvanrossum
commented
Feb 28, 2024
@Fidget-Spinner: It looks like this PR is totally out of date. It adds a new ERROR_IF() macro that should probably be done in a separate cleanup pass. I can do that next (once gh-116062 is merged). The key part of this PR is to add optimizer specializations for |
gvanrossum
left a comment
There was a problem hiding this comment.
LGTM, with one nit (to make merging of my PR simpler).
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
gvanrossum
commented
Feb 29, 2024
Since you've addressed Mark's question I don't see a reason to wait for his explicit approval. |
TO_BOOL#115685