-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-131798: JIT optimizer: Support custom binary op and property frames #143735
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 |
|---|---|---|
|
|
@@ -327,9 +327,20 @@ dummy_func(void) { | |
| GETLOCAL(this_instr->operand0) = sym_new_null(ctx); | ||
| } | ||
|
|
||
| op(_BINARY_OP_SUBSCR_INIT_CALL, (container, sub, getitem -- new_frame)) { | ||
| new_frame = PyJitRef_NULL; | ||
| ctx->done = true; | ||
| op(_BINARY_OP_SUBSCR_INIT_CALL, (container, sub, getitem -- new_frame)) { | ||
| assert((this_instr + 1)->opcode == _PUSH_FRAME); | ||
| PyCodeObject *co = get_code_with_logging(this_instr + 1); | ||
| if (co == NULL) { | ||
| ctx->done = true; | ||
| break; | ||
| } | ||
| _Py_UOpsAbstractFrame *f = frame_new(ctx, co, 0, NULL, 0); | ||
| if (f == NULL) { | ||
| break; | ||
| } | ||
| f->locals[0] = container; | ||
| f->locals[1] = sub; | ||
| new_frame = PyJitRef_Wrap((JitOptSymbol *)f); | ||
| } | ||
|
|
||
| op(_BINARY_OP_SUBSCR_STR_INT, (str_st, sub_st -- res, s, i)) { | ||
|
|
@@ -759,9 +770,19 @@ dummy_func(void) { | |
| } | ||
|
|
||
| op(_LOAD_ATTR_PROPERTY_FRAME, (fget/4, owner -- new_frame)) { | ||
| (void)fget; | ||
| new_frame = PyJitRef_NULL; | ||
| ctx->done = true; | ||
| // + 1 for _SAVE_RETURN_OFFSET | ||
| assert((this_instr + 2)->opcode == _PUSH_FRAME); | ||
| PyCodeObject *co = get_code_with_logging(this_instr + 2); | ||
| if (co == NULL) { | ||
| ctx->done = true; | ||
| break; | ||
| } | ||
| _Py_UOpsAbstractFrame *f = frame_new(ctx, co, 0, NULL, 0); | ||
| if (f == NULL) { | ||
| break; | ||
| } | ||
| f->locals[0] = owner; | ||
|
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. I think we need to check if frame is NULL before this, right?
Member
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. This was an excellent catch, thank you. We could've let in a segfault because of this! |
||
| new_frame = PyJitRef_Wrap((JitOptSymbol *)f); | ||
| } | ||
|
|
||
| op(_INIT_CALL_BOUND_METHOD_EXACT_ARGS, (callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to add a comment about why are using +2, since I don't know if it's abundantly clear? IIUC, it's because
_SAVE_RETURN_OFFSETis between_LOAD_ATTR_PROPERTY_FRAMEand_PUSH_FRAME.