diff options
author | Ken Jin <kenjin@python.org> | 2024-06-20 15:55:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-20 15:55:20 (GMT) |
commit | 7c7aa5a99cce256ff726654038092a333a1f0531 (patch) | |
tree | 5965d6c59fcec54f7f9511c7bb71ff22ac81488e /Python/optimizer_symbols.c | |
parent | b8fd80f91b980598cb378dba224cdb595b132fb4 (diff) | |
download | cpython-7c7aa5a99cce256ff726654038092a333a1f0531.zip cpython-7c7aa5a99cce256ff726654038092a333a1f0531.tar.gz cpython-7c7aa5a99cce256ff726654038092a333a1f0531.tar.bz2 |
[3.13] gh-119258: Backport optimizer frame fixes in GH-119365 (GH-120699)
(cherry picked from commit 55402d3)
Diffstat (limited to 'Python/optimizer_symbols.c')
-rw-r--r-- | Python/optimizer_symbols.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/Python/optimizer_symbols.c b/Python/optimizer_symbols.c index 4aeb04f..e80d15b 100644 --- a/Python/optimizer_symbols.c +++ b/Python/optimizer_symbols.c @@ -303,9 +303,9 @@ _Py_UOpsAbstractFrame * _Py_uop_frame_new( _Py_UOpsContext *ctx, PyCodeObject *co, - _Py_UopsSymbol **localsplus_start, - int n_locals_already_filled, - int curr_stackentries) + int curr_stackentries, + _Py_UopsSymbol **args, + int arg_len) { assert(ctx->curr_frame_depth < MAX_ABSTRACT_FRAME_DEPTH); _Py_UOpsAbstractFrame *frame = &ctx->frames[ctx->curr_frame_depth]; @@ -313,21 +313,21 @@ _Py_uop_frame_new( frame->stack_len = co->co_stacksize; frame->locals_len = co->co_nlocalsplus; - frame->locals = localsplus_start; + frame->locals = ctx->n_consumed; frame->stack = frame->locals + co->co_nlocalsplus; frame->stack_pointer = frame->stack + curr_stackentries; - ctx->n_consumed = localsplus_start + (co->co_nlocalsplus + co->co_stacksize); + ctx->n_consumed = ctx->n_consumed + (co->co_nlocalsplus + co->co_stacksize); if (ctx->n_consumed >= ctx->limit) { return NULL; } - // Initialize with the initial state of all local variables - for (int i = n_locals_already_filled; i < co->co_nlocalsplus; i++) { + for (int i = 0; i < arg_len; i++) { + frame->locals[i] = args[i]; + } + + for (int i = arg_len; i < co->co_nlocalsplus; i++) { _Py_UopsSymbol *local = _Py_uop_sym_new_unknown(ctx); - if (local == NULL) { - return NULL; - } frame->locals[i] = local; } @@ -335,9 +335,6 @@ _Py_uop_frame_new( // Initialize the stack as well for (int i = 0; i < curr_stackentries; i++) { _Py_UopsSymbol *stackvar = _Py_uop_sym_new_unknown(ctx); - if (stackvar == NULL) { - return NULL; - } frame->stack[i] = stackvar; } |