Skip to content

Commit 6c4031d

Browse files
committed
Deal with instrumentation deleting locals
1 parent 3d5359b commit 6c4031d

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3336,7 +3336,7 @@ public Frame getLocalFrame(VirtualFrame frame) {
33363336
@TruffleBoundary
33373337
private static Object doInvokeTraceFunction(PythonContext.TraceEvent event, PFrame pyFrame, Object traceFn, Object nonNullArg) {
33383338
// Force locals dict sync, so that we can sync them back later
3339-
GetFrameLocalsNode.executeUncached(pyFrame, false);
3339+
GetFrameLocalsNode.executeUncached(pyFrame, true);
33403340
pyFrame.setLocalsAccessed(false);
33413341
return CallTernaryMethodNode.getUncached().execute(null, traceFn, pyFrame, event.pythonName, nonNullArg);
33423342
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ private void invokeTraceFunction(VirtualFrame virtualFrame, BytecodeNode locatio
629629
}
630630

631631
// Force locals dict sync, so that we can sync them back later
632-
GetFrameLocalsNode.executeUncached(pyFrame, false);
632+
GetFrameLocalsNode.executeUncached(pyFrame, true);
633633
Object result = doInvokeProfileOrTraceFunction(virtualFrame, location, threadState, traceFn, pyFrame, event.pythonName, nonNullArg);
634634
syncLocalsBackToFrame(virtualFrame, pyFrame, location);
635635
// https://github.com/python/cpython/issues/104232

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/GetFrameLocalsNode.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
package com.oracle.graal.python.nodes.frame;
4242

4343
import com.oracle.graal.python.PythonLanguage;
44+
import com.oracle.graal.python.builtins.objects.PNone;
4445
import com.oracle.graal.python.builtins.objects.cell.PCell;
4546
import com.oracle.graal.python.builtins.objects.common.HashingStorage;
4647
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageDelItem;
@@ -218,6 +219,10 @@ private static void copyLocalsArray(Frame localFrame, PDict localsDict, Bytecode
218219
PCell cell = (PCell) bytecodeNode.getLocalValue(0, localFrame, offset + i);
219220
cell.setRef(value);
220221
} else {
222+
if (value == null) {
223+
value = PNone.NONE;
224+
// TODO warn: "assigning None to unbound local %s"
225+
}
221226
bytecodeNode.setLocalValue(0, localFrame, offset + i, value);
222227
}
223228
}
@@ -229,6 +234,10 @@ private static void copyLocalsArray(Frame localFrame, PDict localsDict, Bytecode
229234
PCell cell = (PCell) localFrame.getObject(offset + i);
230235
cell.setRef(value);
231236
} else {
237+
if (value == null) {
238+
value = PNone.NONE;
239+
// TODO warn: "assigning None to unbound local %s"
240+
}
232241
localFrame.setObject(offset + i, value);
233242
}
234243
}

0 commit comments

Comments
 (0)