Skip to content

Commit 7a78803

Browse files
committed
Use copyTo for syncing frame locals
1 parent 49b439e commit 7a78803

File tree

2 files changed

+5
-42
lines changed

2 files changed

+5
-42
lines changed

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,9 @@ public abstract static class SyncFrameValuesNode extends Node {
236236
public abstract void execute(PFrame pyFrame, Frame frameToSync);
237237

238238
@Specialization(guards = {"!pyFrame.hasCustomLocals()",
239-
"frameToSync.getFrameDescriptor() == cachedFd",
240-
"variableSlotCount(cachedFd) < 32"}, limit = "1")
239+
"frameToSync.getFrameDescriptor() == cachedFd"}, limit = "1")
241240
@ExplodeLoop
242-
static void doSyncExploded(PFrame pyFrame, Frame frameToSync,
241+
static void doSyncCached(PFrame pyFrame, Frame frameToSync,
243242
@Cached(value = "frameToSync.getFrameDescriptor()") FrameDescriptor cachedFd) {
244243
MaterializedFrame target = pyFrame.getLocals();
245244
assert cachedFd == target.getFrameDescriptor();
@@ -252,30 +251,14 @@ static void doSyncExploded(PFrame pyFrame, Frame frameToSync,
252251
rootNode.getBytecodeNode().copyLocalValues(0, frameToSync, target, 0, slotCount);
253252
}
254253
} else {
255-
for (int i = 0; i < slotCount; i++) {
256-
PythonUtils.copyFrameSlot(frameToSync, target, i);
257-
}
254+
frameToSync.copyTo(0, target, 0, slotCount);
258255
}
259256
}
260257

261-
@Specialization(guards = "!pyFrame.hasCustomLocals()", replaces = "doSyncExploded")
258+
@Specialization(guards = "!pyFrame.hasCustomLocals()", replaces = "doSyncCached")
262259
@ExplodeLoop
263260
static void doSync(PFrame pyFrame, Frame frameToSync) {
264-
MaterializedFrame target = pyFrame.getLocals();
265-
FrameDescriptor fd = target.getFrameDescriptor();
266-
int slotCount = variableSlotCount(fd);
267-
268-
if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
269-
FrameInfo info = (FrameInfo) fd.getInfo();
270-
if (info instanceof BytecodeDSLFrameInfo bytecodeDSLFrameInfo) {
271-
PBytecodeDSLRootNode rootNode = bytecodeDSLFrameInfo.getRootNode();
272-
rootNode.getBytecodeNode().copyLocalValues(0, frameToSync, target, 0, slotCount);
273-
}
274-
} else {
275-
for (int i = 0; i < slotCount; i++) {
276-
PythonUtils.copyFrameSlot(frameToSync, target, i);
277-
}
278-
}
261+
doSyncCached(pyFrame, frameToSync, frameToSync.getFrameDescriptor());
279262
}
280263

281264
@Specialization(guards = "pyFrame.hasCustomLocals()")

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@
9292
import com.oracle.truffle.api.TruffleOptions;
9393
import com.oracle.truffle.api.dsl.GeneratedBy;
9494
import com.oracle.truffle.api.dsl.NodeFactory;
95-
import com.oracle.truffle.api.frame.Frame;
96-
import com.oracle.truffle.api.frame.MaterializedFrame;
9795
import com.oracle.truffle.api.interop.InteropLibrary;
9896
import com.oracle.truffle.api.interop.UnsupportedMessageException;
9997
import com.oracle.truffle.api.memory.ByteArraySupport;
@@ -742,24 +740,6 @@ public static Unsafe initUnsafe() {
742740
}
743741
}
744742

745-
public static void copyFrameSlot(Frame frameToSync, MaterializedFrame target, int slot) {
746-
if (frameToSync.isObject(slot)) {
747-
target.setObject(slot, frameToSync.getObject(slot));
748-
} else if (frameToSync.isInt(slot)) {
749-
target.setInt(slot, frameToSync.getInt(slot));
750-
} else if (frameToSync.isLong(slot)) {
751-
target.setLong(slot, frameToSync.getLong(slot));
752-
} else if (frameToSync.isBoolean(slot)) {
753-
target.setBoolean(slot, frameToSync.getBoolean(slot));
754-
} else if (frameToSync.isDouble(slot)) {
755-
target.setDouble(slot, frameToSync.getDouble(slot));
756-
} else if (frameToSync.isFloat(slot)) {
757-
target.setFloat(slot, frameToSync.getFloat(slot));
758-
} else if (frameToSync.isByte(slot)) {
759-
target.setByte(slot, frameToSync.getByte(slot));
760-
}
761-
}
762-
763743
public static TruffleString[] objectArrayToTruffleStringArray(Node inliningTarget, Object[] array, CastToTruffleStringNode cast) {
764744
if (array.length == 0) {
765745
return EMPTY_TRUFFLESTRING_ARRAY;

0 commit comments

Comments
 (0)