Skip to content

Commit 4e6c792

Browse files
fix a bugs in _COPY_FREE_VARS and frame creation
1 parent 89dc467 commit 4e6c792

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Python/optimizer_bytecodes.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ dummy_func(void) {
9696
value = PyJitRef_StripBorrowInfo(value);
9797
}
9898

99+
op(_COPY_FREE_VARS, (--)) {
100+
PyCodeObject *co = get_current_code_object(ctx);
101+
if (co == NULL) {
102+
ctx->done = true;
103+
break;
104+
}
105+
int offset = co->co_nlocalsplus - oparg;
106+
for (int i = 0; i < oparg; ++i) {
107+
ctx->frame->locals[offset + i] = sym_new_not_null(ctx);
108+
}
109+
}
110+
99111
op(_LOAD_FAST_CHECK, (-- value)) {
100112
value = GETLOCAL(oparg);
101113
// We guarantee this will error - just bail and don't optimize it.

Python/optimizer_cases.c.h

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_symbols.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ _Py_uop_frame_new(
15211521

15221522
// Initialize with the initial state of all local variables
15231523
for (int i = 0; i < arg_len; i++) {
1524-
frame->locals[i] = args[i];
1524+
frame->locals[i] = PyJitRef_RemoveUnique(args[i]);
15251525
}
15261526

15271527
// If the args are known, then it's safe to just initialize

0 commit comments

Comments
 (0)