Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
import com.oracle.graal.python.lib.PyNumberAsSizeNode;
import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
import com.oracle.graal.python.lib.PyObjectGetAttr;
import com.oracle.graal.python.lib.PyObjectIsInstanceNode;
import com.oracle.graal.python.lib.PyObjectLookupAttr;
import com.oracle.graal.python.lib.PyObjectReprAsObjectNode;
import com.oracle.graal.python.lib.PyObjectSetAttr;
Expand Down Expand Up @@ -1925,7 +1926,7 @@ Object doHook(VirtualFrame frame, Object[] args, PKeyword[] keywords,
@Cached PyObjectGetAttr getAttr,
@Cached PyImportImport importNode,
@Cached IsBuiltinObjectProfile attrErrorProfile,
@Cached BuiltinFunctions.IsInstanceNode isInstanceNode,
@Cached PyObjectIsInstanceNode isInstanceNode,
@Cached WarningsModuleBuiltins.WarnNode warnNode,
@Cached TruffleString.CodePointLengthNode codePointLengthNode,
@Cached TruffleString.CodePointAtIndexUTF32Node codePointAtIndexNode,
Expand Down Expand Up @@ -1962,7 +1963,7 @@ Object doHook(VirtualFrame frame, Object[] args, PKeyword[] keywords,
try {
module = importNode.execute(frame, inliningTarget, modPath);
} catch (PException pe) {
if (isInstanceNode.executeWith(frame, pe.getUnreifiedException(), ImportError)) {
if (isInstanceNode.execute(frame, pe.getUnreifiedException(), ImportError)) {
warnNode.warnFormat(frame, RuntimeWarning, WARN_IGNORE_UNIMPORTABLE_BREAKPOINT_S, hookName);
}
return PNone.NONE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
import com.oracle.graal.python.builtins.Python3Core;
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
import com.oracle.graal.python.builtins.PythonBuiltins;
import com.oracle.graal.python.builtins.modules.BuiltinFunctions.IsSubClassNode;
import com.oracle.graal.python.builtins.modules.WarningsModuleBuiltinsClinicProviders.WarnBuiltinNodeClinicProviderGen;
import com.oracle.graal.python.builtins.modules.WarningsModuleBuiltinsFactory.WarnBuiltinNodeFactory;
import com.oracle.graal.python.builtins.objects.PNone;
Expand All @@ -95,6 +94,7 @@
import com.oracle.graal.python.lib.PyNumberAsSizeNode;
import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
import com.oracle.graal.python.lib.PyObjectIsTrueNode;
import com.oracle.graal.python.lib.PyObjectIsSubclassNode;
import com.oracle.graal.python.lib.PyObjectLookupAttr;
import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode;
import com.oracle.graal.python.lib.PyObjectRichCompareBool.CachedPyObjectRichCompareBool;
Expand Down Expand Up @@ -210,7 +210,7 @@ static final class WarningsModuleNode extends Node {
@Child GetClassNode getClassNode;
@Child PyNumberAsSizeNode asSizeNode;
@Child PyObjectIsTrueNode isTrueNode;
@Child IsSubClassNode isSubClassNode;
@Child PyObjectIsSubclassNode isSubClassNode;
@Child GetOrCreateDictNode getDictNode;
@Child ReadFrameNode readFrameNode;
@Child PyObjectLookupAttr lookupAttrNode;
Expand Down Expand Up @@ -376,11 +376,11 @@ private TruffleString.SubstringNode getSubstringNode() {
return substringNode;
}

private IsSubClassNode getIsSubClass() {
private PyObjectIsSubclassNode getIsSubClass() {
if (isSubClassNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
reportPolymorphicSpecialize();
isSubClassNode = insert(IsSubClassNode.create());
isSubClassNode = insert(PyObjectIsSubclassNode.create());
}
return isSubClassNode;
}
Expand Down Expand Up @@ -595,7 +595,7 @@ private TruffleString getFilter(VirtualFrame frame, BoundaryCallData boundaryCal

boolean goodMsg = checkMatched(frame, msg, text);
boolean goodMod = checkMatched(frame, mod, module);
boolean isSubclass = getIsSubClass().executeBoolean(frame, category, cat);
boolean isSubclass = getIsSubClass().execute(frame, category, cat);
int ln = getAsSizeNode().executeExactCached(frame, lnObj);
if (goodMsg && isSubclass && goodMod && (ln == 0 || lineno == ln)) {
// if we're ignoring warnings, the first action will match all and the loop
Expand Down Expand Up @@ -778,7 +778,7 @@ private void warnExplicit(VirtualFrame frame, PythonModule warnings,
// Python code uses PyObject_IsInstance but on the built-in Warning class, so we know
// what __instancecheck__ does
Object text;
if (getIsSubClass().executeBoolean(frame, getPythonClass(message), PythonBuiltinClassType.Warning)) {
if (getIsSubClass().execute(frame, getPythonClass(message), PythonBuiltinClassType.Warning)) {
text = getStrNode().executeCached(frame, message);
category = getPythonClass(message);
} else {
Expand Down Expand Up @@ -907,11 +907,11 @@ private void setupContext(VirtualFrame frame, int stackLevel, TruffleString[] sk
*/
private Object getCategory(VirtualFrame frame, Object message, Object category) {
Object messageType = getPythonClass(message);
if (getIsSubClass().executeBoolean(frame, messageType, PythonBuiltinClassType.Warning)) {
if (getIsSubClass().execute(frame, messageType, PythonBuiltinClassType.Warning)) {
return messageType;
} else if (category == null || category == PNone.NONE) {
return PythonBuiltinClassType.UserWarning;
} else if (!getIsTypeNode().executeCached(category) || !getIsSubClass().executeBoolean(frame, category, PythonBuiltinClassType.Warning)) {
} else if (!getIsTypeNode().executeCached(category) || !getIsSubClass().execute(frame, category, PythonBuiltinClassType.Warning)) {
throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.CATEGORY_MUST_BE_WARN_SUBCLS, category);
} else {
return category;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@

import com.oracle.graal.python.PythonLanguage;
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
import com.oracle.graal.python.builtins.modules.BuiltinFunctions.IsSubClassNode;
import com.oracle.graal.python.builtins.modules.PosixModuleBuiltins.ExitNode;
import com.oracle.graal.python.builtins.modules.SysModuleBuiltins;
import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode;
Expand Down Expand Up @@ -95,6 +94,7 @@
import com.oracle.graal.python.lib.PyLongCheckNode;
import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
import com.oracle.graal.python.lib.PyObjectGetAttr;
import com.oracle.graal.python.lib.PyObjectIsSubclassNode;
import com.oracle.graal.python.lib.PyObjectLookupAttr;
import com.oracle.graal.python.lib.PyObjectSetAttr;
import com.oracle.graal.python.lib.PyObjectStrAsObjectNode;
Expand Down Expand Up @@ -198,7 +198,7 @@ abstract static class GraalPyPrivate_Err_CreateAndSetException extends CApiBinar
@Specialization(guards = "!isExceptionClass(inliningTarget, type, isTypeNode, isSubClassNode)")
static Object create(Object type, @SuppressWarnings("unused") Object value,
@SuppressWarnings("unused") @Shared @Cached IsTypeNode isTypeNode,
@SuppressWarnings("unused") @Shared @Cached IsSubClassNode isSubClassNode,
@SuppressWarnings("unused") @Shared @Cached PyObjectIsSubclassNode isSubClassNode,
@Bind Node inliningTarget) {
throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.SystemError, EXCEPTION_NOT_BASEEXCEPTION, new Object[]{type});
}
Expand All @@ -207,14 +207,14 @@ static Object create(Object type, @SuppressWarnings("unused") Object value,
static Object create(Object type, Object value,
@Bind Node inliningTarget,
@SuppressWarnings("unused") @Shared @Cached IsTypeNode isTypeNode,
@SuppressWarnings("unused") @Shared @Cached IsSubClassNode isSubClassNode,
@SuppressWarnings("unused") @Shared @Cached PyObjectIsSubclassNode isSubClassNode,
@Cached PrepareExceptionNode prepareExceptionNode) {
Object exception = prepareExceptionNode.execute(null, type, value);
throw PRaiseNode.raiseExceptionObjectStatic(inliningTarget, exception);
}

protected static boolean isExceptionClass(Node inliningTarget, Object obj, IsTypeNode isTypeNode, IsSubClassNode isSubClassNode) {
return isTypeNode.execute(inliningTarget, obj) && isSubClassNode.executeWith(null, obj, PythonBuiltinClassType.PBaseException);
protected static boolean isExceptionClass(Node inliningTarget, Object obj, IsTypeNode isTypeNode, PyObjectIsSubclassNode isSubClassNode) {
return isTypeNode.execute(inliningTarget, obj) && isSubClassNode.execute(null, obj, PythonBuiltinClassType.PBaseException);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@

import com.oracle.graal.python.PythonLanguage;
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
import com.oracle.graal.python.builtins.modules.BuiltinFunctions.FormatNode;
import com.oracle.graal.python.builtins.modules.BuiltinFunctions.IsInstanceNode;
import com.oracle.graal.python.builtins.modules.BuiltinFunctions.IsSubClassNode;
import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApi5BuiltinNode;
import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode;
import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin;
Expand Down Expand Up @@ -112,9 +109,12 @@
import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
import com.oracle.graal.python.lib.PyObjectDelItem;
import com.oracle.graal.python.lib.PyObjectDir;
import com.oracle.graal.python.lib.PyObjectFormat;
import com.oracle.graal.python.lib.PyObjectGetAttrO;
import com.oracle.graal.python.lib.PyObjectGetIter;
import com.oracle.graal.python.lib.PyObjectHashNode;
import com.oracle.graal.python.lib.PyObjectIsInstanceNode;
import com.oracle.graal.python.lib.PyObjectIsSubclassNode;
import com.oracle.graal.python.lib.PyObjectIsTrueNode;
import com.oracle.graal.python.lib.PyObjectLookupAttrO;
import com.oracle.graal.python.lib.PyObjectReprAsObjectNode;
Expand Down Expand Up @@ -403,17 +403,17 @@ static Object doGeneric(Object obj, Object k, Object v,
abstract static class PyObject_IsInstance extends CApiBinaryBuiltinNode {
@Specialization
static int doGeneric(Object obj, Object typ,
@Cached IsInstanceNode isInstanceNode) {
return intValue((boolean) isInstanceNode.execute(null, obj, typ));
@Cached PyObjectIsInstanceNode isInstanceNode) {
return intValue(isInstanceNode.execute(null, obj, typ));
}
}

@CApiBuiltin(ret = Int, args = {PyObject, PyObject}, call = Direct)
abstract static class PyObject_IsSubclass extends CApiBinaryBuiltinNode {
@Specialization
static int doGeneric(Object obj, Object typ,
@Cached IsSubClassNode isSubclassNode) {
return intValue((boolean) isSubclassNode.execute(null, obj, typ));
@Cached PyObjectIsSubclassNode isSubclassNode) {
return intValue(isSubclassNode.execute(null, obj, typ));
}
}

Expand Down Expand Up @@ -675,7 +675,7 @@ static TruffleString asciiNone(@SuppressWarnings("unused") PNone obj) {
abstract static class PyObject_Format extends CApiBinaryBuiltinNode {
@Specialization
static Object ascii(Object obj, Object spec,
@Cached FormatNode format) {
@Cached PyObjectFormat format) {
return format.execute(null, obj, spec);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageCopy;
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageDiff;
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageForEach;
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageForEachCallback;
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageGetItem;
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageGetItemWithHash;
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageGetIterator;
Expand All @@ -75,7 +76,6 @@
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageSetItem;
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageTransferItem;
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageXor;
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageForEachCallback;
import com.oracle.graal.python.builtins.objects.common.ObjectHashMap;
import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
import com.oracle.graal.python.builtins.objects.dict.DictViewBuiltinsFactory.ContainedInNodeGen;
Expand Down Expand Up @@ -458,7 +458,7 @@ static PBaseSet doItemsView(VirtualFrame frame, PDictItemsView self, PBaseSet ot
return PFactory.createSet(language, storage);
}

@Specialization
@Fallback
static PBaseSet doGeneric(VirtualFrame frame, Object self, Object other,
@Bind Node inliningTarget,
@Shared("constrSet") @Cached SetNodes.ConstructSetNode constructSetNode,
Expand Down Expand Up @@ -670,7 +670,7 @@ private static HashingStorage getKeysViewOrSetStorage(Object self) {
return ((PBaseSet) self).getDictStorage();
}

@Specialization(guards = {"!isDictKeysView(self)", "!isAnySet(self)"})
@Fallback
static PBaseSet doGeneric(VirtualFrame frame, Object self, Object other,
@Bind Node inliningTarget,
@Cached SetNodes.ConstructSetNode constructSetNode,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -44,13 +44,13 @@

import com.oracle.graal.python.PythonLanguage;
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
import com.oracle.graal.python.builtins.objects.PNone;
import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject;
import com.oracle.graal.python.builtins.objects.common.SequenceNodes;
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode;
import com.oracle.graal.python.lib.PyExceptionInstanceCheckNode;
import com.oracle.graal.python.lib.PyObjectIsInstanceNode;
import com.oracle.graal.python.nodes.ErrorMessages;
import com.oracle.graal.python.nodes.PGuards;
import com.oracle.graal.python.nodes.PRaiseNode;
Expand Down Expand Up @@ -101,13 +101,13 @@ static Object doExceptionOrCreate(VirtualFrame frame, Object type, Object value,
@Bind Node inliningTarget,
@SuppressWarnings("unused") @Exclusive @Cached IsTypeNode isTypeNode,
@Exclusive @Cached PyExceptionInstanceCheckNode check,
@Cached BuiltinFunctions.IsInstanceNode isInstanceNode,
@Cached PyObjectIsInstanceNode isInstanceNode,
@Cached InlinedConditionProfile isInstanceProfile,
@Shared @Cached IsSubtypeNode isSubtypeNode,
@Exclusive @Cached PRaiseNode raiseNode,
@Shared("callCtor") @Cached CallNode callConstructor) {
checkExceptionClass(inliningTarget, type, isSubtypeNode, raiseNode);
if (isInstanceProfile.profile(inliningTarget, isInstanceNode.executeWith(frame, value, type))) {
if (isInstanceProfile.profile(inliningTarget, isInstanceNode.execute(frame, value, type))) {
return value;
} else {
Object instance = callConstructor.execute(frame, type, value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -76,7 +76,7 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
@Slot(value = SlotKind.tp_init, isComplex = true)
@SlotSignature(minNumOfPositionalArgs = 1, takesVarArgs = true, takesVarKeywordArgs = true)
@GenerateNodeFactory
public abstract static class StopIterationInitNode extends PythonVarargsBuiltinNode {
abstract static class StopIterationInitNode extends PythonVarargsBuiltinNode {

@Specialization
static Object init(VirtualFrame frame, PBaseException self, Object[] args, PKeyword[] keywords,
Expand All @@ -89,7 +89,7 @@ static Object init(VirtualFrame frame, PBaseException self, Object[] args, PKeyw

@Builtin(name = "value", minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 2, isGetter = true, isSetter = true, allowsDelete = true, doc = "generator return value")
@GenerateNodeFactory
public abstract static class StopIterationValueNode extends PythonBinaryBuiltinNode {
abstract static class StopIterationValueNode extends PythonBinaryBuiltinNode {
public final Object execute(PBaseException self) {
return execute(null, self, PNone.NO_VALUE);
}
Expand Down
Loading
Loading