GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-131798: Split `_CHECK_AND_ALLOCATE_OBJECT` into smaller uops by Sacul0457 · Pull Request #148433 · python/cpython Conversation
|
|
Hey @Fidget-Spinner, I'm a little lost here
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| assert(init != NULL); | ||
| assert(PyFunction_Check(init)); | ||
| callable = sym_new_const(ctx, init); | ||
| sym_set_const(callable, init); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
callable = sym_new_const(ctx, init); not sym_set_const(callable, init);. There's a difference --- the first overrides the current callable with a new one, the second sets the current callable to a known constant. If you read the code in bytecodes.c, you'll see it's the first one.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type); | ||
| _Py_BloomFilter_Add(dependencies, type); | ||
| } | ||
| } |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Same to bytecodes.c:
| } | |
| } | |
| self_or_null = sym_new_not_null(ctx); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Wait sorry, shouldn't this be sym_set_non_null?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
No. Please look at bytecodes.c. It's creating a new object, self. That's what _ALLOCATE_OBJECT does. So it should be a new non-null. This is same as the above where it grabs a new __init__ callable. In both of these cases, we do not set the existing symbol, but create a new one. This is a good learning point as it's tricky and requires observing bytecodes.c!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ah ok
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Hai Zhu <[email protected]>
|
@Sacul0457 I'm going to push to this PR, as I think it's a little tricky to get right. Please add a test after I push. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@Sacul0457 please add the following tests:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry for the wait, I printed the uops trace for the second test and how can we tell if it is constant folded? ['_START_EXECUTOR', '_MAKE_WARM', '_SET_IP', '_CHECK_PERIODIC', '_CHECK_VALIDITY', '_ITER_CHECK_RANGE', '_GUARD_NOT_EXHAUSTED_RANGE', '_ITER_NEXT_RANGE', '_SET_IP', '_SWAP_FAST_1', '_SPILL_OR_RELOAD', '_POP_TOP', '_CHECK_VALIDITY', '_SET_IP', '_LOAD_DEREF', '_CHECK_VALIDITY', '_PUSH_NULL', '_LOAD_CONST_INLINE_BORROW', '_SPILL_OR_RELOAD', '_LOAD_CONST_INLINE_BORROW', '_SET_IP', '_SPILL_OR_RELOAD', '_CHECK_OBJECT', '_ALLOCATE_OBJECT', '_CREATE_INIT_FRAME', '_PUSH_FRAME', '_CHECK_VALIDITY', '_TIER2_RESUME_CHECK', '_LOAD_CONST_INLINE_BORROW', '_SET_IP', '_RETURN_VALUE', '_CHECK_VALIDITY', '_SET_IP', '_EXIT_INIT_CHECK', '_CHECK_VALIDITY', '_SET_IP', '_MAKE_HEAP_SAFE', '_RETURN_VALUE', '_GUARD_IP_RETURN_VALUE', '_GUARD_CODE_VERSION_RETURN_VALUE', '_CHECK_VALIDITY', '_SET_IP', '_SWAP_FAST_2', '_POP_TOP', '_CHECK_VALIDITY', '_SET_IP', '_LOAD_DEREF', '_CHECK_VALIDITY', '_PUSH_NULL', '_LOAD_CONST_INLINE_BORROW', '_SPILL_OR_RELOAD', '_LOAD_CONST_INLINE_BORROW', '_SET_IP', '_SPILL_OR_RELOAD', '_CHECK_OBJECT', '_ALLOCATE_OBJECT', '_CREATE_INIT_FRAME', '_PUSH_FRAME', '_CHECK_VALIDITY', '_TIER2_RESUME_CHECK', '_LOAD_CONST_INLINE_BORROW', '_SET_IP', '_RETURN_VALUE', '_CHECK_VALIDITY', '_SET_IP', '_EXIT_INIT_CHECK', '_CHECK_VALIDITY', '_SET_IP', '_MAKE_HEAP_SAFE', '_RETURN_VALUE', '_GUARD_IP_RETURN_VALUE', '_GUARD_CODE_VERSION_RETURN_VALUE', '_CHECK_VALIDITY', '_SET_IP', '_SWAP_FAST_2', '_POP_TOP', '_JUMP_TO_TOP', ...] |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@Sacul0457 that's strange, seems like it's not being constant folded in the second case. Let me fix that. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Oh alright. I'm probably going to bed now, please feel free to add the tests too as I don't want to hold up this PR being merged. Thank you! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry Sacul, I forgot to mention that you can't nest |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you for splitting the ops in bytecodes.c Sacul.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…ler uops (pythonGH-148433)" This reverts commit 18d7d90.
…pythonGH-148433) Co-authored-by: Hai Zhu <[email protected]> Co-authored-by: Ken Jin <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.