-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
gh-148276: Optimize object creation and method calls in the JIT by resolving __init__ at trace optimization time #148277
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
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 |
|---|---|---|
|
|
@@ -134,6 +134,21 @@ dummy_func(void) { | |
| assert(!PyJitRef_IsUnique(value)); | ||
| } | ||
|
|
||
| op(_GUARD_TYPE_VERSION_LOCKED, (type_version/2, owner -- owner)) { | ||
Fidget-Spinner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert(type_version); | ||
| if (sym_matches_type_version(owner, type_version)) { | ||
| ADD_OP(_NOP, 0, 0); | ||
|
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. We should not be removing this as we are moving towards FT compatibility. This uop unlocks objects on FT as well, so we need to keep it around as it's side effecting. Instead, you should break out the
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. I do not fully understand. The unlock only happens when the type version doesn't match. If that cannot happen, there is no need to keep the unlock part or is there?
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. I'm renaming the opcode references from
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.
There still is. Some op previously might have LOCK_OBJECT this uop (it probably did). So you still need the matching UNLOCK_OBJECT in FT. |
||
| } else { | ||
| PyTypeObject *type = _PyType_LookupByVersion(type_version); | ||
| if (type) { | ||
| if (sym_set_type_version(owner, type_version)) { | ||
| PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type); | ||
| _Py_BloomFilter_Add(dependencies, type); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| op(_STORE_ATTR_INSTANCE_VALUE, (offset/1, value, owner -- o)) { | ||
| (void)offset; | ||
| (void)value; | ||
|
|
@@ -1027,9 +1042,25 @@ dummy_func(void) { | |
| } | ||
|
|
||
| op(_CHECK_AND_ALLOCATE_OBJECT, (type_version/2, callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) { | ||
| (void)type_version; | ||
| (void)args; | ||
| callable = sym_new_not_null(ctx); | ||
| PyTypeObject *type = _PyType_LookupByVersion(type_version); | ||
| if (type) { | ||
| PyHeapTypeObject *cls = (PyHeapTypeObject *)type; | ||
| PyObject *init = FT_ATOMIC_LOAD_PTR_ACQUIRE(cls->_spec_cache.init); | ||
| if (init != NULL && PyFunction_Check(init)) { | ||
| // Propagate the __init__ function so _CREATE_INIT_FRAME can | ||
| // resolve the code object and continue optimizing. | ||
| callable = sym_new_const(ctx, init); | ||
| PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type); | ||
| _Py_BloomFilter_Add(dependencies, type); | ||
| } | ||
| else { | ||
| callable = sym_new_not_null(ctx); | ||
| } | ||
| } | ||
| else { | ||
| callable = sym_new_not_null(ctx); | ||
| } | ||
| self_or_null = sym_new_not_null(ctx); | ||
| } | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.