diff --git a/AGENTS.md b/AGENTS.md index a8b507d1a0..c99af625c0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,6 +35,7 @@ It consists of: Java (Truffle) + C (CPython C-API compatibility) + Python stdlib ## CONVENTIONS (DEVIATIONS) - `mx` is the primary build/test entrypoint; suite definition lives in `mx.graalpython/suite.py`. +- By default always pass `--java-home=lookup:default` to `mx` to select the default JDK. - `black` is configured but intentionally **disabled** for this repo (root `pyproject.toml`); line length is 120 and version locked to `23` for consistency. - Formatting/linting is enforced via **pre-commit** with repo-specific hooks (Eclipse formatter, checkstyle, copyright), and pylint only on `mx.graalpython/*.py`. - Large generated/build outputs exist in-tree (`mxbuild/`, `*.dist/`); do not use them as the source of truth when navigating code. @@ -71,7 +72,6 @@ It consists of: Java (Truffle) + C (CPython C-API compatibility) + Python stdlib `mx python-gate --tags style` * Building standalones for benchmarking - use `mx --env native-ee sforceimports && mx --env native-ee checkout-downstream compiler graal-enterprise` to get the right revisions - - use `mx -p ../graal/vm fetch-jdk -jdk-id labsjdk-ce-latest` and set JAVA_HOME as per that command's output - use `mx --env jvm-ee-libgraal` and `mx --env native-ee` to build the JAVA and NATIVE standalone distributions ## NOTES diff --git a/common.json b/common.json new file mode 120000 index 0000000000..e1cbf5e3c1 --- /dev/null +++ b/common.json @@ -0,0 +1 @@ +./ci/graal/common.json \ No newline at end of file diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalPythonModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalPythonModuleBuiltins.java index 93730906d9..08b0421d06 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalPythonModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalPythonModuleBuiltins.java @@ -107,6 +107,7 @@ import com.oracle.graal.python.builtins.objects.cext.capi.CApiContext; import com.oracle.graal.python.builtins.objects.cext.capi.PySequenceArrayWrapper.ToNativeStorageNode; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions; +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.CApiNativeStub; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.HandlePointerConverter; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonObjectReference; import com.oracle.graal.python.builtins.objects.cext.copying.NativeLibraryLocator; @@ -1275,9 +1276,8 @@ abstract static class IsWeakHandleTableRef extends PythonUnaryBuiltinNode { @Specialization @TruffleBoundary static boolean doGeneric(int id) { - Object ref = CApiTransitions.nativeStubLookupGet(PythonContext.get(null).handleContext, 0, id); - assert ref == null || ref instanceof PythonAbstractObject || ref instanceof PythonObjectReference; - return ref instanceof PythonAbstractObject || ref != null && ((PythonObjectReference) ref).isStrongReference(); + CApiNativeStub ref = CApiTransitions.nativeStubLookupGet(PythonContext.get(null).handleContext, 0, id); + return ref instanceof PythonAbstractObject || ref instanceof PythonObjectReference pythonObjectReference && pythonObjectReference.isStrongReference(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java index c225d3c1f0..0c35fc57a1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java @@ -67,6 +67,7 @@ import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary; +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.CApiNativeStub; import com.oracle.graal.python.builtins.objects.common.DynamicObjectStorage; import com.oracle.graal.python.builtins.objects.common.HashingStorage; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageGetIterator; @@ -186,7 +187,7 @@ @ImportStatic(SpecialMethodNames.class) @ExportLibrary(InteropLibrary.class) -public abstract class PythonAbstractObject extends DynamicObject implements TruffleObject, Comparable { +public abstract class PythonAbstractObject extends DynamicObject implements TruffleObject, CApiNativeStub, Comparable { public static final long UNINITIALIZED = -1; public static final long NATIVE_POINTER_FREED = 0; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/CApiTransitions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/CApiTransitions.java index 4dd463333d..bc1ec478ed 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/CApiTransitions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/CApiTransitions.java @@ -220,7 +220,7 @@ public static final class HandleContext { public HandleContext(boolean useShadowTable) { nativeStubLookupShadowTable = useShadowTable ? new HashMap<>() : null; - nativeStubLookup = new Object[DEFAULT_CAPACITY]; + nativeStubLookup = new CApiNativeStub[DEFAULT_CAPACITY]; nativeStubLookupFreeStack = new HandleStack(DEFAULT_CAPACITY); nativeStubLookupFreeStack.pushRange(FIRST_VALID_INDEX, DEFAULT_CAPACITY); nativeTypeLookup = new IdReference[DEFAULT_CAPACITY]; @@ -232,8 +232,8 @@ public HandleContext(boolean useShadowTable) { public IdReference[] nativeTypeLookup; - private final HashMap nativeStubLookupShadowTable; - public Object[] nativeStubLookup; + private final HashMap nativeStubLookupShadowTable; + public CApiNativeStub[] nativeStubLookup; public final HandleStack nativeStubLookupFreeStack; public final Set nativeStorageReferences = new HashSet<>(); @@ -281,10 +281,16 @@ public IdReference(HandleContext handleContext, T referent) { } + /** + * Marker interface for types that can be looked up. + */ + public interface CApiNativeStub { + } + /** * A weak and unique reference to a native wrapper of a reference counted managed object. */ - public static final class PythonObjectReference extends IdReference { + public static final class PythonObjectReference extends IdReference implements CApiNativeStub { /** * This reference forces the wrapper to remain alive, and can be set to null when the * refcount falls to {@link PythonObject#MANAGED_REFCNT}. @@ -931,7 +937,7 @@ public static void freeNativeObjectStubs(HandleContext handleContext) { assert PythonContext.get(null).ownsGil(); assert PythonContext.get(null).isFinalizing(); for (int i = HandleContext.FIRST_VALID_INDEX; i < handleContext.nativeStubLookup.length; i++) { - Object ref = handleContext.nativeStubLookup[i]; + CApiNativeStub ref = handleContext.nativeStubLookup[i]; // not all slots of the handle table are currently used if (ref == null) { continue; @@ -1152,14 +1158,14 @@ private static boolean isValidTypeLookupEntry(Object entry, long ptr) { entry instanceof PythonNativeClass nativeClass && nativeClass.getPtr() == ptr; } - public static Object nativeStubLookupGet(HandleContext context, long pointer, int idx) { + public static CApiNativeStub nativeStubLookupGet(HandleContext context, long pointer, int idx) { if (idx <= 0) { if (PythonContext.DEBUG_CAPI && HandleContext.getShadowTable(context.nativeStubLookupShadowTable, pointer) != null) { throw CompilerDirectives.shouldNotReachHere(); } return null; } - Object result = context.nativeStubLookup[idx]; + CApiNativeStub result = context.nativeStubLookup[idx]; if (PythonContext.DEBUG_CAPI && HandleContext.getShadowTable(context.nativeStubLookupShadowTable, pointer) != result) { throw CompilerDirectives.shouldNotReachHere(); } @@ -1197,14 +1203,14 @@ private static int resizeNativeStubLookupTable(HandleContext context) throws Ove return context.nativeStubLookupFreeStack.pop(); } - private static int nativeStubLookupPut(HandleContext context, int idx, Object value, long pointer) { + private static int nativeStubLookupPut(HandleContext context, int idx, CApiNativeStub value, long pointer) { assert idx > 0; assert HandlePointerConverter.pointsToPyHandleSpace(pointer); assert value instanceof PythonObject || value instanceof PythonObjectReference || CApiContext.isSpecialSingleton(value); assert context.nativeStubLookup[idx] == null || context.nativeStubLookup[idx] == value; context.nativeStubLookup[idx] = value; if (PythonContext.DEBUG_CAPI) { - Object prev = HandleContext.putShadowTable(context.nativeStubLookupShadowTable, pointer, value); + CApiNativeStub prev = HandleContext.putShadowTable(context.nativeStubLookupShadowTable, pointer, value); if (prev != null && prev != value) { throw CompilerDirectives.shouldNotReachHere(); } @@ -1219,7 +1225,7 @@ private static int nativeStubLookupReplaceByWeak(HandleContext context, int idx, assert context.nativeStubLookup[idx] == value.get(); context.nativeStubLookup[idx] = value; if (PythonContext.DEBUG_CAPI) { - Object prev = HandleContext.putShadowTable(context.nativeStubLookupShadowTable, pointer, value); + CApiNativeStub prev = HandleContext.putShadowTable(context.nativeStubLookupShadowTable, pointer, value); if (prev != value.get()) { throw CompilerDirectives.shouldNotReachHere(); } @@ -1232,9 +1238,9 @@ public static void nativeStubLookupRemove(HandleContext context, PythonObjectRef nativeStubLookupRemove(context, ref.handleTableIndex); } - public static Object nativeStubLookupRemove(HandleContext context, int idx) { + public static CApiNativeStub nativeStubLookupRemove(HandleContext context, int idx) { assert idx >= HandleContext.FIRST_VALID_INDEX; - Object result = context.nativeStubLookup[idx]; + CApiNativeStub result = context.nativeStubLookup[idx]; assert result instanceof PythonObjectReference || result instanceof PythonObject || CApiContext.isSpecialSingleton(result); context.nativeStubLookup[idx] = null; context.nativeStubLookupFreeStack.push(idx); @@ -1540,7 +1546,7 @@ static long doGeneric(Node inliningTarget, PythonAbstractObject object, Object t // accidentally maps to some valid object. assert idx > 0; CStructAccess.writeIntField(stubPointer, CFields.GraalPyObject__handle_table_index, idx); - Object ref; + CApiNativeStub ref; if (initialRefCount > MANAGED_REFCNT) { ref = object; @@ -2133,7 +2139,7 @@ static Object doGeneric(Node inliningTarget, long pointer, boolean needsTransfer return HandlePointerConverter.pointerToDouble(pointer); } int idx = readIntField(HandlePointerConverter.pointerToStub(pointer), CFields.GraalPyObject__handle_table_index); - Object reference = nativeStubLookupGet(handleContext, pointer, idx); + CApiNativeStub reference = nativeStubLookupGet(handleContext, pointer, idx); if (reference instanceof PythonAbstractObject) { result = (PythonAbstractObject) reference; } else if (reference instanceof PythonObjectReference pythonObjectReference) { @@ -2331,7 +2337,7 @@ static Object doNonWrapper(long pointer, boolean stealing, return HandlePointerConverter.pointerToDouble(pointer); } int idx = readIntField(HandlePointerConverter.pointerToStub(pointer), CFields.GraalPyObject__handle_table_index); - Object reference = nativeStubLookupGet(handleContext, pointer, idx); + CApiNativeStub reference = nativeStubLookupGet(handleContext, pointer, idx); if (reference instanceof PythonAbstractObject) { pythonAbstractObject = (PythonAbstractObject) reference; } else if (reference instanceof PythonObjectReference pythonObjectReference) { @@ -2411,7 +2417,7 @@ static Object doLong(Node inliningTarget, long pointer, } int idx = readIntField(HandlePointerConverter.pointerToStub(pointer), CFields.GraalPyObject__handle_table_index); PythonObject pythonObject; - Object reference = nativeStubLookupGet(handleContext, pointer, idx); + CApiNativeStub reference = nativeStubLookupGet(handleContext, pointer, idx); if (reference instanceof PythonObject) { pythonObject = (PythonObject) reference; } else if (reference instanceof PythonObjectReference pythonObjectReference) { @@ -2810,7 +2816,7 @@ static void doGeneric(Node inliningTarget, HandleContext handleContext, long tag assert !HandlePointerConverter.pointsToPyIntHandle(taggedPointer); assert !HandlePointerConverter.pointsToPyFloatHandle(taggedPointer); - Object ref = nativeStubLookupGet(handleContext, taggedPointer, handleTableIndex); + CApiNativeStub ref = nativeStubLookupGet(handleContext, taggedPointer, handleTableIndex); if (ref instanceof PythonObjectReference pythonObjectReference) { hasWeakRef.enter(inliningTarget); handlePythonObjectReference(inliningTarget, pythonObjectReference, taggedPointer, handleTableIndex, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberAddFastPathsBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberAddFastPathsBase.java index a0aa6904be..4208b9e29f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberAddFastPathsBase.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberAddFastPathsBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 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 @@ -45,7 +45,7 @@ import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntToLongTypes; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateCached; @@ -57,7 +57,7 @@ * generated code. */ @GenerateCached(false) -@TypeSystemReference(PythonIntegerTypes.class) +@TypeSystemReference(PythonIntToLongTypes.class) public abstract class PyNumberAddFastPathsBase extends BinaryOpNode { /* diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberFloorDivideFastPathsBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberFloorDivideFastPathsBase.java index 451cdeeb44..09efdb2d1d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberFloorDivideFastPathsBase.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberFloorDivideFastPathsBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 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 @@ -41,7 +41,7 @@ package com.oracle.graal.python.lib.fastpath; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntToLongTypes; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; @@ -51,7 +51,7 @@ * generated code. */ @GenerateCached(false) -@TypeSystemReference(PythonIntegerTypes.class) +@TypeSystemReference(PythonIntToLongTypes.class) public abstract class PyNumberFloorDivideFastPathsBase extends BinaryOpNode { /* diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberMultiplyFastPathsBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberMultiplyFastPathsBase.java index 27b2106a3b..ac0be7477e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberMultiplyFastPathsBase.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberMultiplyFastPathsBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 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 @@ -45,7 +45,7 @@ import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntToLongTypes; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateCached; @@ -58,7 +58,7 @@ * generated code. */ @GenerateCached(false) -@TypeSystemReference(PythonIntegerTypes.class) +@TypeSystemReference(PythonIntToLongTypes.class) public abstract class PyNumberMultiplyFastPathsBase extends BinaryOpNode { /* diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberRemainderFastPathsBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberRemainderFastPathsBase.java index 09b0c57412..44c6c107f3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberRemainderFastPathsBase.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberRemainderFastPathsBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 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 @@ -41,7 +41,7 @@ package com.oracle.graal.python.lib.fastpath; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntToLongTypes; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; @@ -51,7 +51,7 @@ * generated code. */ @GenerateCached(false) -@TypeSystemReference(PythonIntegerTypes.class) +@TypeSystemReference(PythonIntToLongTypes.class) public abstract class PyNumberRemainderFastPathsBase extends BinaryOpNode { @Specialization(guards = "right != 0") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberSubtractFastPathsBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberSubtractFastPathsBase.java index 08079d96b4..f4a3e4ffab 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberSubtractFastPathsBase.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberSubtractFastPathsBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 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 @@ -44,7 +44,7 @@ import com.oracle.graal.python.builtins.objects.ints.IntBuiltins; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntToLongTypes; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; @@ -54,7 +54,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateCached(false) -@TypeSystemReference(PythonIntegerTypes.class) +@TypeSystemReference(PythonIntToLongTypes.class) public abstract class PyNumberSubtractFastPathsBase extends BinaryOpNode { /* diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberTrueDivideFastPathsBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberTrueDivideFastPathsBase.java index cdc180ab9b..f7647bba9c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberTrueDivideFastPathsBase.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberTrueDivideFastPathsBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 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 @@ -42,7 +42,7 @@ import com.oracle.graal.python.builtins.objects.ints.IntBuiltins; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntToLongTypes; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; @@ -53,7 +53,7 @@ * generated code. */ @GenerateCached(false) -@TypeSystemReference(PythonIntegerTypes.class) +@TypeSystemReference(PythonIntToLongTypes.class) @ImportStatic(IntBuiltins.TrueDivNode.class) public abstract class PyNumberTrueDivideFastPathsBase extends BinaryOpNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java index 56f0f6b6c2..df5de928d6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java @@ -2047,7 +2047,6 @@ public static boolean isBuiltinWithObjectOrModuleGetattro(Shape cachedShape) { } @ForceQuickening - @StoreBytecodeIndex // looking up attribute in MRO may have side effects @Specialization(guards = { "!hasMaterializedDict(cachedShape)", "managedClass != null || isBuiltinWithObjectOrModuleGetattro(cachedShape)", // "getter != null", "getter.accepts(receiver)", // diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntToLongTypes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntToLongTypes.java new file mode 100644 index 0000000000..6c28a81849 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntToLongTypes.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 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 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.graal.python.nodes.truffle; + +import com.oracle.truffle.api.dsl.ImplicitCast; +import com.oracle.truffle.api.dsl.TypeSystem; + +/** + * This type system is supposed to be used by arithmetic operations where the boolean case is + * uncommon and can be handled by the generic fallback. Compared to {@link PythonIntegerTypes} this + * type system saves few bits in the state bitset and some complexity in the + * {@code @Specialization}/{@code @Fallback} guards. + */ +@TypeSystem +public abstract class PythonIntToLongTypes { + + @ImplicitCast + public static long intToLong(int value) { + return value; + } +}