Skip to content

Commit 14b284a

Browse files
committed
Skip locals back-sync when not necessary in DSL root too
1 parent 6c4031d commit 14b284a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,9 @@ private PFrame ensurePyFrame(VirtualFrame frame, BytecodeNode location) {
541541
}
542542

543543
private void syncLocalsBackToFrame(VirtualFrame frame, PFrame pyFrame, BytecodeNode location) {
544-
GetFrameLocalsNode.syncLocalsBackToFrame(co, pyFrame, frame, location);
544+
if (pyFrame.localsAccessed()) {
545+
GetFrameLocalsNode.syncLocalsBackToFrame(co, pyFrame, frame, location);
546+
}
545547
}
546548

547549
/**
@@ -582,6 +584,7 @@ private void invokeProfileFunction(VirtualFrame virtualFrame, BytecodeNode locat
582584
try {
583585
// Force locals dict sync, so that we can sync them back later
584586
GetFrameLocalsNode.executeUncached(pyFrame, false);
587+
pyFrame.setLocalsAccessed(false);
585588
Object result = doInvokeProfileOrTraceFunction(virtualFrame, location, threadState, profileFun, pyFrame, event.name, arg);
586589
syncLocalsBackToFrame(virtualFrame, pyFrame, location);
587590
Object realResult = result == PNone.NONE ? null : result;
@@ -630,6 +633,7 @@ private void invokeTraceFunction(VirtualFrame virtualFrame, BytecodeNode locatio
630633

631634
// Force locals dict sync, so that we can sync them back later
632635
GetFrameLocalsNode.executeUncached(pyFrame, true);
636+
pyFrame.setLocalsAccessed(false);
633637
Object result = doInvokeProfileOrTraceFunction(virtualFrame, location, threadState, traceFn, pyFrame, event.pythonName, nonNullArg);
634638
syncLocalsBackToFrame(virtualFrame, pyFrame, location);
635639
// https://github.com/python/cpython/issues/104232

0 commit comments

Comments
 (0)