mirror of
https://github.com/python/cpython.git
synced 2026-04-14 07:41:00 +00:00
gh-131798: JIT optimizer: Support custom binary op and property frames (GH-143735)
This commit is contained in:
parent
dfc66e5c8d
commit
2873c31edf
3 changed files with 94 additions and 11 deletions
|
|
@ -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)) {
|
||||
|
|
@ -761,9 +772,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;
|
||||
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])) {
|
||||
|
|
|
|||
36
Python/optimizer_cases.c.h
generated
36
Python/optimizer_cases.c.h
generated
|
|
@ -1114,9 +1114,24 @@
|
|||
}
|
||||
|
||||
case _BINARY_OP_SUBSCR_INIT_CALL: {
|
||||
JitOptRef sub;
|
||||
JitOptRef container;
|
||||
JitOptRef new_frame;
|
||||
new_frame = PyJitRef_NULL;
|
||||
ctx->done = true;
|
||||
sub = stack_pointer[-2];
|
||||
container = stack_pointer[-3];
|
||||
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);
|
||||
CHECK_STACK_BOUNDS(-2);
|
||||
stack_pointer[-3] = new_frame;
|
||||
stack_pointer += -2;
|
||||
|
|
@ -1947,11 +1962,22 @@
|
|||
}
|
||||
|
||||
case _LOAD_ATTR_PROPERTY_FRAME: {
|
||||
JitOptRef owner;
|
||||
JitOptRef new_frame;
|
||||
owner = stack_pointer[-1];
|
||||
PyObject *fget = (PyObject *)this_instr->operand0;
|
||||
(void)fget;
|
||||
new_frame = PyJitRef_NULL;
|
||||
ctx->done = true;
|
||||
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;
|
||||
new_frame = PyJitRef_Wrap((JitOptSymbol *)f);
|
||||
stack_pointer[-1] = new_frame;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue