Skip to content

Commit c3d87ad

Browse files
committed
CellBuiltins, CExtNodes use PythonLanguage#isSingleContext
1 parent 1b1e8e7 commit c3d87ad

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cell/CellBuiltins.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
import java.util.List;
5454

55-
import com.oracle.graal.python.PythonLanguage;
5655
import com.oracle.graal.python.builtins.Builtin;
5756
import com.oracle.graal.python.builtins.CoreFunctions;
5857
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
@@ -64,18 +63,17 @@
6463
import com.oracle.graal.python.builtins.objects.type.TypeNodes;
6564
import com.oracle.graal.python.lib.PyObjectRichCompareBool;
6665
import com.oracle.graal.python.nodes.ErrorMessages;
66+
import com.oracle.graal.python.nodes.PNodeWithContext;
6767
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
6868
import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
6969
import com.oracle.graal.python.nodes.object.GetClassNode;
7070
import com.oracle.graal.python.util.PythonUtils;
71-
import com.oracle.truffle.api.Assumption;
7271
import com.oracle.truffle.api.dsl.Cached;
7372
import com.oracle.truffle.api.dsl.Fallback;
7473
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
7574
import com.oracle.truffle.api.dsl.NodeFactory;
7675
import com.oracle.truffle.api.dsl.Specialization;
7776
import com.oracle.truffle.api.frame.VirtualFrame;
78-
import com.oracle.truffle.api.nodes.Node;
7977
import com.oracle.truffle.api.profiles.ConditionProfile;
8078

8179
@CoreFunctions(extendClasses = PythonBuiltinClassType.PCell)
@@ -298,16 +296,11 @@ Object set(PCell self, Object ref) {
298296
}
299297
}
300298

301-
public abstract static class GetRefNode extends Node {
299+
public abstract static class GetRefNode extends PNodeWithContext {
302300
public abstract Object execute(PCell self);
303301

304-
protected Assumption singleContextAssumption() {
305-
return PythonLanguage.get(this).singleContextAssumption;
306-
}
307-
308-
@Specialization(guards = "self == cachedSelf", assumptions = {"cachedSelf.isEffectivelyFinalAssumption()", "singleContextAssumption"}, limit = "1")
302+
@Specialization(guards = {"isSingleContext()", "self == cachedSelf"}, assumptions = {"cachedSelf.isEffectivelyFinalAssumption()"}, limit = "1")
309303
Object cached(@SuppressWarnings("unused") PCell self,
310-
@SuppressWarnings("unused") @Cached("singleContextAssumption()") Assumption singleContextAssumption,
311304
@SuppressWarnings("unused") @Cached("self") PCell cachedSelf,
312305
@Cached("self.getRef()") Object ref) {
313306
return ref;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3160,15 +3160,14 @@ static boolean isLazyContext(CApiContext cApiContext) {
31603160
}
31613161

31623162
@GenerateUncached
3163-
public abstract static class ResolveHandleNode extends Node {
3163+
public abstract static class ResolveHandleNode extends PNodeWithContext {
31643164

31653165
public abstract Object execute(Object pointerObject);
31663166

31673167
public abstract Object executeLong(long pointer);
31683168

31693169
@Specialization(limit = "3", //
3170-
guards = {"cachedPointer == pointer", "cachedValue != null"}, //
3171-
assumptions = "singleContextAssumption()", //
3170+
guards = {"isSingleContext()", "cachedPointer == pointer", "cachedValue != null"}, //
31723171
rewriteOn = InvalidAssumptionException.class)
31733172
static PythonNativeWrapper resolveLongCached(@SuppressWarnings("unused") long pointer,
31743173
@Cached("pointer") @SuppressWarnings("unused") long cachedPointer,
@@ -3179,8 +3178,7 @@ static PythonNativeWrapper resolveLongCached(@SuppressWarnings("unused") long po
31793178
}
31803179

31813180
@Specialization(limit = "3", //
3182-
guards = {"isSame(lib, cachedPointerObject, pointerObject)", "cachedValue != null"}, //
3183-
assumptions = "singleContextAssumption()", //
3181+
guards = {"isSingleContext()", "isSame(lib, cachedPointerObject, pointerObject)", "cachedValue != null"}, //
31843182
rewriteOn = InvalidAssumptionException.class)
31853183
static PythonNativeWrapper resolveObjectCached(@SuppressWarnings("unused") Object pointerObject,
31863184
@Cached("pointerObject") @SuppressWarnings("unused") Object cachedPointerObject,
@@ -3220,10 +3218,6 @@ static boolean isSame(InteropLibrary lib, Object left, Object right) {
32203218
return lib.isIdentical(left, right, lib);
32213219
}
32223220

3223-
Assumption singleContextAssumption() {
3224-
return PythonLanguage.get(this).singleContextAssumption;
3225-
}
3226-
32273221
static Assumption getHandleValidAssumption(PythonNativeWrapper nativeWrapper) {
32283222
return nativeWrapper.ensureHandleValidAssumption();
32293223
}

0 commit comments

Comments
 (0)