Skip to content

Commit 242dce1

Browse files
committed
[GR-71363] Bytecode DSL: delete arguments of generators after the prolog.
PullRequest: graalpython/4139
2 parents 7a6d384 + 62c7e4a commit 242dce1

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
@@ -1212,6 +1212,19 @@ public static void perform(VirtualFrame frame, LocalRangeAccessor locals,
12121212
}
12131213
}
12141214

1215+
@Operation(storeBytecodeIndex = false)
1216+
@ConstantOperand(type = int.class)
1217+
public static final class ClearArguments {
1218+
@Specialization
1219+
@ExplodeLoop
1220+
public static void perform(VirtualFrame frame, int count,
1221+
@Bind BytecodeNode bytecodeNode) {
1222+
for (int i = 0; i < count; i++) {
1223+
PArguments.setArgument(frame.getArguments(), i, null);
1224+
}
1225+
}
1226+
}
1227+
12151228
@Operation(storeBytecodeIndex = false)
12161229
@ConstantOperand(type = int.class)
12171230
public static final class LoadVariableArguments {

0 commit comments

Comments
 (0)