|
27 | 27 |
|
28 | 28 | import static com.oracle.graal.python.builtins.objects.PNone.NO_VALUE;
|
29 | 29 |
|
| 30 | +import com.oracle.graal.python.PythonLanguage; |
30 | 31 | import com.oracle.graal.python.builtins.objects.cell.PCell;
|
31 | 32 | import com.oracle.graal.python.nodes.expression.ExpressionNode;
|
32 | 33 | import com.oracle.graal.python.nodes.frame.WriteIdentifierNode;
|
33 | 34 | import com.oracle.graal.python.nodes.statement.StatementNode;
|
| 35 | +import com.oracle.graal.python.runtime.PythonOptions; |
34 | 36 | import com.oracle.truffle.api.Assumption;
|
35 | 37 | import com.oracle.truffle.api.CompilerDirectives;
|
36 | 38 | import com.oracle.truffle.api.dsl.Cached;
|
| 39 | +import com.oracle.truffle.api.dsl.ImportStatic; |
37 | 40 | import com.oracle.truffle.api.dsl.NodeChild;
|
| 41 | +import com.oracle.truffle.api.dsl.ReportPolymorphism; |
38 | 42 | import com.oracle.truffle.api.dsl.Specialization;
|
39 | 43 | import com.oracle.truffle.api.frame.FrameSlot;
|
40 | 44 | import com.oracle.truffle.api.frame.VirtualFrame;
|
@@ -83,21 +87,32 @@ public Object getIdentifier() {
|
83 | 87 | return frameSlot.getIdentifier();
|
84 | 88 | }
|
85 | 89 |
|
| 90 | + @ImportStatic(PythonOptions.class) |
| 91 | + @ReportPolymorphism |
86 | 92 | abstract static class WriteToCellNode extends Node {
|
87 | 93 |
|
88 | 94 | public abstract void execute(PCell cell, Object value);
|
89 | 95 |
|
90 |
| - @Specialization(guards = "cell == cachedCell", limit = "1") |
| 96 | + protected static Assumption singleContextAssumption() { |
| 97 | + return PythonLanguage.getCurrent().singleContextAssumption; |
| 98 | + } |
| 99 | + |
| 100 | + @Specialization(guards = "cell == cachedCell", limit = "getAttributeAccessInlineCacheMaxDepth()", assumptions = "singleContextAssumption") |
91 | 101 | void doWriteCached(@SuppressWarnings("unused") PCell cell, Object value,
|
| 102 | + @SuppressWarnings("unused") @Cached("singleContextAssumption()") Assumption singleContextAssumption, |
92 | 103 | @Cached("cell") PCell cachedCell) {
|
93 |
| - doWriteGeneric(cachedCell, value); |
| 104 | + if (value == NO_VALUE) { |
| 105 | + cachedCell.clearRef(cachedCell.isEffectivelyFinalAssumption()); |
| 106 | + } else { |
| 107 | + cachedCell.setRef(value, cachedCell.isEffectivelyFinalAssumption()); |
| 108 | + } |
94 | 109 | }
|
95 | 110 |
|
96 |
| - @Specialization(guards = "cell.isEffectivelyFinalAssumption() == effectivelyFinalAssumption", limit = "1", assumptions = "effectivelyFinalAssumption") |
| 111 | + @Specialization(guards = "cell.isEffectivelyFinalAssumption() == effectivelyFinalAssumption", limit = "getAttributeAccessInlineCacheMaxDepth()", assumptions = "effectivelyFinalAssumption") |
97 | 112 | void doWriteCachedAssumption(PCell cell, Object value,
|
98 | 113 | @SuppressWarnings("unused") @Cached("cell.isEffectivelyFinalAssumption()") Assumption effectivelyFinalAssumption) {
|
99 | 114 | if (value == NO_VALUE) {
|
100 |
| - cell.clearRef(); |
| 115 | + cell.clearRef(effectivelyFinalAssumption); |
101 | 116 | } else {
|
102 | 117 | cell.setRef(value, effectivelyFinalAssumption);
|
103 | 118 | }
|
|
0 commit comments