Skip to content

gh-115419: Change default sym to not_null #116562

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/test/test_generated_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ def test_overridden_abstract_args(self):

case OP2: {
_Py_UopsSymbol *out;
out = sym_new_unknown(ctx);
out = sym_new_not_null(ctx);
if (out == NULL) goto out_of_space;
stack_pointer[-1] = out;
break;
Expand All @@ -933,7 +933,7 @@ def test_no_overridden_case(self):
output = """
case OP: {
_Py_UopsSymbol *out;
out = sym_new_unknown(ctx);
out = sym_new_not_null(ctx);
if (out == NULL) goto out_of_space;
stack_pointer[-1] = out;
break;
Expand Down
9 changes: 8 additions & 1 deletion Python/optimizer_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,14 @@ dummy_func(void) {
}
}

op(_LOAD_ATTR, (owner -- attr, self_or_null if (oparg & 1))) {
(void)owner;
OUT_OF_SPACE_IF_NULL(attr = sym_new_not_null(ctx));
if (oparg & 1) {
OUT_OF_SPACE_IF_NULL(self_or_null = sym_new_unknown(ctx));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point in the future we will be able to tell whether the attribute is a method or not, and hence we will be able to set it to either null or not_null -- but not today, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No not for _LOAD_ATTR - this opcode is special, it means we dont know anything and it's only decideable at runtime.

}
}

op(_LOAD_ATTR_MODULE, (index/1, owner -- attr, null if (oparg & 1))) {
(void)index;
OUT_OF_SPACE_IF_NULL(null = sym_new_null(ctx));
Expand Down Expand Up @@ -513,7 +521,6 @@ dummy_func(void) {
OUT_OF_SPACE_IF_NULL(self = sym_new_not_null(ctx));
}


op(_CHECK_FUNCTION_EXACT_ARGS, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {
if (!sym_set_type(callable, &PyFunction_Type)) {
goto hit_bottom;
Expand Down
Loading