Skip to content

Commit 3d16caf

Browse files
committed
Now nulls the ref to the args array for #1586 instead of clearing the array, so callee code has no copy responsibility (Phil Jenvey's suggestion). Backed out change to thread.PyLocal accordingly in r7047. Bumped bytecode magic.
1 parent c8df8bf commit 3d16caf

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/org/python/compiler/CodeCompiler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,12 @@ public void freeArray(int array) {
413413
code.freeLocal(array);
414414
}
415415

416+
public void freeArrayRef(int array) {
417+
code.aconst_null();
418+
code.astore(array);
419+
code.freeLocal(array);
420+
}
421+
416422
public Str getDocStr(java.util.List<stmt> suite) {
417423
if (suite.size() > 0) {
418424
stmt stmt = suite.get(0);
@@ -1811,7 +1817,7 @@ public Object visitCall(Call node) throws Exception {
18111817
stackConsume(3); // target + starargs + kwargs
18121818
code.invokevirtual(p(PyObject.class), "_callextra", sig(PyObject.class,
18131819
PyObject[].class, String[].class, PyObject.class, PyObject.class));
1814-
freeArray(argArray);
1820+
freeArrayRef(argArray);
18151821
} else if (keys.size() > 0) {
18161822
loadThreadState();
18171823
stackProduce(p(ThreadState.class));
@@ -1823,7 +1829,7 @@ public Object visitCall(Call node) throws Exception {
18231829
stackConsume(2); // target + ts
18241830
code.invokevirtual(p(PyObject.class), "__call__", sig(PyObject.class, ThreadState.class,
18251831
PyObject[].class, String[].class));
1826-
freeArray(argArray);
1832+
freeArrayRef(argArray);
18271833
} else {
18281834
loadThreadState();
18291835
stackProduce(p(ThreadState.class));

src/org/python/core/imp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class imp {
2121

2222
private static final String UNKNOWN_SOURCEFILE = "<unknown>";
2323

24-
private static final int APIVersion = 29;
24+
private static final int APIVersion = 30;
2525

2626
public static final int NO_MTIME = -1;
2727

src/org/python/modules/thread/PyLocal.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ final void _local___init__(PyObject[] args, String[] keywords) {
5959
if (where[0] == TYPE && args.length > 0) {
6060
throw Py.TypeError("Initialization arguments are not supported");
6161
}
62-
// caller zeros out `args`
63-
this.args = new PyObject[args.length];
64-
System.arraycopy(args, 0, this.args, 0, args.length);
62+
this.args = args;
6563
this.keywords = keywords;
6664
}
6765

0 commit comments

Comments
 (0)