Skip to content

Commit 62c7e4a

Browse files
committed
Delete arguments of generators after the prolog
1 parent fe9d49e commit 62c7e4a

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contextlib.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ test.test_contextlib.TestSuppress.test_no_args @ linux-x86_64
8484
test.test_contextlib.TestSuppress.test_no_exception @ linux-x86_64
8585
test.test_contextlib.TestSuppress.test_no_result_from_enter @ linux-x86_64
8686
test.test_contextlib.TestSuppress.test_other_exception @ linux-x86_64
87+
test_contextlib.txt:test.test_contextlib.ContextManagerTestCase.test_nokeepref @ linux-x86_64

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1652,9 +1652,13 @@ private void copyArguments(ArgumentsTy args, Builder b) {
16521652
BytecodeLocal local = getLocal(args.kwArg.arg);
16531653
assert local != null;
16541654
b.beginStoreLocal(local);
1655-
b.emitLoadKeywordArguments(idx);
1655+
b.emitLoadKeywordArguments(idx++);
16561656
b.endStoreLocal();
16571657
}
1658+
1659+
if (scope.isCoroutine() || scope.isGenerator()) {
1660+
b.emitClearArguments(idx);
1661+
}
16581662
}
16591663

16601664
/* ---------------- StatementCompiler -------------------- */

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,19 @@ public static void perform(VirtualFrame frame, LocalRangeAccessor locals,
12041204
}
12051205
}
12061206

1207+
@Operation(storeBytecodeIndex = false)
1208+
@ConstantOperand(type = int.class)
1209+
public static final class ClearArguments {
1210+
@Specialization
1211+
@ExplodeLoop
1212+
public static void perform(VirtualFrame frame, int count,
1213+
@Bind BytecodeNode bytecodeNode) {
1214+
for (int i = 0; i < count; i++) {
1215+
PArguments.setArgument(frame.getArguments(), i, null);
1216+
}
1217+
}
1218+
}
1219+
12071220
@Operation(storeBytecodeIndex = false)
12081221
@ConstantOperand(type = int.class)
12091222
public static final class LoadVariableArguments {

0 commit comments

Comments
 (0)