Skip to content

Commit 350b4a3

Browse files
committed
Create all cells in one instruction
1 parent fb00bf6 commit 350b4a3

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,31 +1449,21 @@ public void setUpFrame(ArgumentsTy args, Builder b) {
14491449
copyArguments(args, b);
14501450

14511451
if (cellVariableLocals.length > 0) {
1452-
List<BytecodeLocal> toClear = new ArrayList<>();
1453-
1454-
b.beginStoreRange(cellVariableLocals);
1455-
b.beginCollectToObjectArray();
1452+
b.emitCreateCells(cellVariableLocals);
14561453
for (int i = 0; i < cellVariableLocals.length; i++) {
1457-
b.beginCreateCell(i);
14581454
if (scope.getUseOfName(cellVariables[i]).contains(DefUse.DefParam)) {
14591455
/*
14601456
* To simplify the argument copying performed above, we copy cell params into
14611457
* regular locals just like all other arguments. Then, here we move the value
14621458
* into a cell and clear the regular local.
14631459
*/
14641460
BytecodeLocal param = getLocal(cellVariables[i]);
1461+
b.beginStoreCell();
1462+
b.emitLoadLocal(cellVariableLocals[i]);
14651463
b.emitLoadLocal(param);
1466-
toClear.add(param);
1467-
} else {
1468-
b.emitLoadNull();
1464+
b.endStoreCell();
1465+
b.emitClearLocal(param);
14691466
}
1470-
b.endCreateCell();
1471-
}
1472-
b.endCollectToObjectArray();
1473-
b.endStoreRange();
1474-
1475-
for (BytecodeLocal local : toClear) {
1476-
b.emitClearLocal(local);
14771467
}
14781468
}
14791469

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,14 +2459,15 @@ public static void doStoreCell(PCell cell, Object value) {
24592459
}
24602460

24612461
@Operation
2462-
@ConstantOperand(type = int.class)
2463-
public static final class CreateCell {
2462+
@ConstantOperand(type = LocalRangeAccessor.class)
2463+
public static final class CreateCells {
24642464
@Specialization
2465-
public static PCell doCreateCell(int index, Object value,
2465+
public static void doCreateCells(VirtualFrame frame, LocalRangeAccessor locals,
24662466
@Bind PBytecodeDSLRootNode rootNode) {
2467-
PCell cell = new PCell(rootNode.cellEffectivelyFinalAssumptions[index]);
2468-
cell.setRef(value);
2469-
return cell;
2467+
for (int i = 0; i < locals.getLength(); i++) {
2468+
PCell cell = new PCell(rootNode.cellEffectivelyFinalAssumptions[i]);
2469+
locals.setObject(rootNode.getBytecodeNode(), frame, i, cell);
2470+
}
24702471
}
24712472
}
24722473

0 commit comments

Comments
 (0)