Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-131798: JIT: Narrow the return type of _GET_LEN to int#133345
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
cabe8f11f8a607f2f71d91662b4752ce698b1640edcf17d92c401539619a8469adefc39c6efcb69b929bd1e3a2be0e374581c499693e1e866b5282f2eefeb39c58f2cf9822e96a06aff6d926145cfbad4File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Allow the JIT to remove int guards after ``_GET_LEN`` by setting the return | ||
| type to int. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1116,6 +1116,25 @@ dummy_func(void) { | ||
| res = sym_new_type(ctx, &PyLong_Type); | ||
| } | ||
| op(_GET_LEN, (obj -- obj, len)) { | ||
| int tuple_length = sym_tuple_length(obj); | ||
| if (tuple_length == -1) { | ||
| len = sym_new_type(ctx, &PyLong_Type); | ||
Zheaoli marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| else { | ||
| assert(tuple_length >= 0); | ||
| PyObject *temp = PyLong_FromLong(tuple_length); | ||
| if (temp == NULL) { | ||
| goto error; | ||
| } | ||
| if (_Py_IsImmortal(temp)) { | ||
| REPLACE_OP(this_instr, _LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)temp); | ||
| } | ||
| len = sym_new_const(ctx, temp); | ||
Zheaoli marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Py_DECREF(temp); | ||
| } | ||
| } | ||
| op(_GUARD_CALLABLE_LEN, (callable, unused, unused -- callable, unused, unused)) { | ||
| PyObject *len = _PyInterpreterState_GET()->callable_cache.len; | ||
| if (sym_get_const(ctx, callable) == len) { | ||
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.
Uh oh!
There was an error while loading. Please reload this page.