Skip to content

Commit 285ab98

Browse files
committed
[GR-52788] Add missing ExplodeLoops annotation to PBytecodeRootNode#bytecodeCollectionFromStack
PullRequest: graalpython/3281
2 parents 3fd766b + d140931 commit 285ab98

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

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

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5543,6 +5543,27 @@ private static <T> void moveFromStack(VirtualFrame virtualFrame, int start, int
55435543
}
55445544
}
55455545

5546+
@ExplodeLoop
5547+
private static void moveFromStack(VirtualFrame virtualFrame, int start, int stop, PSet target, HashingCollectionNodes.SetItemNode setItem) {
5548+
CompilerAsserts.partialEvaluationConstant(start);
5549+
CompilerAsserts.partialEvaluationConstant(stop);
5550+
for (int i = start; i < stop; i++) {
5551+
setItem.executeCached(virtualFrame, target, virtualFrame.getObject(i), PNone.NONE);
5552+
virtualFrame.setObject(i, null);
5553+
}
5554+
}
5555+
5556+
@ExplodeLoop
5557+
private static void moveFromStack(VirtualFrame virtualFrame, int start, int stop, PDict target, HashingCollectionNodes.SetItemNode setItem) {
5558+
CompilerAsserts.partialEvaluationConstant(start);
5559+
CompilerAsserts.partialEvaluationConstant(stop);
5560+
for (int i = start; i + 1 < stop; i += 2) {
5561+
setItem.executeCached(virtualFrame, target, virtualFrame.getObject(i), virtualFrame.getObject(i + 1));
5562+
virtualFrame.setObject(i, null);
5563+
virtualFrame.setObject(i + 1, null);
5564+
}
5565+
}
5566+
55465567
@BytecodeInterpreterSwitch
55475568
private int bytecodeCollectionFromStack(VirtualFrame virtualFrame, int type, int count, int oldStackTop, Node[] localNodes, int nodeIndex, boolean useCachedNodes) {
55485569
int stackTop = oldStackTop;
@@ -5564,10 +5585,7 @@ private int bytecodeCollectionFromStack(VirtualFrame virtualFrame, int type, int
55645585
PSet set = factory.createSet();
55655586
HashingCollectionNodes.SetItemNode newNode = insertChildNode(localNodes, nodeIndex, UNCACHED_SET_ITEM, HashingCollectionNodesFactory.SetItemNodeGen.class, NODE_SET_ITEM,
55665587
useCachedNodes);
5567-
for (int i = stackTop - count + 1; i <= stackTop; i++) {
5568-
newNode.executeCached(virtualFrame, set, virtualFrame.getObject(i), PNone.NONE);
5569-
virtualFrame.setObject(i, null);
5570-
}
5588+
moveFromStack(virtualFrame, stackTop - count + 1, stackTop + 1, set, newNode);
55715589
res = set;
55725590
break;
55735591
}
@@ -5576,11 +5594,7 @@ private int bytecodeCollectionFromStack(VirtualFrame virtualFrame, int type, int
55765594
HashingCollectionNodes.SetItemNode setItem = insertChildNode(localNodes, nodeIndex, UNCACHED_SET_ITEM, HashingCollectionNodesFactory.SetItemNodeGen.class, NODE_SET_ITEM,
55775595
useCachedNodes);
55785596
assert count % 2 == 0;
5579-
for (int i = stackTop - count + 1; i <= stackTop; i += 2) {
5580-
setItem.executeCached(virtualFrame, dict, virtualFrame.getObject(i), virtualFrame.getObject(i + 1));
5581-
virtualFrame.setObject(i, null);
5582-
virtualFrame.setObject(i + 1, null);
5583-
}
5597+
moveFromStack(virtualFrame, stackTop - count + 1, stackTop + 1, dict, setItem);
55845598
res = dict;
55855599
break;
55865600
}

0 commit comments

Comments
 (0)