Skip to content

Commit dd197a1

Browse files
committed
Create cell assumptions ahead of execution in DSL interpreter
1 parent fc07038 commit dd197a1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ public void setUpFrame(ArgumentsTy args, Builder b) {
14541454
b.beginStoreRange(cellVariableLocals);
14551455
b.beginCollectToObjectArray();
14561456
for (int i = 0; i < cellVariableLocals.length; i++) {
1457-
b.beginCreateCell();
1457+
b.beginCreateCell(i);
14581458
if (scope.getUseOfName(cellVariables[i]).contains(DefUse.DefParam)) {
14591459
/*
14601460
* To simplify the argument copying performed above, we copy cell params into

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@
228228
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
229229
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
230230
import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
231+
import com.oracle.truffle.api.Truffle;
231232
import com.oracle.truffle.api.bytecode.BytecodeConfig;
232233
import com.oracle.truffle.api.bytecode.BytecodeLocation;
233234
import com.oracle.truffle.api.bytecode.BytecodeNode;
@@ -345,6 +346,7 @@ public abstract class PBytecodeDSLRootNode extends PRootNode implements Bytecode
345346
@CompilationFinal protected transient int selfIndex;
346347
@CompilationFinal protected transient int classcellIndex;
347348
@CompilationFinal public int yieldFromGeneratorIndex = -1;
349+
@CompilationFinal(dimensions = 1) protected transient Assumption[] cellEffectivelyFinalAssumptions;
348350

349351
private transient boolean pythonInternal;
350352
@CompilationFinal private transient boolean internal;
@@ -370,6 +372,12 @@ public void setMetadata(BytecodeDSLCodeUnit co, ParserCallbacksImpl parserErrorC
370372
this.selfIndex = co.selfIndex;
371373
this.internal = getSource().isInternal();
372374
this.parserErrorCallback = parserErrorCallback;
375+
if (co.cellvars.length > 0) {
376+
this.cellEffectivelyFinalAssumptions = new Assumption[co.cellvars.length];
377+
for (int i = 0; i < co.cellvars.length; i++) {
378+
cellEffectivelyFinalAssumptions[i] = Truffle.getRuntime().createAssumption("cell is effectively final");
379+
}
380+
}
373381
}
374382

375383
@Override
@@ -2454,10 +2462,12 @@ public static void doStoreCell(PCell cell, Object value) {
24542462
}
24552463

24562464
@Operation
2465+
@ConstantOperand(type = int.class)
24572466
public static final class CreateCell {
24582467
@Specialization
2459-
public static PCell doCreateCell(Object value) {
2460-
PCell cell = new PCell(Assumption.create());
2468+
public static PCell doCreateCell(int index, Object value,
2469+
@Bind PBytecodeDSLRootNode rootNode) {
2470+
PCell cell = new PCell(rootNode.cellEffectivelyFinalAssumptions[index]);
24612471
cell.setRef(value);
24622472
return cell;
24632473
}

0 commit comments

Comments
 (0)